Mercurial > hg > index.cgi
diff lwlink/link.c @ 325:6821f4855702
Fix bug with section padding and downward allocation.
When placing sections with the "high" method, padding was added to the
section instance at the lowest address insted of the highest as is
appropriate for the padafter option. Explicitly handle the padding for the
first instance encountered (highest address) when growing down.
author | William Astle <lost@l-w.ca> |
---|---|
date | Fri, 21 Mar 2014 23:49:23 -0600 |
parents | fcd103148aa6 |
children | 221b5f58d8ad |
line wrap: on
line diff
--- a/lwlink/link.c Tue Mar 04 23:10:13 2014 -0700 +++ b/lwlink/link.c Fri Mar 21 23:49:23 2014 -0600 @@ -47,10 +47,16 @@ void check_section_name(char *name, int *base, fileinfo_t *fn, int down) { int sn; + sectopt_t *so; + // fprintf(stderr, "Considering sections in %s (%d) for %s\n", fn -> filename, fn -> forced, name); if (fn -> forced == 0) return; + for (so = section_opts; so; so = so -> next) + if (!strcmp(so -> name, name)) + break; + for (sn = 0; sn < fn -> nsections; sn++) { // fprintf(stderr, " Considering section %s\n", fn -> sections[sn].name); @@ -62,7 +68,8 @@ // fprintf(stderr, " Found\n"); sectlist = lw_realloc(sectlist, sizeof(struct section_list) * (nsects + 1)); sectlist[nsects].ptr = &(fn -> sections[sn]); - + + fn -> sections[sn].processed = 1; if (down) { @@ -74,6 +81,14 @@ fn -> sections[sn].loadaddress = *base; *base += fn -> sections[sn].codesize; } + if (down && so && so -> aftersize) + { + sectlist[nsects].ptr -> afterbytes = so -> afterbytes; + sectlist[nsects].ptr -> aftersize = so -> aftersize; + sectlist[nsects].ptr -> loadaddress -= so -> aftersize; + *base -= so -> aftersize; + so -> aftersize = 0; + } nsects++; // fprintf(stderr, "Adding section %s (%s)\n",fn -> sections[sn].name, fn -> filename); }