diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2010-04-21 15:45:09 +0400 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2010-04-21 18:10:00 +0400 |
commit | f8dc028c0712acaf67f4cdd14d5f04433ad9ff37 (patch) | |
tree | 5999e46b55c094c0ddb0f446867288a6af4a52b7 /output | |
parent | 2ef5c27be7a4e94c49560823d5074dafca6a2ac5 (diff) | |
download | nasm-f8dc028c0712acaf67f4cdd14d5f04433ad9ff37.tar.gz |
coff: Implement sectalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'output')
-rw-r--r-- | output/outcoff.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/output/outcoff.c b/output/outcoff.c index 07974d8c..67b90448 100644 --- a/output/outcoff.c +++ b/output/outcoff.c @@ -971,6 +971,34 @@ static void coff_write_symbols(void) } } +static void coff_sectalign(int32_t seg, unsigned int value) +{ + struct Section *s = NULL; + uint32_t align; + int i; + + for (i = 0; i < nsects; i++) { + if (sects[i]->index == seg) { + s = sects[i]; + break; + } + } + + if (!s || !is_power2(value) || value > 64) + return; + + align = (s->flags & 0x00F00000L); + value = (value == 1 ? 0x00100000L : + value == 2 ? 0x00200000L : + value == 4 ? 0x00300000L : + value == 8 ? 0x00400000L : + value == 16 ? 0x00500000L : + value == 32 ? 0x00600000L : 0x00700000L); + + if (value > align) + s->flags = (s->flags & ~0x00F00000L) | value; +} + static int32_t coff_segbase(int32_t segment) { return segment; @@ -1012,7 +1040,7 @@ struct ofmt of_coff = { coff_out, coff_deflabel, coff_section_names, - null_sectalign, + coff_sectalign, coff_segbase, coff_directives, coff_std_filename, @@ -1035,7 +1063,7 @@ struct ofmt of_win32 = { coff_out, coff_deflabel, coff_section_names, - null_sectalign, + coff_sectalign, coff_segbase, coff_directives, coff_win32_filename, @@ -1058,7 +1086,7 @@ struct ofmt of_win64 = { coff_out, coff_deflabel, coff_section_names, - null_sectalign, + coff_sectalign, coff_segbase, coff_directives, coff_win32_filename, |