From 573d25fe92fac7209c0695c5904dc5b067cf902e Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Sun, 25 Apr 2010 21:35:09 +0400 Subject: [PATCH] macho: Implement sectalign handler Signed-off-by: Cyrill Gorcunov --- output/outmacho32.c | 19 ++++++++++++++++++- output/outmacho64.c | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/output/outmacho32.c b/output/outmacho32.c index 16a6958d..fb9f398e 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 4de53004..3aa94681 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,