This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/11464] New: vararg function assembled into int $0x5


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11464

           Summary: vararg function assembled into int $0x5
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kostya at tessart dot kiev dot ua
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-unknown-freebsd4.
  GCC host triplet: i386-unknown-freebsd4.
GCC target triplet: i386-unknown-freebsd4.

in the code below, function open is assembled to the instruction int $0x5

deviant% cc3 -v                                              ~/work/oasis/utils
Reading specs from
/usr/local/opt/gcc-3.3//lib/gcc-lib/i386-unknown-freebsd4.8/3.3/specs
Configured with: ../gcc-3.3/configure --prefix=/usr/local/opt/gcc-3.3/
--enable-shared --enable-threads --enable-languages=c,c++,f77,objc,ada
--disable-nls --with-as=/usr/local/opt/binutils/bin/as
--with-ld=/usr/local/opt/binutils/bin/ld
Thread model: posix
gcc version 3.3

command line:
cc3 -shared -fpic -O -g -W -Wall -save-temps -o vobs.so vobs.c

preprocessed source:

# 1 "vobs.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "vobs.c"



# 1 "/usr/include/unistd.h" 1 3 4
# 40 "/usr/include/unistd.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 41 "/usr/include/unistd.h" 2 3 4
# 1
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/sys/types.h"
1 3 4
# 57
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/sys/types.h"
3 4
# 1 "/usr/include/sys/inttypes.h" 1 3 4
# 9 "/usr/include/sys/inttypes.h" 3 4
# 1
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/machine/ansi.h"
1 3 4
# 127
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/machine/ansi.h"
3 4
typedef int __attribute__((__mode__(__DI__))) __int64_t;
typedef unsigned int __attribute__((__mode__(__DI__))) __uint64_t;
# 139
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/machine/ansi.h"
3 4
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;

typedef int __intptr_t;
typedef unsigned int __uintptr_t;





typedef union {
        char __mbstate8[128];
        __int64_t _mbstateL;
} __mbstate_t;
# 10 "/usr/include/sys/inttypes.h" 2 3 4

typedef __int8_t int8_t;
typedef __int16_t int16_t;
typedef __int32_t int32_t;
typedef __int64_t int64_t;

typedef __uint8_t uint8_t;
typedef __uint16_t uint16_t;
typedef __uint32_t uint32_t;
typedef __uint64_t uint64_t;

typedef __intptr_t intptr_t;
typedef __uintptr_t uintptr_t;
# 58
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/sys/types.h"
2 3 4
# 1 "/usr/include/machine/types.h" 1 3 4
# 41 "/usr/include/machine/types.h" 3 4
typedef struct _physadr {
        int r[1];
} *physadr;

typedef struct label_t {
        int val[6];
} label_t;


typedef unsigned int vm_offset_t;
typedef __int64_t vm_ooffset_t;
typedef unsigned int vm_pindex_t;
typedef unsigned int vm_size_t;

typedef __int32_t register_t;
typedef __uint32_t u_register_t;







typedef __uint32_t intrmask_t;


typedef void inthand2_t (void *_cookie);
typedef void ointhand2_t (int _device_id);
# 59
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/sys/types.h"
2 3 4


typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned short ushort;
typedef unsigned int uint;


typedef __uint8_t u_int8_t;
typedef __uint16_t u_int16_t;
typedef __uint32_t u_int32_t;
typedef __uint64_t u_int64_t;

typedef u_int64_t u_quad_t;
typedef int64_t quad_t;
typedef quad_t * qaddr_t;

typedef char * caddr_t;
typedef const char * c_caddr_t;
typedef volatile char *v_caddr_t;
typedef int32_t daddr_t;
typedef u_int32_t u_daddr_t;
typedef u_int32_t fixpt_t;
typedef u_int32_t gid_t;
typedef u_int32_t in_addr_t;
typedef u_int16_t in_port_t;
typedef u_int32_t ino_t;
typedef long key_t;
typedef u_int16_t mode_t;
typedef u_int16_t nlink_t;
typedef __int64_t off_t;
typedef int pid_t;
typedef quad_t rlim_t;



typedef int32_t segsz_t;

typedef int32_t swblk_t;
typedef int32_t ufs_daddr_t;
typedef u_int32_t uid_t;
# 117
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/sys/types.h"
3 4
typedef u_int32_t dev_t;
# 135
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/sys/types.h"
3 4
# 1 "/usr/include/machine/endian.h" 1 3 4
# 62 "/usr/include/machine/endian.h" 3 4

