2.3.30: shared library text mapped at offset != 0.

Tigran Aivazian (tigran@sco.COM)
Wed, 8 Dec 1999 07:50:29 +0000 (GMT)


Hi guys,

Imagine Linux kernel loading an ELF dynamically linked executable. At
do_load_elf_binary() stage it will discover the ELF interpreter (say
/lib/libc.so.1, this is not PER_LINUX) and then load_elf_interp() will
create a shared mapping for the text and a private for data. All is well
so far. Now, the interpreter will proceed (in userspace) using mmap(2)
system call to map all the other libraries that the binary was linked with
(well simplified picture). I trace the parameters passed to do_mmap()
(and therefore do_mmap_pgoff()) and see that the text is mapped at file
offset = 0. But when I look at the /proc/<pid>/maps I see nonzero value
there:

(gdb) shell cat /proc/322/maps
00000000-00001000 r-xp 00000000 00:00 0
08048000-08049000 r-xp 00000000 08:03 133507 /root/uw7/h
08049000-0804a000 rwxp 00000000 08:03 133507 /root/uw7/h
40000000-4007d000 r-xp 00000000 08:03 54874 /uw7/usr/lib/libc.so.1
4007d000-4007f000 rwxp 0007d000 08:03 54874 /uw7/usr/lib/libc.so.1
40080000-4008d000 r-xp 00010000 08:03 53742
/uw7/usr/lib/libsocket.so.2
4008d000-40090000 rwxp 0000c000 08:03 53742
/uw7/usr/lib/libsocket.so.2
40090000-40091000 rw-p 00000000 08:03 179334 /dev/zero
40091000-400da000 r-xp 0004c000 08:03 53739 /uw7/usr/lib/libnsl.so.1
400da000-400dd000 rwxp 00048000 08:03 53739 /uw7/usr/lib/libnsl.so.1
400dd000-400e2000 rw-p 00000000 08:03 179334 /dev/zero
bffff000-c0000000 rwxp 00000000 00:00 0

see, the values 4c000 and 10000 in the 3rd column above?

In 2.3.24 the output looks like:

(gdb) shell cat /proc/338/maps
00000000-00001000 r-xp 00000000 00:00 0
08048000-08049000 r-xp 00000000 08:03 133507 /root/uw7/h
08049000-0804a000 rwxp 00000000 08:03 133507 /root/uw7/h
40000000-4007d000 r-xp 00000000 08:03 54874 /uw7/usr/lib/libc.so.1
4007d000-4007f000 rwxp 0007d000 08:03 54874 /uw7/usr/lib/libc.so.1
40080000-4008d000 r-xp 00000000 08:03 53742
/uw7/usr/lib/libsocket.so.2
4008d000-40090000 rwxp 0000c000 08:03 53742
/uw7/usr/lib/libsocket.so.2
40090000-40091000 rw-p 00000000 08:03 179334 /dev/zero
40091000-400da000 r-xp 00000000 08:03 53739 /uw7/usr/lib/libnsl.so.1
400da000-400dd000 rwxp 00048000 08:03 53739 /uw7/usr/lib/libnsl.so.1
400dd000-400e2000 rw-p 00000000 08:03 179334 /dev/zero
bffff000-c0000000 rwxp 00000000 00:00 0

so, we get offset=0 and everything works fine.

Although you cannot easily reproduce it (as it is not in PER_LINUX
personality), you can easily produce useful ideas as to how that offset
could have changed (without unmapping and remapping it) and send them to
me.

Thank you,
------
Tigran A. Aivazian | http://www.sco.com
Escalations Research Group | tel: +44-(0)1923-813796
Santa Cruz Operation Ltd | http://www.ocston.org/~tigran

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/