From: Petr Machata Date: Fri, 3 Jul 2009 15:59:47 +0000 (+0200) Subject: dwarflint: Check alignment of section base address X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5223933968799344657c27de37018ebce2315762;p=thirdparty%2Felfutils.git dwarflint: Check alignment of section base address --- diff --git a/src/dwarflint.c b/src/dwarflint.c index 957634999..06ab869ba 100644 --- a/src/dwarflint.c +++ b/src/dwarflint.c @@ -1064,6 +1064,12 @@ where_reset_3 (struct where *wh, uint64_t addr) #define WHERE_SECDATA(DATA, PARENT) (WHERE (data_get_sec (DATA)->id, PARENT)) +static bool +address_aligned (uint64_t addr, uint64_t align) +{ + return align < 2 || (addr % align == 0); +} + static void process_file (Dwarf *dwarf, const char *fname, bool only_one) { @@ -1169,6 +1175,11 @@ process_file (Dwarf *dwarf, const char *fname, bool only_one) if (scnname == NULL) goto invalid_elf; + if (!address_aligned (shdr->sh_addr, shdr->sh_addralign)) + wr_error (NULL, "Base address of section %s, %#" PRIx64 + ", should have an alignment of %" PRId64 ".\n", + scnname, shdr->sh_addr, shdr->sh_addralign); + struct secinfo *secentry = find_secentry (scnname); struct section_data *secdata = secentry != NULL ? secentry->dataptr : NULL; cursec->scn = scn;