blob: 34a708e22bad64eee2ab26f3a645cd8ff9ffb38c [file] [log] [blame]
Denys Vlasenko9aa97962011-08-19 17:07:38 +02001/* 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 Vlasenko1ba85432013-02-19 11:28:20 +010018 * Fixed 2013-02-19. Now all mmaps on all arches should show byte offsets.
Denys Vlasenko9aa97962011-08-19 17:07:38 +020019 */
Denys Vlasenko9aa97962011-08-19 17:07:38 +020020#define _LARGEFILE_SOURCE
21#define _LARGEFILE64_SOURCE
22#define _FILE_OFFSET_BITS 64
23#include <sys/mman.h>
24#include <errno.h>
25int 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}