From 2cc3049ac981e8485698b7592397bd66ddb5d9d0 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Sat, 2 Feb 2013 15:04:59 -0600 Subject: [PATCH] Fixed compiler not checking for INCBIN in BSS sections. Apparently the compiler did not care if an INCBIN happened in a BSS section or not. Now the compiler cares and gives an error if you try to do this terrible, terrible thing. :-D --- direct.c | 14 +++++++++++++- sect.c | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/direct.c b/direct.c index d3e0303..4a9311c 100644 --- a/direct.c +++ b/direct.c @@ -333,6 +333,13 @@ int d_incbin(void) long pos, size; char buf; + // Check to see if we're in BSS, and, if so, throw an error + if (scattr & SBSS) + { + errors("Cannot include binary file \"%s\" in BSS section", string[tok[1]]); + return ERROR; + } + if (*tok != STRING) { error(syntax_error); @@ -345,7 +352,12 @@ int d_incbin(void) size = lseek(j, 0L, SEEK_END); chcheck(size); pos = lseek(j, 0L, SEEK_SET); - + + DEBUG + { + printf("INCBIN: File '%s' is %li bytes.\n", string[tok[1]], size); + } + for(i=0; i= (int)amt) return 0; if (amt < CH_CODE_SIZE) amt = CH_CODE_SIZE; + DEBUG { printf(" amt (adjusted)=%u\n", amt); } SECT * p = §[cursect]; CHUNK * cp = malloc(sizeof(CHUNK) + amt); -- 2.37.2