unsigned long htonl (unsigned long);
unsigned short htons (unsigned short);
unsigned long ntohl (unsigned long);
unsigned short ntohs (unsigned short);

# 136
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/sys/types.h"
2 3 4


typedef unsigned long clock_t;




typedef int clockid_t;






typedef unsigned int size_t;






typedef int ssize_t;




typedef long time_t;




typedef int timer_t;
# 184
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/sys/types.h"
3 4
typedef unsigned long fd_mask;






typedef struct fd_set {
        fd_mask fds_bits[(((1024) + (((sizeof(fd_mask) * 8)) - 1)) /
((sizeof(fd_mask) * 8)))];
} fd_set;
# 208
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/sys/types.h"
3 4



int ftruncate (int, off_t);



off_t lseek (int, off_t, int);



void * mmap (void *, size_t, int, int, int, off_t);



int truncate (const char *, off_t);


# 42 "/usr/include/unistd.h" 2 3 4
# 1 "/usr/include/sys/unistd.h" 1 3 4
# 40 "/usr/include/sys/unistd.h" 3 4
# 1 "/usr/include/sys/_posix.h" 1 3 4
# 41 "/usr/include/sys/unistd.h" 2 3 4
# 43 "/usr/include/unistd.h" 2 3 4
# 59 "/usr/include/unistd.h" 3 4

void _exit (int) __attribute__((__noreturn__));
int access (const char *, int);
unsigned int alarm (unsigned int);
int chdir (const char *);
int chown (const char *, uid_t, gid_t);
int close (int);
int dup (int);
int dup2 (int, int);
int execl (const char *, const char *, ...);
int execle (const char *, const char *, ...);
int execlp (const char *, const char *, ...);
int execv (const char *, char * const *);
int execve (const char *, char * const *, char * const *);
int execvp (const char *, char * const *);
pid_t fork (void);
long fpathconf (int, int);
char *getcwd (char *, size_t);
gid_t getegid (void);
uid_t geteuid (void);
gid_t getgid (void);
int getgroups (int, gid_t []);
char *getlogin (void);
pid_t getpgrp (void);
pid_t getpid (void);
pid_t getppid (void);
uid_t getuid (void);
int isatty (int);
int link (const char *, const char *);




long pathconf (const char *, int);
int pause (void);
int pipe (int *);
ssize_t read (int, void *, size_t);
int rmdir (const char *);
int setgid (gid_t);
int setpgid (pid_t, pid_t);
void setproctitle (const char *_fmt, ...) ;
pid_t setsid (void);
int setuid (uid_t);
unsigned int sleep (unsigned int);
long sysconf (int);
pid_t tcgetpgrp (int);
int tcsetpgrp (int, pid_t);
char *ttyname (int);
int unlink (const char *);
ssize_t write (int, const void *, size_t);

extern char *optarg;
extern int optind, opterr, optopt;
int getopt (int, char * const [], const char *);



struct timeval;

int acct (const char *);
int async_daemon (void);
int brk (const void *);
int chroot (const char *);
size_t confstr (int, char *, size_t);
char *crypt (const char *, const char *);
const char *
         crypt_get_format (void);
int crypt_set_format (const char *);
int des_cipher (const char *, char *, long, int);
int des_setkey (const char *key);
int encrypt (char *, int);
void endusershell (void);
int exect (const char *, char * const *, char * const *);
int fchdir (int);
int fchown (int, uid_t, gid_t);
char *fflagstostr (u_long);
int fsync (int);




int getdomainname (char *, int);
int getdtablesize (void);
int getgrouplist (const char *, int, int *, int *);
long gethostid (void);
int gethostname (char *, int);
int getlogin_r (char *, int);
mode_t getmode (const void *, mode_t);
int getpagesize (void) __attribute__((__const__));
char *getpass (const char *);
int getpeereid (int, uid_t *, gid_t *);
int getpgid (pid_t _pid);
int getresgid (gid_t *, gid_t *, gid_t *);
int getresuid (uid_t *, uid_t *, uid_t *);
int getsid (pid_t _pid);
char *getusershell (void);
char *getwd (char *);
int initgroups (const char *, int);
int iruserok (unsigned long, int, const char *, const char *);
int iruserok_sa (const void *, int, int, const char *, const char *);
int issetugid (void);
int lchown (const char *, uid_t, gid_t);
int lockf (int, int, off_t);
char *mkdtemp (char *);
int mknod (const char *, mode_t, dev_t);
int mkstemp (char *);
int mkstemps (char *, int);
char *mktemp (char *);
int nfssvc (int, void *);
int nice (int);
ssize_t pread (int, void *, size_t, off_t);
int profil (char *, size_t, vm_offset_t, int);
ssize_t pwrite (int, const void *, size_t, off_t);
int rcmd (char **, int, const char *, const char *, const char *, int *);

