Skip to content

nativeGen: Explicitly set flags of text sections

Ben Gamari requested to merge wip/T22834 into master

The binutils documentation (for COFF) claims,

If no flags are specified, the default flags depend upon the section name. If the section name is not recognized, the default will be for the section to be loaded and writable.

We previously assumed that this would do the right thing for split sections (e.g. a section named .text$foo would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation).

Avoid this by setting section flags explicitly. This should fix split sections on Windows.

As I suspect this same issue applies to non-PE platforms, I have extended this to the other platforms as well and removed splitSectionsBroken from the CI configuration under the hope that split sections is now functional.

Fixes #22834 (closed). Fixes #22722.

Edited by Ben Gamari

Merge request reports