summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2000-04-18 02:39:26 +0000
committerobrien <obrien@FreeBSD.org>2000-04-18 02:39:26 +0000
commit0eac6bbc676f298cf518321aa0d24cc001c69611 (patch)
tree0215bcb520740db905cae767cb8c981d2e3f8a50 /contrib
parent2e1592d902d16ed9876e30509b0d925e1a30e2c7 (diff)
downloadFreeBSD-src-0eac6bbc676f298cf518321aa0d24cc001c69611.zip
FreeBSD-src-0eac6bbc676f298cf518321aa0d24cc001c69611.tar.gz
Change our ELF binary branding to something more acceptable to the Binutils
maintainers. After we established our branding method of writing upto 8 characters of the OS name into the ELF header in the padding; the Binutils maintainers and/or SCO (as USL) decided that instead the ELF header should grow two new fields -- EI_OSABI and EI_ABIVERSION. Each of these are an 8-bit unsigned integer. SCO has assigned official values for the EI_OSABI field. In addition to this, the Binutils maintainers and NetBSD decided that a better ELF branding method was to include ABI information in a ".note" ELF section. With this set of changes, we will now create ELF binaries branded using both "official" methods. Due to the complexity of adding a section to a binary, binaries branded with ``brandelf'' will only brand using the EI_OSABI method. Also due to the complexity of pulling a section out of an ELF file vs. poking around in the ELF header, our image activator only looks at the EI_OSABI header field. Note that a new kernel can still properly load old binaries except for Linux static binaries branded in our old method. * * For a short period of time, ``ld'' will also brand ELF binaries * using our old method. This is so people can still use kernel.old * with a new world. This support will be removed before 5.0-RELEASE, * and may not last anywhere upto the actual release. My expiration * time for this is about 6mo. *
Diffstat (limited to 'contrib')
-rw-r--r--contrib/binutils/bfd/elf.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/contrib/binutils/bfd/elf.c b/contrib/binutils/bfd/elf.c
index 90c27d5..44d1e91 100644
--- a/contrib/binutils/bfd/elf.c
+++ b/contrib/binutils/bfd/elf.c
@@ -40,13 +40,6 @@ SECTION
#define ARCH_SIZE 0
#include "elf-bfd.h"
-#define EI_BRAND_OFFSET 8 /* should be in binutils/include/elf/common.h */
-#if defined(__FreeBSD__)
-#define BRANDING "FreeBSD"
-#else
-#define BRANDING ""
-#endif
-
static INLINE struct elf_segment_map *make_mapping
PARAMS ((bfd *, asection **, unsigned int, unsigned int, boolean));
static boolean map_sections_to_segments PARAMS ((bfd *));
@@ -2932,9 +2925,24 @@ prep_headers (abfd)
bfd_big_endian (abfd) ? ELFDATA2MSB : ELFDATA2LSB;
i_ehdrp->e_ident[EI_VERSION] = bed->s->ev_current;
+#ifdef __FreeBSD__
+ /* Quick and dirty hack to brand the file as a FreeBSD ELF file. */
+ i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
+ i_ehdrp->e_ident[EI_ABIVERSION] = 0;
+#endif
+
for (count = EI_PAD; count < EI_NIDENT; count++)
i_ehdrp->e_ident[count] = 0;
+#ifdef __FreeBSD__
+/* #ifdef BRANDELF_CHANGE_BOOTSTRAP */
+#define _OLD_EI_BRAND_OFFSET 8
+#define _OLD_BRANDING "FreeBSD"
+ strncpy((char *) &i_ehdrp->e_ident[_OLD_EI_BRAND_OFFSET], _OLD_BRANDING,
+ EI_NIDENT-_OLD_EI_BRAND_OFFSET);
+/* #endif */
+#endif
+
if ((abfd->flags & DYNAMIC) != 0)
i_ehdrp->e_type = ET_DYN;
else if ((abfd->flags & EXEC_P) != 0)
@@ -2949,7 +2957,7 @@ prep_headers (abfd)
break;
case bfd_arch_sparc:
if (bed->s->arch_size == 64)
- i_ehdrp->e_machine = EM_SPARC64;
+ i_ehdrp->e_machine = EM_SPARCV9;
else
i_ehdrp->e_machine = EM_SPARC;
break;
@@ -3009,11 +3017,6 @@ prep_headers (abfd)
i_ehdrp->e_version = bed->s->ev_current;
i_ehdrp->e_ehsize = bed->s->sizeof_ehdr;
- /* Some OS's brands all ELF binaries so the image loader knows what system
- call set, etc. to use. */
- strncpy((char *) &i_ehdrp->e_ident[EI_BRAND_OFFSET], BRANDING,
- EI_NIDENT-EI_BRAND_OFFSET);
-
/* no program header, for now. */
i_ehdrp->e_phoff = 0;
i_ehdrp->e_phentsize = 0;
OpenPOWER on IntegriCloud