diff --git a/ChangeLog b/ChangeLog
index 65a04946..a5b93d12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-04-18  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	* fileio.c (elf2b): When checking the bounds of the current
+	program header segment, subtract `low' from ph[n].p_paddr in order
+	to correct the magic section offsets for the AVR's non-flash
+	memory regions.
+
 2012-04-18  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	* fileio.c (elf_get_scn): Rather than trying to just match whether
diff --git a/fileio.c b/fileio.c
index 0f859f19..f625543e 100644
--- a/fileio.c
+++ b/fileio.c
@@ -948,7 +948,7 @@ static int elf2b(char * infile, FILE * inf,
      * from it, using the "foff" offset obtained above.
      */
     if (mem->size != 1 &&
-        ph[i].p_paddr + ph[i].p_filesz > mem->size) {
+        ph[i].p_paddr - low + ph[i].p_filesz > mem->size) {
       fprintf(stderr,
               "%s: ERROR: program header entry #%d does not fit into \"%s\" memory:\n"
               "    0x%x + %u > %u\n",