int rcmd_af (char **, int, const char *, const char *, const char *, int *, int);

int rcmdsh (char **, int, const char *, const char *, const char *, const char *);

char *re_comp (const char *);
int re_exec (const char *);
int readlink (const char *, char *, int);
int reboot (int);
int revoke (const char *);
pid_t rfork (int);
pid_t rfork_thread (int, void *, int (*) (void *), void *);
int rresvport (int *);
int rresvport_af (int *, int);
int ruserok (const char *, int, const char *, const char *);
void *sbrk (intptr_t);
int select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
int setdomainname (const char *, int);
int setegid (gid_t);
int seteuid (uid_t);
int setgroups (int, const gid_t *);
void sethostid (long);
int sethostname (const char *, int);
int setkey (const char *);
int setlogin (const char *);
void *setmode (const char *);
int setpgrp (pid_t _pid, pid_t _pgrp);
int setregid (gid_t, gid_t);
int setresgid (gid_t, gid_t, gid_t);
int setresuid (uid_t, uid_t, uid_t);
int setreuid (uid_t, uid_t);
int setrgid (gid_t);
int setruid (uid_t);
void setusershell (void);
int strtofflags (char **, u_long *, u_long *);
int swapon (const char *);
int symlink (const char *, const char *);
void sync (void);
int syscall (int, ...);
off_t __syscall (quad_t, ...);




int ttyslot (void);
unsigned int ualarm (unsigned int, unsigned int);
int undelete (const char *);
int unwhiteout (const char *);
int usleep (unsigned int);
void *valloc (size_t);
pid_t vfork (void);

extern char *suboptarg;
int getsubopt (char **, char * const *, char **);

extern int optreset;

# 5 "vobs.c" 2
# 1 "/usr/include/fcntl.h" 1 3 4
# 180 "/usr/include/fcntl.h" 3 4
struct flock {
        off_t l_start;
        off_t l_len;
        pid_t l_pid;
        short l_type;
        short l_whence;
};
# 201 "/usr/include/fcntl.h" 3 4

int open (const char *, int, ...);
int creat (const char *, mode_t);
int fcntl (int, int, ...);

int flock (int, int);


# 6 "vobs.c" 2
# 1
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/stdlib.h"
1 3 4
# 55
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/stdlib.h"
3 4
typedef int rune_t;
# 74
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/stdlib.h"
3 4
typedef int wchar_t;







typedef struct {
        int quot;
        int rem;
} div_t;

typedef struct {
        long quot;
        long rem;
} ldiv_t;
# 101
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/stdlib.h"
3 4
extern int __mb_cur_max;



void abort (void) __attribute__((__noreturn__));
int abs (int) __attribute__((__const__));
int atexit (void (*)(void));
double atof (const char *);
int atoi (const char *);
long atol (const char *);
void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *,
const void *));

void *calloc (size_t, size_t);
div_t div (int, int) __attribute__((__const__));
void exit (int) __attribute__((__noreturn__));
void free (void *);
char *getenv (const char *);
long labs (long) __attribute__((__const__));
ldiv_t ldiv (long, long) __attribute__((__const__));
void *malloc (size_t);
void qsort (void *, size_t, size_t, int (*)(const void *, const void *));

int rand (void);
void *realloc (void *, size_t);
void srand (unsigned);
double strtod (const char *, char **);
long strtol (const char *, char **, int);

long long
         strtoll (const char *, char **, int);

unsigned long
         strtoul (const char *, char **, int);

unsigned long long
         strtoull (const char *, char **, int);

int system (const char *);

int mblen (const char *, size_t);
size_t mbstowcs (wchar_t *, const char *, size_t);
int wctomb (char *, wchar_t);
int mbtowc (wchar_t *, const char *, size_t);
size_t wcstombs (char *, const wchar_t *, size_t);


int putenv (const char *);
int setenv (const char *, const char *, int);

