ld.so slight difference Linux and FreeBSD ports/127946

Maho NAKATA chat95 at mac.com
Fri Jun 19 04:53:53 UTC 2009


Hi Alxander and Konstantin,

Thanks for committing rtld patch.
according to the commit log,
http://www.freebsd.org/cgi/cvsweb.cgi/src/libexec/rtld-elf/rtld.c?rev=1.135;content-type=text%2Fx-cvsweb-markup
it seems the first one has been committed instead of the
modified one.

Konstantin says:
>> After discussion with Alexander, who pointed out that handles
>> returned from dlopen done over non-NULL name shall not search
>> in the namespace of objects opened with RTLD_GLOBAL flag,
>> I modified the patch.
his modified patch was not committed. I'm not sure which would fit
for FreeBSD, though.

>> Would be nice if you could retest the change below.
agian, it was tested on 7.2 and works fine.

Thanks,

From: Maho NAKATA <chat95 at mac.com>
Subject: Re: ld.so slight difference Linux and FreeBSD ports/127946
Date: Tue, 16 Jun 2009 21:01:03 +0900 (JST)

> Hi Konstantin and Alexander,
> 
> in short, your patch is ok.
> 
> * applied to 7.2-RELEASE/i386
> * small test program works.
> * ooo bad transfer error went away (tested with 3.1.0 from ports,
> and backout except.cc)
> 
> many thanks for your patch!!
> 
> Best,
> 
> From: Kostik Belousov <kostikbel at gmail.com>
> Subject: Re: ld.so slight difference Linux and FreeBSD ports/127946
> Date: Tue, 16 Jun 2009 00:08:31 +0300
> 
>> On Mon, Jun 15, 2009 at 05:46:54AM +0900, Maho NAKATA wrote:
>>> Hi Konstantin,
>>> 
>>> Your patch rocks! tested on FBSD7/i386 and it works!
>>> 
>>> * Small test program works.
>>> * also PR 127946 and Issue 22253 went away.
>>>  
>>> Is your patch can be commit to FBSD8 or MFC'ed to 7?
>> 
>> After discussion with Alexander, who pointed out that handles
>> returned from dlopen done over non-NULL name shall not search
>> in the namespace of objects opened with RTLD_GLOBAL flag,
>> I modified the patch.
>> 
>> Would be nice if you could retest the change below.
>> 
>> diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
>> index 40ed6ed..54acb8a 100644
>> --- a/libexec/rtld-elf/rtld.c
>> +++ b/libexec/rtld-elf/rtld.c
>> @@ -1048,9 +1048,13 @@ dlcheck(void *handle)
>>  {
>>      Obj_Entry *obj;
>>  
>> -    for (obj = obj_list;  obj != NULL;  obj = obj->next)
>> -	if (obj == (Obj_Entry *) handle)
>> -	    break;
>> +    if (handle == RTLD_HANDLE_FROM_NULL)
>> +	obj = obj_main;
>> +    else {
>> +	for (obj = obj_list;  obj != NULL;  obj = obj->next)
>> +	    if (obj == (Obj_Entry *) handle)
>> +		break;
>> +    }
>>  
>>      if (obj == NULL || obj->refcount == 0 || obj->dl_refcount == 0) {
>>  	_rtld_error("Invalid shared object handle %p", handle);
>> @@ -2054,6 +2058,8 @@ dlopen(const char *name, int mode)
>>      objlist_call_init(&initlist, &lockstate);
>>      objlist_clear(&initlist);
>>      wlock_release(rtld_bind_lock, lockstate);
>> +    if (name == NULL)
>> +	obj = RTLD_HANDLE_FROM_NULL;
>>      return obj;
>>  trace:
>>      trace_loaded_objects(obj);
>> @@ -2069,7 +2075,7 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve,
>>      const Obj_Entry *obj, *defobj;
>>      const Elf_Sym *def, *symp;
>>      unsigned long hash;
>> -    int lockstate;
>> +    int lockstate, search_global;
>>  
>>      hash = elf_hash(name);
>>      def = NULL;
>> @@ -2079,6 +2085,7 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve,
>>      lockstate = rlock_acquire(rtld_bind_lock);
>>      if (handle == NULL || handle == RTLD_NEXT ||
>>  	handle == RTLD_DEFAULT || handle == RTLD_SELF) {
>> +	search_global = true;
>>  
>>  	if ((obj = obj_from_addr(retaddr)) == NULL) {
>>  	    _rtld_error("Cannot determine caller's shared object");
>> @@ -2120,6 +2127,7 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve,
>>  	    def = symlook_default(name, hash, obj, &defobj, ve, flags);
>>  	}
>>      } else {
>> +	search_global = (handle == RTLD_HANDLE_FROM_NULL);
>>  	if ((obj = dlcheck(handle)) == NULL) {
>>  	    rlock_release(rtld_bind_lock, lockstate);
>>  	    return NULL;
>> @@ -2141,6 +2149,11 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve,
>>  				 &donelist);
>>  	}
>>      }
>> +    if (def == NULL && search_global) {
>> +	donelist_init(&donelist);
>> +	def = symlook_list(name, hash, &list_global, &defobj, ve, flags,
>> +			   &donelist);
>> +    }
>>  
>>      if (def != NULL) {
>>  	rlock_release(rtld_bind_lock, lockstate);
>> diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h
>> index 2b3b897..b16e57e 100644
>> --- a/libexec/rtld-elf/rtld.h
>> +++ b/libexec/rtld-elf/rtld.h
>> @@ -238,6 +238,9 @@ typedef struct Struct_Obj_Entry {
>>  #define SYMLOOK_DLSYM	0x02	/* Return newes versioned symbol. Used by
>>  				   dlsym. */
>>  
>> +/* Handle returned by dlopen(NULL, flags). */
>> +#define	RTLD_HANDLE_FROM_NULL	((void *) -100)
>> +
>>  /*
>>   * Symbol cache entry used during relocation to avoid multiple lookups
>>   * of the same symbol.
> _______________________________________________
> freebsd-openoffice at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-openoffice
> To unsubscribe, send any mail to "freebsd-openoffice-unsubscribe at freebsd.org"
> 


More information about the freebsd-openoffice mailing list