Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 1 | /* Should strace show byte or page offsets in mmap syscalls |
| 2 | * which take page offset parameters? |
| 3 | * |
| 4 | * At the time of writing, sys_mmap() converts page to byte offsets, |
| 5 | * but only for SH64! But this routine is used on i386 too - by mmap2 syscall, |
| 6 | * which uses page offsets too. As it stands now, SH64 and i386 are inconsistent. |
| 7 | * |
| 8 | * sys_old_mmap() is used for old mmap syscall, which uses byte offset - |
| 9 | * should be ok. |
| 10 | * sys_mmap64() is currently buggy (should print bogus offset, but I can't |
| 11 | * test it right now. What arch/bitness invokes sys_mmap64?) |
| 12 | * |
| 13 | * This program is intended for testing what strace actually shows. Usage: |
| 14 | * $ gcc test/mmap_offset_decode.c -o mmap_offset_decode -static |
| 15 | * $ strace ./mmap_offset_decode |
| 16 | * |
| 17 | * As of today (2011-08), on i386 strace prints page offset. |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 18 | * Fixed 2013-02-19. Now all mmaps on all arches should show byte offsets. |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 19 | */ |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 20 | #define _LARGEFILE_SOURCE |
| 21 | #define _LARGEFILE64_SOURCE |
| 22 | #define _FILE_OFFSET_BITS 64 |
| 23 | #include <sys/mman.h> |
| 24 | #include <errno.h> |
| 25 | int main() |
| 26 | { |
| 27 | /* 0x1000 is meant to be page size multiplier */ |
| 28 | mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, |
| 29 | 0x7fff0000LL * 0x1000); |
| 30 | return errno != 0; |
| 31 | } |