double drand48 (void);
double erand48 (unsigned short[3]);
long jrand48 (unsigned short[3]);
void lcong48 (unsigned short[7]);
long lrand48 (void);
long mrand48 (void);
long nrand48 (unsigned short[3]);
unsigned short
        *seed48 (unsigned short[3]);
void srand48 (long);

void *alloca (size_t);

__uint32_t
         arc4random (void);
void arc4random_addrandom (unsigned char *dat, int datlen);
void arc4random_stir (void);
char *getbsize (int *, long *);
char *cgetcap (char *, char *, int);
int cgetclose (void);
int cgetent (char **, char **, char *);
int cgetfirst (char **, char **);
int cgetmatch (char *, char *);
int cgetnext (char **, char **);
int cgetnum (char *, char *, long *);
int cgetset (char *);
int cgetstr (char *, char *, char **);
int cgetustr (char *, char *, char **);

int daemon (int, int);
char *devname (int, int);
int getloadavg (double [], int);
const char *
        getprogname (void);

char *group_from_gid (unsigned long, int);
int heapsort (void *, size_t, size_t, int (*)(const void *, const void *));

char *initstate (unsigned long, char *, long);
int mergesort (void *, size_t, size_t, int (*)(const void *, const void *));

int radixsort (const unsigned char **, int, const unsigned char *, unsigned);

int sradixsort (const unsigned char **, int, const unsigned char *, unsigned);

int rand_r (unsigned *);
long random (void);
void *reallocf (void *, size_t);
char *realpath (const char *, char resolved_path[]);
void setprogname (const char *);
char *setstate (char *);
void srandom (unsigned long);
void srandomdev (void);
char *user_from_uid (unsigned long, int);

__int64_t strtoq (const char *, char **, int);
__uint64_t
         strtouq (const char *, char **, int);

void unsetenv (const char *);


# 7 "vobs.c" 2
# 1 "/usr/include/string.h" 1 3 4
# 52 "/usr/include/string.h" 3 4

void *memchr (const void *, int, size_t);
int memcmp (const void *, const void *, size_t);
void *memcpy (void *, const void *, size_t);
void *memmove (void *, const void *, size_t);
void *memset (void *, int, size_t);
char *strcat (char *, const char *);
char *strchr (const char *, int);
int strcmp (const char *, const char *);
int strcoll (const char *, const char *);
char *strcpy (char *, const char *);
size_t strcspn (const char *, const char *);
char *strerror (int);
size_t strlen (const char *);
char *strncat (char *, const char *, size_t);
int strncmp (const char *, const char *, size_t);
char *strncpy (char *, const char *, size_t);
char *strpbrk (const char *, const char *);
char *strrchr (const char *, int);
size_t strspn (const char *, const char *);
char *strstr (const char *, const char *);
char *strtok (char *, const char *);
size_t strxfrm (char *, const char *, size_t);



int bcmp (const void *, const void *, size_t);
void bcopy (const void *, void *, size_t);
void bzero (void *, size_t);
int ffs (int);
char *index (const char *, int);
void *memccpy (void *, const void *, int, size_t);
char *rindex (const char *, int);
int strcasecmp (const char *, const char *);
char *strcasestr (const char *, const char *);
char *strdup (const char *);
int strerror_r (int, char *, size_t);
size_t strlcat (char *, const char *, size_t);
size_t strlcpy (char *, const char *, size_t);
void strmode (int, char *);
int strncasecmp (const char *, const char *, size_t);
char *strnstr (const char *, const char *, size_t);
char *strsep (char **, const char *);
char *strsignal (int);
char *strtok_r (char *, const char *, char **);
void swab (const void *, void *, size_t);


# 8 "vobs.c" 2
# 1 "/usr/include/dlfcn.h" 1 3 4
# 70 "/usr/include/dlfcn.h" 3 4
typedef struct dl_info {
        const char *dli_fname;
        void *dli_fbase;
        const char *dli_sname;
        void *dli_saddr;
} Dl_info;
# 88 "/usr/include/dlfcn.h" 3 4
typedef struct dl_serpath {
        char * dls_name;
        unsigned int dls_flags;
} Dl_serpath;

typedef struct dl_serinfo {
        size_t dls_size;
        unsigned int dls_cnt;
        Dl_serpath dls_serpath[1];
} Dl_serinfo;


