Skip to content
Snippets Groups Projects
Commit 873de118 authored by dem7yw's avatar dem7yw
Browse files

Add ifdefs around debug statements, update the makefile to actually use the...

Add ifdefs around debug statements, update the makefile to actually use the tests dir for the test target.
parent 171c6859
No related merge requests found
......@@ -9,7 +9,6 @@ noh.so: noh.o
noh.o: noh.c
$(CC) $(CFLAGS) noh.c
test:
LD_PRELOAD="./noh.so" ls
LD_PRELOAD="./noh.so ../DieHard/src/libheaprand.so" ls
make -C tests test
clean:
rm *.so *.o
......@@ -112,7 +112,9 @@ void* mmap(void* address, size_t length, int protect, int flags, int filedes, of
//size_t originallength = length;
size_t alignedlength = length;
void* new_mapping = MAP_FAILED;
#ifdef DEBUG
printf("entering mmap call\n");
#endif
if(
(address && (flags & MAP_FIXED)) // must use normal mmap, since the program is now guaranteed the destination address or failure
|| (flags & MAP_SHARED) // we're sharing between multiple programs, which is complex enough as it is - alignment is important, and we'd have to do funky stuff to ensure non-overlappingness with this regardless
......@@ -188,6 +190,8 @@ void* mmap(void* address, size_t length, int protect, int flags, int filedes, of
// in the event that we got the memory and such, mprotect the other portions so that they won't be able to be accesssed improperly
mprotect(new_mapping, alignedlength * nthisvar, PROT_NONE);
mprotect(new_mapping + alignedlength * (nthisvar+1), alignedlength * (nnumvar - (nthisvar + 1)), PROT_NONE);
#ifdef DEBUG
printf("returning new mapping at %p\n", new_mapping + alignedlength * nthisvar);
#endif
return new_mapping + alignedlength * nthisvar;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment