Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.os.linux.development.apps > #893

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

From Johann Klammer <klammerj@NOSPAM.a1.net>
Newsgroups comp.os.linux.development.apps
Subject Re: How do I link against a specific version-script tag?
Date 2019-01-18 23:06 +0100
Organization Aioe.org NNTP Server
Message-ID <q1tiks$1qqb$1@gioia.aioe.org> (permalink)
References <q1mu7c$81l$1@gioia.aioe.org>

Show all headers | View raw


On 01/16/2019 10:41 AM, Johann Klammer wrote:
> 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
> 
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)



Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Find similar


Thread

How do I link against a specific version-script tag? Johann Klammer <klammerj@NOSPAM.a1.net> - 2019-01-16 10:41 +0100
  Re: How do I link against a specific version-script tag? Johann Klammer <klammerj@NOSPAM.a1.net> - 2019-01-18 23:06 +0100

csiph-web