aboutsummaryrefslogtreecommitdiffstats
path: root/fs/binfmt_elf.c
diff options
context:
space:
mode:
authorPetr Vandrovec <petr@vandrovec.name>2006-10-13 12:42:07 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-15 14:24:49 -0400
commita7a0d86f5aa40a2215e36fe21d7911cf718ba428 (patch)
tree39c07a323bf37f9e81c0b77cc17c9ba639a43d60 /fs/binfmt_elf.c
parent0b269d8462a9f0058afb46eaee56e0732acf16c4 (diff)
[PATCH] Fix core files so they make sense to gdb...
It is silly to use non-static variable for writting zeroes to the file. And more seriously, foffset in core dump file dump function was incremented too much, so some parts of core dump were shifted by size of few phdrs and notes down, so although gdb was able to load that file, it did not make lot of sense - in my test case data pages were shifted down by about 900 bytes. Signed-off-by: Petr Vandrovec <petr@vandrovec.name> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r--fs/binfmt_elf.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 561006127902..79b05a1a4365 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1220,7 +1220,7 @@ static int notesize(struct memelfnote *en)
1220 1220
1221static int alignfile(struct file *file, loff_t *foffset) 1221static int alignfile(struct file *file, loff_t *foffset)
1222{ 1222{
1223 char buf[4] = { 0, }; 1223 static const char buf[4] = { 0, };
1224 DUMP_WRITE(buf, roundup(*foffset, 4) - *foffset, foffset); 1224 DUMP_WRITE(buf, roundup(*foffset, 4) - *foffset, foffset);
1225 return 1; 1225 return 1;
1226} 1226}
@@ -1569,7 +1569,8 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
1569 1569
1570 DUMP_WRITE(elf, sizeof(*elf)); 1570 DUMP_WRITE(elf, sizeof(*elf));
1571 offset += sizeof(*elf); /* Elf header */ 1571 offset += sizeof(*elf); /* Elf header */
1572 offset += (segs+1) * sizeof(struct elf_phdr); /* Program headers */ 1572 offset += (segs + 1) * sizeof(struct elf_phdr); /* Program headers */
1573 foffset = offset;
1573 1574
1574 /* Write notes phdr entry */ 1575 /* Write notes phdr entry */
1575 { 1576 {
@@ -1586,8 +1587,6 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
1586 DUMP_WRITE(&phdr, sizeof(phdr)); 1587 DUMP_WRITE(&phdr, sizeof(phdr));
1587 } 1588 }
1588 1589
1589 foffset = offset;
1590
1591 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE); 1590 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
1592 1591
1593 /* Write program headers for segments dump */ 1592 /* Write program headers for segments dump */
@@ -1612,7 +1611,6 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
1612 phdr.p_align = ELF_EXEC_PAGESIZE; 1611 phdr.p_align = ELF_EXEC_PAGESIZE;
1613 1612
1614 DUMP_WRITE(&phdr, sizeof(phdr)); 1613 DUMP_WRITE(&phdr, sizeof(phdr));
1615 foffset += sizeof(phdr);
1616 } 1614 }
1617 1615
1618#ifdef ELF_CORE_WRITE_EXTRA_PHDRS 1616#ifdef ELF_CORE_WRITE_EXTRA_PHDRS