Master the fundamental concepts of linkers & loaders through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksA Linux process sees text, data, heap, mmap regions, stack, and kernel space in virtual memory. pmap, /proc/self/maps, and lldb's memory view show the same layout compilers and exploit mitigations depend on.
Low addresses: executable text, read-only rodata, writable data and BSS. Heap grows up via brk/mmap. Stack grows down from a high address. Libraries mmap between heap and stack.
cLoading…
mmap places shared libs and anonymous mappingsProduction compilers embed this step inside a longer pipeline. GCC flows through cpp, cc1, assembly, and ld; Clang uses the driver, Sema, LLVM IR passes, and a target backend. LLVM bitcode, JVM bytecode, and WASM are other familiar IRs at the same layer. The exercise isolates one pass so you can test it alone before chaining it to the next stage.
You will understand and visualize process memory layout. This exercise asks you to model segment addresses, heap/stack growth, and how the loader places ELF sections in virtual memory.
Turn a raw /proc/PID/maps dump into a readable picture of a process's memory layout: classify every mapping (program text, read-only data, data, heap, stack, shared libraries, anonymous memory, kernel-provided pages), total them up, and flag mappings that are both writable and executable.
Lines in /proc/PID/maps format, possibly unsorted:
cLoading…
START/END are hex; PERMS is four characters like r-xp. PATH is optional.
The program is the path of the mapping with the lowest start address.
| Category | Rule |
|---|---|
text | the program's path, executable |
rodata | the program's path, not executable, not writable |
data | the program's path, writable |
heap | path [heap] |
stack | path [stack] |
kernel | path [vdso], [vvar] or [vsyscall] |
lib | any other path containing .so |
file | any other path |
anon | no path |
Mappings sorted by start address:
cLoading…
with addresses as lower-case hex zero-padded to at least 12 digits, and sizes in KiB (4K). Then:
cLoading…
Input:
cLoading…
Output:
cLoading…
Hidden tests use unsorted input with a memory-mapped data file and the [vsyscall] page, and JIT-style rwxp mappings.