Mercurial > hg > index.cgi
diff lwlink/script.c @ 315:fcd103148aa6
Add ability to load sections downward instead of upward
Add "section ... high ..." statement to link scripts to allow a section to
be placed based on its end address instead of its start address. All
sections listed after such a statement are treated as growing downward until
the next section statement specifying a load address.
author | William Astle <lost@l-w.ca> |
---|---|
date | Wed, 27 Nov 2013 16:01:26 -0700 |
parents | 86eb8814a05c |
children | 55c1f9a321e9 |
line wrap: on
line diff
--- a/lwlink/script.c Tue Nov 12 21:03:48 2013 -0700 +++ b/lwlink/script.c Wed Nov 27 16:01:26 2013 -0700 @@ -380,6 +380,7 @@ } else if (!strcmp(line, "section")) { + int growsdown = 0; // section // parse out the section name and flags for (ptr2 = ptr; *ptr2 && !isspace(*ptr2); ptr2++) @@ -404,12 +405,24 @@ ptr2++; } + else if (!strncmp(ptr2, "high", 4)) + { + ptr2 += 4; + while (*ptr2 && isspace(*ptr2)) + ptr2++; + growsdown = 1; + } else { fprintf(stderr, "%s: bad script\n", scriptfile); exit(1); } } + else + { + if (linkscript.nlines > 0) + growsdown = linkscript.lines[linkscript.nlines - 1].growsdown; + } // now ptr2 points to the load address if there is one // or NUL if not @@ -417,6 +430,7 @@ linkscript.lines[linkscript.nlines].noflags = 0; linkscript.lines[linkscript.nlines].yesflags = 0; + linkscript.lines[linkscript.nlines].growsdown = growsdown; if (*ptr2) linkscript.lines[linkscript.nlines].loadat = strtol(ptr2, NULL, 16); else