mmap64 on sparc64

Tom Duffy tduffy at sun.com
Thu Jan 13 13:58:01 UTC 2005


There seems to be a bug in strace when displaying mmap64() on
Linux/sparc64.  If I pass in a 64 bit address, it only displays the
32bit version in strace.

For instance, a block of code like this:

#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

#define __USE_FILE_OFFSET64

int main()
{
	int fd;
	void *ptr;
	fd = open("/dev/mem",O_RDWR | O_SYNC);
	if (fd<0) {
		perror("open");
		return 1;
	}

	ptr = mmap64(NULL, 0x100000, PROT_READ | PROT_WRITE,
			MAP_SHARED, fd, 0x1ff00100000ull);

	if ( (! ptr) || (ptr == MAP_FAILED) ) {
		perror("map");
		return 1;
	}

	return 0;
err:
	return 1;
}

Displays in strace like:

# strace ./strace-test
execve("./strace-test", ["./strace-test"], [/* 15 vars */]) = 0
uname({sys="Linux", node="tat", ...})   = 0
brk(0)                                  = 0x22000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=53602, ...}) = 0
mmap(NULL, 53602, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7002c000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\2\0\0\0\1\0\1\316"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=1291948, ...}) = 0
mmap(NULL, 1361864, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x7003c000
mprotect(0x70170000, 100296, PROT_NONE) = 0
mmap(0x7017c000, 49152, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0x130000) = 0x7017c000
mmap(0x70188000, 1992, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x70188000
close(3)                                = 0
munmap(0x7002c000, 53602)               = 0
open("/dev/mem", O_RDWR|O_SYNC)         = 3
mmap2(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x1ff00100) = 0x7018c000
exit_group(0)                           = ?

Note the last item in mmap2 above ...

# more /proc/2718/maps
00010000-00012000 r-xp 00000000 00:0e 5552169                            /root/strace-test
00020000-00022000 rwxp 00000000 00:0e 5552169                            /root/strace-test
70000000-7001a000 r-xp 00000000 08:01 700792                             /lib/ld-2.3.2.so
70028000-7002a000 rwxp 00018000 08:01 700792                             /lib/ld-2.3.2.so
7003c000-70170000 r-xp 00000000 08:01 700795                             /lib/libc-2.3.2.so
70170000-7017c000 ---p 00134000 08:01 700795                             /lib/libc-2.3.2.so
7017c000-70188000 rwxp 00130000 08:01 700795                             /lib/libc-2.3.2.so
70188000-7018a000 rwxp 70188000 00:00 0
7018c000-7028c000 rw-s 1ff00100000 00:0d 316                             /dev/mem
efffe000-f0000000 rw-p efffe000 00:00 0

# uname -a
Linux tat 2.6.10 #14 SMP Mon Jan 3 12:30:51 PST 2005 sparc64 GNU/Linux

# strace -V
strace -- version 4.5.7

# dpkg -l strace
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
ii  strace         4.5.7-1.1      A system call tracer

# apt-get install strace
Reading Package Lists... Done
Building Dependency Tree... Done
strace is already the newest version.

Thanks,

-tduffy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20050113/46b397c7/attachment.bin>


More information about the Strace-devel mailing list