From: Jan-Benedict G. <jb...@us...> - 2005-12-12 21:55:09
|
Update of /cvsroot/linux-vax/toolchain/patches In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4577 Added Files: glibc-000000-experimental.patch Log Message: - Starting to hack GNU libc. --- NEW FILE: glibc-000000-experimental.patch --- diff -Nurp glibc-clean/sysdeps/generic/ldsodefs.h glibc/sysdeps/generic/ldsodefs.h --- glibc-clean/sysdeps/generic/ldsodefs.h 2005-11-22 22:30:14.000000000 +0100 +++ glibc/sysdeps/generic/ldsodefs.h 2005-12-12 21:01:54.000000000 +0100 @@ -211,6 +211,8 @@ struct La_sparc32_regs; struct La_sparc32_retval; struct La_sparc64_regs; struct La_sparc64_retval; +struct La_vax_regs; +struct La_vax_retval; struct audit_ifaces { @@ -292,6 +294,11 @@ struct audit_ifaces const struct La_sparc64_regs *, unsigned int *, const char *name, long int *framesizep); + Elf32_Addr (*vax_gnu_pltenter) (Elf32_Sym *, unsigned int, + uintptr_t *, uintptr_t *, + const struct La_vax_regs *, + unsigned int *, const char *name, + long int *framesizep); #ifdef ARCH_PLTENTER_MEMBERS ARCH_PLTENTER_MEMBERS; #endif @@ -363,6 +370,11 @@ struct audit_ifaces const struct La_sparc32_regs *, struct La_sparc32_retval *, const char *); + unsigned int (*vax_gnu_pltexit) (Elf32_Sym *, unsigned int, + uintptr_t *, uintptr_t *, + const struct La_vax_regs *, + struct La_vax_retval *, + const char *); #ifdef ARCH_PLTEXIT_MEMBERS ARCH_PLTEXIT_MEMBERS; #endif diff -Nurp glibc-clean/sysdeps/unix/sysv/linux/vax/bits/fcntl.h glibc/sysdeps/unix/sysv/linux/vax/bits/fcntl.h --- glibc-clean/sysdeps/unix/sysv/linux/vax/bits/fcntl.h 1970-01-01 01:00:00.000000000 +0100 +++ glibc/sysdeps/unix/sysv/linux/vax/bits/fcntl.h 2005-12-12 19:58:40.000000000 +0100 @@ -0,0 +1,141 @@ +/* O_*, F_*, FD_* bit values for Linux. + Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _FCNTL_H +# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead." +#endif + + +#include <sys/types.h> + +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files + located on an ext2 file system */ +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_NOCTTY 0400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_NDELAY O_NONBLOCK +#define O_SYNC 010000 +#define O_FSYNC O_SYNC +#define O_ASYNC 020000 + +#ifdef __USE_GNU +# define O_DIRECTORY 040000 /* Must be a directory. */ +# define O_NOFOLLOW 0100000 /* Do not follow links. */ +#endif + +/* XXX missing */ +#ifdef __USE_LARGEFILE64 +# define O_LARGEFILE 0 +#endif + +/* For now Linux has synchronisity options for data and read operations. + We define the symbols here but let them do the same as O_SYNC since + this is a superset. */ +#if defined __USE_POSIX199309 || defined __USE_UNIX98 +# define O_DSYNC O_SYNC /* Synchronize data. */ +# define O_RSYNC O_SYNC /* Synchronize read operations. */ +#endif + +/* Values for the second argument to `fcntl'. */ +#define F_DUPFD 0 /* Duplicate file descriptor. */ +#define F_GETFD 1 /* Get file descriptor flags. */ +#define F_SETFD 2 /* Set file descriptor flags. */ +#define F_GETFL 3 /* Get file status flags. */ +#define F_SETFL 4 /* Set file status flags. */ +#define F_GETLK 5 /* Get record locking info. */ +#define F_SETLK 6 /* Set record locking info (non-blocking). */ +#define F_SETLKW 7 /* Set record locking info (blocking). */ + +/* XXX missing */ +#define F_GETLK64 5 /* Get record locking info. */ +#define F_SETLK64 6 /* Set record locking info (non-blocking). */ +#define F_SETLKW64 7 /* Set record locking info (blocking). */ + +#ifdef __USE_BSD +# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */ +# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */ +#endif + +#ifdef __USE_GNU +# define F_SETSIG 10 /* Set number of signal to be sent. */ +# define F_GETSIG 11 /* Get number of signal to be sent. */ +#endif + +/* For F_[GET|SET]FL. */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */ +#define F_RDLCK 0 /* Read lock. */ +#define F_WRLCK 1 /* Write lock. */ +#define F_UNLCK 2 /* Remove lock. */ + +/* for old implementation of bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +#ifdef __USE_BSD +/* Operations for bsd flock(), also used by the kernel implementation */ +# define LOCK_SH 1 /* shared lock */ +# define LOCK_EX 2 /* exclusive lock */ +# define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +# define LOCK_UN 8 /* remove lock */ +#endif + +struct flock + { + short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ + short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ +#ifndef __USE_FILE_OFFSET64 + __off_t l_start; /* Offset where the lock begins. */ + __off_t l_len; /* Size of the locked area; zero means until EOF. */ +#else + __off64_t l_start; /* Offset where the lock begins. */ + __off64_t l_len; /* Size of the locked area; zero means until EOF. */ +#endif + __pid_t l_pid; /* Process holding the lock. */ + }; + +#ifdef __USE_LARGEFILE64 +struct flock64 + { + short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ + short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ + __off64_t l_start; /* Offset where the lock begins. */ + __off64_t l_len; /* Size of the locked area; zero means until EOF. */ + __pid_t l_pid; /* Process holding the lock. */ + }; +#endif + +/* Define some more compatibility macros to be backward compatible with + BSD systems which did not managed to hide these kernel macros. */ +#ifdef __USE_BSD +# define FAPPEND O_APPEND +# define FFSYNC O_FSYNC +# define FASYNC O_ASYNC +# define FNONBLOCK O_NONBLOCK +# define FNDELAY O_NDELAY +#endif /* Use BSD. */ diff -Nurp glibc-clean/sysdeps/vax/bits/endian.h glibc/sysdeps/vax/bits/endian.h --- glibc-clean/sysdeps/vax/bits/endian.h 1970-01-01 01:00:00.000000000 +0100 +++ glibc/sysdeps/vax/bits/endian.h 2005-12-12 19:50:57.000000000 +0100 @@ -0,0 +1,7 @@ +/* VAX is little-endian. */ + +#ifndef _ENDIAN_H +# error "Never use <bits/endian.h> directly; include <endian.h> instead." +#endif + +#define __BYTE_ORDER __LITTLE_ENDIAN diff -Nurp glibc-clean/sysdeps/vax/bits/link.h glibc/sysdeps/vax/bits/link.h --- glibc-clean/sysdeps/vax/bits/link.h 1970-01-01 01:00:00.000000000 +0100 +++ glibc/sysdeps/vax/bits/link.h 2005-12-12 21:08:29.000000000 +0100 @@ -0,0 +1,56 @@ +/* Copyright (C) 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _LINK_H +# error "Never include <bits/link.h> directly; use <link.h> instead." +#endif + + +/* Registers for entry into PLT on VAX. */ +typedef struct La_vax_regs +{ + uint32_t lr_a0; + uint32_t lr_a1; + uint32_t lr_sp; +} La_vax_regs; + +/* Return values for calls from PLT on VAX. */ +typedef struct La_vax_retval +{ + uint32_t lrv_d0; + uint32_t lrv_d1; + uint32_t lrv_a0; + long double lrv_fp0; +} La_vax_retval; + +__BEGIN_DECLS +extern Elf32_Addr la_vax_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + La_vax_regs *__regs, + unsigned int *__flags, + const char *__symname, + long int *__framesizep); +extern unsigned int la_vax_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + const La_vax_regs *__inregs, + La_vax_retval *__outregs, + const char *symname); +__END_DECLS + diff -Nurp glibc-clean/sysdeps/vax/dl-machine.h glibc/sysdeps/vax/dl-machine.h --- glibc-clean/sysdeps/vax/dl-machine.h 1970-01-01 01:00:00.000000000 +0100 +++ glibc/sysdeps/vax/dl-machine.h 2005-12-12 22:42:00.000000000 +0100 @@ -0,0 +1,293 @@ +/* Machine-dependent ELF dynamic relocation inline functions. m68k version. + Copyright (C) 1996-2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef dl_machine_h +#define dl_machine_h + +#define ELF_MACHINE_NAME "vax" + +#include <sys/param.h> + +/* Return nonzero iff ELF header is compatible with the running host. */ +static inline int +elf_machine_matches_host (const Elf32_Ehdr *ehdr) +{ + return ehdr->e_machine == EM_VAX; +} + + +/* Return the link-time address of _DYNAMIC. Conveniently, this is the + first element of the GOT. This must be inlined in a function which + uses global data. */ +static inline Elf32_Addr +elf_machine_dynamic (void) +{ +#error "Not yet implemented -- this is from m68k" + register Elf32_Addr *got asm ("%a5"); + return *got; +} + + +/* Return the run-time load address of the shared object. */ +static inline Elf32_Addr +elf_machine_load_address (void) +{ +#error "Not yet implemented -- this is from m68k" + Elf32_Addr addr; + asm ("lea _dl_start(%%pc), %0\n\t" + "sub.l _dl_start@GOT.w(%%a5), %0" + : "=a" (addr)); + return addr; +} + + +/* Set up the loaded object described by L so its unrelocated PLT + entries will jump to the on-demand fixup code in dl-runtime.c. */ + +static inline int __attribute__ ((always_inline)) +elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) +{ +#error "Not yet implemented -- this is from m68k" + Elf32_Addr *got; + extern void _dl_runtime_resolve (Elf32_Word); + extern void _dl_runtime_profile (Elf32_Word); + + if (l->l_info[DT_JMPREL] && lazy) + { + /* The GOT entries for functions in the PLT have not yet been + filled in. Their initial contents will arrange when called + to push an offset into the .rela.plt section, push + _GLOBAL_OFFSET_TABLE_[1], and then jump to + _GLOBAL_OFFSET_TABLE_[2]. */ + got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]); + got[1] = (Elf32_Addr) l; /* Identify this shared object. */ + + /* The got[2] entry contains the address of a function which gets + called to get the address of a so far unresolved function and + jump to it. The profiling extension of the dynamic linker allows + to intercept the calls to collect information. In this case we + don't store the address in the GOT so that all future calls also + end in this function. */ + if (profile) + { + got[2] = (Elf32_Addr) &_dl_runtime_profile; + + if (GLRO(dl_profile) != NULL + && _dl_name_match_p (GLRO(dl_profile), l)) + { + /* This is the object we are looking for. Say that we really + want profiling and the timers are started. */ + GL(dl_profile_map) = l; + } + } + else + /* This function will get called to fix up the GOT entry indicated by + the offset on the stack, and then jump to the resolved address. */ + got[2] = (Elf32_Addr) &_dl_runtime_resolve; + } + + return lazy; +} + +#define ELF_MACHINE_RUNTIME_FIXUP_ARGS long int save_a0, long int save_a1 + + +/* Mask identifying addresses reserved for the user program, + where the dynamic linker should not map anything. */ +#define ELF_MACHINE_USER_ADDRESS_MASK 0x80000000UL + +/* Initial entry point code for the dynamic linker. + The C function `_dl_start' is the real entry point; + its return value is the user program's entry point. */ + +#define RTLD_START asm ("\ + .text\n\ + .globl _start\n\ + .type _start,@function\n\ +_start:\n\ + move.l %sp, -(%sp)\n\ + jbsr _dl_start\n\ + addq.l #4, %sp\n\ + /* FALLTHRU */\n\ +\n\ + .globl _dl_start_user\n\ + .type _dl_start_user,@function\n\ +_dl_start_user:\n\ + | Save the user entry point address in %a4.\n\ + move.l %d0, %a4\n\ + | See if we were run as a command with the executable file\n\ + | name as an extra leading argument.\n\ + move.l _dl_skip_args(%pc), %d0\n\ + | Pop the original argument count\n\ + move.l (%sp)+, %d1\n\ + | Subtract _dl_skip_args from it.\n\ + sub.l %d0, %d1\n\ + | Adjust the stack pointer to skip _dl_skip_args words.\n\ + lea (%sp, %d0*4), %sp\n\ + | Push back the modified argument count.\n\ + move.l %d1, -(%sp)\n\ + # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\ + pea 8(%sp, %d1*4)\n\ + pea 8(%sp)\n\ + move.l %d1, -(%sp)\n\ + move.l _rtld_local(%pc), -(%sp)\n\ + jbsr _dl_init_internal@PLTPC\n\ + addq.l #8, %sp\n\ + addq.l #8, %sp\n\ + | Pass our finalizer function to the user in %a1.\n\ + lea _dl_fini(%pc), %a1\n\ + | Initialize %fp with the stack pointer.\n\ + move.l %sp, %fp\n\ + | Jump to the user's entry point.\n\ + jmp (%a4)\n\ + .size _dl_start_user, . - _dl_start_user\n\ + .previous"); + +/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so + PLT entries should not be allowed to define the value. + ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one + of the main executable's symbols, as for a COPY reloc. */ +#define elf_machine_type_class(type) \ + ((((type) == R_68K_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \ + | (((type) == R_68K_COPY) * ELF_RTYPE_CLASS_COPY)) + +/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ +#define ELF_MACHINE_JMP_SLOT R_68K_JMP_SLOT + +/* The m68k never uses Elf32_Rel relocations. */ +#define ELF_MACHINE_NO_REL 1 + +static inline Elf32_Addr +elf_machine_fixup_plt (struct link_map *map, lookup_t t, + const Elf32_Rela *reloc, + Elf32_Addr *reloc_addr, Elf32_Addr value) +{ + return *reloc_addr = value; +} + +/* Return the final value of a plt relocation. On the m68k the JMP_SLOT + relocation ignores the addend. */ +static inline Elf32_Addr +elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, + Elf32_Addr value) +{ + return value; +} + +/* Names of the architecture-specific auditing callback functions. */ +#define ARCH_LA_PLTENTER vax_gnu_pltenter +#define ARCH_LA_PLTEXIT vax_gnu_pltexit + +#endif /* !dl_machine_h */ + +#ifdef RESOLVE_MAP + +/* Perform the relocation specified by RELOC and SYM (which is fully resolved). + MAP is the object containing the reloc. */ + +auto inline void __attribute__ ((unused, always_inline)) +elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, + const Elf32_Sym *sym, const struct r_found_version *version, + void *const reloc_addr_arg) +{ + Elf32_Addr *const reloc_addr = reloc_addr_arg; + const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); + + if (__builtin_expect (r_type == R_68K_RELATIVE, 0)) + *reloc_addr = map->l_addr + reloc->r_addend; + else + { + const Elf32_Sym *const refsym = sym; + struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type); + Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value; + + switch (r_type) + { + case R_68K_COPY: + if (sym == NULL) + /* This can happen in trace mode if an object could not be + found. */ + break; + if (sym->st_size > refsym->st_size + || (sym->st_size < refsym->st_size && GLRO(dl_verbose))) + { + const char *strtab; + + strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]); + _dl_error_printf ("\ +%s: Symbol `%s' has different size in shared object, consider re-linking\n", + rtld_progname ?: "<program name unknown>", + strtab + refsym->st_name); + } + memcpy (reloc_addr_arg, (void *) value, + MIN (sym->st_size, refsym->st_size)); + break; + case R_68K_GLOB_DAT: + case R_68K_JMP_SLOT: + *reloc_addr = value; + break; + case R_68K_8: + *(char *) reloc_addr = value + reloc->r_addend; + break; + case R_68K_16: + *(short *) reloc_addr = value + reloc->r_addend; + break; + case R_68K_32: + *reloc_addr = value + reloc->r_addend; + break; + case R_68K_PC8: + *(char *) reloc_addr + = value + reloc->r_addend - (Elf32_Addr) reloc_addr; + break; + case R_68K_PC16: + *(short *) reloc_addr + = value + reloc->r_addend - (Elf32_Addr) reloc_addr; + break; + case R_68K_PC32: + *reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr; + break; + case R_68K_NONE: /* Alright, Wilbur. */ + break; + default: + _dl_reloc_bad_type (map, r_type, 0); + break; + } + } +} + +auto inline void __attribute__ ((unused, always_inline)) +elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc, + void *const reloc_addr_arg) +{ + Elf32_Addr *const reloc_addr = reloc_addr_arg; + *reloc_addr = l_addr + reloc->r_addend; +} + +auto inline void __attribute__ ((unused, always_inline)) +elf_machine_lazy_rel (struct link_map *map, + Elf32_Addr l_addr, const Elf32_Rela *reloc) +{ + Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); + if (ELF32_R_TYPE (reloc->r_info) == R_68K_JMP_SLOT) + *reloc_addr += l_addr; + else + _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1); +} + +#endif /* RESOLVE_MAP */ diff -Nurp glibc-clean/sysdeps/vax/Implies glibc/sysdeps/vax/Implies --- glibc-clean/sysdeps/vax/Implies 1970-01-01 01:00:00.000000000 +0100 +++ glibc/sysdeps/vax/Implies 2005-12-12 19:49:25.000000000 +0100 @@ -0,0 +1 @@ +wordsize-32 |