Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Dec 1997 20:30:24 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        hsu@FreeBSD.ORG (Jeffrey Hsu)
Cc:        jkh@time.cdrom.com, mike@smith.net.au, hackers@hub.freebsd.org, tlambert@primenet.com
Subject:   Re: shared library with static Motif?
Message-ID:  <199712072030.NAA28719@usr02.primenet.com>
In-Reply-To: <199712070013.QAA26928@hub.freebsd.org> from "Jeffrey Hsu" at Dec 6, 97 04:13:31 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> That is what I was trying to do.  The 2 points I was asking are
>   o How to do this technically.  You get the dreaded RSS relocation
> 	error messages when trying to statically link libXm.a functions
> 	into a shared library.  I now believe this is not possible.
>   o Does this qualify as static linking for redistribution purposes?
> 	If I pulled functions out of libXm.so and combined them into
> 	my liba.so, then the answer is obviously no.  Pulling functions
> 	out of libXm.a does not appear to be technically feasible (point
> 	one above).
> So it appears that this solution loses on both points.  Linking Motif
> routines statically into the final executable (rather than an intermediate
> shared library) does work okay.  I guess I'll have to do it that way.

You make a data reference to a routine or datum in each of the .o's in
libXm.a, and force the inclusion of your data object by making a non
called stub function to reference it:

	void *library_datum[] = {
		(void *)datum_from_object_one,
		(void *)function_from_object_two,
		(void *)function_from_object_three,
		...
		(void *)datum_from_object_N
	};

	void
	my_dummy_function( void)
	{
		void *save;

		save = library_datum[ 0];
		library_datum[ 0] = library_datum[ 1];
		library_datum[ 1] = save;
	}


The function reference from a non-library .o drags in the things
it references from libXm.a.

When you link, link ld -r  and link with the .a instead of as a lib
so that no relocation is done on the Motif library.

You now have an object which includes the Motif library.

Archive the object in your library.

You now have a library which includes Motif.


If you are ill, instead of making data references, you can make
function references using stub functions.  You can link the Motif
library high in the program address space so it is unlikely to
collide with data or code from a user program.  Then the library
can stay "shared".


I still don't think this is within the terms of the license.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712072030.NAA28719>