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

Code before:
            : 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;
            }

            // 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)
            {
                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 (suggestion):
I don't understand this issue? PE files are limited to 2GB in total size in all scenarios in any case, so a 2GB reloc should always work.

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