summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2010-04-25 21:35:09 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2010-04-25 21:35:09 +0400
commit573d25fe92fac7209c0695c5904dc5b067cf902e (patch)
tree6c1c513812378abd8e2728896ce5c313f2117d25
parent9868bfe80f56ff44664c4c5cf018822908b51529 (diff)
downloadnasm-573d25fe92fac7209c0695c5904dc5b067cf902e.tar.gz
nasm-573d25fe92fac7209c0695c5904dc5b067cf902e.tar.bz2
nasm-573d25fe92fac7209c0695c5904dc5b067cf902e.zip
macho: Implement sectalign handler
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--output/outmacho32.c19
-rw-r--r--output/outmacho64.c19
2 files changed, 36 insertions, 2 deletions
diff --git a/output/outmacho32.c b/output/outmacho32.c
index 16a6958..fb9f398 100644
--- a/output/outmacho32.c
+++ b/output/outmacho32.c
@@ -664,6 +664,23 @@ static void macho_symdef(char *name, int32_t section, int64_t offset,
++nsyms;
}
+static void macho_setcalign(int32_t seg, unsigned int value)
+{
+ struct section *s;
+
+ list_for_each(s, sects) {
+ if (s->index == seg)
+ break;
+ }
+
+ if (!s || !is_power2(value))
+ return;
+
+ value = alignlog2_32(value);
+ if (s->align < (int)value)
+ s->align = value;
+}
+
static int32_t macho_segbase(int32_t section)
{
return section;
@@ -1288,7 +1305,7 @@ struct ofmt of_macho32 = {
macho_output,
macho_symdef,
macho_section,
- null_sectalign,
+ macho_setcalign,
macho_segbase,
null_directive,
macho_filename,
diff --git a/output/outmacho64.c b/output/outmacho64.c
index 4de5300..3aa9468 100644
--- a/output/outmacho64.c
+++ b/output/outmacho64.c
@@ -813,6 +813,23 @@ static void macho_symdef(char *name, int32_t section, int64_t offset,
++nsyms;
}
+static void macho_setcalign(int32_t seg, unsigned int value)
+{
+ struct section *s;
+
+ list_for_each(s, sects) {
+ if (s->index == seg)
+ break;
+ }
+
+ if (!s || !is_power2(value))
+ return;
+
+ value = alignlog2_32(value);
+ if (s->align < (int)value)
+ s->align = value;
+}
+
static int32_t macho_segbase(int32_t section)
{
return section;
@@ -1459,7 +1476,7 @@ struct ofmt of_macho64 = {
macho_output,
macho_symdef,
macho_section,
- null_sectalign,
+ macho_setcalign,
macho_segbase,
null_directive,
macho_filename,