This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Fwd: Re: [Meta?] Where do I post proposals/ideas?
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: "Soni L." <fakedme+libc at gmail dot com>
- Cc: libc-help at sourceware dot org
- Date: Thu, 08 Jan 2015 10:52:41 -0200
- Subject: Re: Fwd: Re: [Meta?] Where do I post proposals/ideas?
- Authentication-results: sourceware.org; auth=none
- References: <54AE6EDF dot 6070501 at gmail dot com> <54AE70FA dot 20806 at gmail dot com> <54AE7C11 dot 1050307 at linux dot vnet dot ibm dot com> <54AE7D32 dot 60706 at gmail dot com>
On 08-01-2015 10:50, Soni L. wrote:
>
>
> On 08/01/15 10:46 AM, Adhemerval Zanella wrote:
>> On 08-01-2015 09:58, Soni L. wrote:
>>> Eh, I forgot to reply to the list...
>>>
>>>
>>> -------- Forwarded Message --------
>>> Subject: Re: [Meta?] Where do I post proposals/ideas?
>>> Date: Thu, 08 Jan 2015 09:49:51 -0200
>>> From: Soni L. <fakedme+libc@gmail.com>
>>> To: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
>>>
>>>
>>>
>>> On 08/01/15 09:33 AM, Adhemerval Zanella wrote:
>>>> On 08-01-2015 07:06, Soni L. wrote:
>>>>>
>>>>> On 08/01/15 02:13 AM, Paul Pluzhnikov wrote:
>>>>>> On Wed, Jan 7, 2015 at 5:56 PM, Soni L. <fakedme@gmail.com> wrote:
>>>>>>
>>>>>>> This is my proposal/idea:
>>>>>> 1. What actual problem does your proposal solve?
>>>>>> 2. Are you aware of dlmopen ?
>>>>>>
>>>>>
>>>>> Oh great I derped when configuring that gmail alias >.>
>>>>>
>>>>> 1. It solves a problem when loading 2 different <Lua/Python/insert something else> versions where you can't load extensions. For example, if you load Python 2 and Python 3, you can make it so trying to load Python 2 modules works, but then you wouldn't be able to load Python 3 modules, or vice-versa.
>>>>>
>>>>> 2. `man dlmopen`: No manual entry for dlmopen
>>>>>
>>>> dlfcn/dlfcn.h :
>>>>
>>>> #ifdef __USE_GNU
>>>> [...]
>>>> /* Type for namespace indeces. */
>>>> typedef long int Lmid_t;
>>>>
>>>> /* Special namespace ID values. */
>>>> # define LM_ID_BASE 0 /* Initial namespace. */
>>>> # define LM_ID_NEWLM -1 /* For dlmopen: request new namespace. */
>>>> [...]
>>>> /* Like `dlopen', but request object to be allocated in a new namespace. */
>>>> extern void *dlmopen (Lmid_t __nsid, const char *__file, int __mode) __THROWNL;
>>>>
>>>> /* Find the run-time address in the shared object HANDLE refers to
>>>> of the symbol called NAME with VERSION. */
>>>> extern void *dlvsym (void *__restrict __handle,
>>>> const char *__restrict __name,
>>>> const char *__restrict __version)
>>>> __THROW __nonnull ((2, 3));
>>>> #endif
>>>>
>>>
>>> Oh... And how do I use it?
>>>
>>>
>>>
>> $ cat dlmopen_test.c
>> #define _GNU_SOURCE
>>
>> #include <dlfcn.h>
>> #include <link.h>
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>> typedef void (*foo_t)(void);
>>
>> int
>> main (int argc, char **argv)
>> {
>> const char lib_string[] = "dummy.so.1";
>>
>> void *handle1 = dlmopen (LM_ID_NEWLM, lib_string, RTLD_LOCAL | RTLD_LAZY);
>> if (handle1 == NULL)
>> {
>> printf ("error: dlmopen failed (1)\n");
>> exit (EXIT_FAILURE);
>> }
>> printf ("handle1 = 0x%p\n", handle1);
>>
>> void *handle2 = dlmopen (LM_ID_NEWLM, lib_string, RTLD_LOCAL | RTLD_LAZY);
>> if (handle1 == NULL)
>> {
>> printf ("error: dlmopen failed (2)\n");
>> exit (EXIT_FAILURE);
>> }
>> printf ("handle1 = 0x%p\n", handle2);
>>
>> foo_t foo1 = (foo_t) dlsym (handle1, "foo");
>> if (foo1 == NULL)
>> {
>> printf ("error: dlvsym failed (1)\n");
>> exit (EXIT_FAILURE);
>> }
>> foo_t foo2 = (foo_t) dlsym (handle1, "foo");
>> if (foo1 == NULL)
>> {
>> printf ("error: dlvsym failed (2)\n");
>> exit (EXIT_FAILURE);
>> }
>>
>> foo1 ();
>> foo2 ();
>>
>> dlclose (handle1);
>> dlclose (handle2);
>>
>> return 0;
>> }
>>
>> $ cat dummy.c
>> #include <stdio.h>
>>
>> void foo(void)
>> {
>> printf ("foo\n");
>> }
>>
>> $ cat Makefile
>> CC=gcc
>> CFLAGS = -g -Wall
>>
>> all: dlmopen_test
>>
>> dlmopen_test: dlmopen_test.c dummy.so.1
>> $(CC) $< $(CFLAGS) -ldl -o $@
>>
>> dummy.so.1: dummy.o
>> $(CC) $< $(CFLAGS) -shared -o $@
>>
>> dummy.o: dummy.c
>> $(CC) $< $(CFLAGS) -fPIC -c -o $@
>>
>> .PHONY: clean
>>
>> clean:
>> rm -f dlmopen_test *.o dummy.so.1
>>
>> $ make
>> gcc dummy.c -g -Wall -fPIC -c -o dummy.o
>> gcc dummy.o -g -Wall -shared -o dummy.so.1
>> gcc dlmopen_test.c -g -Wall -ldl -o dlmopen_test
>>
>> $ LD_LIBRARY_PATH=. ./dlmopen_test
>> handle1 = 0x0xd12030
>> handle1 = 0x0xd132b0
>> foo
>> foo
>>
>
> And if I want dummy.c/dummy.so to open more .so's?
>
I can't see why not, I never tried thou.