171 lines
4.4 KiB
Text
171 lines
4.4 KiB
Text
$NetBSD: patch-az,v 1.1.1.1 2003/04/11 00:31:45 uebayasi Exp $
|
|
|
|
--- src/unexelf.c.orig Mon May 15 01:14:02 2000
|
|
+++ src/unexelf.c Tue Sep 26 14:18:05 2000
|
|
@@ -470,7 +470,7 @@
|
|
/*
|
|
* NetBSD does not have normal-looking user-land ELF support.
|
|
*/
|
|
-# ifdef __alpha__
|
|
+# if defined(__alpha__) || defined(__sparc_v9__)
|
|
# define ELFSIZE 64
|
|
# else
|
|
# define ELFSIZE 32
|
|
@@ -479,6 +479,7 @@
|
|
|
|
# ifndef PT_LOAD
|
|
# define PT_LOAD Elf_pt_load
|
|
+# define SHT_PROGBITS Elf_sht_progbits
|
|
# define SHT_SYMTAB Elf_sht_symtab
|
|
# define SHT_DYNSYM Elf_sht_dynsym
|
|
# define SHT_NULL Elf_sht_null
|
|
@@ -495,9 +496,14 @@
|
|
# include <sys/exec_ecoff.h>
|
|
# define HDRR struct ecoff_symhdr
|
|
# define pHDRR HDRR *
|
|
-# endif
|
|
+# endif /* __alpha__ */
|
|
#endif /* __NetBSD__ */
|
|
|
|
+# ifdef __mips__
|
|
+# define SHT_MIPS_DEBUG DT_MIPS_FLAGS
|
|
+# define HDRR struct Elf_Shdr
|
|
+# endif /* __mips__ */
|
|
+
|
|
#ifdef __OpenBSD__
|
|
# include <sys/exec_elf.h>
|
|
#endif
|
|
@@ -512,7 +518,7 @@
|
|
# else
|
|
# define ElfBitsW(bits, type) Elf/**/bits/**/_/**/type
|
|
# endif
|
|
-# ifdef _LP64
|
|
+# if defined (_LP64) || defined(__alpha__)
|
|
# define ELFSIZE 64
|
|
# else
|
|
# define ELFSIZE 32
|
|
@@ -522,6 +528,14 @@
|
|
# define ElfW(type) ElfExpandBitsW (ELFSIZE, type)
|
|
#endif
|
|
|
|
+#if defined ( __sony_news) && defined (_SYSTYPE_SYSV)
|
|
+# define HAVE_MIPS_SBSS
|
|
+#endif
|
|
+
|
|
+#if defined (__mips__) && (defined(__NetBSD__) || defined(__OpenBSD__))
|
|
+# define HAVE_MIPS_SBSS
|
|
+#endif
|
|
+
|
|
#ifndef ELF_BSS_SECTION_NAME
|
|
#define ELF_BSS_SECTION_NAME ".bss"
|
|
#endif
|
|
@@ -613,12 +627,53 @@
|
|
if (noerror)
|
|
return -1;
|
|
else
|
|
- fatal ("Can't find %s in %s.\n", name, file_name, 0);
|
|
+ fatal ("Can't find %s in %s.\n", name, file_name);
|
|
}
|
|
|
|
return idx;
|
|
}
|
|
|
|
+#if defined(__alpha__) || (defined ( __sony_news) && defined (_SYSTYPE_SYSV))
|
|
+/* We are using ECOFF symbols embedded in ELF. */
|
|
+
|
|
+void
|
|
+relocate_ecoff_symhdr(symhdr, diff)
|
|
+ HDRR *symhdr;
|
|
+ ElfW(Word) diff;
|
|
+{
|
|
+ symhdr->cbLineOffset += diff;
|
|
+ symhdr->cbDnOffset += diff;
|
|
+ symhdr->cbPdOffset += diff;
|
|
+ symhdr->cbSymOffset += diff;
|
|
+ symhdr->cbOptOffset += diff;
|
|
+ symhdr->cbAuxOffset += diff;
|
|
+ symhdr->cbSsOffset += diff;
|
|
+ symhdr->cbSsExtOffset += diff;
|
|
+ symhdr->cbFdOffset += diff;
|
|
+ symhdr->cbRfdOffset += diff;
|
|
+ symhdr->cbExtOffset += diff;
|
|
+}
|
|
+#endif /* __alpha__ or __sony_news and systype_sysv */
|
|
+
|
|
+#ifdef notyet
|
|
+void
|
|
+relocate_elf_proghdr(p, diff)
|
|
+ HDRR *symhdr;
|
|
+ Elfw(Word) diff;
|
|
+{
|
|
+ phdr->sh_name += diff;
|
|
+ phdr->sh_type += diff;
|
|
+ phdr->sh_flags += diff;
|
|
+ phdr->sh_addr += diff;
|
|
+ phdr->sh_offset += diff;
|
|
+ phdr->sh_size += diff;
|
|
+ phdr->sh_link += diff;
|
|
+ phdr->sh_info += diff;
|
|
+ phdr->sh_addralign += diff;
|
|
+ phdr->sh_entsize += diff;
|
|
+};
|
|
+#endif /* notyet */
|
|
+
|
|
/* ****************************************************************
|
|
* unexec
|
|
*
|
|
@@ -1005,22 +1060,11 @@
|
|
== 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;
|
|
+ relocate_ecoff_symhdr(symhdr, new_data2_size);
|
|
}
|
|
#endif /* __alpha__ */
|
|
|
|
-#if defined (__sony_news) && defined (_SYSTYPE_SYSV)
|
|
+#ifdef HAVE_MIPS_SBSS
|
|
if (NEW_SECTION_H (nn).sh_type == SHT_MIPS_DEBUG
|
|
&& old_mdebug_index != -1)
|
|
{
|
|
@@ -1030,20 +1074,17 @@
|
|
|
|
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;
|
|
+#if defined ( __sony_news) && defined (_SYSTYPE_SYSV)
|
|
+ relocate_ecoff_symhdr(phdr, diff);
|
|
+#else
|
|
+ /* xxxBSD with GNU binutils has .mdebug, but not ecoff(???) */
|
|
+#ifdef DEBUG
|
|
+ printf("Dont know how to relocate mdebug syms by %0x\n", diff);
|
|
+#endif
|
|
+#endif
|
|
}
|
|
}
|
|
-#endif /* __sony_news && _SYSTYPE_SYSV */
|
|
+#endif /* HAVE_MIPS_SBSS */
|
|
|
|
#if __sgi
|
|
/* Adjust the HDRR offsets in .mdebug and copy the
|