int dladdr (const void *, Dl_info *);
int dlclose (void *);
const char *dlerror (void);
int dlinfo (void *, int, void *);
void dllockinit (void *_context, void *(*_lock_create)(void *_context), void
(*_rlock_acquire)(void *_lock), void (*_wlock_acquire)(void *_lock), void
(*_lock_release)(void *_lock), void (*_lock_destroy)(void *_lock), void
(*_context_destroy)(void *_context));






void *dlopen (const char *, int);
void *dlsym (void *, const char *);

# 9 "vobs.c" 2
# 1 "/usr/include/stdio.h" 1 3 4
# 55 "/usr/include/stdio.h" 3 4
typedef __int64_t fpos_t;
# 66 "/usr/include/stdio.h" 3 4
struct __sbuf {
        unsigned char *_base;
        int _size;
};
# 97 "/usr/include/stdio.h" 3 4
typedef struct __sFILE {
        unsigned char *_p;
        int _r;
        int _w;
        short _flags;
        short _file;
        struct __sbuf _bf;
        int _lbfsize;


        void *_cookie;
        int (*_close) (void *);
        int (*_read) (void *, char *, int);
        fpos_t (*_seek) (void *, fpos_t, int);
        int (*_write) (void *, const char *, int);


        struct __sbuf _ub;
        unsigned char *_up;
        int _ur;


        unsigned char _ubuf[3];
        unsigned char _nbuf[1];


        struct __sbuf _lb;


        int _blksize;
        fpos_t _offset;
} FILE;


extern FILE *__stdinp, *__stdoutp, *__stderrp;

# 200 "/usr/include/stdio.h" 3 4

void clearerr (FILE *);
int fclose (FILE *);
int feof (FILE *);
int ferror (FILE *);
int fflush (FILE *);
int fgetc (FILE *);
int fgetpos (FILE *, fpos_t *);
char *fgets (char *, int, FILE *);
FILE *fopen (const char *, const char *);
int fprintf (FILE *, const char *, ...);
int fputc (int, FILE *);
int fputs (const char *, FILE *);
size_t fread (void *, size_t, size_t, FILE *);
FILE *freopen (const char *, const char *, FILE *);
int fscanf (FILE *, const char *, ...);
int fseek (FILE *, long, int);
int fsetpos (FILE *, const fpos_t *);
long ftell (FILE *);
size_t fwrite (const void *, size_t, size_t, FILE *);
int getc (FILE *);
int getchar (void);
char *gets (char *);

extern const int sys_nerr;
extern const char *const sys_errlist[];

void perror (const char *);
int printf (const char *, ...);
int putc (int, FILE *);
int putchar (int);
int puts (const char *);
int remove (const char *);
int rename (const char *, const char *);
void rewind (FILE *);
int scanf (const char *, ...);
void setbuf (FILE *, char *);
int setvbuf (FILE *, char *, int, size_t);
int sprintf (char *, const char *, ...);
int sscanf (const char *, const char *, ...);
FILE *tmpfile (void);
char *tmpnam (char *);
int ungetc (int, FILE *);
int vfprintf (FILE *, const char *, __builtin_va_list);
int vprintf (const char *, __builtin_va_list);
int vsprintf (char *, const char *, __builtin_va_list);

# 257 "/usr/include/stdio.h" 3 4

char *ctermid (char *);
FILE *fdopen (int, const char *);
int fileno (FILE *);
int ftrylockfile (FILE *);
void flockfile (FILE *);
void funlockfile (FILE *);








# 288 "/usr/include/stdio.h" 3 4








int asprintf (char **, const char *, ...) __attribute__((__format__ (__printf__,
2, 3)));
char *ctermid_r (char *);
char *fgetln (FILE *, size_t *);





const char *fmtcheck (const char *, const char *)
__attribute__((__format_arg__(2)));
int fpurge (FILE *);
int fseeko (FILE *, __int64_t, int);
__int64_t ftello (FILE *);
int getw (FILE *);
int pclose (FILE *);
FILE *popen (const char *, const char *);
int putw (int, FILE *);
void setbuffer (FILE *, char *, int);
int setlinebuf (FILE *);
char *tempnam (const char *, const char *);
int snprintf (char *, size_t, const char *, ...) __attribute__((__format__
(__printf__, 3, 4)));
int vasprintf (char **, const char *, __builtin_va_list)
            __attribute__((__format__ (__printf__, 2, 0)));
int vsnprintf (char *, size_t, const char *, __builtin_va_list)
            __attribute__((__format__ (__printf__, 3, 0)));
