///malloc replacement
void *bmalloc (size_t sz) __attribute__ (( alias ("malloc")));
///free replacement
void bfree (void *ptr) __attribute__ (( alias ("free")));
///posix_memalign replacement
int bposix_memalign (void **memptr, size_t alignment, size_t size) __attribute__ (( alias ("posix_memalign")));
///valloc replacement
void *bvalloc (size_t size) __attribute__ (( alias ("valloc")));
///memalign replacement
void *bmemalign (size_t boundary, size_t size) __attribute__ (( alias ("memalign")));
///calloc replacement
void *bcalloc (size_t nmemb, size_t size) __attribute__ (( alias ("calloc")));
///realloc replacement
void *brealloc (void *ptr, size_t size) __attribute__ (( alias ("realloc"))); struct ptr_info bptr_info (void *ptr) __attribute__ (( alias ("ptr_info")));
NORMAL {
global:
malloc;
calloc;
realloc;
free;
posix_memalign;
valloc;
memalign;
ptr_info;
envGetVal;
envGetNum;
envGetNumLim;
int_to_string;
local:
*;
};
DEBUG {
global:
bmalloc;
bcalloc;
brealloc;
bfree;
bposix_memalign;
bvalloc;
bmemalign;
bptr_info;
envGetVal;
envGetNum;
envGetNumLim;
int_to_string;
local:
*;
};
cc -D_REENTRANT -g -O0 -lpthread --library :../../libbmalloc.so.DEBUG -I../.. -Wall ./main.c
Hello,
I am just writing a library. It's buggy as hell.
It's the first compilable version after an episode of intense edits.
It's a malloc preload lib. with the default symbol names,
Of course the gdb will crash at startup.
So, I'd like to rename the symbols.
So I can run a minimal test.
in the c file I have(besides the malloc etc..)
the following aliases:
///malloc replacement
void *bmalloc (size_t sz) __attribute__ (( alias ("malloc")));
///free replacement
void bfree (void *ptr) __attribute__ (( alias ("free")));
///posix_memalign replacement
int bposix_memalign (void **memptr, size_t alignment, size_t size) __attribute__ (( alias ("posix_memalign")));
///valloc replacement
void *bvalloc (size_t size) __attribute__ (( alias ("valloc")));
///memalign replacement
void *bmemalign (size_t boundary, size_t size) __attribute__ (( alias ("memalign")));
///calloc replacement
void *bcalloc (size_t nmemb, size_t size) __attribute__ (( alias ("calloc")));
///realloc replacement
void *brealloc (void *ptr, size_t size) __attribute__ (( alias ("realloc")));
struct ptr_info bptr_info (void *ptr) __attribute__ (( alias ("ptr_info")));
the version script is:
NORMAL {
global:
malloc;
calloc;
realloc;
free;
posix_memalign;
valloc;
memalign;
ptr_info;
envGetVal;
envGetNum;
envGetNumLim;
int_to_string;
local:
*;
};
DEBUG {
global:
bmalloc;
bcalloc;
brealloc;
bfree;
bposix_memalign;
bvalloc;
bmemalign;
bptr_info;
envGetVal;
envGetNum;
envGetNumLim;
int_to_string;
local:
*;
};
linking the test program against the generated lib fails.
I've tried setting the soname to libbmalloc.so.DEBUG and linking to that filename
with
cc -D_REENTRANT -g -O0 -lpthread --library :../../libbmalloc.so.DEBUG -I../.. -Wall ./main.c
but none of the symbols are known. /home/klammerj/projects/alc/src/libbmalloc/tests/burn_in/./main.c:48: undefined reference to `bfree'
how do I do this?
Regards,
Johann
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 380 |
Nodes: | 16 (2 / 14) |
Uptime: | 53:01:21 |
Calls: | 8,144 |
Files: | 13,085 |
Messages: | 5,858,807 |