bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

weak aliases


From: Neal H Walfield
Subject: weak aliases
Date: Mon, 26 Mar 2001 22:57:35 +0200
User-agent: Mutt/1.3.15i

If I turn functions into weak aliases to other functions, all works
fine until I reboot and get the following:

... ext2fs.static initmemory_object_data_request (0x0, 0x0, 0xf6000,
0x1000, 0x1) failed, 268435459.

What I am trying to do exactly is to convert the public functions
in libports into weak aliases so that other programs and libraries
can wrap them.  E.g. function x is renamed _x and x is made a weak
alias to _x.

I am using the weak_alias macro from libs/include/libc-symbols.h.

Here is one example:

<<
--- ../../hurd-20010307-snapshot/libports/port-ref.c    Tue Jun 20
18:31:54 1995
+++ port-ref.c  Sun Mar 25 16:26:55 2001
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1995 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001 Free Software Foundation, Inc.
    Written by Michael I. Bushnell.
 
    This file is part of the GNU Hurd.
@@ -18,12 +18,13 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
+#include "priv.h"
 #include "ports.h"
 #include <cthreads.h>
 #include <assert.h>
 
 void
-ports_port_ref (void *portstruct)
+_ports_port_ref (void *portstruct)
 {
   struct port_info *pi = portstruct;
   
@@ -33,4 +34,4 @@
   mutex_unlock (&_ports_lock);
 }
 
-  
+weak_alias (_ports_port_ref, ports_port_ref)   
>>

My motivation for doing this is the following: libdiskfs/dead-name.c
wraps the ports_dead_name in libports/dead-name.c inappropriately.
Which is to say that currently, it uses the linker to override the
function and then copies the code verbatim from libports/dead-name.c.
This meathod has at least two major failings failings: 

        * If libports/dead-name.c is changed, the override is now
        out of sink.  By using weak aliases, libdiskfs can override
        ports_dead_name and then call _ports_dead_name.

        * If libports is linked before libdiskfs, the function from
        libports will silently be used.

Comments?

Attachment: pgpBHNROttXFr.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]