Repository: dotnet/runtime
File: src/coreclr/tools/Common/Compiler/ObjectWriter/PEObjectWriter.cs (C#)

Code before:
            _outputPath = outputPath;
            _requestedSectionAlignment = sectionAlignment;
            _coffTimestamp = coffTimestamp;
        }

        public void AddExportedSymbol(string symbol)
        {
            if (!string.IsNullOrEmpty(symbol))
            {
                _exportedSymbolNames.Add(symbol);
            }
        }

        private protected override ObjectNodeSection GetEmitSection(ObjectNodeSection section)
        {
            // Put executable code into .text for PE files as AV software really
            // doesn't like executable code in non-standard sections.
            if (section == ObjectNodeSection.ManagedCodeWindowsContentSection)
            {
                return ObjectNodeSection.TextSection;
            }

            // RISC-V and LoongArch64 have a limited addressing range (±2GB) for relocs.
            // Don't merge rdata into text to avoid relocation overflow.
            if (_nodeFactory.Target.Architecture == TargetArchitecture.RiscV64
                || _nodeFactory.Target.Architecture == TargetArchitecture.LoongArch64)
            {
                return section;
            }

            // We want to reduce the number of sections in the PE files we emit,
            // so merge the read-only data section into the .text section.
            if (section == ObjectNodeSection.ReadOnlyDataSection)
            {
                return ObjectNodeSection.TextSection;
            }

            // Otherwise, use the requested section.
            return section;
        }

        private protected override void CreateSection(ObjectNodeSection section, Utf8String comdatName, Utf8String symbolName, int sectionIndex, Stream sectionStream)
        {
            // COMDAT sections are not supported in PE files
            base.CreateSection(section, comdatName: default, symbolName, sectionIndex, sectionStream);

            if (_requestedSectionAlignment != 0)
            {
                UpdateSectionAlignment(sectionIndex, _requestedSectionAlignment);
            }
        }

Review comment (bug):
AFAIK, LA64 doesn't have a problem.
```suggestion
            // RISC-V has a limited addressing range (±2GB) for relocs.
            // Don't merge rdata into text to avoid relocation overflow.
            if (_nodeFactory.Target.Architecture == TargetArchitecture.RiscV64)
```

Code after:
            : base(factory, options, outputInfoBuilder)
        {
            _outputPath = outputPath;
            _requestedSectionAlignment = sectionAlignment;
            _coffTimestamp = coffTimestamp;
        }

        public void AddExportedSymbol(string symbol)
        {
            if (!string.IsNullOrEmpty(symbol))
            {
                _exportedSymbolNames.Add(symbol);
            }
        }

        private protected override ObjectNodeSection GetEmitSection(ObjectNodeSection section)
        {
            // Put executable code into .text for PE files as AV software really
            // doesn't like executable code in non-standard sections.
            if (section == ObjectNodeSection.ManagedCodeWindowsContentSection)
            {
                return ObjectNodeSection.TextSection;
            }

            // We want to reduce the number of sections in the PE files we emit,
            // so merge the read-only data section into the .text section.
            if (section == ObjectNodeSection.ReadOnlyDataSection)
            {
                return ObjectNodeSection.TextSection;
            }

            // Otherwise, use the requested section.
            return section;
        }

        private protected override void CreateSection(ObjectNodeSection section, Utf8String comdatName, Utf8String symbolName, int sectionIndex, Stream sectionStream)
        {
            // COMDAT sections are not supported in PE files
            base.CreateSection(section, comdatName: default, symbolName, sectionIndex, sectionStream);

            if (_requestedSectionAlignment != 0)
            {
                UpdateSectionAlignment(sectionIndex, _requestedSectionAlignment);
            }
        }

        private struct PEOptionalHeader
        {
            public bool IsPE32Plus { get; }

            // Standard fields