Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I link against a specific version-script tag?

14 views
Skip to first unread message

Johann Klammer

unread,
Jan 16, 2019, 4:41:02 AM1/16/19
to
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

Johann Klammer

unread,
Jan 18, 2019, 5:06:25 PM1/18/19
to
nevermind, it was missing a -Wl,...
also, it seems the -l:../../stuff
doesn't quite work without an additional path setting... -L../..
I seem to recall this is mentioned differently in some documentation....
(either the program library howto or info ld)




0 new messages