Skip to content

Add a priority parameter for forcing SECTION FRAGMENTs to be sorted in a certain order using only code #1843

Description

@nitro2k01

Currently SECTION FRAGMENTs are placed by the linker in the order of the input arguments. This can cause subtle breakage if a build tool like make reorders the files. My suggestion is a priority parameter which can be used to describe the order of SECTION FRAGMENTs using only the file contents, and not having to rely on forcing a certain parameter order by for example requiring alphabetically sorted file names and using sort to set the order explicitly.

The feature could have an integer argument, where a SECTION FRAGMENT with a lower argument will always be inserted before one with a higher argument.

The use case where this came up is code that starts in one SECTION FRAGMENT, runs to the end and then resumes in a different SECTION FRAGMENT in a different file. An example of how the proposed feature might work:

file1.asm:

SECTION FRAGMENT[0] "Stuff", ROMX 
DoSomeStuff::
    ; Stuff is being done

file2.asm:

SECTION FRAGMENT[10] "Stuff", ROMX 
    ; Do some cleanup
    ret

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingThis is a breaking change that requires a major version updateenhancementTypically new features; lesser priority than bugsrgbasmThis affects RGBASMrgblinkThis affects RGBLINK

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions