Skip to content

Commit 55a4528

Browse files
committed
_sizeof_* calculation for labels takes now unused output bytes into acocunt. Should fix GitHub issue #618.
1 parent bc8a974 commit 55a4528

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

Diff for: CHANGELOG

+2-1
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,8 @@ v1.0 (10-Jul-2000) The first public release.
15221522
4... WLALINK History
15231523
------------------------------------------------------------------------------
15241524

1525-
v5.22 (10-Dec-2023)
1525+
v5.22 (05-Feb-2024) When calculating _sizeof_* for lables we now take unused
1526+
output bytes into account.
15261527

15271528
v5.21 (19-Nov-2023) WLALINK writes now version 3 WLA symbol files.
15281529
Symbol files created with -S contain now [sections] and

Diff for: wlalink/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define WLALINK_DEBUG 1
3333
*/
3434

35-
char g_version_string[] = "$VER: wlalink 5.22a (10.12.2023)";
35+
char g_version_string[] = "$VER: wlalink 5.22a (05.02.2024)";
3636

3737
#if defined(AMIGA)
3838
__near long __stack = 200000;

Diff for: wlalink/write.c

+21-15
Original file line numberDiff line numberDiff line change
@@ -4611,16 +4611,6 @@ static int _labels_compare(const void *a, const void *b) {
46114611
const struct label *l1 = a;
46124612
const struct label *l2 = b;
46134613

4614-
if (l1->section_status == OFF && l2->section_status == ON)
4615-
return 1;
4616-
if (l1->section_status == ON && l2->section_status == OFF)
4617-
return -1;
4618-
4619-
if (l1->section > l2->section)
4620-
return 1;
4621-
else if (l1->section < l2->section)
4622-
return -1;
4623-
46244614
if (l1->rom_address > l2->rom_address)
46254615
return 1;
46264616
else if (l1->rom_address < l2->rom_address)
@@ -4933,15 +4923,31 @@ int generate_sizeof_label_definitions(void) {
49334923
}
49344924

49354925
if (ls == NULL) {
4936-
if (j == labelsN - 1 || labels[j]->section != labels[j+1]->section) {
4937-
/* last label in this section */
4938-
if (labels[j]->section_struct != NULL)
4926+
if (labels[j]->section_struct != NULL) {
4927+
/* inside a .SECTION, there are no holes in .SECTIONs so use labels to calculate the size */
4928+
if (j == labelsN - 1 || labels[j]->section != labels[j+1]->section) {
4929+
/* last label in this .SECTION */
49394930
size = labels[j]->section_struct->size - labels[j]->address_in_section;
4931+
}
49404932
else
4941-
continue;
4933+
size = (int)labels[j+1]->rom_address - (int)labels[j]->rom_address;
49424934
}
49434935
else {
4944-
size = (int)labels[j+1]->rom_address - (int)labels[j]->rom_address;
4936+
/* find the size by examining g_rom_usage */
4937+
int absolute_end, i;
4938+
4939+
if (j == labelsN - 1)
4940+
absolute_end = g_romsize;
4941+
else
4942+
absolute_end = (int)labels[j+1]->rom_address;
4943+
4944+
/* find the next unused byte or encounter absolute_end */
4945+
for (i = (int)labels[j]->rom_address; i < absolute_end; i++) {
4946+
if (g_rom_usage[i] == 0)
4947+
break;
4948+
}
4949+
4950+
size = i - (int)labels[j]->rom_address;
49454951
}
49464952
}
49474953

0 commit comments

Comments
 (0)