Write a set of C functions to augment the standard C storage allocation routines to provide memory leak detection on the Intel IA-32 architecture.
The following functions will need to be provided:
When the user requests the allocation of a block, you must determine and remember which function is doing the allocation. You can do this by retrieving the return address for the call to the memory allocation routine and comparing this to the start and end addresses for registered functions.
You can call malloc and free to allocate and free blocks of memory. You might consider "over-allocating" memory in order to store control information with the allocated blocks.
When MLD_checkForLeak is called you must determine the address of the top of stack in order to bound the scan of the run-time stack.
When scanning memory for references to allocated blocks, assume that references (pointer values) will be allocated on a 32-bit boundary (i.e. address is evenly divisible by four). Also assume that if a pointer points into the middle of an allocated block, then the whole block is referenced.
Providing memory leak detection without function identification is worth 75% of the points. In this case MLD_registerFunction can do nothing, but it must be present (perhaps with a null function body).
Your implementation should be performed using C and Intel assembler. Put all your C code in the mld.c file and the Intel assembler code in the mld_asm.s file.
Your program will be graded primarily by testing it for correct functionality. However, you may lose points if your program is not properly structured or adequately documented. See the mandatory guidelines given in the course overview webpage.
Your assignment should be submitted for grading from a
CIS Linux machine (e.g. turing.unh.edu).
To turn in this assignment, type:
~cs611/bin/submit prog7 mld.c mld_asm.s
Do not turn in any other files!
Submissions can be checked by typing:
~cs611/bin/scheck prog7
To receive full credit for the assignment, you must turn in your files prior to 8am on Monday December 13. Programming assignments may be handed in late at a penalty of 2 points for one day late, 5 points for two days late, 10 points for three days late, 20 points for four days late, and 40 points for five days late. No program may be turned in more than 5 days late.
Your programs will be graded using an CIS Linux machine (e.g. turing.unh.edu) so be sure to test in that environment.
Remember: as always you are expected to do your own work on this assignment.
Comments and questions should be directed to hatcher@unh.edu