aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-16 02:59:26 +1300
committerAndrew Chambers <[email protected]>2021-10-16 02:59:26 +1300
commitfccfcc2043e56306935dff29e66c414fd6c0a6d0 (patch)
tree859cbf877a44f7b7c328cfe32b260095c08cfb54
parent490cb559cc4713b43d38c5667e56abc2f52973f9 (diff)
Take section alignment into account for align directives.
-rw-r--r--main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/main.c b/main.c
index 86721e8..b47fbec 100644
--- a/main.c
+++ b/main.c
@@ -799,9 +799,10 @@ static void assemble(void) {
sb(0x00);
break;
case ASM_DIR_BALIGN: {
- int64_t i, rem, amnt;
+ int64_t offset, i, rem, amnt;
amnt = 0;
- rem = cursection->hdr.sh_size % v->balign.align;
+ offset = cursection->hdr.sh_addralign + cursection->hdr.sh_size;
+ rem = offset % v->balign.align;
if (rem)
amnt = v->balign.align - rem;
for (i = 0; i < amnt; i++) {