gbdev / gbdev/rgbds

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

Open
#1,843 11 comments 0 reactions 0 assignees View on GitHub
breaking enhancement rgbasm rgblink
Dominant language
C++
Stars
1.6k
Forks
193
Avg merge
1d 33m
Merged PRs (30d)
23

Description

Currently `SECTION FRAGMENT`s 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 FRAGMENT`s 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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.