Merge pull request #226 from tkchia/tkchia/sepid
aslod: fix: use section alignments when computing section sizes
This commit is contained in:
commit
ced1e91800
|
@ -95,9 +95,10 @@ int follows(struct outsect* pa, struct outsect* pb)
|
||||||
* to the output stream, zero filling any uninitialised
|
* to the output stream, zero filling any uninitialised
|
||||||
* space. */
|
* space. */
|
||||||
|
|
||||||
void emits(struct outsect* section)
|
void emits(struct outsect* section, struct outsect* nextsect)
|
||||||
{
|
{
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
|
uint32_t real_size;
|
||||||
|
|
||||||
/* Copy the actual data. */
|
/* Copy the actual data. */
|
||||||
|
|
||||||
|
@ -112,11 +113,18 @@ void emits(struct outsect* section)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Calculate the actual size of the section in the final memory
|
||||||
|
* layout. Take into account the next section's alignment, if any. */
|
||||||
|
real_size = section->os_size;
|
||||||
|
if (nextsect)
|
||||||
|
real_size = align(section->os_base + real_size, nextsect->os_lign)
|
||||||
|
- section->os_base;
|
||||||
|
|
||||||
/* Zero fill any remaining space. */
|
/* Zero fill any remaining space. */
|
||||||
|
|
||||||
if (section->os_flen != section->os_size)
|
if (section->os_flen != real_size)
|
||||||
{
|
{
|
||||||
long n = section->os_size - section->os_flen;
|
uint32_t n = real_size - section->os_flen;
|
||||||
memset(buffer, 0, BUFSIZ);
|
memset(buffer, 0, BUFSIZ);
|
||||||
|
|
||||||
while (n > 0)
|
while (n > 0)
|
||||||
|
@ -280,9 +288,9 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
/* And go! */
|
/* And go! */
|
||||||
|
|
||||||
emits(&outsect[TEXT]);
|
emits(&outsect[TEXT], &outsect[ROM]);
|
||||||
emits(&outsect[ROM]);
|
emits(&outsect[ROM], &outsect[DATA]);
|
||||||
emits(&outsect[DATA]);
|
emits(&outsect[DATA], NULL);
|
||||||
|
|
||||||
if (ferror(output))
|
if (ferror(output))
|
||||||
fatal("output write error");
|
fatal("output write error");
|
||||||
|
|
Loading…
Reference in a new issue