Reputation: 509
I am looking for a program that does the following things:
./prog &
pmap
tool, program and [stack]
fields.This question isn't purely academic, I'm working on a memory scanner and I need a minimal example to work with.
The smallest I could come up with (in pure C) is:
#include <unistd.h>
int main(int argc, char **argv)
{
pause();
return 0;
}
but I'm sure this can be dwarfed with some assembly/compiler/C arcane magic, as this one eats over 180 KB of program+stack.
Upvotes: 1
Views: 265
Reputation: 93172
Try this program:
#include <sys/syscall.h>
.text
.globl _start
.type _start,@function
_start:
mov $SYS_pause,%eax
syscall # pause();
ud2 # crash if pause() returns (should not happen)
Save in a file named pause.S
(capital S) and assemble and link like this:
cc -c pause.S
ld -o pause pause.o
This shows as consuming one page of memory on my machine. This page is probably one page of stack space, as the text segment is mapped from the binary and thus does not consume RAM.
Upvotes: 6