Skip to content

Commit d20fb07

Browse files
authored
Merge pull request #114 from WorksButNotTested/dontdump
Support madvise(MADV_DONTDUMP) when creating core dumps for qemu-user
2 parents 54b1f3f + 15fcf9a commit d20fb07

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

include/exec/page-protection.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
*/
3939
#define PAGE_PASSTHROUGH 0x0800
4040

41+
/*
42+
* For linux-user, indicates that the page should not be included in a core
43+
* dump.
44+
*/
45+
#define PAGE_DONTDUMP 0x1000
46+
4147
#ifdef CONFIG_USER_ONLY
4248

4349
void TSA_NO_TSA mmap_lock(void);

linux-user/elfload.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4068,6 +4068,10 @@ static size_t vma_dump_size(target_ulong start, target_ulong end,
40684068
return 0;
40694069
}
40704070

4071+
if (flags & PAGE_DONTDUMP) {
4072+
return 0;
4073+
}
4074+
40714075
/*
40724076
* Usually we don't dump executable pages as they contain
40734077
* non-writable code that debugger can read directly from

linux-user/mmap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,11 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)
12461246
*/
12471247
mmap_lock();
12481248
switch (advice) {
1249+
case MADV_DONTDUMP:
1250+
if (len > 0) {
1251+
page_set_flags(start, start + len - 1, PAGE_DONTDUMP);
1252+
}
1253+
break;
12491254
case MADV_WIPEONFORK:
12501255
case MADV_KEEPONFORK:
12511256
ret = -EINVAL;

0 commit comments

Comments
 (0)