Subject: Re: TenDRA compiler __RENAME and more
To: =?us-ascii?Q?=3D=3Fiso-8859-1=3FQ=3FSebasti=3DE1n=5FJ?= =?us-ascii?Q?=2E?= _D=B4Alessandro?= <wonb@uolsinectis.com.ar>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-userlevel
Date: 08/04/2004 11:02:59
--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Aug 01, 2004 at 09:39:13PM -0300, =3D?iso-8859-1?Q?Sebasti=3DE1n_J.=
 _D=3DB4Alessandro?=3D wrote:

[snip]

>                         The question is: why is required the __RENAME
> definition on the system?, returning to the example, why would I define i=
n a
> program a function with 2 names (2 names before compiling)? Is this becau=
se
> the function was named diferent among other systems and this way someone =
can
> compile the program on all them?. I?m sorry if it obvious, I just don?t k=
now
> why __RENAME was created.

It's a way to change a function's prototype when you have shared=20
dynamic libraries without having to bump the library's major number.

The problem is that once a symbol (routine) is added to such a library,=20
you can compile a program to use it. Once you do that, you can't change=20
the symbol without breaking your program.

Note that the above definition of what a symbol is includes the layout of=
=20
structure(s) used. So the layout of a struct foo either passed to a=20
subroutine or exposed as a symbol is within the set of stuff you can't=20
change.

So what do we do when we want to change the layout of a structure or=20
otherwise change a prototype? Like we want to add stuff to the mount=20
arguements or change the data returned by stat(2)?

For extensive reasons, bumping the major number of libc is not an option.=
=20

So what do we do? We use RENAME(). We change struct stat and add a=20
__RENAME() to the stat(2) prototype to point to a prototype that will=20
always use this structure. If we ever change the structure (struct stat in=
=20
this example), we change the contents of the __RENAME() macro.

There also is a hook in the compilation of libc where we turn the=20
__RENAME() macro off, so that we can compile the old, pointed-to routines.

Take care,

Bill

--mP3DRpeJDSE+ciuQ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFBESTSWz+3JHUci9cRAq3aAJ9asIz76XduQYkrxPV3RrHU1MxVwwCfZ7Wz
GLXQGFCB90vWxbxFh5128AU=
=1WpS
-----END PGP SIGNATURE-----

--mP3DRpeJDSE+ciuQ--