3.4 Mapping files

Radare IO allows to virtually map contents of files in the same IO space at random offsets. This is useful to open multiple files in a single view or just to 'emulate' an static environment like if it was in the debugger with the program and all its libraries mapped there.

Using the 'S'ections command you'll be able to define different base address for each library loaded at different offsets.

Mapping files is done with the 'o' (open) command. Let's read the help:

[0x00000000]> o?
Usage: o [file] [offset]
 > o /bin/ls                  ; open file
 > o /lib/libc.so 0xC848000   ; map file at offset
 > o- /lib/libc.so            ; unmap

Let's prepare a simple layout:

$ rabin -l ./a.out
$ radare -u ./a.out
[0x00000000]> o /lib/libc.so.6 0x10000000
[0x00000000]> o /lib/ld-2.7.so 0x465f2000

NOTE: radare has been started with the -u flag to ignore file size limits and being able to seek on far places like where we have mapped our libs.

Listing mapped files:

[0x00000000]> o
0x00000000 0x000018da ./a.out
0x465f2000 0x4660cf28 /lib/ld-2.7.so
0x10000000 0x101370ec /lib/libc.so.6

Let's print some strings from ld.so

[0x00000000]> pa @ 0x465F0000+ 2469

To unmap these files just use the 'o-' command giving the mapped file name as argument.