Subject: Re: Compiling NetBSD with another compiler.
To: Bill Stouder-Studenmund <wrstuden@netbsd.org>
From: Aleksey Cheusov <cheusov@tut.by>
List: tech-userlevel
Date: 10/13/2007 13:01:09
> Renaming lets us patch the two things together. With it, your C code that 
> is written to call "stat()" really calls "__stat30()" which is the routine 
> (stub in libc for the syscall) that expects the new stat structure.

> So that's how we use renaming. We actually like it a lot. :-) We've done 
> it a number of times for struct stat...

Thank you all for your answers and detailed explanations
and especialy for a list of exceptions I also asked for.

As far as I understand the following demonstrates
an idea of function renaming.

     0 ~> cat main.c 
     #include <sys/cdefs.h>

     extern int func (void) __RENAME(func_new);

     int main (int argc, char **argv)
     {
        return func ();
     }
     0 ~> cat X.c    
     int func (void)
     {
        return 1;
     }

     int func_new (void)
     {
        return 2;
     }
     0 ~> gcc -c -o main.o main.c  
     0 ~> gcc -c -o X.o X.c        
     0 ~> nm main.o
     U func_new
     00000000 T main
     0 ~> nm X.o    
     00000000 T func
     0000000a T func_new
     0 ~> gcc -o main main.o X.o   
     0 ~> ./main
     2 ~> 

But I still don't understand one aspect.
Why non-portable way of doing this renaming is used instead of
just using macro like

   #define func func_new

for the example above. This may work for all compilers, not only gcc and pcc.

-- 
Best regards, Aleksey Cheusov.