int vscanf (const char *, __builtin_va_list) __attribute__((__format__
(__scanf__, 1, 0)));
int vsscanf (const char *, const char *, __builtin_va_list)
            __attribute__((__format__ (__scanf__, 2, 0)));

# 335 "/usr/include/stdio.h" 3 4

FILE *funopen (const void *, int (*)(void *, char *, int), int (*)(void *, const
char *, int), fpos_t (*)(void *, fpos_t, int), int (*)(void *));













int __srget (FILE *);
int __svfscanf (FILE *, const char *, __builtin_va_list);
int __swbuf (int, FILE *);








static __inline int __sputc(int _c, FILE *_p) {
        if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
                return (*_p->_p++ = _c);
        else
                return (__swbuf(_c, _p));
}
# 10 "vobs.c" 2
# 1
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/stdarg.h"
1 3 4
# 43
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/stdarg.h"
3 4
typedef __builtin_va_list __gnuc_va_list;
# 105
"/usr/local/opt/gcc-3.3/lib/gcc-lib/i386-unknown-freebsd4.8/3.3/include/stdarg.h"
3 4
typedef __gnuc_va_list va_list;
# 11 "vobs.c" 2

static int (*real_open)(const char *path, int flags, int mode);
static int (*real_creat)(const char *path, mode_t mode);

struct vob
{
        const char *prefix;
        int prefix_len;
        const char *replacement;
        int replacement_len;
};

static struct vob v[2];

static void ctr1(void) __attribute__((constructor));
void ctr1(void)
{
        void *libc_h;
        libc_h = dlopen("libc.so.4", 2);
        if (libc_h == 0)
        {
                fprintf((__stderrp), "Vobs.so: opening libc failed, %s\n",
dlerror());
                exit(13);
        }
        real_open = dlsym(libc_h, "open");
        real_creat = dlsym(libc_h, "creat");
        dlclose(libc_h);
}

static void ctr2(void) __attribute__((constructor));
void ctr2(void)
{
        const char *envv;
        const char *p, *p1;
        struct vob *vv;

        envv = getenv("VOBS");
        if (envv == 0)
                return;
        vv = &v[0];
        for (p = envv; *p && *p != ':'; p++)
                ;
        vv -> prefix_len = p - envv;
        vv -> prefix = malloc(vv -> prefix_len + 1);
        strncpy((char *)(vv -> prefix), envv, vv -> prefix_len);
        ((char *)(vv -> prefix))[vv -> prefix_len] = '\0';
        if (*p == '\0')
                vv -> replacement = "";
        else
        {
                for (p1 = ++p; *p1; p1++)
                        ;
                vv -> replacement_len = p1 - p;
                vv -> replacement = malloc(vv -> replacement_len + 1);
                strncpy((char *)(vv -> replacement), p, vv -> replacement_len);
                ((char *)(vv -> replacement))[vv -> replacement_len] = '\0';
        }
}

static const char *mangle_path(const char *path)
{
        struct vob *vv;
        char *res;
        int l;

        for (vv = &v[0]; vv -> prefix != 0; vv++)
        {
                if (strncmp(path, vv -> prefix, vv -> prefix_len))
                        continue;
                l = strlen(path) + vv -> replacement_len - vv -> prefix_len;
                res = malloc(l + 1);
                strncpy(res, vv -> replacement, vv -> replacement_len);
                strncpy(res + vv -> replacement_len, path + vv -> prefix_len,
                        l - vv -> prefix_len);
                res[l] = '\0';
                fprintf((__stderrp), "Vobs: replaced %s by %s", path, res);
                return res;
        }

        return 0;
}

int open(const char *path, int flags, ...)
{
        va_list va;
        const char *mpath;
        mode_t mode;

        fprintf((__stderrp), "Vobs: trying to open %s\n", path);

        __builtin_va_start(va,flags);
        mode = __builtin_va_arg(va,mode_t);
        __builtin_va_end(va);
        mpath = mangle_path(path);
        if (mpath)
        {
                int ret = real_open(mpath, flags, mode);
                free((void *)mpath);
                return ret;
        }
        else
                return real_open(path, flags, mode);
}

int creat(const char *path, mode_t mode)
{
        const char *mpath = mangle_path(path);
        if (mpath)
        {
                int ret = real_creat(mpath, mode);
                free((void *)mpath);
                return ret;
        }
        else
                return real_creat(path, mode);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]