From a2e1b046f6891ac76830353f7afc97b0c6d27a64 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 7 Jan 1996 10:00:21 +0000 Subject: Sat Jan 6 16:39:14 1996 Roland McGrath * Makefile (subdirs): Added db. * resolv/Makefile (routines): Add res_data. * resolv/res_data.c, resolv/res_debug.c, resolv/resolv.h: Updated from BIND 4.9.3 final release. * elf/dynamic-link.h (elf_get_dynamic_info): Handle processor-specific tags. (ELF_DYNAMIC_DO_REL, ELF_DYNAMIC_DO_RELA): Handle absent DT_PLTREL tag. * elf/elf.h (DT_MIPS_NUM, DT_PROCNUM): New macros. * elf/link.h (struct link_map): Extend `l_info' by DT_PROCNUM. * sysdeps/i386/dl-machine.h (elf_machine_runtime_setup): Take new arg LAZY. Only do our work if LAZY and there is a DT_JMPREL record. * elf/dl-reloc.c (_dl_relocate_object): Call elf_machine_runtime_setup unconditionally, and pass it LAZY flag. * elf/dl-load.c: Fixed ELFMAG check to work for either byte order. Align end of load segment only to page size, not to segment alignment. --- ChangeLog | 23 ++++++++++ Makefile | 4 +- elf/dl-reloc.c | 9 ++-- elf/dynamic-link.h | 20 +++++--- elf/elf.h | 6 ++- elf/link.h | 9 ++-- resolv/Makefile | 4 +- resolv/res_data.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++ resolv/res_debug.c | 47 +++---------------- resolv/resolv.h | 3 +- sysdeps/i386/dl-machine.h | 25 +++++----- 11 files changed, 191 insertions(+), 73 deletions(-) create mode 100644 resolv/res_data.c diff --git a/ChangeLog b/ChangeLog index c7b7ded..bc02d71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +Sat Jan 6 16:39:14 1996 Roland McGrath + + * Makefile (subdirs): Added db. + + * resolv/Makefile (routines): Add res_data. + * resolv/res_data.c, resolv/res_debug.c, resolv/resolv.h: + Updated from BIND 4.9.3 final release. + + * elf/dynamic-link.h (elf_get_dynamic_info): Handle + processor-specific tags. + (ELF_DYNAMIC_DO_REL, ELF_DYNAMIC_DO_RELA): Handle absent DT_PLTREL tag. + + * elf/elf.h (DT_MIPS_NUM, DT_PROCNUM): New macros. + * elf/link.h (struct link_map): Extend `l_info' by DT_PROCNUM. + + * sysdeps/i386/dl-machine.h (elf_machine_runtime_setup): Take new + arg LAZY. Only do our work if LAZY and there is a DT_JMPREL record. + * elf/dl-reloc.c (_dl_relocate_object): Call + elf_machine_runtime_setup unconditionally, and pass it LAZY flag. + + * elf/dl-load.c: Fixed ELFMAG check to work for either byte order. + Align end of load segment only to page size, not to segment alignment. + Thu Jan 4 11:35:18 1996 Roland McGrath * sysdeps/mach/hurd/setitimer.c: Code rearranged a bit to use new diff --git a/Makefile b/Makefile index f1aae8e..4f1191d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. +# Copyright (C) 1991, 92, 93, 94, 95, 96 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 @@ -51,7 +51,7 @@ sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs)) endif # These are the subdirectories containing the library source. -subdirs = csu assert ctype locale intl math setjmp signal stdlib \ +subdirs = csu assert ctype db locale intl math setjmp signal stdlib \ stdio-common $(stdio) malloc string time dirent grp pwd \ posix io termios resource misc socket sysvipc gmon gnulib \ $(wildcard crypt) manual $(sysdep-subdirs) elf diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index 7e4f499..b7d484d 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -1,5 +1,5 @@ /* Relocate a shared object and resolve its references to other loaded objects. -Copyright (C) 1995 Free Software Foundation, Inc. +Copyright (C) 1995, 1996 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 @@ -93,10 +93,9 @@ _dl_relocate_object (struct link_map *l, int lazy) l->l_prev->l_next = l; } - if (l->l_info[DT_JMPREL] && lazy) - /* Set up the PLT so its unrelocated entries will - jump to _dl_runtime_resolve, which will relocate them. */ - elf_machine_runtime_setup (l); + /* Set up the PLT so its unrelocated entries will + jump to _dl_runtime_resolve, which will relocate them. */ + elf_machine_runtime_setup (l, lazy); l->l_relocated = 1; diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h index 84d440e..0c4e99d 100644 --- a/elf/dynamic-link.h +++ b/elf/dynamic-link.h @@ -25,11 +25,11 @@ Cambridge, MA 02139, USA. */ /* Read the dynamic section at DYN and fill in INFO with indices DT_*. */ static inline void -elf_get_dynamic_info (Elf32_Dyn *dyn, Elf32_Dyn *info[DT_NUM]) +elf_get_dynamic_info (Elf32_Dyn *dyn, Elf32_Dyn *info[DT_NUM + DT_PROCNUM]) { unsigned int i; - for (i = 0; i < DT_NUM; ++i) + for (i = 0; i < DT_NUM + DT_PROCNUM; ++i) info[i] = NULL; if (! dyn) @@ -37,8 +37,14 @@ elf_get_dynamic_info (Elf32_Dyn *dyn, Elf32_Dyn *info[DT_NUM]) while (dyn->d_tag != DT_NULL) { - assert (dyn->d_tag < DT_NUM); - info[dyn->d_tag] = dyn++; + if (dyn->d_tag < DT_NUM) + info[dyn->d_tag] = dyn; + else if (dyn->d_tag >= DT_LOPROC && + dyn->d_tag < DT_LOPROC + DT_PROCNUM) + info[dyn->d_tag - DT_LOPROC + DT_NUM] = dyn; + else + assert (! "bad dynamic tag"); + dyn++; } if (info[DT_RELA]) @@ -60,7 +66,8 @@ elf_get_dynamic_info (Elf32_Dyn *dyn, Elf32_Dyn *info[DT_NUM]) #define ELF_DYNAMIC_DO_REL(map, lazy, resolve) \ if ((map)->l_info[DT_REL]) \ elf_dynamic_do_rel ((map), DT_REL, DT_RELSZ, (resolve), 0); \ - if ((map)->l_info[DT_PLTREL]->d_un.d_val == DT_REL) \ + if ((map)->l_info[DT_PLTREL] && \ + (map)->l_info[DT_PLTREL]->d_un.d_val == DT_REL) \ elf_dynamic_do_rel ((map), DT_JMPREL, DT_PLTRELSZ, (resolve), (lazy)); #else #define ELF_DYNAMIC_DO_RELA(map, lazy, resolve) /* Nothing to do. */ @@ -72,7 +79,8 @@ elf_get_dynamic_info (Elf32_Dyn *dyn, Elf32_Dyn *info[DT_NUM]) #define ELF_DYNAMIC_DO_RELA(map, lazy, resolve) \ if ((map)->l_info[DT_RELA]) \ elf_dynamic_do_rela ((map), DT_RELA, DT_RELASZ, (resolve), 0); \ - if ((map)->l_info[DT_PLTREL]->d_un.d_val == DT_RELA) \ + if ((map)->l_info[DT_PLTREL] && \ + (map)->l_info[DT_PLTREL]->d_un.d_val == DT_RELA) \ elf_dynamic_do_rela ((map), DT_JMPREL, DT_PLTRELSZ, (resolve), (lazy)); #else #define ELF_DYNAMIC_DO_RELA(map, lazy, resolve) /* Nothing to do. */ diff --git a/elf/elf.h b/elf/elf.h index 85c992c..6eaf31f 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -1,5 +1,5 @@ /* This file defines standard ELF types, structures, and macros. -Copyright (C) 1995 Free Software Foundation, Inc. +Copyright (C) 1995, 1996 Free Software Foundation, Inc. Contributed by Ian Lance Taylor (ian@cygnus.com). This file is part of the GNU C Library. @@ -326,9 +326,10 @@ typedef struct #define DT_DEBUG 21 /* For debugging; unspecified */ #define DT_TEXTREL 22 /* Reloc might modify .text */ #define DT_JMPREL 23 /* Address of PLT relocs */ -#define DT_NUM 24 /* Number used. */ +#define DT_NUM 24 /* Number used */ #define DT_LOPROC 0x70000000 /* Start of processor-specific */ #define DT_HIPROC 0x7fffffff /* End of processor-specific */ +#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */ /* Standard 64 bit ELF types. */ @@ -573,6 +574,7 @@ typedef struct #define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ #define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ #define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ +#define DT_MIPS_NUM 0x15 /* Legal values for DT_MIPS_FLAG Elf32_Dyn entry. */ diff --git a/elf/link.h b/elf/link.h index 4848f4b..bdcfcf2 100644 --- a/elf/link.h +++ b/elf/link.h @@ -1,5 +1,5 @@ /* Run-time dynamic linker data structures for loaded ELF shared objects. -Copyright (C) 1995 Free Software Foundation, Inc. +Copyright (C) 1995, 1996 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 @@ -82,7 +82,10 @@ struct link_map They may change without notice. */ const char *l_libname; /* Name requested (before search). */ - Elf32_Dyn *l_info[DT_NUM]; /* Indexed pointers to dynamic section. */ + /* Indexed pointers to dynamic section. + [0,DT_NUM) are indexed by the processor-independent tags. + [DT_NUM,DT_NUM+DT_PROCNUM] are indexed by the tag minus DT_LOPROC. */ + Elf32_Dyn *l_info[DT_NUM + DT_PROCNUM]; const Elf32_Phdr *l_phdr; /* Pointer to program header table in core. */ Elf32_Word l_phnum; /* Number of program header entries. */ Elf32_Addr l_entry; /* Entry point location. */ @@ -141,7 +144,7 @@ extern int _dl_secure; zero; OBJECT is the name of the problematical shared object, or null if it is a general problem; ERRSTRING is a string describing the specific problem. */ - + extern void _dl_signal_error (int errcode, const char *object, const char *errstring) diff --git a/resolv/Makefile b/resolv/Makefile index f1a8701..db90dc7 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1994, 1995 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995, 1996 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 @@ -25,7 +25,7 @@ headers := resolv.h netdb.h arpa/nameser.h sys/bitypes.h distribute := ../conf/portability.h routines := gethnamaddr getnetbyaddr getnetbyname getnetent getnetnamadr \ - herror nsap_addr res_comp res_debug res_init res_mkquery \ + herror nsap_addr res_comp res_debug res_data res_init res_mkquery \ res_query res_send sethostent inet_addr include ../Rules diff --git a/resolv/res_data.c b/resolv/res_data.c new file mode 100644 index 0000000..18dbc83 --- /dev/null +++ b/resolv/res_data.c @@ -0,0 +1,114 @@ +/* + * ++Copyright++ 1995 + * - + * Copyright (c) 1995 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * - + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * - + * --Copyright-- + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char rcsid[] = "$Id$"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#if defined(BSD) && (BSD >= 199103) +# include +# include +# include +#else +# include "../conf/portability.h" +#endif + +const char *_res_opcodes[] = { + "QUERY", + "IQUERY", + "CQUERYM", + "CQUERYU", /* experimental */ + "NOTIFY", /* experimental */ + "5", + "6", + "7", + "8", + "UPDATEA", + "UPDATED", + "UPDATEDA", + "UPDATEM", + "UPDATEMA", + "ZONEINIT", + "ZONEREF", +}; + +const char *_res_resultcodes[] = { + "NOERROR", + "FORMERR", + "SERVFAIL", + "NXDOMAIN", + "NOTIMP", + "REFUSED", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "NOCHANGE", +}; diff --git a/resolv/res_debug.c b/resolv/res_debug.c index c5e68e3..b3dfcdf 100644 --- a/resolv/res_debug.c +++ b/resolv/res_debug.c @@ -76,43 +76,8 @@ static char rcsid[] = "$Id$"; # include "../conf/options.h" #endif -const char *_res_opcodes[] = { - "QUERY", - "IQUERY", - "CQUERYM", - "CQUERYU", /* experimental */ - "NOTIFY", /* experimental */ - "5", - "6", - "7", - "8", - "UPDATEA", - "UPDATED", - "UPDATEDA", - "UPDATEM", - "UPDATEMA", - "ZONEINIT", - "ZONEREF", -}; - -const char *_res_resultcodes[] = { - "NOERROR", - "FORMERR", - "SERVFAIL", - "NXDOMAIN", - "NOTIMP", - "REFUSED", - "6", - "7", - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "NOCHANGE", -}; +extern const char *_res_opcodes[]; +extern const char *_res_resultcodes[]; /* XXX: we should use getservbyport() instead. */ static const char * @@ -310,7 +275,7 @@ __fp_nquery(msg, len, file) putc('\n', file); } if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX)) - putc(';', file); + putc(';', file); if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) { fprintf(file, "; flags:"); if (hp->qr) @@ -342,10 +307,10 @@ __fp_nquery(msg, len, file) fprintf(file, ";; QUESTIONS:\n"); while (--n >= 0) { if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES)) - fprintf(file, ";;\t"); + fprintf(file, ";;\t"); TruncTest(cp); if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES)) - cp = p_cdnname(cp, msg, len, file); + cp = p_cdnname(cp, msg, len, file); else { int n; char name[MAXDNAME]; @@ -368,7 +333,7 @@ __fp_nquery(msg, len, file) __p_class(_getshort((u_char*)cp))); cp += INT16SZ; if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES)) - putc('\n', file); + putc('\n', file); } } /* diff --git a/resolv/resolv.h b/resolv/resolv.h index af92be4..fb3de28 100644 --- a/resolv/resolv.h +++ b/resolv/resolv.h @@ -78,7 +78,7 @@ * is new enough to contain a certain feature. */ -#define __RES 19950621 +#define __RES 19951031 /* * Resolver configuration file. @@ -121,6 +121,7 @@ struct __res_state { struct in_addr addr; u_int32_t mask; } sort_list[MAXRESOLVSORT]; + char pad[72]; /* On an i38this means 512b total. */ }; /* diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 7c22305..4ce4d4b 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -1,5 +1,5 @@ /* Machine-dependent ELF dynamic relocation inline functions. i386 version. -Copyright (C) 1995 Free Software Foundation, Inc. +Copyright (C) 1995, 1996 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 @@ -140,20 +140,23 @@ elf_machine_lazy_rel (struct link_map *map, const Elf32_Rel *reloc) entries will jump to the on-demand fixup code in dl-runtime.c. */ static inline void -elf_machine_runtime_setup (struct link_map *l) +elf_machine_runtime_setup (struct link_map *l, int lazy) { Elf32_Addr *got; extern void _dl_runtime_resolve (Elf32_Word); - /* 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 .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1], - and then jump to _GLOBAL_OFFSET_TABLE[2]. */ - got = (Elf32_Addr *) (l->l_addr + l->l_info[DT_PLTGOT]->d_un.d_ptr); - got[1] = (Elf32_Addr) l; /* Identify this shared object. */ - /* 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; + 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 .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1], + and then jump to _GLOBAL_OFFSET_TABLE[2]. */ + got = (Elf32_Addr *) (l->l_addr + l->l_info[DT_PLTGOT]->d_un.d_ptr); + got[1] = (Elf32_Addr) l; /* Identify this shared object. */ + /* 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; + } } -- cgit v1.1