summaryrefslogtreecommitdiff
path: root/output
diff options
context:
space:
mode:
authorKeith Kanios <keith@kanios.net>2009-10-16 21:53:59 -0500
committerKeith Kanios <keith@kanios.net>2009-10-16 21:53:59 -0500
commitd2a553c0728989f159df5ba0ba1a0441d7726f44 (patch)
treefaa13a1f505fe1525e0112e3adb330f9faa8a216 /output
parentc2509508b5ed3d4662f054fa992c4e0c9244dfd2 (diff)
downloadnasm-d2a553c0728989f159df5ba0ba1a0441d7726f44.tar.gz
nasm-d2a553c0728989f159df5ba0ba1a0441d7726f44.tar.bz2
nasm-d2a553c0728989f159df5ba0ba1a0441d7726f44.zip
BR 2840300: fix macho symbol alignment bug
Diffstat (limited to 'output')
-rw-r--r--output/outmacho32.c9
-rw-r--r--output/outmacho64.c9
2 files changed, 12 insertions, 6 deletions
diff --git a/output/outmacho32.c b/output/outmacho32.c
index 234cf28..4ce9eea 100644
--- a/output/outmacho32.c
+++ b/output/outmacho32.c
@@ -1050,9 +1050,12 @@ static void macho_write_symtab (void)
/* Fix up the symbol value now that we know the final section
sizes. */
if (((sym->type & N_TYPE) == N_SECT) && (sym->sect != NO_SECT)) {
- for (s = sects, fi = 1;
- s != NULL && fi < sym->sect; s = s->next, ++fi)
- sym->value += s->size;
+ for (s = sects, fi = 1; s != NULL; s = s->next, fi++) {
+ if (fi == sym->sect) {
+ sym->value += s->addr;
+ break;
+ }
+ }
}
fwriteint32_t(sym->value, ofile); /* value (i.e. offset) */
diff --git a/output/outmacho64.c b/output/outmacho64.c
index a0da134..dfe523b 100644
--- a/output/outmacho64.c
+++ b/output/outmacho64.c
@@ -1219,9 +1219,12 @@ static void macho_write_symtab (void)
/* Fix up the symbol value now that we know the final section
sizes. */
if (((sym->type & N_TYPE) == N_SECT) && (sym->sect != NO_SECT)) {
- for (s = sects, fi = 1;
- s != NULL && fi < sym->sect; s = s->next, ++fi)
- sym->value += s->size;
+ for (s = sects, fi = 1; s != NULL; s = s->next, fi++) {
+ if (fi == sym->sect) {
+ sym->value += s->addr;
+ break;
+ }
+ }
}
fwriteint64_t(sym->value, ofile); /* value (i.e. offset) */