Use the platform specific ELF branding expected under FreeBSD. This is similar to what the vendor ld(1) does on this platform. Additionally, recognize and ignore Solaris 10's "Solaris Cryptographic Framework" ELF header type "SUNW_signature", Solaris 10 "Symbol information" ELF header type "SUNW_syminfo" and Solaris 10 "DTrace Object Format" ELF header type. Also, fix the path to the dynamic linker under Solaris 10/amd64. Index: include/elf/common.h --- include/elf/common.h.orig 2004-10-08 15:55:08 +0200 +++ include/elf/common.h 2006-04-10 13:58:15 +0200 @@ -335,6 +335,9 @@ #define SHT_SUNW_verdef 0x6ffffffd /* Versions defined by file */ #define SHT_SUNW_verneed 0x6ffffffe /* Versions needed by file */ #define SHT_SUNW_versym 0x6fffffff /* Symbol versions */ +#define SHT_SUNW_syminfo 0x6ffffffc /* Symbol information */ +#define SHT_SUNW_signature 0x6ffffff6 /* Solaris Cryptographic Framework: Digital Signature */ +#define SHT_SUNW_dof 0x6ffffff4 /* Solaris DTrace Object Format */ #define SHT_GNU_verdef SHT_SUNW_verdef #define SHT_GNU_verneed SHT_SUNW_verneed Index: bfd/elf.c --- bfd/elf.c.orig 2005-05-30 00:00:10 +0200 +++ bfd/elf.c 2006-04-10 13:58:42 +0200 @@ -2009,6 +2009,11 @@ return _bfd_elf_make_section_from_shdr (abfd, hdr, name); break; + case SHT_SUNW_syminfo: + case SHT_SUNW_signature: + case SHT_SUNW_dof: + return TRUE; + case SHT_SHLIB: return TRUE; @@ -4627,6 +4632,12 @@ else i_ehdrp->e_type = ET_REL; + /* OpenPKG platform branding BEGIN */ +#if defined(OPENPKG_OS_FREEBSD) + i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD; +#endif + /* OpenPKG platform branding END */ + switch (bfd_get_arch (abfd)) { case bfd_arch_unknown: Index: bfd/elf64-x86-64.c --- bfd/elf64-x86-64.c.orig 2005-02-06 19:11:30 +0100 +++ bfd/elf64-x86-64.c 2006-04-10 15:34:03 +0200 @@ -259,7 +259,11 @@ /* The name of the dynamic interpreter. This is put in the .interp section. */ +#if defined(OPENPKG_OS_SOLARIS) +#define ELF_DYNAMIC_INTERPRETER "/lib/amd64/ld.so.1" +#else #define ELF_DYNAMIC_INTERPRETER "/lib/ld64.so.1" +#endif /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid copying dynamic variables from a shared lib into an app's dynbss ----------------------------------------------------------------------------- Support FreeBSD >= 4.10 by fixing platform detection. Index: bfd/configure --- bfd/configure.orig 2005-05-02 21:43:54 +0200 +++ bfd/configure 2005-05-03 19:49:53 +0200 @@ -9956,6 +9956,10 @@ i[3-7]86-*-bsdi) COREFILE= ;; + i[3456]86-*-freebsd4.1[0-9]*) + COREFILE='' + TRAD_HEADER='"hosts/i386bsd.h"' + ;; i[3-7]86-*-bsd* | i[3-7]86-*-freebsd[123] | i[3-7]86-*-freebsd[123]\.* | i[3-7]86-*-freebsd4\.[01234] | i[3-7]86-*-freebsd4\.[01234]\.* | i[3-7]86-*-freebsd*aout*) COREFILE=trad-core.lo TRAD_HEADER='"hosts/i386bsd.h"' ----------------------------------------------------------------------------- Fight problems with --disable-nls under Solaris Index: binutils/bucomm.h --- binutils/bucomm.h.orig 2005-08-16 21:35:21.000000000 +0200 +++ binutils/bucomm.h 2005-09-13 16:55:29.276456000 +0200 @@ -125,6 +125,11 @@ # endif /* HAVE_ALLOCA_H */ #endif +#ifndef ENABLE_NLS +# define _LIBINTL_H +# define _LIBGETTEXT_H +#endif + #ifdef HAVE_LOCALE_H # include #endif Index: gas/asintl.h --- gas/asintl.h.orig 2005-05-05 11:12:43.000000000 +0200 +++ gas/asintl.h 2005-09-13 16:58:29.082469000 +0200 @@ -20,6 +20,11 @@ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +#ifndef ENABLE_NLS +# define _LIBINTL_H +# define _LIBGETTEXT_H +#endif + #ifdef HAVE_LOCALE_H # include #endif Index: gprof/gprof.c --- gprof/gprof.c.orig 2005-04-23 19:13:31.000000000 +0200 +++ gprof/gprof.c 2005-09-13 17:13:52.242443000 +0200 @@ -189,8 +189,10 @@ #if defined (HAVE_SETLOCALE) setlocale (LC_CTYPE, ""); #endif +#ifdef ENABLE_NLS bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); +#endif whoami = argv[0]; xmalloc_set_program_name (whoami); Index: ld/ld.h --- ld/ld.h.orig 2005-06-09 04:05:46.000000000 +0200 +++ ld/ld.h 2005-09-13 17:24:03.767249000 +0200 @@ -23,6 +23,11 @@ #ifndef LD_H #define LD_H +#ifndef ENABLE_NLS +# define _LIBINTL_H +# define _LIBGETTEXT_H +#endif + #ifdef HAVE_LOCALE_H # include #endif Index: ld/Makefile.in --- ld/Makefile.in.orig 2005-01-23 06:36:37 +0100 +++ ld/Makefile.in 2005-09-21 21:06:55 +0200 @@ -139,7 +139,7 @@ # We put the scripts in the directory $(scriptdir)/ldscripts. # We can't put the scripts in $(datadir) because the SEARCH_DIR # directives need to be different for native and cross linkers. -scriptdir = $(tooldir)/lib +scriptdir = $(libdir) EMUL = @EMUL@ EMULATION_OFILES = @EMULATION_OFILES@ ----------------------------------------------------------------------------- Security Issue (PR binutils/2584, CVE-2006-2362) Index: bfd/tekhex.c --- bfd/tekhex.c.orig 2004-10-08 16:54:02 +0200 +++ bfd/tekhex.c 2006-05-26 20:21:02 +0200 @@ -99,7 +99,7 @@ #define ISHEX(x) hex_p(x) static void tekhex_init PARAMS ((void)); -static bfd_vma getvalue PARAMS ((char **)); +static bfd_boolean getvalue PARAMS ((char **, bfd_vma *)); static void tekhex_print_symbol PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type)); static void tekhex_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *)); @@ -121,11 +121,11 @@ static bfd_boolean tekhex_mkobject PARAMS ((bfd *)); static long tekhex_get_symtab_upper_bound PARAMS ((bfd *)); static long tekhex_canonicalize_symtab PARAMS ((bfd *, asymbol **)); -static void pass_over PARAMS ((bfd *, void (*) (bfd*, int, char *))); -static void first_phase PARAMS ((bfd *, int, char *)); +static bfd_boolean pass_over PARAMS ((bfd *, bfd_boolean (*) (bfd*, int, char *))); +static bfd_boolean first_phase PARAMS ((bfd *, int, char *)); static void insert_byte PARAMS ((bfd *, int, bfd_vma)); static struct data_struct *find_chunk PARAMS ((bfd *, bfd_vma)); -static unsigned int getsym PARAMS ((char *, char **)); +static bfd_boolean getsym PARAMS ((char *, char **, unsigned int *)); /* Here's an example @@ -304,40 +304,53 @@ #define enda(x) (x->vma + x->size) -static bfd_vma -getvalue (srcp) +static bfd_boolean +getvalue (srcp, valuep) char **srcp; + bfd_vma *valuep; { char *src = *srcp; bfd_vma value = 0; - unsigned int len = hex_value(*src++); + unsigned int len; + + if (!ISHEX(*src)) + return FALSE; + len = hex_value(*src++); if (len == 0) len = 16; while (len--) { + if (!ISHEX(*src)) + return FALSE; value = value << 4 | hex_value(*src++); } *srcp = src; - return value; + *valuep = value; + return TRUE; } -static unsigned int -getsym (dstp, srcp) +static bfd_boolean +getsym (dstp, srcp, lenp) char *dstp; char **srcp; + unsigned int *lenp; { char *src = *srcp; unsigned int i; - unsigned int len = hex_value(*src++); + unsigned int len; + if (!ISHEX(*src)) + return FALSE; + len = hex_value(*src++); if (len == 0) len = 16; for (i = 0; i < len; i++) dstp[i] = src[i]; dstp[i] = 0; *srcp = src + i; - return len; + *lenp = len; + return TRUE; } static struct data_struct * @@ -383,7 +396,7 @@ /* The first pass is to find the names of all the sections, and see how big the data is */ -static void +static bfd_boolean first_phase (abfd, type, src) bfd *abfd; int type; @@ -391,6 +404,7 @@ { asection *section = bfd_abs_section_ptr; unsigned int len; + bfd_vma val; char sym[17]; /* A symbol can only be 16chars long */ switch (type) @@ -398,7 +412,10 @@ case '6': /* Data record - read it and store it */ { - bfd_vma addr = getvalue (&src); + bfd_vma addr; + + if (!getvalue (&src, &addr)) + return FALSE; while (*src) { @@ -408,17 +425,18 @@ } } - return; + return TRUE; case '3': /* Symbol record, read the segment */ - len = getsym (sym, &src); + if (!getsym (sym, &src, &len)) + return FALSE; section = bfd_get_section_by_name (abfd, sym); if (section == (asection *) NULL) { char *n = bfd_alloc (abfd, (bfd_size_type) len + 1); if (!n) - abort (); /* FIXME */ + return FALSE; memcpy (n, sym, len + 1); section = bfd_make_section (abfd, n); } @@ -428,8 +446,11 @@ { case '1': /* section range */ src++; - section->vma = getvalue (&src); - section->size = getvalue (&src) - section->vma; + if (!getvalue (&src, §ion->vma)) + return FALSE; + if (!getvalue (&src, &val)) + return FALSE; + section->size = val - section->vma; section->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC; break; case '0': @@ -447,37 +468,43 @@ char stype = (*src); if (!new) - abort (); /* FIXME */ + return FALSE; new->symbol.the_bfd = abfd; src++; abfd->symcount++; abfd->flags |= HAS_SYMS; new->prev = abfd->tdata.tekhex_data->symbols; abfd->tdata.tekhex_data->symbols = new; - len = getsym (sym, &src); + if (!getsym (sym, &src, &len)) + return FALSE; new->symbol.name = bfd_alloc (abfd, (bfd_size_type) len + 1); if (!new->symbol.name) - abort (); /* FIXME */ + return FALSE; memcpy ((char *) (new->symbol.name), sym, len + 1); new->symbol.section = section; if (stype <= '4') new->symbol.flags = (BSF_GLOBAL | BSF_EXPORT); else new->symbol.flags = BSF_LOCAL; - new->symbol.value = getvalue (&src) - section->vma; + if (!getvalue (&src, &val)) + return FALSE; + new->symbol.value = val - section->vma; } + default: + return FALSE; } } } + return TRUE; } /* Pass over a tekhex, calling one of the above functions on each record. */ -static void +static bfd_boolean pass_over (abfd, func) bfd *abfd; - void (*func) PARAMS ((bfd *, int, char *)); + bfd_boolean (*func) PARAMS ((bfd *, int, char *)); { unsigned int chars_on_line; bfd_boolean eof = FALSE; @@ -516,9 +543,10 @@ abort (); /* FIXME */ src[chars_on_line] = 0; /* put a null at the end */ - func (abfd, type, src); + if (!func (abfd, type, src)) + return FALSE; } - + return TRUE; } static long @@ -585,7 +613,9 @@ tekhex_mkobject (abfd); - pass_over (abfd, first_phase); + if (!pass_over (abfd, first_phase)) + return NULL; + return abfd->xvec; }