FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
numalloc/source-reducememory/real.cpp at master · UTSASRG/numalloc · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
UTSASRG
/
numalloc
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
3
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
numalloc
/
source-reducememory
/
real.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (48 loc) · 1.88 KB
Breadcrumbs
numalloc
/
source-reducememory
/
real.cpp
Copy path
File metadata and controls
52 lines (48 loc) · 1.88 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* FreeGuard: A Faster Secure Heap Allocator
* Copyright (C) 2017 Sam Silvestro, Hongyu Liu, Corey Crosser,
* Zhiqiang Lin, and Tongping Liu
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @file real.cpp: provides wrappers to glibc thread & memory functions.
* @author Tongping Liu <http://www.cs.utsa.edu/~tongpingliu/>
* @author Sam Silvestro <sam.silvestro@utsa.edu>
*/
#
include
<
dlfcn.h
>
#
include
<
stdlib.h
>
#
include
"
real.hh
"
#
define
DEFINE_WRAPPER
(
name
)
decltype
(::name) * name;
#
define
INIT_WRAPPER
(
name, handle
) name = (
decltype
(::name)*)dlsym(handle, #name);
namespace
Real
{
DEFINE_WRAPPER
(malloc);
DEFINE_WRAPPER
(free);
DEFINE_WRAPPER
(calloc);
DEFINE_WRAPPER
(realloc);
DEFINE_WRAPPER
(pthread_create);
DEFINE_WRAPPER
(pthread_join);
DEFINE_WRAPPER
(pthread_kill);
void
initializer
() {
INIT_WRAPPER
(malloc,
RTLD_NEXT
);
INIT_WRAPPER
(free,
RTLD_NEXT
);
INIT_WRAPPER
(calloc,
RTLD_NEXT
);
INIT_WRAPPER
(realloc,
RTLD_NEXT
);
//
FIXME about the flags
void
*pthread_handle =
dlopen
(
"
libpthread.so.0
"
,
RTLD_NOW
|
RTLD_GLOBAL
|
RTLD_NOLOAD
);
INIT_WRAPPER
(pthread_create, pthread_handle);
INIT_WRAPPER
(pthread_join, pthread_handle);
INIT_WRAPPER
(pthread_kill, pthread_handle);
}
}
Back
|
FazBrowse Home
|
New Git URL