elf: Correct the merging code for differing alignment
authorH. Peter Anvin <hpa@zytor.com>
Tue, 8 Jan 2008 22:30:26 +0000 (14:30 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 8 Jan 2008 22:30:26 +0000 (14:30 -0800)
Handle the case of unequal alignment (first.align > second.align) when
merging PHDRs.

elf.c

diff --git a/elf.c b/elf.c
index 841211b..aed35f1 100644 (file)
--- a/elf.c
+++ b/elf.c
@@ -155,8 +155,8 @@ static int gen_elf(struct segment *segs, Elf32_Ehdr *ehdr, FILE *out)
                    s->next->align <= s->align &&
                    (s->next->address ==
                     align_up(address+memsize, s->next->align))) {
-                       align = UINT32_C(1) << s->align;
                        s = s->next;
+                       align = UINT32_C(1) << s->align;
                        pad = (s->address - address) & (align-1);
                        if (s->sh_type != SHT_NOBITS) {
                                assert(pad ==