shithub: rgbds

Download patch

ref: 8397b3d8ecbd4271a3a68f7c118eac3383132d6a
parent: 296e5489c973cbef5ce92b3c32122f0605126f9b
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sun May 2 13:56:43 EDT 2021

.sym file sorts symbols from zero-length sections first

This will, for instance, ensure that a zero-length
`SECTION "NULL", ROM0[0] / NULL::` comes first.

--- a/src/link/output.c
+++ b/src/link/output.c
@@ -302,11 +302,11 @@
 
 	uint32_t nbSymbols = 0;
 
-	for (struct SortedSection const *ptr = bankSections->sections; ptr; ptr = ptr->next) {
+	for (struct SortedSection const *ptr = bankSections->zeroLenSections; ptr; ptr = ptr->next) {
 		for (struct Section const *sect = ptr->section; sect; sect = sect->nextu)
 			nbSymbols += sect->nbSymbols;
 	}
-	for (struct SortedSection const *ptr = bankSections->zeroLenSections; ptr; ptr = ptr->next) {
+	for (struct SortedSection const *ptr = bankSections->sections; ptr; ptr = ptr->next) {
 		for (struct Section const *sect = ptr->section; sect; sect = sect->nextu)
 			nbSymbols += sect->nbSymbols;
 	}
@@ -321,7 +321,7 @@
 
 	uint32_t idx = 0;
 
-	for (struct SortedSection const *ptr = bankSections->sections; ptr; ptr = ptr->next) {
+	for (struct SortedSection const *ptr = bankSections->zeroLenSections; ptr; ptr = ptr->next) {
 		for (struct Section const *sect = ptr->section; sect; sect = sect->nextu) {
 			for (uint32_t i = 0; i < sect->nbSymbols; i++) {
 				symList[idx].idx = idx;
@@ -331,7 +331,7 @@
 			}
 		}
 	}
-	for (struct SortedSection const *ptr = bankSections->zeroLenSections; ptr; ptr = ptr->next) {
+	for (struct SortedSection const *ptr = bankSections->sections; ptr; ptr = ptr->next) {
 		for (struct Section const *sect = ptr->section; sect; sect = sect->nextu) {
 			for (uint32_t i = 0; i < sect->nbSymbols; i++) {
 				symList[idx].idx = idx;