Binary compatibility loss regarding errno

Daniel Jacobowitz drow@mvista.com
Mon Dec 23 08:02:00 GMT 2002


Consider this program:

int rename (const char *, const char *);
extern int errno;

int main()
{
  printf ("%d\n", errno);
  errno = 1;
  printf ("%d\n", errno);
  rename ("foof", "barf");
  printf ("%d\n", errno);
  return 0;
}


OK, we all know that's not correct.  And it won't link with current CVS
glibc, which is OK.  However, it doesn't _work_ either, if compiled against
an older glibc (say 2.2.5, since that's what I've got lying around).  The
program has an R_386_COPY relocation for errno, glibc 2.2.5 had an
R_386_GLOB_DAT relocation for its accesses to errno.  But glibc 2.3 doesn't,
and the call to rename() sets errno inside of libc instead of in the
application's .bss section.


This is a pretty severe problem, since it silently makes applications ignore
errno.  I don't know how to resolve this without putting the external
relocation back in glibc, which I suspect you're trying to avoid.  Any
ideas?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



More information about the Libc-alpha mailing list