From owner-freebsd-ports Tue Sep 29 10:30:24 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA29615 for freebsd-ports-outgoing; Tue, 29 Sep 1998 10:30:24 -0700 (PDT) (envelope-from owner-freebsd-ports@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA29521 for ; Tue, 29 Sep 1998 10:30:08 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id KAA09737; Tue, 29 Sep 1998 10:30:01 -0700 (PDT) Received: (from nobody@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA28601; Tue, 29 Sep 1998 10:24:48 -0700 (PDT) (envelope-from nobody) Message-Id: <199809291724.KAA28601@hub.freebsd.org> Date: Tue, 29 Sep 1998 10:24:48 -0700 (PDT) From: taoka@infonets.hiroshima-u.ac.jp To: freebsd-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: www-1.0 Subject: ports/8090: ELF patch for editors/emacs (emacs-19.34b) Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 8090 >Category: ports >Synopsis: ELF patch for editors/emacs (emacs-19.34b) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Sep 29 10:30:00 PDT 1998 >Last-Modified: >Originator: Satoshi Taoka >Organization: Hiroshima Univ. in Japan >Release: FreeBSD 3.0-19980921-BETA >Environment: >Description: [ELF patch for editors/emacs (emacs-19.34b)] This PR has two patch files for editors/emacs (emacs-19.34b). patch-ac is a file which is renewed, and patch-ae is a new patch file. These were derived from emacs-20.3. [Notice] If you apply new patch-ac, then -ltermcap is linked to emacs instead of -lncurses. Because emacs terminates with a message 'Fatal error (11)' if -lncurses is linked under ELF system. >How-To-Repeat: >Fix: #!/bin/sh # This is a shell archive (produced by GNU sharutils 4.2). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 1998-09-30 01:41 JST by . # Source directory was `/a/brenda/work'. # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 1973 -rw-r--r-- patch-ac # 17911 -rw-r--r-- patch-ae # save_IFS="${IFS}" IFS="${IFS}:" gettext_dir=FAILED locale_dir=FAILED first_param="$1" for dir in $PATH do if test "$gettext_dir" = FAILED && test -f $dir/gettext \ && ($dir/gettext --version >/dev/null 2>&1) then set `$dir/gettext --version 2>&1` if test "$3" = GNU then gettext_dir=$dir fi fi if test "$locale_dir" = FAILED && test -f $dir/shar \ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1) then locale_dir=`$dir/shar --print-text-domain-dir` fi done IFS="$save_IFS" if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED then echo=echo else TEXTDOMAINDIR=$locale_dir export TEXTDOMAINDIR TEXTDOMAIN=sharutils export TEXTDOMAIN echo="$gettext_dir/gettext -s" fi touch -am 1231235999 $$.touch >/dev/null 2>&1 if test ! -f 1231235999 && test -f $$.touch; then shar_touch=touch else shar_touch=: echo $echo 'WARNING: not restoring timestamps. Consider getting and' $echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi rm -f 1231235999 $$.touch # if mkdir _sh06928; then $echo 'x -' 'creating lock directory' else $echo 'failed to create lock directory' exit 1 fi # ============= patch-ac ============== if test -f 'patch-ac' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'patch-ac' '(file already exists)' else $echo 'x -' extracting 'patch-ac' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'patch-ac' && --- orig/s/freebsd.h Mon Jun 10 05:14:32 1996 +++ src/s/freebsd.h Tue Sep 29 11:35:32 1998 @@ -1,5 +1,15 @@ X /* s/ file for freebsd system. */ X +/* Get the correct __FreeBSD_version, even if this is before that was + defined. */ +#ifndef __FreeBSD__ +#define __FreeBSD_version 199401 +#elif __FreeBSD__ == 1 +#define __FreeBSD_version 199405 +#else +#include +#endif + X /* '__FreeBSD__' is defined by the preprocessor on FreeBSD-1.1 and up. X Earlier versions do not have shared libraries, so inhibit them. X You can inhibit them on newer systems if you wish @@ -34,7 +44,6 @@ X #define LIBS_DEBUG X #define LIBS_SYSTEM -lutil X #define LIBS_TERMCAP -ltermcap -#define LIB_GCC -lgcc X X #define SYSV_SYSTEM_DIR X @@ -42,12 +51,28 @@ X #undef BSD_PGRPS X #define GETPGRP_NO_ARG X +#ifdef __ELF__ + +#define LD_SWITCH_SYSTEM +#define START_FILES pre-crt0.o /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o +#define UNEXEC unexelf.o +#define LIB_STANDARD -lgcc -lc -lgcc /usr/lib/crtend.o /usr/lib/crtn.o +#undef LIB_GCC +#define LIB_GCC + +#else /* not __ELF__ */ + X #ifndef NO_SHARED_LIBS X #define LD_SWITCH_SYSTEM -e start -dc -dp X #define HAVE_TEXT_START /* No need to define `start_of_text'. */ +#if __FreeBSD_version >= 300002 +#define START_FILES pre-crt0.o /usr/lib/aout/crt0.o +#else /* __FreeBSD_version < 300002 */ X #define START_FILES pre-crt0.o /usr/lib/crt0.o -#define UNEXEC unexsunos4.o +#endif /* __FreeBSD_version < 300002 */ +#define UNEXEC unexfreebsd.o X #define RUN_TIME_REMAP +#define LIB_GCC -lgcc X X #ifndef N_TRELOFF X #define N_PAGSIZ(x) __LDPGSZ @@ -63,6 +88,8 @@ X #endif /* __FreeBSD__ */ X #endif /* NO_SHARED_LIBS */ X +#endif /* not __ELF__ */ + X #define HAVE_WAIT_HEADER X #define HAVE_GETLOADAVG X /*#define HAVE_GETPAGESIZE /* configure now puts this in config.h */ @@ -80,6 +107,8 @@ X #define BSD 199103 X #elif __FreeBSD__ == 2 X #define BSD 199306 +#elif __FreeBSD__ == 3 +#define BSD 199506 X #endif X X #define WAITTYPE int SHAR_EOF $shar_touch -am 0930013598 'patch-ac' && chmod 0644 'patch-ac' || $echo 'restore of' 'patch-ac' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'patch-ac:' 'MD5 check failed' 6b6793eaa4fe80789a6a827d84178b0f patch-ac SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'patch-ac'`" test 1973 -eq "$shar_count" || $echo 'patch-ac:' 'original size' '1973,' 'current size' "$shar_count!" fi fi # ============= patch-ae ============== if test -f 'patch-ae' && test "$first_param" != -c; then $echo 'x -' SKIPPING 'patch-ae' '(file already exists)' else $echo 'x -' extracting 'patch-ae' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'patch-ae' && XFrom emacs-20.3/src/unexelf.c X X --- orig/unexelf.c Wed Jul 17 07:39:03 1996 +++ src/unexelf.c Mon Aug 10 11:33:12 1998 @@ -33,14 +33,14 @@ X * Modified heavily since then. X * X * Synopsis: - * unexec (new_name, a_name, data_start, bss_start, entry_address) - * char *new_name, *a_name; + * unexec (new_name, old_name, data_start, bss_start, entry_address) + * char *new_name, *old_name; X * unsigned data_start, bss_start, entry_address; X * X * Takes a snapshot of the program and makes an a.out format file in the X * file named by the string argument new_name. - * If a_name is non-NULL, the symbol table will be taken from the given file. - * On some machines, an existing a_name file is required. + * If old_name is non-NULL, the symbol table will be taken from the given file. + * On some machines, an existing old_name file is required. X * X * The boundaries within the a.out file may be adjusted with the data_start X * and bss_start arguments. Either or both may be given as 0 for defaults. @@ -420,8 +420,105 @@ X #include X #include X #include +#if !defined (__NetBSD__) && !defined (__OpenBSD__) X #include +#endif X #include +#if defined (__sony_news) && defined (_SYSTYPE_SYSV) +#include +#include +#endif /* __sony_news && _SYSTYPE_SYSV */ + +#if defined (__alpha__) && !defined (__NetBSD__) && !defined (__OpenBSD__) +/* Declare COFF debugging symbol table. This used to be in + /usr/include/sym.h, but this file is no longer included in Red Hat + 5.0 and presumably in any other glibc 2.x based distribution. */ +typedef struct { + short magic; + short vstamp; + int ilineMax; + int idnMax; + int ipdMax; + int isymMax; + int ioptMax; + int iauxMax; + int issMax; + int issExtMax; + int ifdMax; + int crfd; + int iextMax; + long cbLine; + long cbLineOffset; + long cbDnOffset; + long cbPdOffset; + long cbSymOffset; + long cbOptOffset; + long cbAuxOffset; + long cbSsOffset; + long cbSsExtOffset; + long cbFdOffset; + long cbRfdOffset; + long cbExtOffset; +} HDRR, *pHDRR; +#define cbHDRR sizeof(HDRR) +#define hdrNil ((pHDRR)0) +#endif + +#ifdef __NetBSD__ +/* + * NetBSD does not have normal-looking user-land ELF support. + */ +# ifdef __alpha__ +# define ELFSIZE 64 +# else +# define ELFSIZE 32 +# endif +# include + +# define PT_LOAD Elf_pt_load +# define SHT_SYMTAB Elf_sht_symtab +# define SHT_DYNSYM Elf_sht_dynsym +# define SHT_NULL Elf_sht_null +# define SHT_NOBITS Elf_sht_nobits +# define SHT_REL Elf_sht_rel +# define SHT_RELA Elf_sht_rela + +# define SHN_UNDEF Elf_eshn_undefined +# define SHN_ABS Elf_eshn_absolute +# define SHN_COMMON Elf_eshn_common + +/* + * The magic of picking the right size types is handled by the ELFSIZE + * definition above. + */ +# ifdef __STDC__ +# define ElfW(type) Elf_##type +# else +# define ElfW(type) Elf_/**/type +# endif + +# ifdef __alpha__ +# include +# define HDRR struct ecoff_symhdr +# define pHDRR HDRR * +# endif +#endif /* __NetBSD__ */ + +#ifdef __OpenBSD__ +# include +#endif + +#if __GNU_LIBRARY__ - 0 >= 6 +# include /* get ElfW etc */ +#endif + +#ifndef ElfW +# ifdef __STDC__ +# define ElfW(type) Elf32_##type +# else +# define ElfW(type) Elf32_/**/type +# endif +#endif X X #ifndef emacs X #define fatal(a, b, c) fprintf (stderr, a, b, c), exit (1) @@ -462,13 +559,13 @@ X */ X X #define OLD_SECTION_H(n) \ - (*(Elf32_Shdr *) ((byte *) old_section_h + old_file_h->e_shentsize * (n))) + (*(ElfW(Shdr) *) ((byte *) old_section_h + old_file_h->e_shentsize * (n))) X #define NEW_SECTION_H(n) \ - (*(Elf32_Shdr *) ((byte *) new_section_h + new_file_h->e_shentsize * (n))) + (*(ElfW(Shdr) *) ((byte *) new_section_h + new_file_h->e_shentsize * (n))) X #define OLD_PROGRAM_H(n) \ - (*(Elf32_Phdr *) ((byte *) old_program_h + old_file_h->e_phentsize * (n))) + (*(ElfW(Phdr) *) ((byte *) old_program_h + old_file_h->e_phentsize * (n))) X #define NEW_PROGRAM_H(n) \ - (*(Elf32_Phdr *) ((byte *) new_program_h + new_file_h->e_phentsize * (n))) + (*(ElfW(Phdr) *) ((byte *) new_program_h + new_file_h->e_phentsize * (n))) X X #define PATCH_INDEX(n) \ X do { \ @@ -478,9 +575,9 @@ X X /* Round X up to a multiple of Y. */ X -int +ElfW(Addr) X round_up (x, y) - int x, y; + ElfW(Addr) x, y; X { X int rem = x % y; X if (rem == 0) @@ -510,19 +607,22 @@ X /* Pointers to the file, program and section headers for the old and new X * files. X */ - Elf32_Ehdr *old_file_h, *new_file_h; - Elf32_Phdr *old_program_h, *new_program_h; - Elf32_Shdr *old_section_h, *new_section_h; + ElfW(Ehdr) *old_file_h, *new_file_h; + ElfW(Phdr) *old_program_h, *new_program_h; + ElfW(Shdr) *old_section_h, *new_section_h; X X /* Point to the section name table in the old file */ X char *old_section_names; X - Elf32_Addr old_bss_addr, new_bss_addr; - Elf32_Word old_bss_size, new_data2_size; - Elf32_Off new_data2_offset; - Elf32_Addr new_data2_addr; + ElfW(Addr) old_bss_addr, new_bss_addr; + ElfW(Word) old_bss_size, new_data2_size; + ElfW(Off) new_data2_offset; + ElfW(Addr) new_data2_addr; X X int n, nn, old_bss_index, old_data_index, new_data2_index; +#if defined ( __sony_news) && defined (_SYSTYPE_SYSV) + int old_sbss_index, old_mdebug_index; +#endif /* __sony_news && _SYSTYPE_SYSV */ X struct stat stat_buf; X X /* Open the old file & map it into the address space. */ @@ -535,7 +635,8 @@ X if (fstat (old_file, &stat_buf) == -1) X fatal ("Can't fstat (%s): errno %d\n", old_name, errno); X - old_base = mmap (0, stat_buf.st_size, PROT_READ, MAP_SHARED, old_file, 0); + old_base = mmap ((caddr_t) 0, stat_buf.st_size, PROT_READ, MAP_SHARED, + old_file, 0); X X if (old_base == (caddr_t) -1) X fatal ("Can't mmap (%s): errno %d\n", old_name, errno); @@ -547,9 +648,9 @@ X X /* Get pointers to headers & section names */ X - old_file_h = (Elf32_Ehdr *) old_base; - old_program_h = (Elf32_Phdr *) ((byte *) old_base + old_file_h->e_phoff); - old_section_h = (Elf32_Shdr *) ((byte *) old_base + old_file_h->e_shoff); + old_file_h = (ElfW(Ehdr) *) old_base; + old_program_h = (ElfW(Phdr) *) ((byte *) old_base + old_file_h->e_phoff); + old_section_h = (ElfW(Shdr) *) ((byte *) old_base + old_file_h->e_shoff); X old_section_names = (char *) old_base X + OLD_SECTION_H (old_file_h->e_shstrndx).sh_offset; X @@ -571,16 +672,61 @@ X if (old_bss_index == old_file_h->e_shnum) X fatal ("Can't find .bss in %s.\n", old_name, 0); X +#if defined (__sony_news) && defined (_SYSTYPE_SYSV) + for (old_sbss_index = 1; old_sbss_index < (int) old_file_h->e_shnum; + old_sbss_index++) + { +#ifdef DEBUG + fprintf (stderr, "Looking for .sbss - found %s\n", + old_section_names + OLD_SECTION_H (old_sbss_index).sh_name); +#endif + if (!strcmp (old_section_names + OLD_SECTION_H (old_sbss_index).sh_name, + ".sbss")) + break; + } + if (old_sbss_index == old_file_h->e_shnum) + { + old_bss_addr = OLD_SECTION_H(old_bss_index).sh_addr; + old_bss_size = OLD_SECTION_H(old_bss_index).sh_size; + new_data2_offset = OLD_SECTION_H(old_bss_index).sh_offset; + new_data2_index = old_bss_index; + } + else + { + old_bss_addr = OLD_SECTION_H(old_sbss_index).sh_addr; + old_bss_size = OLD_SECTION_H(old_bss_index).sh_size + + OLD_SECTION_H(old_sbss_index).sh_size; + new_data2_offset = OLD_SECTION_H(old_sbss_index).sh_offset; + new_data2_index = old_sbss_index; + } + + for (old_mdebug_index = 1; old_mdebug_index < (int) old_file_h->e_shnum; + old_mdebug_index++) + { +#ifdef DEBUG + fprintf (stderr, "Looking for .mdebug - found %s\n", + old_section_names + OLD_SECTION_H (old_mdebug_index).sh_name); +#endif + if (!strcmp (old_section_names + OLD_SECTION_H (old_mdebug_index).sh_name, + ".mdebug")) + break; + } + if (old_mdebug_index == old_file_h->e_shnum) + old_mdebug_index = 0; +#else /* not (__sony_news && _SYSTYPE_SYSV) */ X old_bss_addr = OLD_SECTION_H (old_bss_index).sh_addr; X old_bss_size = OLD_SECTION_H (old_bss_index).sh_size; -#if defined(emacs) || !defined(DEBUG) - new_bss_addr = (Elf32_Addr) sbrk (0); +#endif /* not (__sony_news && _SYSTYPE_SYSV) */ +#if defined (emacs) || !defined (DEBUG) + new_bss_addr = (ElfW(Addr)) sbrk (0); X #else X new_bss_addr = old_bss_addr + old_bss_size + 0x1234; X #endif X new_data2_addr = old_bss_addr; X new_data2_size = new_bss_addr - old_bss_addr; +#if !defined (__sony_news) || !defined (_SYSTYPE_SYSV) X new_data2_offset = OLD_SECTION_H (old_bss_index).sh_offset; +#endif /* not (__sony_news && _SYSTYPE_SYSV) */ X X #ifdef DEBUG X fprintf (stderr, "old_bss_index %d\n", old_bss_index); @@ -610,19 +756,19 @@ X fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno); X X #ifdef UNEXEC_USE_MAP_PRIVATE - new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, - new_file, 0); + new_base = mmap ((caddr_t) 0, new_file_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE, new_file, 0); X #else - new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_SHARED, - new_file, 0); + new_base = mmap ((caddr_t) 0, new_file_size, PROT_READ | PROT_WRITE, + MAP_SHARED, new_file, 0); X #endif X X if (new_base == (caddr_t) -1) X fatal ("Can't mmap (%s): errno %d\n", new_name, errno); X - new_file_h = (Elf32_Ehdr *) new_base; - new_program_h = (Elf32_Phdr *) ((byte *) new_base + old_file_h->e_phoff); - new_section_h = (Elf32_Shdr *) + new_file_h = (ElfW(Ehdr) *) new_base; + new_program_h = (ElfW(Phdr) *) ((byte *) new_base + old_file_h->e_phoff); + new_section_h = (ElfW(Shdr) *) X ((byte *) new_base + old_file_h->e_shoff + new_data2_size); X X /* Make our new file, program and section headers as copies of the @@ -665,8 +811,14 @@ X if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment) X alignment = OLD_SECTION_H (old_bss_index).sh_addralign; X +#if defined (__sony_news) && defined (_SYSTYPE_SYSV) + if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz + > round_up (old_bss_addr, alignment)) + fatal ("Program segment above .bss in %s\n", old_name, 0); +#else /* not (__sony_news && _SYSTYPE_SYSV) */ X if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz > old_bss_addr) X fatal ("Program segment above .bss in %s\n", old_name, 0); +#endif /* not (__sony_news && _SYSTYPE_SYSV) */ X X if (NEW_PROGRAM_H (n).p_type == PT_LOAD X && (round_up ((NEW_PROGRAM_H (n)).p_vaddr @@ -678,7 +830,9 @@ X if (n < 0) X fatal ("Couldn't find segment next to .bss in %s\n", old_name, 0); X - NEW_PROGRAM_H (n).p_filesz += new_data2_size; + /* Make sure that the size includes any padding before the old .bss + section. */ + NEW_PROGRAM_H (n).p_filesz = new_bss_addr - NEW_PROGRAM_H (n).p_vaddr; X NEW_PROGRAM_H (n).p_memsz = NEW_PROGRAM_H (n).p_filesz; X X #if 0 /* Maybe allow section after data2 - does this ever happen? */ @@ -712,8 +866,17 @@ X for (n = 1, nn = 1; n < (int) old_file_h->e_shnum; n++, nn++) X { X caddr_t src; - /* If it is bss section, insert the new data2 section before it. */ - if (n == old_bss_index) + int temp_index; +#if defined (__sony_news) && defined (_SYSTYPE_SYSV) + /* If it is (s)bss section, insert the new data2 section before it. */ + /* new_data2_index is the index of either old_sbss or old_bss, that was + chosen as a section for new_data2. */ + temp_index = new_data2_index; +#else /* not (__sony_news && _SYSTYPE_SYSV) */ + /* If it is bss section, insert the new data2 section before it. */ + temp_index = old_bss_index; +#endif /* not (__sony_news && _SYSTYPE_SYSV) */ + if (n == temp_index) X { X /* Steal the data section header for this data2 section. */ X memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (old_data_index), @@ -736,10 +899,14 @@ X X memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n), X old_file_h->e_shentsize); - - /* The new bss section's size is zero, and its file offset and virtual - address should be off by NEW_DATA2_SIZE. */ - if (n == old_bss_index) + + if (n == old_bss_index +#if defined (__sony_news) && defined (_SYSTYPE_SYSV) + /* The new bss and sbss section's size is zero, and its file offset + and virtual address should be off by NEW_DATA2_SIZE. */ + || n == old_sbss_index +#endif /* __sony_news and _SYSTYPE_SYSV */ + ) X { X /* NN should be `old_bss_index + 1' at this point. */ X NEW_SECTION_H (nn).sh_offset += new_data2_size; @@ -799,6 +966,18 @@ X ".data" in the strings table) get copied from the current process X instead of the old file. */ X if (!strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".data") +#ifdef _nec_ews_svr4 /* hir, 1994.6.13 */ + || !strcmp ((old_section_names + NEW_SECTION_H(n).sh_name), + ".sdata") +#endif +#if defined (__sony_news) && defined (_SYSTYPE_SYSV) + || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), + ".sdata") + || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), + ".lit4") + || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), + ".lit8") +#endif /* __sony_news && _SYSTYPE_SYSV */ X || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), X ".data1")) X src = (caddr_t) OLD_SECTION_H (n).sh_addr; @@ -808,13 +987,57 @@ X memcpy (NEW_SECTION_H (nn).sh_offset + new_base, src, X NEW_SECTION_H (nn).sh_size); X +#ifdef __alpha__ + /* Update Alpha COFF symbol table: */ + if (strcmp (old_section_names + OLD_SECTION_H (n).sh_name, ".mdebug") + == 0) + { + pHDRR symhdr = (pHDRR) (NEW_SECTION_H (nn).sh_offset + new_base); + + symhdr->cbLineOffset += new_data2_size; + symhdr->cbDnOffset += new_data2_size; + symhdr->cbPdOffset += new_data2_size; + symhdr->cbSymOffset += new_data2_size; + symhdr->cbOptOffset += new_data2_size; + symhdr->cbAuxOffset += new_data2_size; + symhdr->cbSsOffset += new_data2_size; + symhdr->cbSsExtOffset += new_data2_size; + symhdr->cbFdOffset += new_data2_size; + symhdr->cbRfdOffset += new_data2_size; + symhdr->cbExtOffset += new_data2_size; + } +#endif /* __alpha__ */ + +#if defined (__sony_news) && defined (_SYSTYPE_SYSV) + if (NEW_SECTION_H (nn).sh_type == SHT_MIPS_DEBUG && old_mdebug_index) + { + int diff = NEW_SECTION_H(nn).sh_offset + - OLD_SECTION_H(old_mdebug_index).sh_offset; + HDRR *phdr = (HDRR *)(NEW_SECTION_H (nn).sh_offset + new_base); + + if (diff) + { + phdr->cbLineOffset += diff; + phdr->cbDnOffset += diff; + phdr->cbPdOffset += diff; + phdr->cbSymOffset += diff; + phdr->cbOptOffset += diff; + phdr->cbAuxOffset += diff; + phdr->cbSsOffset += diff; + phdr->cbSsExtOffset += diff; + phdr->cbFdOffset += diff; + phdr->cbRfdOffset += diff; + phdr->cbExtOffset += diff; + } + } +#endif /* __sony_news && _SYSTYPE_SYSV */ X /* If it is the symbol table, its st_shndx field needs to be patched. */ X if (NEW_SECTION_H (nn).sh_type == SHT_SYMTAB X || NEW_SECTION_H (nn).sh_type == SHT_DYNSYM) X { - Elf32_Shdr *spt = &NEW_SECTION_H (nn); + ElfW(Shdr) *spt = &NEW_SECTION_H (nn); X unsigned int num = spt->sh_size / spt->sh_entsize; - Elf32_Sym * sym = (Elf32_Sym *) (NEW_SECTION_H (nn).sh_offset + + ElfW(Sym) * sym = (ElfW(Sym) *) (NEW_SECTION_H (nn).sh_offset + X new_base); X for (; num--; sym++) X { @@ -832,7 +1055,7 @@ X for (n = new_file_h->e_shnum - 1; n; n--) X { X byte *symnames; - Elf32_Sym *symp, *symendp; + ElfW(Sym) *symp, *symendp; X X if (NEW_SECTION_H (n).sh_type != SHT_DYNSYM X && NEW_SECTION_H (n).sh_type != SHT_SYMTAB) @@ -840,12 +1063,14 @@ X X symnames = ((byte *) new_base X + NEW_SECTION_H (NEW_SECTION_H (n).sh_link).sh_offset); - symp = (Elf32_Sym *) (NEW_SECTION_H (n).sh_offset + new_base); - symendp = (Elf32_Sym *) ((byte *)symp + NEW_SECTION_H (n).sh_size); + symp = (ElfW(Sym) *) (NEW_SECTION_H (n).sh_offset + new_base); + symendp = (ElfW(Sym) *) ((byte *)symp + NEW_SECTION_H (n).sh_size); X X for (; symp < symendp; symp ++) X if (strcmp ((char *) (symnames + symp->st_name), "_end") == 0 - || strcmp ((char *) (symnames + symp->st_name), "_edata") == 0) + || strcmp ((char *) (symnames + symp->st_name), "end") == 0 + || strcmp ((char *) (symnames + symp->st_name), "_edata") == 0 + || strcmp ((char *) (symnames + symp->st_name), "edata") == 0) X memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr)); X } X @@ -853,7 +1078,7 @@ X that it can undo relocations performed by the runtime linker. */ X for (n = new_file_h->e_shnum - 1; n; n--) X { - Elf32_Shdr section = NEW_SECTION_H (n); + ElfW(Shdr) section = NEW_SECTION_H (n); X switch (section.sh_type) { X default: X break; @@ -867,14 +1092,21 @@ X || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name), X ".data1")) X { - Elf32_Addr offset = NEW_SECTION_H (nn).sh_addr - + ElfW(Addr) offset = NEW_SECTION_H (nn).sh_addr - X NEW_SECTION_H (nn).sh_offset; X caddr_t reloc = old_base + section.sh_offset, end; X for (end = reloc + section.sh_size; reloc < end; X reloc += section.sh_entsize) X { - Elf32_Addr addr = ((Elf32_Rel *) reloc)->r_offset - offset; - memcpy (new_base + addr, old_base + addr, 4); + ElfW(Addr) addr = ((ElfW(Rel) *) reloc)->r_offset - offset; +#ifdef __alpha__ + /* The Alpha ELF binutils currently have a bug that + sometimes results in relocs that contain all + zeroes. Work around this for now... */ + if (((ElfW(Rel) *) reloc)->r_offset == 0) + continue; +#endif + memcpy (new_base + addr, old_base + addr, sizeof(ElfW(Addr))); X } X } X break; SHAR_EOF $shar_touch -am 0930013598 'patch-ae' && chmod 0644 'patch-ae' || $echo 'restore of' 'patch-ae' 'failed' if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then md5sum -c << SHAR_EOF >/dev/null 2>&1 \ || $echo 'patch-ae:' 'MD5 check failed' 391359ae76201d765f16d0a38362d109 patch-ae SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'patch-ae'`" test 17911 -eq "$shar_count" || $echo 'patch-ae:' 'original size' '17911,' 'current size' "$shar_count!" fi fi rm -fr _sh06928 exit 0 >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message