* Problems when compiling -static
@ 2000-06-27 21:22 Michal Jaegermann
0 siblings, 0 replies; only message in thread
From: Michal Jaegermann @ 2000-06-27 21:22 UTC (permalink / raw)
To: axp-list
Before I will start to tear the whole system apart - does anybody
has a handle on that? I do not recall seeing something of that sort.
The following program (file, say, 'name.c'):
#include <stdio.h>
#include <stdlib.h>
#include <pwd.h>
#include <sys/types.h>
int
main (int argc, char *argv[])
{
struct passwd *pw;
uid_t uid = 0;
if (argc > 1) {
uid = atoi(argv[1]);
}
pw = getpwuid(uid);
printf("%p\n", pw);
if (pw) {
printf("%s\n", pw->pw_name);
}
return 0;
}
compiled on RH 6.2 on alpha with 'gcc -o name name.c' behaves like
expected. That means that it prints things of that sort:
$ ./name
0x2000034ff08
root
$ ./name 99
0x2000034ff08
nobody
But compiled with 'gcc -static -o name name.c' it will print
$ ./name
(nil)
$ ./name 99
(nil)
In other words getpwuid() always returns NULL if '-static' is present.
Changing optimization levels, versions of a compiler or a version of
binutils does not seem to have any effect; but when compiling on RH
6.1 distro everything looks ok. Still executables compiled 'static'
on RH 6.1, and running there correctly, will exhibit the same faulty
behaviour when copied to RH 6.2 installation (in other words, they are
not that static; bummer!).
I have reasons to suspect that libnss_... stuff is messed up here
but maybe only as a side effect? I will be grateful for any hits.
Oh, BTW, /etc/nsswitch.conf is sane on the system in question.
Michal
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-06-27 21:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-06-27 21:22 Problems when compiling -static Michal Jaegermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox