diff options
Diffstat (limited to 'tools')
65 files changed, 2058 insertions, 4752 deletions
diff --git a/tools/Makefile b/tools/Makefile index ca034911c..1d65e50ba 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -15,7 +15,7 @@ tools-y += gmp mpfr mpc libelf endif tools-y += m4 libtool autoconf automake flex bison pkg-config sed mklibs tools-y += sstrip ipkg-utils genext2fs e2fsprogs mtd-utils mkimage -tools-y += firmware-utils patch-cmdline quilt yaffs2 flock padjffs2 +tools-y += firmware-utils patch-image patch quilt yaffs2 flock padjffs2 tools-y += mm-macros xorg-macros xfce-macros missing-macros xz cmake scons tools-$(CONFIG_TARGET_orion_generic) += wrt350nv2-builder upslug2 tools-$(CONFIG_powerpc) += upx @@ -25,6 +25,9 @@ ifneq ($(CONFIG_TARGET_ar71xx),) tools-y += lzma-old squashfs endif tools-y += lzma squashfs4 +ifneq ($(CONFIG_PACKAGE_kmod-b43)$(CONFIG_PACKAGE_kmod-b43legacy)$(CONFIG_BRCMSMAC_USE_FW_FROM_WL),) +tools-y += b43-tools +endif ifneq ($(CONFIG_PACKAGE_firmwarehotplug),) tools-y += sdcc @@ -39,6 +42,7 @@ endif # builddir dependencies $(curdir)/bison/compile := $(curdir)/flex/install +$(curdir)/flex/compile := $(curdir)/m4/install $(curdir)/pkg-config/compile := $(curdir)/sed/install $(curdir)/libtool/compile := $(curdir)/sed/install $(curdir)/squashfs/compile := $(curdir)/lzma-old/install @@ -54,6 +58,7 @@ $(curdir)/ppl/compile := $(curdir)/gmp/install $(curdir)/cloog/compile := $(curdir)/ppl/install $(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/install $(curdir)/xz/install $(curdir)/mkimage/compile := $(curdir)/sed/install +$(curdir)/mklibs/compile := $(curdir)/automake/install $(curdir)/qemu/compile := $(curdir)/e2fsprogs/install $(curdir)/upslug2/compile := $(curdir)/automake/install $(curdir)/mm-macros/compile := $(curdir)/automake/install @@ -63,6 +68,7 @@ $(curdir)/missing-macros/compile := $(curdir)/automake/install $(curdir)/e2fsprogs/compile := $(curdir)/automake/install $(curdir)/libelf/compile := $(curdir)/automake/install $(curdir)/sdcc/compile := $(curdir)/bison/install +$(curdir)/b43-tools/compile := $(curdir)/bison/install ifneq ($(CONFIG_CCACHE),) $(foreach tool, $(tools-y), $(eval $(curdir)/$(tool)/compile += $(curdir)/ccache/install)) @@ -113,6 +119,8 @@ $(STAGING_DIR_HOST)/bin/stat: $(STAGING_DIR)/.prepared ln -s `which stat` $@; \ elif gstat --version > /dev/null 2>&1; then \ ln -s `which gstat` $@; \ + elif gnustat --version > /dev/null 2>&1; then \ + ln -s `which gnustat` $@; \ else \ echo "GNU stat not found"; \ false; \ @@ -122,9 +130,14 @@ $(eval $(call PrepareCommand,find,gfind find)) $(eval $(call PrepareCommand,md5sum,gmd5sum md5sum $(SCRIPT_DIR)/md5sum)) $(eval $(call PrepareCommand,cp,gcp cp)) $(eval $(call PrepareCommand,seq,gseq seq)) -$(eval $(call PrepareCommand,python,python2 python)) - -$(curdir)/cmddeps = $(patsubst %,$(STAGING_DIR_HOST)/bin/%,find md5sum cp stat seq python) +$(eval $(call PrepareCommand,python,python2 python2.7 python)) +$(eval $(call PrepareCommand,awk,gawk awk)) +$(eval $(call PrepareCommand,getopt,gnugetopt /usr/local/bin/getopt getopt)) +$(eval $(call PrepareCommand,grep,ggrep grep)) +$(eval $(call PrepareCommand,tar,gtar tar)) +$(eval $(call PrepareCommand,diff,gdiff diff)) + +$(curdir)/cmddeps = $(patsubst %,$(STAGING_DIR_HOST)/bin/%,find md5sum cp stat seq python awk getopt grep tar diff) $(curdir)//prepare = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $($(curdir)/cmddeps) $(curdir)//compile = $(STAGING_DIR)/.prepared $(STAGING_DIR_HOST)/.prepared $($(curdir)/cmddeps) diff --git a/tools/b43-tools/Makefile b/tools/b43-tools/Makefile new file mode 100644 index 000000000..e25bfc23c --- /dev/null +++ b/tools/b43-tools/Makefile @@ -0,0 +1,51 @@ +# +# Copyright (C) 2012 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=b43-tools +PKG_VERSION:=017 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=git://git.bues.ch/b43-tools.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_SUBDIR:=$(PKG_NAME) +PKG_SOURCE_VERSION:=691cd291afdb3dbfcf6b9624f8f4bd068af153d0 +#PKG_MIRROR_MD5SUM:=50ca3c763ee21ee213addd17cf1c1b86 +HOST_BUILD_DIR=$(BUILD_DIR_HOST)/$(PKG_NAME) + +include $(INCLUDE_DIR)/host-build.mk + + +define Host/Compile + +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR)/fwcutter \ + CFLAGS="$(HOST_CFLAGS) -include endian.h" \ + $(HOST_MAKE_FLAGS) \ + $(1) QUIET_SPARSE=: + +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR)/assembler \ + CFLAGS="$(HOST_CFLAGS) -include endian.h" \ + $(HOST_MAKE_FLAGS) \ + LDFLAGS= \ + $(1) QUIET_SPARSE=: +endef + +define Host/Install + $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin + $(INSTALL_BIN) $(HOST_BUILD_DIR)/fwcutter/b43-fwcutter $(STAGING_DIR_HOST)/bin/ + $(INSTALL_BIN) $(HOST_BUILD_DIR)/assembler/b43-asm $(STAGING_DIR_HOST)/bin/ + $(INSTALL_BIN) $(HOST_BUILD_DIR)/assembler/b43-asm.bin $(STAGING_DIR_HOST)/bin/ + $(INSTALL_BIN) ./files/b43-fwsquash.py $(STAGING_DIR_HOST)/bin/ +endef + +define Host/Clean + rm -f $(STAGING_DIR_HOST)/bin/b43-fwcutter + rm -f $(STAGING_DIR_HOST)/bin/b43-asm + rm -f $(STAGING_DIR_HOST)/bin/b43-asm.bin + rm -f $(STAGING_DIR_HOST)/bin/b43-fwsquash.py +endef + +$(eval $(call HostBuild)) diff --git a/tools/b43-tools/files/b43-fwsquash.py b/tools/b43-tools/files/b43-fwsquash.py new file mode 100755 index 000000000..cd8818167 --- /dev/null +++ b/tools/b43-tools/files/b43-fwsquash.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python +# +# b43 firmware file squasher +# Removes unnecessary firmware files +# +# Copyright (c) 2009 Michael Buesch <mb@bu3sch.de> +# +# Licensed under the GNU/GPL version 2 or (at your option) any later version. +# + +import sys +import os + +def usage(): + print("Usage: %s PHYTYPES COREREVS /path/to/extracted/firmware" % sys.argv[0]) + print("") + print("PHYTYPES is a comma separated list of:") + print("A => A-PHY") + print("AG => Dual A-PHY G-PHY") + print("G => G-PHY") + print("LP => LP-PHY") + print("N => N-PHY") + print("HT => HT-PHY") + print("LCN => LCN-PHY") + print("") + print("COREREVS is a comma separated list of core revision numbers.") + +if len(sys.argv) != 4: + usage() + sys.exit(1) + +phytypes = sys.argv[1] +corerevs = sys.argv[2] +fwpath = sys.argv[3] + +phytypes = phytypes.split(',') +try: + corerevs = map(lambda r: int(r), corerevs.split(',')) +except ValueError: + print("ERROR: \"%s\" is not a valid COREREVS string\n" % corerevs) + usage() + sys.exit(1) + + +fwfiles = os.listdir(fwpath) +fwfiles = filter(lambda str: str.endswith(".fw"), fwfiles) +if not fwfiles: + print("ERROR: No firmware files found in %s" % fwpath) + sys.exit(1) + +required_fwfiles = [] + +def revs_match(revs_a, revs_b): + for rev in revs_a: + if rev in revs_b: + return True + return False + +def phytypes_match(types_a, types_b): + for type in types_a: + type = type.strip().upper() + if type in types_b: + return True + return False + +revmapping = { + "ucode2.fw" : (2,3,), + "ucode4.fw" : (4,), + "ucode5.fw" : (5,6,7,8,9,10,), + "ucode11.fw" : (11,12,), + "ucode13.fw" : (13,), + "ucode14.fw" : (14,), + "ucode15.fw" : (15,), + "ucode16_mimo.fw" : (16,), + "ucode24_mimo.fw" : (24,), + "ucode29_mimo.fw" : (29,), + "pcm4.fw" : (1,2,3,4,), + "pcm5.fw" : (5,6,7,8,9,10,), +} + +initvalmapping = { + "a0g1initvals5.fw" : ( (5,6,7,8,9,10,), ("AG",), ), + "a0g0initvals5.fw" : ( (5,6,7,8,9,10,), ("A", "AG",), ), + "b0g0initvals2.fw" : ( (2,4,), ("G",), ), + "b0g0initvals5.fw" : ( (5,6,7,8,9,10,), ("G",), ), + "b0g0initvals13.fw" : ( (13,), ("G",), ), + "n0initvals11.fw" : ( (11,12,), ("N",), ), + "n0initvals16.fw" : ( (16,), ("N",), ), + "lp0initvals13.fw" : ( (13,), ("LP",), ), + "lp0initvals14.fw" : ( (14,), ("LP",), ), + "lp0initvals15.fw" : ( (15,), ("LP",), ), + "lcn0initvals24.fw" : ( (24,), ("LCN",), ), + "ht0initvals29.fw" : ( (29,), ("HT",), ), + "a0g1bsinitvals5.fw" : ( (5,6,7,8,9,10,), ("AG",), ), + "a0g0bsinitvals5.fw" : ( (5,6,7,8,9,10,), ("A", "AG"), ), + "b0g0bsinitvals5.fw" : ( (5,6,7,8,9,10,), ("G",), ), + "n0bsinitvals11.fw" : ( (11,12,), ("N",), ), + "n0bsinitvals16.fw" : ( (16,), ("N",), ), + "lp0bsinitvals13.fw" : ( (13,), ("LP",), ), + "lp0bsinitvals14.fw" : ( (14,), ("LP",), ), + "lp0bsinitvals15.fw" : ( (15,), ("LP",), ), + "lcn0bsinitvals24.fw" : ( (24,), ("LCN",), ), + "ht0bsinitvals29.fw" : ( (29,), ("HT",), ), +} + +for f in fwfiles: + if f in revmapping: + if revs_match(corerevs, revmapping[f]): + required_fwfiles += [f] + continue + if f in initvalmapping: + if revs_match(corerevs, initvalmapping[f][0]) and\ + phytypes_match(phytypes, initvalmapping[f][1]): + required_fwfiles += [f] + continue + print("WARNING: Firmware file %s not found in the mapping lists" % f) + +for f in fwfiles: + if f not in required_fwfiles: + print("Deleting %s" % f) + os.unlink(fwpath + '/' + f) + diff --git a/tools/b43-tools/patches/001-fw-dirname.patch b/tools/b43-tools/patches/001-fw-dirname.patch new file mode 100644 index 000000000..e9bd03249 --- /dev/null +++ b/tools/b43-tools/patches/001-fw-dirname.patch @@ -0,0 +1,16 @@ +--- a/fwcutter/fwcutter.c ++++ b/fwcutter/fwcutter.c +@@ -48,13 +48,8 @@ + #include "fwcutter.h" + #include "fwcutter_list.h" + +-#if defined(__DragonFly__) || defined(__FreeBSD__) +-#define V3_FW_DIRNAME "v3" +-#define V4_FW_DIRNAME "v4" +-#else + #define V3_FW_DIRNAME "b43legacy" + #define V4_FW_DIRNAME "b43" +-#endif + + static struct cmdline_args cmdargs; + diff --git a/tools/b43-tools/patches/002-no_libfl.patch b/tools/b43-tools/patches/002-no_libfl.patch new file mode 100644 index 000000000..2e55b0803 --- /dev/null +++ b/tools/b43-tools/patches/002-no_libfl.patch @@ -0,0 +1,14 @@ +--- a/assembler/main.c ++++ b/assembler/main.c +@@ -1268,6 +1268,11 @@ static void initialize(void) + #endif /* YYDEBUG */ + } + ++int yywrap(void) ++{ ++ return 1; ++} ++ + int main(int argc, char **argv) + { + int err, res = 1; diff --git a/tools/b43-tools/patches/100-b43-asm-fix-compile-error-undefined-reference-to-yyd.patch b/tools/b43-tools/patches/100-b43-asm-fix-compile-error-undefined-reference-to-yyd.patch new file mode 100644 index 000000000..fc0553d6b --- /dev/null +++ b/tools/b43-tools/patches/100-b43-asm-fix-compile-error-undefined-reference-to-yyd.patch @@ -0,0 +1,27 @@ +--- a/assembler/Makefile ++++ b/assembler/Makefile +@@ -30,7 +30,7 @@ BIN = b43-asm.bin + SRCS = parser.c scanner.c main.c initvals.c util.c args.c + + # YACC related CFLAGS +-CFLAGS += -DYYSTYPE="void *" -DYYERROR_VERBOSE -DYYDEBUG -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -Wno-unused ++CFLAGS += -DYYSTYPE="void *" -DYYERROR_VERBOSE -DYYDEBUG=1 -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -Wno-unused + + .SUFFIXES: + .PHONY: all install clean distclean +diff --git a/assembler/main.c b/assembler/main.c +index afca996..a62a15e 100644 +--- a/assembler/main.c ++++ b/assembler/main.c +@@ -1260,7 +1260,7 @@ static void initialize(void) + { + INIT_LIST_HEAD(&infile.sl); + INIT_LIST_HEAD(&infile.ivals); +-#ifdef YYDEBUG ++#if YYDEBUG + if (IS_INSANE_DEBUG) + yydebug = 1; + else +-- +1.7.10.4 + diff --git a/tools/bison/Makefile b/tools/bison/Makefile index b48862a3d..d20d1c03c 100644 --- a/tools/bison/Makefile +++ b/tools/bison/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2008-2012 OpenWrt.org +# Copyright (C) 2008-2013 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,12 +7,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=bison -PKG_VERSION:=2.5 +PKG_VERSION:=2.7 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/$(PKG_NAME) -PKG_MD5SUM:=9dba20116b13fc61a0846b0058fbe004 -PKG_CAT:=bzcat +PKG_MD5SUM:=234cdfac99257cf99ac4a03c898f37b9 +PKG_CAT:=xzcat + +HOST_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/host-build.mk diff --git a/tools/bison/patches/000-relocatable.patch b/tools/bison/patches/000-relocatable.patch index 50dca6d33..47c0ae8ba 100644 --- a/tools/bison/patches/000-relocatable.patch +++ b/tools/bison/patches/000-relocatable.patch @@ -3,18 +3,18 @@ @@ -81,6 +81,7 @@ MOSTLYCLEANFILES = yacc yacc: - echo '#! /bin/sh' >$@ -+ echo 'test -n "$$STAGING_DIR" && exec "$$STAGING_DIR/../host/bin/bison" -y "$$@"' >>$@ - echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@ - chmod a+x $@ + $(AM_V_GEN)echo '#! /bin/sh' >$@ ++ $(AM_V_at)echo 'test -n "$$STAGING_DIR" && exec "$$STAGING_DIR/../host/bin/bison" -y "$$@"' >>$@ + $(AM_V_at)echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@ + $(AM_V_at)chmod a+x $@ --- a/src/Makefile.in +++ b/src/Makefile.in -@@ -1609,6 +1609,7 @@ uninstall-am: uninstall-binPROGRAMS unin +@@ -1919,6 +1919,7 @@ uninstall-am: uninstall-binPROGRAMS unin yacc: - echo '#! /bin/sh' >$@ -+ echo 'test -n "$$STAGING_DIR" && exec "$$STAGING_DIR/../host/bin/bison" -y "$$@"' >>$@ - echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@ - chmod a+x $@ + $(AM_V_GEN)echo '#! /bin/sh' >$@ ++ $(AM_V_at)echo 'test -n "$$STAGING_DIR" && exec "$$STAGING_DIR/../host/bin/bison" -y "$$@"' >>$@ + $(AM_V_at)echo "exec '$(bindir)/bison' -y "'"$$@"' >>$@ + $(AM_V_at)chmod a+x $@ diff --git a/tools/bison/patches/010-intl-stub-compat.patch b/tools/bison/patches/010-intl-stub-compat.patch index 2cd720b68..d2dfcadba 100644 --- a/tools/bison/patches/010-intl-stub-compat.patch +++ b/tools/bison/patches/010-intl-stub-compat.patch @@ -1,8 +1,8 @@ --- a/src/main.c +++ b/src/main.c -@@ -58,9 +58,9 @@ main (int argc, char *argv[]) +@@ -60,9 +60,9 @@ main (int argc, char *argv[]) { - program_name = argv[0]; + set_program_name (argv[0]); setlocale (LC_ALL, ""); - (void) bindtextdomain (PACKAGE, LOCALEDIR); - (void) bindtextdomain ("bison-runtime", LOCALEDIR); @@ -11,5 +11,5 @@ + bindtextdomain ("bison-runtime", LOCALEDIR); + textdomain (PACKAGE); - uniqstrs_new (); - muscle_init (); + { + char const *cp = getenv ("LC_CTYPE"); diff --git a/tools/bison/patches/100-fix-gets-removal.patch b/tools/bison/patches/100-fix-gets-removal.patch index 1b9031064..169bfd673 100644 --- a/tools/bison/patches/100-fix-gets-removal.patch +++ b/tools/bison/patches/100-fix-gets-removal.patch @@ -1,15 +1,16 @@ --- a/lib/stdio.in.h +++ b/lib/stdio.in.h -@@ -177,12 +177,6 @@ _GL_WARN_ON_USE (fflush, "fflush is not - "use gnulib module fflush for portable POSIX compliance"); +@@ -704,13 +704,6 @@ _GL_WARN_ON_USE (getline, "getline is un + # endif #endif -/* It is very rare that the developer ever has full control of stdin, -- so any use of gets warrants an unconditional warning. Assume it is -- always declared, since it is required by C89. */ +- so any use of gets warrants an unconditional warning; besides, C11 +- removed it. */ -#undef gets +-#if HAVE_RAW_DECL_GETS -_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); -- - #if @GNULIB_FOPEN@ - # if @REPLACE_FOPEN@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) +-#endif + + + #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ diff --git a/tools/ccache/Makefile b/tools/ccache/Makefile index 9020c9c47..aeac39305 100644 --- a/tools/ccache/Makefile +++ b/tools/ccache/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2012 OpenWrt.org +# Copyright (C) 2006-2013 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -8,11 +8,11 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/target.mk PKG_NAME:=ccache -PKG_VERSION:=3.1.7 +PKG_VERSION:=3.1.9 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=http://samba.org/ftp/ccache/ -PKG_MD5SUM:=80a698c22d0b06b19c88ac58e8d8b632 +PKG_MD5SUM:=522a6016bda56892653612bbdefff3e0 include $(INCLUDE_DIR)/host-build.mk diff --git a/tools/cmake/Makefile b/tools/cmake/Makefile index 54c63757c..4e4d71b31 100644 --- a/tools/cmake/Makefile +++ b/tools/cmake/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2012 OpenWrt.org +# Copyright (C) 2006-2013 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,12 +7,21 @@ include $(TOPDIR)/rules.mk PKG_NAME:=cmake -PKG_VERSION:=2.8.7 +PKG_VERSION:=2.8.10.2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.cmake.org/files/v2.8/ -PKG_MD5SUM:=e1b237aeaed880f65dec9c20602452f6 +PKG_MD5SUM:=097278785da7182ec0aea8769d06860c + +HOST_BUILD_PARALLEL:=1 +HOST_CONFIGURE_PARALLEL:=1 include $(INCLUDE_DIR)/host-build.mk +HOST_CONFIGURE_VARS := + +HOST_CONFIGURE_ARGS := \ + --prefix=$(STAGING_DIR_HOST) \ + $(if $(MAKE_JOBSERVER),--parallel="$(MAKE_JOBSERVER)") + $(eval $(call HostBuild)) diff --git a/tools/e2fsprogs/Makefile b/tools/e2fsprogs/Makefile index 665ca0dcd..3b02f1a0c 100644 --- a/tools/e2fsprogs/Makefile +++ b/tools/e2fsprogs/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2010-2012 OpenWrt.org +# Copyright (C) 2010-2013 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -8,13 +8,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=e2fsprogs -PKG_VERSION:=1.42.4 -PKG_MD5SUM:=b6e296f210d642361b7394437ff0f318 +PKG_VERSION:=1.42.7 +PKG_MD5SUM:=a1ec22ef003688dae9f76c74881b22b9 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/e2fsprogs +HOST_BUILD_PARALLEL:=1 + include $(INCLUDE_DIR)/host-build.mk HOST_CFLAGS += $(FPIC) @@ -28,6 +30,11 @@ HOST_CONFIGURE_ARGS += \ --disable-tls \ --disable-nls +define Host/Prepare + $(call Host/Prepare/Default) + rm -rf $(HOST_BUILD_DIR)/doc +endef + define Host/Install $(Host/Install/Default) $(MAKE) -C $(HOST_BUILD_DIR)/lib/uuid install diff --git a/tools/e2fsprogs/patches/003-openbsd-compat.patch b/tools/e2fsprogs/patches/003-openbsd-compat.patch new file mode 100644 index 000000000..1f7cdca0e --- /dev/null +++ b/tools/e2fsprogs/patches/003-openbsd-compat.patch @@ -0,0 +1,24 @@ +diff -Nur e2fsprogs-1.42.7.orig/lib/blkid/getsize.c e2fsprogs-1.42.7/lib/blkid/getsize.c +--- e2fsprogs-1.42.7.orig/lib/blkid/getsize.c Fri Nov 30 03:40:18 2012 ++++ e2fsprogs-1.42.7/lib/blkid/getsize.c Thu Mar 7 14:21:59 2013 +@@ -26,6 +26,9 @@ + #include <fcntl.h> + #ifdef HAVE_SYS_IOCTL_H + #include <sys/ioctl.h> ++#ifdef __OpenBSD__ ++#include <sys/dkio.h> ++#endif + #endif + #ifdef HAVE_LINUX_FD_H + #include <linux/fd.h> +diff -Nur e2fsprogs-1.42.7.orig/lib/quota/mkquota.c e2fsprogs-1.42.7/lib/quota/mkquota.c +--- e2fsprogs-1.42.7.orig/lib/quota/mkquota.c Wed Jan 2 01:47:20 2013 ++++ e2fsprogs-1.42.7/lib/quota/mkquota.c Thu Mar 7 14:21:59 2013 +@@ -8,6 +8,7 @@ + #include <sys/stat.h> + #include <unistd.h> + #include <errno.h> ++#include <stdint.h> + #include <string.h> + #include <fcntl.h> + diff --git a/tools/e2fsprogs/patches/004-freebsd-compat.patch b/tools/e2fsprogs/patches/004-freebsd-compat.patch new file mode 100644 index 000000000..5eff49999 --- /dev/null +++ b/tools/e2fsprogs/patches/004-freebsd-compat.patch @@ -0,0 +1,13 @@ +diff -Nur e2fsprogs-1.42.7.orig/lib/ext2fs/tdb.c e2fsprogs-1.42.7/lib/ext2fs/tdb.c +--- e2fsprogs-1.42.7.orig/lib/ext2fs/tdb.c 2012-07-06 15:37:27.000000000 +0200 ++++ e2fsprogs-1.42.7/lib/ext2fs/tdb.c 2013-03-07 14:54:59.000000000 +0100 +@@ -56,7 +56,9 @@ + #include <utime.h> + #endif + #include <sys/stat.h> ++#ifndef __FreeBSD__ + #include <sys/file.h> ++#endif + #include <fcntl.h> + + #ifdef HAVE_SYS_MMAN_H diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile index 9dca902ae..ce9e1f7ce 100644 --- a/tools/firmware-utils/Makefile +++ b/tools/firmware-utils/Makefile @@ -60,6 +60,8 @@ define Host/Compile $(call cc,mkbrnimg) $(call cc,mkdapimg) $(call cc, mkcameofw, -Wall) + $(call cc,seama md5) + $(call cc,fix-u-media-header cyg_crc32,-Wall) $(call cc,bixutil) $(call cc,cvimg) endef diff --git a/tools/firmware-utils/src/bcm_tag.h b/tools/firmware-utils/src/bcm_tag.h index 2e977a2d7..2730edc9a 120000..100644 --- a/tools/firmware-utils/src/bcm_tag.h +++ b/tools/firmware-utils/src/bcm_tag.h @@ -1 +1,70 @@ -../../../target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h
\ No newline at end of file +#ifndef __BCM63XX_TAG_H +#define __BCM63XX_TAG_H + +#define TAGVER_LEN 4 /* Length of Tag Version */ +#define TAGLAYOUT_LEN 4 /* Length of FlashLayoutVer */ +#define SIG1_LEN 20 /* Company Signature 1 Length */ +#define SIG2_LEN 14 /* Company Signature 2 Lenght */ +#define BOARDID_LEN 16 /* Length of BoardId */ +#define ENDIANFLAG_LEN 2 /* Endian Flag Length */ +#define CHIPID_LEN 6 /* Chip Id Length */ +#define IMAGE_LEN 10 /* Length of Length Field */ +#define ADDRESS_LEN 12 /* Length of Address field */ +#define DUALFLAG_LEN 2 /* Dual Image flag Length */ +#define INACTIVEFLAG_LEN 2 /* Inactie Flag Length */ +#define RSASIG_LEN 20 /* Length of RSA Signature in tag */ +#define TAGINFO1_LEN 30 /* Length of vendor information field1 in tag */ +#define FLASHLAYOUTVER_LEN 4 /* Length of Flash Layout Version String tag */ +#define TAGINFO2_LEN 16 /* Length of vendor information field2 in tag */ +#define CRC_LEN 4 /* Length of CRC in bytes */ +#define ALTTAGINFO_LEN 54 /* Alternate length for vendor information; Pirelli */ + +#define NUM_PIRELLI 2 +#define IMAGETAG_CRC_START 0xFFFFFFFF + +#define PIRELLI_BOARDS { \ + "AGPF-S0", \ + "DWV-S0", \ +} + +/* + * The broadcom firmware assumes the rootfs starts the image, + * therefore uses the rootfs start (flashImageAddress) + * to determine where to flash the image. Since we have the kernel first + * we have to give it the kernel address, but the crc uses the length + * associated with this address (rootLength), which is added to the kernel + * length (kernelLength) to determine the length of image to flash and thus + * needs to be rootfs + deadcode (jffs2 EOF marker) +*/ + +struct bcm_tag { + char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag + char sig_1[SIG1_LEN]; // 4-23: Company Line 1 + char sig_2[SIG2_LEN]; // 24-37: Company Line 2 + char chipid[CHIPID_LEN]; // 38-43: Chip this image is for + char boardid[BOARDID_LEN]; // 44-59: Board name + char big_endian[ENDIANFLAG_LEN]; // 60-61: Map endianness -- 1 BE 0 LE + char totalLength[IMAGE_LEN]; // 62-71: Total length of image + char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE + char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE + char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of image start (kernel for OpenWRT, rootfs for stock firmware) + char flashRootLength[IMAGE_LEN]; // 106-115: Size of rootfs for flashing + char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel + char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel + char dualImage[DUALFLAG_LEN]; // 138-139: Unused at present + char inactiveFlag[INACTIVEFLAG_LEN]; // 140-141: Unused at present + char rsa_signature[RSASIG_LEN]; // 142-161: RSA Signature (unused at present; some vendors may use this) + char information1[TAGINFO1_LEN]; // 162-191: Compilation and related information (not generated/used by OpenWRT) + char flashLayoutVer[FLASHLAYOUTVER_LEN];// 192-195: Version flash layout + char fskernelCRC[CRC_LEN]; // 196-199: kernel+rootfs CRC32 + char information2[TAGINFO2_LEN]; // 200-215: Unused at present except Alice Gate where is is information + char imageCRC[CRC_LEN]; // 216-219: CRC32 of image less imagetag (kernel for Alice Gate) + char rootfsCRC[CRC_LEN]; // 220-223: CRC32 of rootfs partition + char kernelCRC[CRC_LEN]; // 224-227: CRC32 of kernel partition + char imageSequence[4]; // 228-231: Image sequence number + char rootLength[4]; // 232-235: steal from reserved1 to keep the real root length so we can use in the flash map even after we have change the rootLength to 0 to satisfy devices that check CRC on every boot + char headerCRC[CRC_LEN]; // 236-239: CRC32 of header excluding tagVersion + char reserved2[16]; // 240-255: Unused at present +}; + +#endif /* __BCM63XX_TAG_H */ diff --git a/tools/firmware-utils/src/csysimg.h b/tools/firmware-utils/src/csysimg.h index 19dfbd433..65ab062f3 100644 --- a/tools/firmware-utils/src/csysimg.h +++ b/tools/firmware-utils/src/csysimg.h @@ -49,6 +49,7 @@ #define SIG_BR6114WG SIG_BR6104IPC #define SIG_BR6524K "2-K-" #define SIG_BR6524KP "2-KP" /* FIXME: valid? */ +#define SIG_BR6524N "WNRA" #define SIG_BR6524WG "2-WG" /* FIXME: valid? */ #define SIG_BR6524WP "2-WP" /* FIXME: valid? */ #define SIG_BR6541K "4--K" diff --git a/tools/firmware-utils/src/fix-u-media-header.c b/tools/firmware-utils/src/fix-u-media-header.c new file mode 100644 index 000000000..21f184e66 --- /dev/null +++ b/tools/firmware-utils/src/fix-u-media-header.c @@ -0,0 +1,354 @@ +/* + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + * + */ +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <unistd.h> /* for unlink() */ +#include <libgen.h> +#include <getopt.h> /* for getopt() */ +#include <stdarg.h> +#include <errno.h> +#include <sys/stat.h> + +#include "cyg_crc.h" + +#include <arpa/inet.h> +#include <netinet/in.h> + +#define IH_MAGIC 0x27051956 /* Image Magic Number */ +#define IH_NMLEN 32 /* Image Name Length */ + +#define UM_MAGIC 0x55525F46 +#define UM_HEADER_LEN 12 + +/* + * all data in network byte order (aka natural aka bigendian) + */ +struct u_media_header { + uint32_t ih_magic; /* Image Header Magic Number */ + uint32_t ih_hcrc; /* Image Header CRC Checksum */ + uint32_t ih_time; /* Image Creation Timestamp */ + uint32_t ih_size; /* Image Data Size */ + uint32_t ih_load; /* Data Load Address */ + uint32_t ih_ep; /* Entry Point Address */ + uint32_t ih_dcrc; /* Image Data CRC Checksum */ + uint8_t ih_os; /* Operating System */ + uint8_t ih_arch; /* CPU architecture */ + uint8_t ih_type; /* Image Type */ + uint8_t ih_comp; /* Compression Type */ + uint8_t ih_name[IH_NMLEN - UM_HEADER_LEN]; /* Image Name */ + + uint32_t ih_UMedia_magic; /* U-Media magic number */ + uint32_t ih_UMedia_boardID; /* U-Media board ID */ + uint8_t ih_UMedia_imageType; /* U-Media image type */ + uint8_t ih_UMedia_LoadDefault; /* U-Media load to factory default setting */ + uint8_t ih_UMedia_temp1; /* U-Media didn't use this tag */ + uint8_t ih_UMedia_temp2; /* U-Media didn't use this tag */ +} __attribute__ ((packed)); + +struct if_info { + char *file_name; /* name of the file */ + uint32_t file_size; /* length of the file */ +}; + +static char *progname; +static char *ofname; +static struct if_info if_info; +static int factory_defaults; +static uint32_t board_id; +static uint8_t image_type; + +/* + * Message macros + */ +#define ERR(fmt, ...) do { \ + fflush(0); \ + fprintf(stderr, "[%s] *** error: " fmt "\n", \ + progname, ## __VA_ARGS__ ); \ +} while (0) + +#define ERRS(fmt, ...) do { \ + int save = errno; \ + fflush(0); \ + fprintf(stderr, "[%s] *** error: " fmt " (%s)\n", \ + progname, ## __VA_ARGS__, strerror(save)); \ +} while (0) + +#define DBG(fmt, ...) do { \ + fprintf(stderr, "[%s] " fmt "\n", progname, ## __VA_ARGS__ ); \ +} while (0) + +static void usage(int status) +{ + FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; + + fprintf(stream, "Usage: %s [OPTIONS...]\n", progname); + fprintf(stream, +"\n" +"Options:\n" +" -B <board_id> set board ID to <board_id>\n" +" -i <file> read input from the file <file>\n" +" -F load factory defaults\n" +" -o <file> write output to the file <file>\n" +" -T <type> set image type to <type>\n" +" -h show this screen\n" + ); + + exit(status); +} + +static int str2u32(char *arg, uint32_t *val) +{ + char *err = NULL; + uint32_t t; + + errno=0; + t = strtoul(arg, &err, 0); + if (errno || (err==arg) || ((err != NULL) && *err)) { + return -1; + } + + *val = t; + return 0; +} + +static int str2u8(char *arg, uint8_t *val) +{ + char *err = NULL; + uint32_t t; + + errno=0; + t = strtoul(arg, &err, 0); + if (errno || (err==arg) || ((err != NULL) && *err)) { + return -1; + } + + if (t > 255) + return -1; + + *val = t; + return 0; +} + +static int get_file_stat(struct if_info *fdata) +{ + struct stat st; + int res; + + if (fdata->file_name == NULL) + return 0; + + res = stat(fdata->file_name, &st); + if (res){ + ERRS("stat failed on %s", fdata->file_name); + return res; + } + + fdata->file_size = st.st_size; + return 0; +} + +static int read_to_buf(struct if_info *fdata, char *buf) +{ + FILE *f; + int ret = EXIT_FAILURE; + + f = fopen(fdata->file_name, "r"); + if (f == NULL) { + ERRS("could not open \"%s\" for reading", fdata->file_name); + goto out; + } + + errno = 0; + fread(buf, fdata->file_size, 1, f); + if (errno != 0) { + ERRS("unable to read from file \"%s\"", fdata->file_name); + goto out_close; + } + + ret = EXIT_SUCCESS; + +out_close: + fclose(f); +out: + return ret; +} + +static int check_options(void) +{ + int ret; + + if (ofname == NULL) { + ERR("no %s specified", "output file"); + return -1; + } + + if (if_info.file_name == NULL) { + ERR("no %s specified", "input file"); + return -1; + } + + ret = get_file_stat(&if_info); + if (ret) + return ret; + + return 0; +} + +static int write_fw(char *data, int len) +{ + FILE *f; + int ret = EXIT_FAILURE; + + f = fopen(ofname, "w"); + if (f == NULL) { + ERRS("could not open \"%s\" for writing", ofname); + goto out; + } + + errno = 0; + fwrite(data, len, 1, f); + if (errno) { + ERRS("unable to write output file"); + goto out_flush; + } + + ret = EXIT_SUCCESS; + +out_flush: + fflush(f); + fclose(f); + if (ret != EXIT_SUCCESS) { + unlink(ofname); + } +out: + return ret; +} + +static int fix_header(void) +{ + int buflen; + char *buf; + uint32_t crc, crc_orig; + struct u_media_header *hdr; + int ret = EXIT_FAILURE; + + buflen = if_info.file_size; + if (buflen < sizeof(*hdr)) { + ERR("invalid input file\n"); + return ret; + } + + buf = malloc(buflen); + if (!buf) { + ERR("no memory for buffer\n"); + goto out; + } + + ret = read_to_buf(&if_info, buf); + if (ret) + goto out_free_buf; + + hdr = (struct u_media_header *) buf; + if (ntohl(hdr->ih_magic) != IH_MAGIC) { + ERR("invalid input file, bad magic\n"); + goto out_free_buf; + } + + /* verify header CRC */ + crc_orig = ntohl(hdr->ih_hcrc); + hdr->ih_hcrc = 0; + crc = cyg_ether_crc32((unsigned char *)hdr, sizeof(*hdr)); + if (crc != crc_orig) { + ERR("invalid input file, bad header CRC\n"); + goto out_free_buf; + } + + hdr->ih_name[IH_NMLEN - UM_HEADER_LEN - 1] = '\0'; + + /* set U-Media specific fields */ + hdr->ih_UMedia_magic = htonl(UM_MAGIC); + hdr->ih_UMedia_boardID = htonl(board_id); + hdr->ih_UMedia_imageType = image_type; + hdr->ih_UMedia_LoadDefault = (factory_defaults) ? 1 : 0; + + /* update header CRC */ + crc = cyg_ether_crc32((unsigned char *)hdr, sizeof(*hdr)); + hdr->ih_hcrc = htonl(crc); + + ret = write_fw(buf, buflen); + if (ret) + goto out_free_buf; + + DBG("U-Media header fixed in \"%s\"", ofname); + + ret = EXIT_SUCCESS; + +out_free_buf: + free(buf); +out: + return ret; +} + +int main(int argc, char *argv[]) +{ + int ret = EXIT_FAILURE; + + progname = basename(argv[0]); + + while (1) { + int c; + + c = getopt(argc, argv, "B:Fi:o:T:h"); + if (c == -1) + break; + + switch (c) { + case 'B': + if (str2u32(optarg, &board_id)) { + ERR("%s is invalid '%s'", + "board ID", optarg); + goto out; + } + break; + case 'T': + if (str2u8(optarg, &image_type)) { + ERR("%s is invalid '%s'", + "image type", optarg); + goto out; + } + break; + case 'F': + factory_defaults = 1; + break; + case 'i': + if_info.file_name = optarg; + break; + case 'o': + ofname = optarg; + break; + case 'h': + usage(EXIT_SUCCESS); + break; + default: + usage(EXIT_FAILURE); + break; + } + } + + ret = check_options(); + if (ret) + goto out; + + ret = fix_header(); + +out: + return ret; +} diff --git a/tools/firmware-utils/src/mkcameofw.c b/tools/firmware-utils/src/mkcameofw.c index a152eb535..e0da4baf3 100644 --- a/tools/firmware-utils/src/mkcameofw.c +++ b/tools/firmware-utils/src/mkcameofw.c @@ -61,6 +61,7 @@ static struct file_info kernel_info; static struct file_info rootfs_info; static uint32_t kernel_size; static uint32_t image_size; +static int combined; /* * Message macros @@ -91,6 +92,7 @@ static void usage(int status) "\n" "Options:\n" " -k <file> read kernel image from the file <file>\n" +" -c use the kernel image as a combined image\n" " -M <model> set model to <model>\n" " -o <file> write output to the file <file>\n" " -r <file> read rootfs image from the file <file>\n" @@ -196,37 +198,55 @@ static int check_options(void) CHKSTRLEN(version, "version"); CHKSTR(ofname, "output file"); CHKSTR(kernel_info.file_name, "kernel image"); - CHKSTR(rootfs_info.file_name, "rootfs image"); ret = get_file_stat(&kernel_info); if (ret) return ret; - ret = get_file_stat(&rootfs_info); - if (ret) - return ret; + if (combined) { + if (!kernel_size) { + ERR("kernel size must be specified for combined images"); + return -1; \ + } - if (kernel_size) { - /* override kernel size */ - kernel_info.write_size = kernel_size; - } + if (!image_size) + image_size = kernel_info.file_size; - if (image_size) { - if (image_size < kernel_info.write_size) - kernel_info.write_size = image_size; + if (kernel_info.file_size > image_size) { + ERR("kernel image is too big"); + return -1; + } - /* override rootfs size */ - rootfs_info.write_size = image_size - kernel_info.write_size; - } + kernel_info.write_size = image_size; + } else { + CHKSTR(rootfs_info.file_name, "rootfs image"); - if (kernel_info.file_size > kernel_info.write_size) { - ERR("kernel image is too big"); - return -1; - } + ret = get_file_stat(&rootfs_info); + if (ret) + return ret; - if (rootfs_info.file_size > rootfs_info.write_size) { - ERR("rootfs image is too big"); - return -1; + if (kernel_size) { + /* override kernel size */ + kernel_info.write_size = kernel_size; + } + + if (image_size) { + if (image_size < kernel_info.write_size) + kernel_info.write_size = image_size; + + /* override rootfs size */ + rootfs_info.write_size = image_size - kernel_info.write_size; + } + + if (kernel_info.file_size > kernel_info.write_size) { + ERR("kernel image is too big"); + return -1; + } + + if (rootfs_info.file_size > rootfs_info.write_size) { + ERR("rootfs image is too big"); + return -1; + } } return 0; @@ -301,12 +321,14 @@ static int build_fw(void) if (ret) goto out_free_buf; - p += kernel_info.write_size; + if (!combined) { + p += kernel_info.write_size; - /* read rootfs data */ - ret = read_to_buf(&rootfs_info, p); - if (ret) - goto out_free_buf; + /* read rootfs data */ + ret = read_to_buf(&rootfs_info, p); + if (ret) + goto out_free_buf; + } csum = get_csum((unsigned char *)(buf + sizeof(struct img_header)), buflen - sizeof(struct img_header)); @@ -316,7 +338,10 @@ static int build_fw(void) hdr->checksum = htonl(csum); hdr->image_size = htonl(buflen - sizeof(struct img_header)); - hdr->kernel_size = htonl(kernel_info.write_size); + if (!combined) + hdr->kernel_size = htonl(kernel_info.write_size); + else + hdr->kernel_size = htonl(kernel_size); hdr->header_len = sizeof(struct img_header); strncpy(hdr->model, model, sizeof(hdr->model)); strncpy(hdr->signature, signature, sizeof(hdr->signature)); @@ -344,7 +369,7 @@ int main(int argc, char *argv[]) while (1) { int c; - c = getopt(argc, argv, "M:S:V:R:k:K:I:r:o:h"); + c = getopt(argc, argv, "M:S:V:R:k:K:I:r:o:hc"); if (c == -1) break; @@ -381,6 +406,9 @@ int main(int argc, char *argv[]) case 'r': rootfs_info.file_name = optarg; break; + case 'c': + combined = 1; + break; case 'o': ofname = optarg; break; diff --git a/tools/firmware-utils/src/mkcsysimg.c b/tools/firmware-utils/src/mkcsysimg.c index 4f2352a60..c00096f87 100644 --- a/tools/firmware-utils/src/mkcsysimg.c +++ b/tools/firmware-utils/src/mkcsysimg.c @@ -160,6 +160,7 @@ static struct board_info boards[] = { BOARD_ADM("BR-6114WG", "Edimax BR-6114WG", 2, SIG_BR6114WG), BOARD_ADM("BR-6524K", "Edimax BR-6524K", 2, SIG_BR6524K), BOARD_ADM("BR-6524KP", "Edimax BR-6524KP", 2, SIG_BR6524KP), + BOARD_ADM("BR-6524N", "Edimax BR-6524N", 2, SIG_BR6524N), BOARD_ADM("BR-6524WG", "Edimax BR-6524WG", 4, SIG_BR6524WG), BOARD_ADM("BR-6524WP", "Edimax BR-6524WP", 4, SIG_BR6524WP), BOARD_ADM("BR-6541K", "Edimax BR-6541K", 2, SIG_BR6541K), diff --git a/tools/firmware-utils/src/mkdapimg.c b/tools/firmware-utils/src/mkdapimg.c index 8b0359f74..ed662d8ec 100644 --- a/tools/firmware-utils/src/mkdapimg.c +++ b/tools/firmware-utils/src/mkdapimg.c @@ -27,6 +27,8 @@ #define MAX_MODEL_NAME_LEN 20 #define MAX_SIG_LEN 30 +#define MAX_REGION_LEN 4 +#define MAX_VERSION_LEN 12 struct img_hdr_struct { uint32_t checksum; @@ -51,7 +53,7 @@ perrexit(int code, char *msg) void usage() { - fprintf(stderr, "usage: %s [-p] [-m model] -s signature -i input -o output\n", progname); + fprintf(stderr, "usage: %s [-p] [-m model] [-r region] [-v version] -s signature -i input -o output\n", progname); exit(1); } @@ -60,8 +62,11 @@ main(int ac, char *av[]) { char model[MAX_MODEL_NAME_LEN+1]; char signature[MAX_SIG_LEN+1]; + char region[MAX_REGION_LEN+1]; + char version[MAX_VERSION_LEN+1]; int patchmode = 0; int fixmode = 0; + int have_regionversion = 0; FILE *ifile, *ofile; int c; @@ -71,11 +76,13 @@ main(int ac, char *av[]) progname = basename(av[0]); memset(model, 0, sizeof(model)); memset(signature, 0, sizeof(signature)); + memset(region, 0, sizeof(region)); + memset(version, 0, sizeof(version)); while ( 1 ) { int c; - c = getopt(ac, av, "pxm:s:i:o:"); + c = getopt(ac, av, "pxm:r:v:s:i:o:"); if (c == -1) break; @@ -94,6 +101,24 @@ main(int ac, char *av[]) } strcpy(model, optarg); break; + case 'r': + if (strlen(optarg) > MAX_REGION_LEN) { + fprintf(stderr, "%s: region exceeds %d chars\n", + progname, MAX_REGION_LEN); + exit(1); + } + have_regionversion = 1; + strcpy(region, optarg); + break; + case 'v': + if (strlen(optarg) > MAX_VERSION_LEN) { + fprintf(stderr, "%s: version exceeds %d chars\n", + progname, MAX_VERSION_LEN); + exit(1); + } + have_regionversion = 1; + strcpy(version, optarg); + break; case 's': if (strlen(optarg) > MAX_SIG_LEN) { fprintf(stderr, "%s: signature exceeds %d chars\n", @@ -150,6 +175,10 @@ main(int ac, char *av[]) imghdr.checksum = htonl(cksum); imghdr.partition = 0 ; // don't care? imghdr.hdr_len = sizeof(imghdr); + if (have_regionversion) { + imghdr.hdr_len += MAX_REGION_LEN; + imghdr.hdr_len += MAX_VERSION_LEN; + } imghdr.flash_byte_cnt = htonl(bcnt); } else { if (ntohl(imghdr.checksum) != cksum) { @@ -176,6 +205,12 @@ main(int ac, char *av[]) if (fwrite(&imghdr, sizeof(imghdr), 1, ofile) < 0) perrexit(2, "fwrite header on output"); + if (have_regionversion) { + if (fwrite(®ion, MAX_REGION_LEN, 1, ofile) < 0) + perrexit(2, "fwrite header on output"); + if (fwrite(&version, MAX_VERSION_LEN, 1, ofile) < 0) + perrexit(2, "fwrite header on output"); + } while ((c = fgetc(ifile)) != EOF) { if (fputc(c, ofile) == EOF) diff --git a/tools/firmware-utils/src/mkfwimage2.c b/tools/firmware-utils/src/mkfwimage2.c index ee09abba1..993c3d44e 100644 --- a/tools/firmware-utils/src/mkfwimage2.c +++ b/tools/firmware-utils/src/mkfwimage2.c @@ -212,7 +212,7 @@ static int image_layout_add_partition(const char *part_desc) } d = &im.parts[im.part_count]; - t = sscanf(part_desc, "%15[a-zA-Z]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%256s", + t = sscanf(part_desc, "%15[0-9a-zA-Z]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%15[0-9a-fA-Fx]:%256s", d->partition_name, offset, length, diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c index fab208170..74a55fd27 100644 --- a/tools/firmware-utils/src/mktplinkfw.c +++ b/tools/firmware-utils/src/mktplinkfw.c @@ -32,16 +32,25 @@ #define HEADER_VERSION_V1 0x01000000 #define HWID_TL_MR3020_V1 0x30200001 #define HWID_TL_MR3220_V1 0x32200001 +#define HWID_TL_MR3220_V2 0x32200002 #define HWID_TL_MR3420_V1 0x34200001 +#define HWID_TL_MR3420_V2 0x34200002 #define HWID_TL_WA701N_V1 0x07010001 +#define HWID_TL_WA7510N_V1 0x75100001 +#define HWID_TL_WA801ND_V1 0x08010001 +#define HWID_TL_WA830RE_V1 0x08300010 +#define HWID_TL_WA830RE_V2 0x08300002 #define HWID_TL_WA901ND_V1 0x09010001 #define HWID_TL_WA901ND_V2 0x09010002 +#define HWID_TL_WDR4900_V1 0x49000001 #define HWID_TL_WR703N_V1 0x07030101 +#define HWID_TL_WR720N_V3 0x07200103 #define HWID_TL_WR741ND_V1 0x07410001 #define HWID_TL_WR741ND_V4 0x07410004 #define HWID_TL_WR740N_V1 0x07400001 #define HWID_TL_WR740N_V3 0x07400003 #define HWID_TL_WR743ND_V1 0x07430001 +#define HWID_TL_WR743ND_V2 0x07430002 #define HWID_TL_WR841N_V1_5 0x08410002 #define HWID_TL_WR841ND_V3 0x08410003 #define HWID_TL_WR841ND_V5 0x08410005 @@ -172,6 +181,12 @@ static struct flash_layout layouts[] = { .kernel_ep = 0x80060000, .rootfs_ofs = 0x100000, }, { + .id = "16Mppc", + .fw_max_len = 0xf80000, + .kernel_la = 0x00000000, + .kernel_ep = 0xc0000000, + .rootfs_ofs = 0x2a0000, + }, { /* terminating entry */ } }; @@ -188,16 +203,46 @@ static struct board_info boards[] = { .hw_rev = 1, .layout_id = "4M", }, { + .id = "TL-MR3220v2", + .hw_id = HWID_TL_MR3220_V2, + .hw_rev = 1, + .layout_id = "4Mlzma", + }, { .id = "TL-MR3420v1", .hw_id = HWID_TL_MR3420_V1, .hw_rev = 1, .layout_id = "4M", }, { + .id = "TL-MR3420v2", + .hw_id = HWID_TL_MR3420_V2, + .hw_rev = 1, + .layout_id = "4Mlzma", + }, { .id = "TL-WA701Nv1", .hw_id = HWID_TL_WA701N_V1, .hw_rev = 1, .layout_id = "4M", }, { + .id = "TL-WA7510N", + .hw_id = HWID_TL_WA7510N_V1, + .hw_rev = 1, + .layout_id = "4M", + }, { + .id = "TL-WA801NDv1", + .hw_id = HWID_TL_WA801ND_V1, + .hw_rev = 1, + .layout_id = "4M", + }, { + .id = "TL-WA830REv1", + .hw_id = HWID_TL_WA830RE_V1, + .hw_rev = 1, + .layout_id = "4M", + }, { + .id = "TL-WA830REv2", + .hw_id = HWID_TL_WA830RE_V2, + .hw_rev = 1, + .layout_id = "4M", + }, { .id = "TL-WA901NDv1", .hw_id = HWID_TL_WA901ND_V1, .hw_rev = 1, @@ -208,6 +253,11 @@ static struct board_info boards[] = { .hw_rev = 1, .layout_id = "4M", }, { + .id = "TL-WDR4900v1", + .hw_id = HWID_TL_WDR4900_V1, + .hw_rev = 1, + .layout_id = "16Mppc", + }, { .id = "TL-WR741NDv1", .hw_id = HWID_TL_WR741ND_V1, .hw_rev = 1, @@ -233,6 +283,11 @@ static struct board_info boards[] = { .hw_rev = 1, .layout_id = "4M", }, { + .id = "TL-WR743NDv2", + .hw_id = HWID_TL_WR743ND_V2, + .hw_rev = 1, + .layout_id = "4Mlzma", + }, { .id = "TL-WR841Nv1.5", .hw_id = HWID_TL_WR841N_V1_5, .hw_rev = 2, @@ -283,6 +338,11 @@ static struct board_info boards[] = { .hw_rev = 1, .layout_id = "4Mlzma", }, { + .id = "TL-WR720Nv3", + .hw_id = HWID_TL_WR720N_V3, + .hw_rev = 1, + .layout_id = "4Mlzma", + }, { /* terminating entry */ } }; @@ -365,6 +425,7 @@ static void usage(int status) " -E <ep> overwrite kernel entry point with <ep> (hexval prefixed with 0x)\n" " -L <la> overwrite kernel load address with <la> (hexval prefixed with 0x)\n" " -H <hwid> use hardware id specified with <hwid>\n" +" -W <hwrev> use hardware revision specified with <hwrev>\n" " -F <id> use flash layout specified with <id>\n" " -k <file> read kernel image from the file <file>\n" " -r <file> read rootfs image from the file <file>\n" diff --git a/tools/firmware-utils/src/seama.c b/tools/firmware-utils/src/seama.c new file mode 100644 index 000000000..944ed3a44 --- /dev/null +++ b/tools/firmware-utils/src/seama.c @@ -0,0 +1,529 @@ +/* vi: set sw=4 ts=4: */ +/* + * Copyright (C) 2008, Alpha Networks, Inc. + * Created by David Hsieh <david_hsieh@alphanetworks.com> + * All right reserved. + * + * (SEA)ttle i(MA)ge is the image which used in project seattle. + * + * 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. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR + * 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. + * + */ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdarg.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <string.h> +#include <arpa/inet.h> + +#include "md5.h" +#include "seama.h" + +#define PROGNAME "seama" +#define VERSION "0.20" +#define MAX_SEAMA_META_SIZE 1024 +#define MAX_META 128 +#define MAX_IMAGE 128 + +extern int optind; +extern char * optarg; + +static int o_verbose = 0; /* verbose mode. */ +static char * o_dump = NULL; /* Seama file to dump. */ +static char * o_seal = NULL; /* Seal the input images when file name exist. */ +static char * o_extract = NULL; /* Extract the seama file. */ +static char * o_images[MAX_IMAGE];/* The image files to pack or seal */ +static int o_isize = 0; /* number of images */ +static char * o_meta[MAX_META]; /* meta data array */ +static int o_msize = 0; /* size of meta array */ + +static void verbose(const char * format, ...) +{ + va_list marker; + if (o_verbose) + { + va_start(marker, format); + vfprintf(stdout, format, marker); + va_end(marker); + } +} + +static void cleanup_exit(int exit_code) +{ + verbose("%s: exit with code %d\n", PROGNAME, exit_code); + exit(exit_code); +} + +static void show_usage(int exit_code) +{ + printf( PROGNAME " version " VERSION "\n" + "usage: " PROGNAME " [OPTIONS]\n" + " -h show this help message.\n" + " -v verbose mode.\n" + " -m {META data} META data.\n" + " -d {file} dump the info of the seama file.\n" + " -i {input file} image file name.\n" + " -s {file} Seal the images to the seama file.\n" + " -x {seama file} Extract the seama file.\n" + "\n" + " SEAMA can pack the input file (with -i) into a seama file.\n" + " ex: seama -i target.file\n" + " SEAMA can also seal multiple seama files into a single seama file.\n" + " ex: seama -s final.file -i taget1.seama -i target2.seama\n" + " To extract the raw image from SEAMA, you need to specify the meta.\n" + " The first image match the specified meta will be extract to\n" + " the output file which was specified with '-x'.\n" + " ex: seama -x output -i seama.image -m file=sealpac\n" + ); + cleanup_exit(exit_code); +} + +static int parse_args(int argc, char * argv[]) +{ + int opt; + + while ((opt = getopt(argc, argv, "hvd:s:i:m:x:")) > 0) + { + switch (opt) + { + default: show_usage(-1); break; + case 'h': show_usage(0); break; + case 'v': o_verbose++; break; + case 'd': o_dump = optarg; break; + case 's': o_seal = optarg; break; + case 'x': o_extract = optarg; break; + case 'i': + if (o_isize < MAX_IMAGE) o_images[o_isize++] = optarg; + else printf("Exceed the maximum acceptable image files.!\n"); + break; + case 'm': + if (o_msize < MAX_META) o_meta[o_msize++] = optarg; + else printf("Exceed the maximum acceptable META data.!\n"); + break; + } + } + return 0; +} + +/*******************************************************************/ + +static size_t calculate_digest(FILE * fh, size_t size, uint8_t * digest) +{ + MD5_CTX ctx; + size_t bytes_left, bytes_read, i; + uint8_t buf[MAX_SEAMA_META_SIZE]; + + bytes_left = size ? size : sizeof(buf); + bytes_read = 0; + + MD5_Init(&ctx); + while (!feof(fh) && !ferror(fh) && bytes_left > 0) + { + i = bytes_left < sizeof(buf) ? bytes_left : sizeof(buf); + i = fread(buf, sizeof(char), i, fh); + if (i > 0) + { + MD5_Update(&ctx, buf, i); + bytes_read += i; + } + if (size) bytes_left -= i; + } + MD5_Final(digest, &ctx); + return bytes_read; +} + +#define READ_BUFF_SIZE 8*1024 +static size_t copy_file(FILE * to, FILE * from) +{ + size_t i, fsize = 0; + uint8_t buf[READ_BUFF_SIZE]; + + while (!feof(from) && !ferror(from)) + { + i = fread(buf, sizeof(uint8_t), READ_BUFF_SIZE, from); + if (i > 0) + { + fsize += i; + fwrite(buf, sizeof(uint8_t), i, to); + } + } + return fsize; +} + +static int verify_seama(const char * fname, int msg) +{ + FILE * fh = NULL; + struct stat st; + seamahdr_t shdr; + uint8_t checksum[16]; + uint8_t digest[16]; + uint8_t buf[MAX_SEAMA_META_SIZE]; + size_t msize, isize, i; + int ret = -1; + +#define ERRBREAK(fmt, args...) { if (msg) printf(fmt, ##args); break; } + + do + { + if (stat(fname, &st) < 0) ERRBREAK("Unable to get the info of '%s'\n",fname); + if ((fh = fopen(fname, "r+"))==NULL) ERRBREAK("Unable to open '%s' for reading!\n",fname); + + /* Dump SEAMA header */ + if (msg) printf("FILE - %s (%d bytes)\n", fname, (int)st.st_size); + + /* SEAMA */ + while (!feof(fh) && !ferror(fh)) + { + /* read header */ + if (fread(&shdr, sizeof(shdr), 1, fh) != 1) break; + + /* Check the magic number */ + if (shdr.magic != htonl(SEAMA_MAGIC)) ERRBREAK("Invalid SEAMA magic. Probably no more SEAMA!\n"); + + /* Get the size */ + isize = ntohl(shdr.size); + msize = ntohs(shdr.metasize); + + /* The checksum exist only if size is greater than zero. */ + if (isize > 0) + { + if (fread(checksum, sizeof(checksum), 1, fh) != 1) + ERRBREAK("Error reading checksum !\n"); + } + + /* Check the META size. */ + if (msize > sizeof(buf)) ERRBREAK("META data in SEAMA header is too large!\n"); + + /* Read META data. */ + if (fread(buf, sizeof(char), msize, fh) != msize) + ERRBREAK("Unable to read SEAMA META data!\n"); + + /* dump header */ + if (msg) + { + printf("SEAMA ==========================================\n"); + printf(" magic : %08x\n", ntohl(shdr.magic)); + printf(" meta size : %d bytes\n", msize); + for (i=0; i<msize; i+=(strlen((const char *)&buf[i])+1)) + printf(" meta data : %s\n", &buf[i]); + printf(" image size : %d bytes\n", isize); + } + + /* verify checksum */ + if (isize > 0) + { + if (msg) + { + printf(" checksum : "); + for (i=0; i<16; i++) printf("%02X", checksum[i]); + printf("\n"); + } + + /* Calculate the checksum */ + calculate_digest(fh, isize, digest); + if (msg) + { + printf(" digest : "); + for (i=0; i<16; i++) printf("%02X", digest[i]); + printf("\n"); + } + + if (memcmp(checksum, digest, 16)!=0) ERRBREAK("!!ERROR!! checksum error !!\n"); + ret = 0; + } + } + if (msg) printf("================================================\n"); + } while (0); + if (fh) fclose(fh); + return ret; +} + +static size_t write_seama_header(FILE * fh, char * meta[], size_t msize, size_t size) +{ + seamahdr_t shdr; + size_t i; + uint16_t metasize = 0; + + /* Calculate the META size */ + for (i=0; i<msize; i++) metasize += (strlen(meta[i]) + 1); + //+++ let meta data end on 4 alignment by siyou. 2010/3/1 03:58pm + metasize = ((metasize+3)/4)*4; + verbose("SEAMA META : %d bytes\n", metasize); + + /* Fill up the header, all the data endian should be network byte order. */ + shdr.magic = htonl(SEAMA_MAGIC); + shdr.reserved = 0; + shdr.metasize = htons(metasize); + shdr.size = htonl(size); + + /* Write the header */ + return fwrite(&shdr, sizeof(seamahdr_t), 1, fh); +} + +static size_t write_checksum(FILE * fh, uint8_t * checksum) +{ + return fwrite(checksum, sizeof(uint8_t), 16, fh); +} + +static size_t write_meta_data(FILE * fh, char * meta[], size_t size) +{ + size_t i,j; + size_t ret = 0; + + for (i=0; i<size; i++) + { + verbose("SEAMA META data : %s\n", meta[i]); + j = fwrite(meta[i], sizeof(char), strlen(meta[i])+1, fh); + if (j != strlen(meta[i])+1) return 0; + ret += j; + } + //+++ let meta data end on 4 alignment by siyou. 2010/3/1 03:58pm + j = ((ret+3)/4)*4; + for ( ; ret < j; ret++) + fwrite("", sizeof(char), 1, fh); + + return ret; +} + +/*******************************************************************/ + +static void dump_seama(const char * fname) +{ + verify_seama(fname, 1); +} + +static void seal_files(const char * file) +{ + FILE * fh; + FILE * ifh; + size_t i; + + /* Each image should be seama. */ + for (i = 0; i < o_isize; i++) + { + if (verify_seama(o_images[i], 0) < 0) + { + printf("'%s' is not a seama file !\n",o_images[i]); + return; + } + } + + /* Open file for write */ + fh = fopen(file, "w+"); + if (fh) + { + /* Write the header. */ + write_seama_header(fh, o_meta, o_msize, 0); + write_meta_data(fh, o_meta, o_msize); + + /* Write image files */ + for (i=0; i<o_isize; i++) + { + ifh = fopen(o_images[i], "r+"); + if (ifh) + { + copy_file(fh, ifh); + fclose(ifh); + } + } + + fclose(fh); + } +} + +static void pack_files(void) +{ + FILE * fh; + FILE * ifh; + size_t i, fsize; + char filename[512]; + uint8_t digest[16]; + + for (i=0; i<o_isize; i++) + { + /* Open the input file. */ + ifh = fopen(o_images[i], "r+"); + if (ifh) + { + fsize = calculate_digest(ifh, 0, digest); + verbose("file size (%s) : %d\n", o_images[i], fsize); + rewind(ifh); + + /* Open the output file. */ + sprintf(filename, "%s.seama", o_images[i]); + fh = fopen(filename, "w+"); + if (fh) + { + write_seama_header(fh, o_meta, o_msize, fsize); + write_checksum(fh, digest); + write_meta_data(fh, o_meta, o_msize); + copy_file(fh, ifh); + fclose(fh); + } + fclose(ifh); + } + else + { + printf("Unable to open image file '%s'\n",o_images[i]); + } + } +} + +/**************************************************************************/ + +static int match_meta(const char * meta, size_t size) +{ + size_t i, j; + int match; + + for (i = 0; i < o_msize; i++) + { + for (match = 0, j = 0; j < size; j += (strlen(&meta[j])+1)) + if (strcmp(&meta[j], o_meta[i])==0) { match++; break; } + if (!match) return 0; + } + return 1; +} + + +static void extract_file(const char * output) +{ + FILE * ifh = NULL; + FILE * ofh = NULL; + size_t msize, isize, i, m; + seamahdr_t shdr; + uint8_t buf[MAX_SEAMA_META_SIZE]; + int done = 0; + + /* We need meta for searching the target image. */ + if (o_msize == 0) + { + printf("SEAMA: need meta for searching image.\n"); + return; + } + + /* Walk through each input file */ + for (i = 0; i < o_isize; i++) + { + /* verify the input file */ + if (verify_seama(o_images[i], 0) < 0) + { + printf("SEAMA: '%s' is not a seama file !\n", o_images[i]); + continue; + } + /* open the input file */ + ifh = fopen(o_images[i], "r"); + if (!ifh) continue; + /* read file */ + while (!feof(ifh) && !ferror(ifh)) + { + /* read header */ + fread(&shdr, sizeof(shdr), 1, ifh); + if (shdr.magic != htonl(SEAMA_MAGIC)) break; + /* Get the size */ + isize = ntohl(shdr.size); + msize = ntohs(shdr.metasize); + if (isize == 0) + { + while (msize > 0) + { + m = fread(buf, sizeof(char), (msize < MAX_SEAMA_META_SIZE) ? msize : MAX_SEAMA_META_SIZE, ifh); + if (m <= 0) break; + msize -= m; + } + continue; + } + /* read checksum */ + fread(buf, sizeof(char), 16, ifh); + if (msize > 0) + { + /* read META */ + fread(buf, sizeof(char), msize, ifh); + if (match_meta((const char *)buf, msize)) + { + printf("SEAMA: found image @ '%s', image size: %d\n", o_images[i], isize); + /* open output file */ + ofh = fopen(output, "w"); + if (!ofh) printf("SEAMA: unable to open '%s' for writting.\n",output); + else + { + while (isize > 0) + { + m = fread(buf, sizeof(char), (isize < MAX_SEAMA_META_SIZE) ? isize : MAX_SEAMA_META_SIZE, ifh); + if (m <= 0) break; + fwrite(buf, sizeof(char), m, ofh); + isize -= m; + } + fclose(ofh); + } + done++; + break; + } + } + while (isize > 0) + { + m = fread(buf, sizeof(char), (isize < MAX_SEAMA_META_SIZE) ? isize : MAX_SEAMA_META_SIZE, ifh); + if (m <= 0) break; + isize -= m; + } + } + /* close the file. */ + fclose(ifh); + if (done) break; + } + return; +} + +/*******************************************************************/ +#ifdef RGBIN_BOX +int seama_main(int argc, char * argv[], char * env[]) +#else +int main(int argc, char * argv[], char * env[]) +#endif +{ + verbose("SEAMA version " VERSION "\n"); + + /* parse the arguments */ + if (parse_args(argc, argv) < 0) show_usage(9); + + /* Do the works */ + if (o_dump) dump_seama(o_dump); + else if (o_seal) seal_files(o_seal); + else if (o_extract) extract_file(o_extract); + else pack_files(); + + cleanup_exit(0); + return 0; +} diff --git a/tools/firmware-utils/src/seama.h b/tools/firmware-utils/src/seama.h new file mode 100644 index 000000000..02683b6e9 --- /dev/null +++ b/tools/firmware-utils/src/seama.h @@ -0,0 +1,108 @@ +/* vi: set sw=4 ts=4: */ +/* + * (SEA)ttle i(MA)ge is the image which used in project seattle. + * + * Created by David Hsieh <david_hsieh@alphanetworks.com> + * Copyright (C) 2008-2009 Alpha Networks, Inc. + * + * This file is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either' + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful,' + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef __SEAMA_HEADER_FILE__ +#define __SEAMA_HEADER_FILE__ + +#include <stdint.h> + +#define SEAMA_MAGIC 0x5EA3A417 + +/* + * SEAMA looks like the following map. + * All the data of the header should be in network byte order. + * + * +-------------+-------------+------------ + * | SEAMA magic | ^ + * +-------------+-------------+ | + * | reserved | meta size | | + * +-------------+-------------+ header + * | image size (0 bytes) | | + * +-------------+-------------+ | + * ~ Meta data ~ v + * +-------------+-------------+------------ + * | SEAMA magic | ^ ^ + * +-------------+-------------+ | | + * | reserved | meta size | | | + * +-------------+-------------+ | | + * | image size | | | + * +-------------+-------------+ header | + * | | | | + * | 16 bytes of MD5 digest | | | + * | | | | + * | | | | + * +-------------+-------------+ | | + * ~ Meta data ~ v | + * +-------------+-------------+------- | + * | | | + * | Image of the 1st entity | | + * ~ ~ 1st entity + * | | | + * | | v + * +-------------+-------------+------------- + * | SEAMA magic | ^ ^ + * +-------------+-------------+ | | + * | reserved | meta size | | | + * +-------------+-------------+ | | + * | image size | | | + * +-------------+-------------+ header | + * | | | | + * | 16 bytes of MD5 digest | | | + * | | | | + * | | | | + * +-------------+-------------+ | | + * ~ Meta data ~ v | + * +-------------+-------------+------- | + * | | | + * | Image of the 2nd entity | | + * ~ ~ 2nd entity + * | | | + * | | v + * +-------------+-------------+------------- + */ + + +/* + * SEAMA header + * + * |<-------- 32 bits -------->| + * +-------------+-------------+ + * | SEAMA magic | + * +-------------+-------------+ + * | reserved | meta size | + * +-------------+-------------+ + * | image size | + * +-------------+-------------+ + */ +/* seama header */ +typedef struct seama_hdr seamahdr_t; +struct seama_hdr +{ + uint32_t magic; /* should always be SEAMA_MAGIC. */ + uint16_t reserved; /* reserved for */ + uint16_t metasize; /* size of the META data */ + uint32_t size; /* size of the image */ +} __attribute__ ((packed)); + + +#endif diff --git a/tools/flex/Makefile b/tools/flex/Makefile index 659324a64..abb275db8 100644 --- a/tools/flex/Makefile +++ b/tools/flex/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2008 OpenWrt.org +# Copyright (C) 2008-2013 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,13 +7,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=flex -PKG_VERSION:=2.5.35 +PKG_VERSION:=2.5.37 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=@SF/$(PKG_NAME) -PKG_MD5SUM:=10714e50cea54dc7a227e3eddcd44d57 +PKG_MD5SUM:=c75940e1fc25108f2a7b3ef42abdae06 PKG_CAT:=bzcat +HOST_BUILD_PARALLEL:=1 + include $(INCLUDE_DIR)/host-build.mk HOST_LDFLAGS += $(HOST_STATIC_LINKING) diff --git a/tools/gmp/Makefile b/tools/gmp/Makefile index 86c8aa0bc..5028ae062 100644 --- a/tools/gmp/Makefile +++ b/tools/gmp/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2009-2012 OpenWrt.org +# Copyright (C) 2009-2013 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,11 +7,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gmp -PKG_VERSION:=5.0.5 +PKG_VERSION:=5.1.1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/gmp/ -PKG_MD5SUM:=8aef50959acec2a1ad41d144ffe0f3b5 +PKG_MD5SUM:=485b1296e6287fa381e6015b19767989 + +HOST_FIXUP:=autoreconf + +HOST_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/host-build.mk diff --git a/tools/gmp/patches/000-OE-amd64.patch b/tools/gmp/patches/000-OE-amd64.patch deleted file mode 100644 index 260a0d5a7..000000000 --- a/tools/gmp/patches/000-OE-amd64.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/longlong.h -+++ b/longlong.h -@@ -994,8 +994,10 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ( - count is only an int. */ - #define count_trailing_zeros(count, x) \ - do { \ -+ UDItype __cbtmp; \ - ASSERT ((x) != 0); \ -- __asm__ ("bsfq %1,%q0" : "=r" (count) : "rm" ((UDItype)(x))); \ -+ __asm__ ("bsfq %1,%0" : "=r" (__cbtmp) : "rm" ((UDItype)(x))); \ -+ (count) = __cbtmp; \ - } while (0) - #endif /* x86_64 */ - diff --git a/tools/gmp/patches/000-OE-configure.patch b/tools/gmp/patches/000-OE-configure.patch deleted file mode 100644 index 7a0f1d889..000000000 --- a/tools/gmp/patches/000-OE-configure.patch +++ /dev/null @@ -1,199 +0,0 @@ ---- a/acinclude.m4 -+++ b/acinclude.m4 -@@ -30,29 +30,29 @@ dnl a_out.exe - OpenVMS DEC C called - dnl conftest.exe - various DOS compilers - - --define(IA64_PATTERN, -+define([IA64_PATTERN], - [[ia64*-*-* | itanium-*-* | itanium2-*-*]]) - - dnl Need to be careful not to match m6811, m6812, m68hc11 and m68hc12, all - dnl of which config.sub accepts. (Though none of which are likely to work - dnl with GMP.) - dnl --define(M68K_PATTERN, -+define([M68K_PATTERN], - [[m68k-*-* | m68[0-9][0-9][0-9]-*-*]]) - --define(POWERPC64_PATTERN, -+define([POWERPC64_PATTERN], - [[powerpc64-*-* | powerpc64le-*-* | powerpc620-*-* | powerpc630-*-* | powerpc970-*-* | power[3-9]-*-*]]) - --define(S390_PATTERN, -+define([S390_PATTERN], - [[s390-*-* | z900esa-*-* | z990esa-*-* | z9esa-*-* | z10esa-*-* | z196esa-*-*]]) - --define(S390X_PATTERN, -+define([S390X_PATTERN], - [[s390x-*-* | z900-*-* | z990-*-* | z9-*-* | z10-*-* | z196-*-*]]) - --define(X86_PATTERN, -+define([X86_PATTERN], - [[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | geode*-*-* | atom-*-*]]) - --define(X86_64_PATTERN, -+define([X86_64_PATTERN], - [[athlon64-*-* | k8-*-* | k10-*-* | bobcat-*-* | bulldozer-*-* | pentium4-*-* | atom-*-* | core2-*-* | corei*-*-* | x86_64-*-* | nano-*-*]]) - - dnl GMP_FAT_SUFFIX(DSTVAR, DIRECTORY) -@@ -70,7 +70,7 @@ dnl x86 -> x86 - dnl x86/k6 -> k6 - dnl x86/k6/mmx -> k6_mmx - --define(GMP_FAT_SUFFIX, -+define([GMP_FAT_SUFFIX], - [[$1=`echo $2 | sed -e '/\//s:^[^/]*/::' -e 's:[\\/]:_:g'`]]) - - -@@ -79,7 +79,7 @@ dnl ---------------------------------- - dnl Emit code to remove any occurrence of ITEM from $LISTVAR. ITEM can be a - dnl shell expression like $foo if desired. - --define(GMP_REMOVE_FROM_LIST, -+define([GMP_REMOVE_FROM_LIST], - [remove_from_list_tmp= - for remove_from_list_i in $[][$1]; do - if test $remove_from_list_i = [$2]; then :; -@@ -95,12 +95,12 @@ dnl GMP_STRIP_PATH(subdir) - dnl ---------------------- - dnl Strip entries */subdir from $path and $fat_path. - --define(GMP_STRIP_PATH, -+define([GMP_STRIP_PATH], - [GMP_STRIP_PATH_VAR(path, [$1]) - GMP_STRIP_PATH_VAR(fat_path, [$1]) - ]) - --define(GMP_STRIP_PATH_VAR, -+define([GMP_STRIP_PATH_VAR], - [tmp_path= - for i in $[][$1]; do - case $i in -@@ -121,7 +121,7 @@ dnl - dnl Dummy value for GMP_LIMB_BITS is enough - dnl for all current configure-time uses of gmp.h. - --define(GMP_INCLUDE_GMP_H, -+define([GMP_INCLUDE_GMP_H], - [[#define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ - #define GMP_NAIL_BITS $GMP_NAIL_BITS - #define GMP_LIMB_BITS 123 -@@ -136,7 +136,7 @@ dnl Expand at autoconf time to the valu - dnl FILE. The regexps here aren't very rugged, but are enough for gmp. - dnl /dev/null as a parameter prevents a hang if $2 is accidentally omitted. - --define(GMP_HEADER_GETVAL, -+define([GMP_HEADER_GETVAL], - [patsubst(patsubst( - esyscmd([grep "^#define $1 " $2 /dev/null 2>/dev/null]), - [^.*$1[ ]+],[]), -@@ -150,7 +150,7 @@ dnl The gmp version number, extracted f - dnl autoconf time. Two digits like 3.0 if patchlevel <= 0, or three digits - dnl like 3.0.1 if patchlevel > 0. - --define(GMP_VERSION, -+define([GMP_VERSION], - [GMP_HEADER_GETVAL(__GNU_MP_VERSION,gmp-h.in)[]dnl - .GMP_HEADER_GETVAL(__GNU_MP_VERSION_MINOR,gmp-h.in)[]dnl - .GMP_HEADER_GETVAL(__GNU_MP_VERSION_PATCHLEVEL,gmp-h.in)]) -@@ -1512,7 +1512,9 @@ esac - echo ["define(<CONFIG_TOP_SRCDIR>,<\`$tmp'>)"] >>$gmp_tmpconfigm4 - - # All CPUs use asm-defs.m4 --echo ["include][(CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4')"] >>$gmp_tmpconfigm4i -+echo -n ["include("] >>$gmp_tmpconfigm4i -+echo -n ["CONFIG_TOP_SRCDIR\`/mpn/asm-defs.m4'"] >>$gmp_tmpconfigm4i -+echo [")"] >>$gmp_tmpconfigm4i - ]) - - ---- a/configure.in -+++ b/configure.in -@@ -29,12 +29,6 @@ AC_REVISION($Revision$) - AC_PREREQ(2.59) - AC_INIT(GNU MP, GMP_VERSION, [gmp-bugs@gmplib.org, see http://gmplib.org/manual/Reporting-Bugs.html], gmp) - AC_CONFIG_SRCDIR(gmp-impl.h) --m4_pattern_forbid([^[ \t]*GMP_]) --m4_pattern_allow(GMP_LDFLAGS) --m4_pattern_allow(GMP_LIMB_BITS) --m4_pattern_allow(GMP_MPARAM_H_SUGGEST) --m4_pattern_allow(GMP_NAIL_BITS) --m4_pattern_allow(GMP_NUMB_BITS) - - # If --target is not used then $target_alias is empty, but if say - # "./configure athlon-pc-freebsd3.5" is used, then all three of -@@ -311,7 +305,7 @@ AH_VERBATIM([HAVE_HOST_CPU_1], - # After GMP specific searches and tests, the standard autoconf AC_PROG_CC is - # called. User selections of CC etc are respected. - # --# Care is taken not to use macros like AC_TRY_COMPILE during the GMP -+# Care is taken not to use macros like AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) during the GMP - # pre-testing, since they of course depend on AC_PROG_CC, and also some of - # them cache their results, which is not wanted. - # -@@ -403,7 +397,7 @@ abilist="standard" - # FIXME: We'd like to prefer an ANSI compiler, perhaps by preferring - # c89 over cc here. But note that on HP-UX c89 provides a castrated - # environment, and would want to be excluded somehow. Maybe --# AC_PROG_CC_STDC already does enough to stick cc into ANSI mode and -+# already does enough to stick cc into ANSI mode and - # we don't need to worry. - # - cclist="gcc cc" -@@ -1666,7 +1660,7 @@ esac - CFLAGS_or_unset=${CFLAGS-'(unset)'} - CPPFLAGS_or_unset=${CPPFLAGS-'(unset)'} - --cat >&AC_FD_CC <<EOF -+cat >&AS_MESSAGE_LOG_FD() <<EOF - User: - ABI=$ABI - CC=$CC -@@ -2073,7 +2067,6 @@ AC_SUBST(DEFN_LONG_LONG_LIMB) - - # The C compiler and preprocessor, put into ANSI mode if possible. - AC_PROG_CC --AC_PROG_CC_STDC - AC_PROG_CPP - GMP_H_ANSI - -@@ -2096,11 +2089,11 @@ AC_SUBST(CCAS) - - # The C++ compiler, if desired. - want_cxx=no -+AC_PROG_CXX - if test $enable_cxx != no; then - test_CXXFLAGS=${CXXFLAGS+set} -- AC_PROG_CXX - -- echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AC_FD_CC -+ echo "CXXFLAGS chosen by autoconf: $CXXFLAGS" >&AS_MESSAGE_LOG_FD() - cxxflags_ac_prog_cxx=$CXXFLAGS - cxxflags_list=ac_prog_cxx - -@@ -2206,7 +2199,7 @@ case $host in - esac - - --cat >&AC_FD_CC <<EOF -+cat >&AS_MESSAGE_LOG_FD() <<EOF - Decided: - ABI=$ABI - CC=$CC -@@ -3465,7 +3458,7 @@ GMP_FINISH - # FIXME: Upcoming version of autoconf/automake may not like broken lines. - # Right now automake isn't accepting the new AC_CONFIG_FILES scheme. - --AC_OUTPUT(Makefile \ -+AC_CONFIG_FILES([Makefile \ - mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile \ - mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile \ - tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile \ -@@ -3474,4 +3467,5 @@ AC_OUTPUT(Makefile \ - tests/cxx/Makefile \ - doc/Makefile tune/Makefile \ - demos/Makefile demos/calc/Makefile demos/expr/Makefile \ -- gmp.h:gmp-h.in mp.h:mp-h.in) -+ gmp.h:gmp-h.in mp.h:mp-h.in]) -+AC_OUTPUT diff --git a/tools/include/endian.h b/tools/include/endian.h index 0f17b41da..bba70abd8 100644 --- a/tools/include/endian.h +++ b/tools/include/endian.h @@ -15,6 +15,11 @@ #define bswap_16(x) bswap16(x) #define bswap_32(x) bswap32(x) #define bswap_64(x) bswap64(x) +#elif defined(__OpenBSD__) +#include <sys/types.h> +#define bswap_16(x) __swap16(x) +#define bswap_32(x) __swap32(x) +#define bswap_64(x) __swap64(x) #else #include <machine/endian.h> #define bswap_16(x) swap16(x) diff --git a/tools/include/getline.h b/tools/include/getline.h index 02df6c2f7..3ac21715b 100644 --- a/tools/include/getline.h +++ b/tools/include/getline.h @@ -32,7 +32,7 @@ #include <stdlib.h> #include <string.h> -#if !defined(__linux__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L) +#if !defined(__linux__) && !defined(__OpenBSD__) && !(defined(__APPLE__) && __DARWIN_C_LEVEL >= 200809L) /* * Emulate glibc getline() via BSD fgetln(). * Note that outsize is not changed unless memory is allocated. diff --git a/tools/ipkg-utils/patches/200-force_gnu_format.patch b/tools/ipkg-utils/patches/200-force_gnu_format.patch new file mode 100644 index 000000000..f363acbc0 --- /dev/null +++ b/tools/ipkg-utils/patches/200-force_gnu_format.patch @@ -0,0 +1,27 @@ +--- a/ipkg-build ++++ b/ipkg-build +@@ -250,13 +250,13 @@ mkdir $tmp_dir + + echo $CONTROL > $tmp_dir/tarX + # Preserve permissions (-p) when creating data.tar.gz as non-root user +-( cd $pkg_dir && $TAR $ogargs -X $tmp_dir/tarX -czpf $tmp_dir/data.tar.gz . ) ++( cd $pkg_dir && $TAR $ogargs -X $tmp_dir/tarX --format=gnu -czpf $tmp_dir/data.tar.gz . ) + + installed_size=`stat -c "%s" $tmp_dir/data.tar.gz` + sed -i -e "s/^Installed-Size: .*/Installed-Size: $installed_size/" \ + $pkg_dir/$CONTROL/control + +-( cd $pkg_dir/$CONTROL && $TAR $ogargs -czf $tmp_dir/control.tar.gz . ) ++( cd $pkg_dir/$CONTROL && $TAR $ogargs --format=gnu -czf $tmp_dir/control.tar.gz . ) + rm $tmp_dir/tarX + + echo "2.0" > $tmp_dir/debian-binary +@@ -266,7 +266,7 @@ rm -f $pkg_file + if [ "$outer" = "ar" ] ; then + ( cd $tmp_dir && ar -crf $pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz ) + else +- ( cd $tmp_dir && $TAR -zcf $pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz ) ++ ( cd $tmp_dir && $TAR --format=gnu -zcf $pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz ) + fi + + rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz diff --git a/tools/ipkg-utils/patches/210-remove_field_checks.patch b/tools/ipkg-utils/patches/210-remove_field_checks.patch new file mode 100644 index 000000000..2f1f2eab3 --- /dev/null +++ b/tools/ipkg-utils/patches/210-remove_field_checks.patch @@ -0,0 +1,36 @@ +--- a/ipkg-build ++++ b/ipkg-build +@@ -101,9 +101,6 @@ You probably want to chown these to a sy + arch=`required_field Architecture` + [ "$?" -ne 0 ] && PKG_ERROR=1 + +- required_field Maintainer >/dev/null +- [ "$?" -ne 0 ] && PKG_ERROR=1 +- + required_field Description >/dev/null + [ "$?" -ne 0 ] && PKG_ERROR=1 + +@@ -114,23 +111,6 @@ You probably want to chown these to a sy + echo "admin, base, comm, editors, extras, games, graphics, kernel, libs, misc, net, text, web, x11" >&2 + fi + +- priority=`required_field Priority` +- [ "$?" -ne 0 ] && PKG_ERROR=1 +- if [ -z "$priority" ]; then +- echo "The Priority field should have one of the following values:" >&2 +- echo "required, important, standard, optional, extra." >&2 +- echo "If you don't know which priority value you should be using, then use \`optional'" >&2 +- fi +- +- source=`required_field Source` +- [ "$?" -ne 0 ] && PKG_ERROR=1 +- if [ -z "$source" ]; then +- echo "The Source field contain the URL's or filenames of the source code and any patches" +- echo "used to build this package. Either gnu-style tarballs or Debian source packages " +- echo "are acceptable. Relative filenames may be used if they are distributed in the same" +- echo "directory as the .ipk file." +- fi +- + disallowed_filename=`disallowed_field Filename` + [ "$?" -ne 0 ] && PKG_ERROR=1 + diff --git a/tools/libelf/Makefile b/tools/libelf/Makefile index f38d70d09..8036b6f18 100644 --- a/tools/libelf/Makefile +++ b/tools/libelf/Makefile @@ -15,6 +15,8 @@ PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.mr511.de/software/ +HOST_BUILD_PARALLEL:=1 + include $(INCLUDE_DIR)/host-build.mk HOST_CONFIGURE_ARGS += \ @@ -30,7 +32,7 @@ endef define Host/Compile - $(MAKE) -C $(HOST_BUILD_DIR)/lib/ libelf.a + +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR)/lib/ libelf.a endef define Host/Install diff --git a/tools/libtool/Makefile b/tools/libtool/Makefile index 080689b8a..cb6cf4a5c 100644 --- a/tools/libtool/Makefile +++ b/tools/libtool/Makefile @@ -13,6 +13,8 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@GNU/$(PKG_NAME) PKG_MD5SUM:=b32b04148ecdd7344abc6fe8bd1bb021 +HOST_BUILD_PARALLEL:=1 + include $(INCLUDE_DIR)/host-build.mk HOST_CONFIGURE_VARS += \ diff --git a/tools/m4/Makefile b/tools/m4/Makefile index 6470a549a..080eb5d99 100644 --- a/tools/m4/Makefile +++ b/tools/m4/Makefile @@ -14,8 +14,12 @@ PKG_SOURCE_URL:=@GNU/$(PKG_NAME) PKG_MD5SUM:=a5dfb4f2b7370e9d34293d23fd09b280 PKG_CAT:=zcat +HOST_BUILD_PARALLEL:=1 + include $(INCLUDE_DIR)/host-build.mk +HOST_CONFIGURE_VARS += gl_cv_func_strstr_linear=no + HOST_LDFLAGS += $(HOST_STATIC_LINKING) define Host/Clean diff --git a/tools/mkimage/Makefile b/tools/mkimage/Makefile index 373d9bebb..458cca8fe 100644 --- a/tools/mkimage/Makefile +++ b/tools/mkimage/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2012 OpenWrt.org +# Copyright (C) 2006-2013 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,20 +7,27 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mkimage -PKG_VERSION:=2012.04.01 +PKG_VERSION:=2013.04 PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot -PKG_MD5SUM:=192bb231082d9159fb6e16de3039b6b2 +PKG_MD5SUM:=21bf962d69938ed4ed783b792b2b074e PKG_CAT:=bzcat HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/u-boot-$(PKG_VERSION) include $(INCLUDE_DIR)/host-build.mk -define Host/Compile - rm -f $(HOST_BUILD_DIR)/tools/.depend +define Host/Prepare + $(Host/Prepare/Default) + rm -f \ + $(HOST_BUILD_DIR)/include/errno.h \ + $(HOST_BUILD_DIR)/include/malloc.h \ + $(HOST_BUILD_DIR)/tools/.depend touch $(HOST_BUILD_DIR)/include/config.h +endef + +define Host/Compile $(MAKE) -C $(HOST_BUILD_DIR) BUILD_DIR= BIN_FILES-y="mkimage" HOSTLDFLAGS="$(HOST_STATIC_LINKING)" tools endef diff --git a/tools/mkimage/patches/010-freebsd-ulong-fix.patch b/tools/mkimage/patches/010-freebsd-ulong-fix.patch index 32fa07453..715755b87 100644 --- a/tools/mkimage/patches/010-freebsd-ulong-fix.patch +++ b/tools/mkimage/patches/010-freebsd-ulong-fix.patch @@ -1,6 +1,6 @@ --- a/include/image.h +++ b/include/image.h -@@ -50,6 +50,10 @@ +@@ -51,6 +51,10 @@ #endif /* USE_HOSTCC */ @@ -9,5 +9,5 @@ +#endif + #if defined(CONFIG_FIT) - #include <fdt.h> #include <libfdt.h> + #include <fdt_support.h> diff --git a/tools/mkimage/patches/020-openbsd_fixes.patch b/tools/mkimage/patches/020-openbsd_fixes.patch new file mode 100644 index 000000000..4c376caad --- /dev/null +++ b/tools/mkimage/patches/020-openbsd_fixes.patch @@ -0,0 +1,18 @@ +--- a/tools/mkimage.c ++++ b/tools/mkimage.c +@@ -464,6 +464,7 @@ NXTARG: ; + #if defined(_POSIX_SYNCHRONIZED_IO) && \ + !defined(__sun__) && \ + !defined(__FreeBSD__) && \ ++ !defined(__OpenBSD__) && \ + !defined(__APPLE__) + (void) fdatasync (ifd); + #else +@@ -507,6 +508,7 @@ NXTARG: ; + #if defined(_POSIX_SYNCHRONIZED_IO) && \ + !defined(__sun__) && \ + !defined(__FreeBSD__) && \ ++ !defined(__OpenBSD__) && \ + !defined(__APPLE__) + (void) fdatasync (ifd); + #else diff --git a/tools/mkimage/patches/030-allow-to-use-different-magic.patch b/tools/mkimage/patches/030-allow-to-use-different-magic.patch index 23f39ad22..14397964b 100644 --- a/tools/mkimage/patches/030-allow-to-use-different-magic.patch +++ b/tools/mkimage/patches/030-allow-to-use-different-magic.patch @@ -7,8 +7,8 @@ + .magic = IH_MAGIC, .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS, .imagename = "", - }; -@@ -186,6 +187,16 @@ main (int argc, char **argv) + .imagename2 = "", +@@ -189,6 +190,16 @@ main (int argc, char **argv) genimg_get_comp_id (*++argv)) < 0) usage (); goto NXTARG; @@ -25,7 +25,7 @@ case 'D': if (--argc <= 0) usage (); -@@ -596,12 +607,13 @@ usage () +@@ -613,12 +624,13 @@ usage () fprintf (stderr, "Usage: %s -l image\n" " -l ==> list image header information\n", params.cmdname); diff --git a/tools/mkimage/patches/050-image_h_portability.patch b/tools/mkimage/patches/050-image_h_portability.patch new file mode 100644 index 000000000..1f222370b --- /dev/null +++ b/tools/mkimage/patches/050-image_h_portability.patch @@ -0,0 +1,31 @@ +--- a/include/image.h ++++ b/include/image.h +@@ -34,7 +34,6 @@ + #define __IMAGE_H__ + + #include "compiler.h" +-#include <asm/byteorder.h> + + #ifdef USE_HOSTCC + +@@ -191,13 +190,13 @@ + * all data in network byte order (aka natural aka bigendian). + */ + typedef struct image_header { +- __be32 ih_magic; /* Image Header Magic Number */ +- __be32 ih_hcrc; /* Image Header CRC Checksum */ +- __be32 ih_time; /* Image Creation Timestamp */ +- __be32 ih_size; /* Image Data Size */ +- __be32 ih_load; /* Data Load Address */ +- __be32 ih_ep; /* Entry Point Address */ +- __be32 ih_dcrc; /* Image Data CRC Checksum */ ++ uint32_t ih_magic; /* Image Header Magic Number */ ++ uint32_t ih_hcrc; /* Image Header CRC Checksum */ ++ uint32_t ih_time; /* Image Creation Timestamp */ ++ uint32_t ih_size; /* Image Data Size */ ++ uint32_t ih_load; /* Data Load Address */ ++ uint32_t ih_ep; /* Entry Point Address */ ++ uint32_t ih_dcrc; /* Image Data CRC Checksum */ + uint8_t ih_os; /* Operating System */ + uint8_t ih_arch; /* CPU architecture */ + uint8_t ih_type; /* Image Type */ diff --git a/tools/mkimage/patches/060-remove_kernel_includes.patch b/tools/mkimage/patches/060-remove_kernel_includes.patch new file mode 100644 index 000000000..b408bb10f --- /dev/null +++ b/tools/mkimage/patches/060-remove_kernel_includes.patch @@ -0,0 +1,35 @@ +--- a/include/compiler.h ++++ b/include/compiler.h +@@ -53,6 +53,11 @@ + typedef uint16_t __u16; + typedef uint32_t __u32; + typedef unsigned int uint; ++typedef uint64_t __u64; ++#ifndef linux ++typedef int __kernel_daddr_t; ++typedef unsigned int __kernel_ino_t; ++#endif + + #define uswap_16(x) \ + ((((x) & 0xff00) >> 8) | \ +--- a/include/linux/posix_types.h ++++ b/include/linux/posix_types.h +@@ -43,6 +43,8 @@ + /* Type of a SYSV IPC key. */ + typedef int __kernel_key_t; + ++#ifdef linux + #include <asm/posix_types.h> ++#endif + + #endif /* _LINUX_POSIX_TYPES_H */ +--- a/include/linux/types.h ++++ b/include/linux/types.h +@@ -6,7 +6,6 @@ + #endif + + #include <linux/posix_types.h> +-#include <asm/types.h> + #include <stdbool.h> + + #ifndef __KERNEL_STRICT_NAMES diff --git a/tools/mkimage/patches/100-dtc-binary.patch b/tools/mkimage/patches/100-dtc-binary.patch new file mode 100644 index 000000000..50341198b --- /dev/null +++ b/tools/mkimage/patches/100-dtc-binary.patch @@ -0,0 +1,86 @@ +--- a/doc/mkimage.1 ++++ b/doc/mkimage.1 +@@ -82,6 +82,10 @@ + .B Create FIT image: + + .TP ++.BI "\-B [" "dtc bin" "]" ++Set path to the device tree compiler binary. ++ ++.TP + .BI "\-D [" "dtc options" "]" + Provide special options to the device tree compiler that is used to + create the image. +--- a/tools/fit_image.c ++++ b/tools/fit_image.c +@@ -82,7 +82,8 @@ + + /* dtc -I dts -O dtb -p 500 datafile > tmpfile */ + sprintf (cmd, "%s %s %s > %s", +- MKIMAGE_DTC, params->dtc, params->datafile, tmpfile); ++ params->dtc_bin, params->dtc_options, params->datafile, ++ tmpfile); + debug ("Trying to execute \"%s\"\n", cmd); + if (system (cmd) == -1) { + fprintf (stderr, "%s: system(%s) failed: %s\n", +--- a/tools/mkimage.c ++++ b/tools/mkimage.c +@@ -38,7 +38,8 @@ + .type = IH_TYPE_KERNEL, + .comp = IH_COMP_GZIP, + .magic = IH_MAGIC, +- .dtc = MKIMAGE_DEFAULT_DTC_OPTIONS, ++ .dtc_bin = MKIMAGE_DTC, ++ .dtc_options = MKIMAGE_DEFAULT_DTC_OPTIONS, + .imagename = "", + .imagename2 = "", + }; +@@ -200,10 +201,15 @@ + params.cmdname, *argv); + } + goto NXTARG; ++ case 'B': ++ if (--argc <= 0) ++ usage (); ++ params.dtc_bin = *++argv; ++ goto NXTARG; + case 'D': + if (--argc <= 0) + usage (); +- params.dtc = *++argv; ++ params.dtc_options = *++argv; + goto NXTARG; + + case 'O': +@@ -637,7 +643,9 @@ + " -d ==> use image data from 'datafile'\n" + " -x ==> set XIP (execute in place)\n", + params.cmdname); +- fprintf (stderr, " %s [-D dtc_options] -f fit-image.its fit-image\n", ++ fprintf (stderr, " %s [-B dtc_bin] [-D dtc_options] -f fit-image.its fit-image\n", ++ " -B ==> set path to the dtc binary\n", ++ " -D ==> set options that will be passed to dtc\n", + params.cmdname); + fprintf (stderr, " %s -V ==> print version information and exit\n", + params.cmdname); +--- a/tools/mkimage.h ++++ b/tools/mkimage.h +@@ -46,7 +46,7 @@ + #define MKIMAGE_MAX_TMPFILE_LEN 256 + #define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 500" + #define MKIMAGE_MAX_DTC_CMDLINE_LEN 512 +-#define MKIMAGE_DTC "dtc" /* assume dtc is in $PATH */ ++#define MKIMAGE_DTC "dtc" + + /* + * This structure defines all such variables those are initialized by +@@ -66,7 +66,8 @@ + int type; + int comp; + unsigned int magic; +- char *dtc; ++ char *dtc_bin; ++ char *dtc_options; + unsigned int addr; + unsigned int ep; + char *imagename; diff --git a/tools/mklibs/Makefile b/tools/mklibs/Makefile index fd3d233c4..fa0bce70d 100644 --- a/tools/mklibs/Makefile +++ b/tools/mklibs/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2009-2012 OpenWrt.org +# Copyright (C) 2009-2013 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,11 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mklibs -PKG_VERSION:=0.1.34 +PKG_VERSION:=0.1.35 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://ftp.de.debian.org/debian/pool/main/m/mklibs/ -PKG_MD5SUM:=afe0ed527ba96b8a882b5de350603007 +PKG_MD5SUM:=3d2a4bd0bbf5ba964b0a1ecdafd1ea9a + +HOST_FIXUP:=autoreconf include $(INCLUDE_DIR)/host-build.mk diff --git a/tools/mklibs/patches/001-compile.patch b/tools/mklibs/patches/001-compile.patch new file mode 100644 index 000000000..09b831ada --- /dev/null +++ b/tools/mklibs/patches/001-compile.patch @@ -0,0 +1,8 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -1,4 +1,4 @@ +-AC_INIT([mklibs],m4_esyscmd(dpkg-parsechangelog | perl -ne 'print $1 if m/^Version: (.*)$/;')) ++AC_INIT([mklibs],m4_esyscmd([head -n1 debian/changelog | awk -F'[\\\\(\\\\)]' '{ print $2 }' | xargs -I{} echo -n {}])) + AM_INIT_AUTOMAKE([foreign no-define]) + AC_CONFIG_HEADERS([config.h]) + AM_MAINTAINER_MODE diff --git a/tools/mpc/Makefile b/tools/mpc/Makefile index f0918b3b1..adbe33e0b 100644 --- a/tools/mpc/Makefile +++ b/tools/mpc/Makefile @@ -13,6 +13,8 @@ PKG_SOURCE_URL:=http://www.multiprecision.org/mpc/download/ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_MD5SUM:=0d6acab8d214bd7d1fbbc593e83dd00d +HOST_BUILD_PARALLEL:=1 + include $(INCLUDE_DIR)/host-build.mk unexport CFLAGS @@ -23,13 +25,4 @@ HOST_CONFIGURE_ARGS += \ --with-mpfr=$(TOPDIR)/staging_dir/host \ --with-gmp=$(TOPDIR)/staging_dir/host -define Host/Configure - (cd $(HOST_BUILD_DIR)/$(3); \ - $(HOST_CONFIGURE_CMD) \ - $(HOST_CONFIGURE_VARS) \ - $(HOST_CONFIGURE_ARGS); \ - ) -endef - - $(eval $(call HostBuild)) diff --git a/tools/mpfr/Makefile b/tools/mpfr/Makefile index 72712f219..e34830ad5 100644 --- a/tools/mpfr/Makefile +++ b/tools/mpfr/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2009 OpenWrt.org +# Copyright (C) 2009-2013 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,12 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mpfr -PKG_VERSION:=3.0.0 +PKG_VERSION:=3.1.1 PKG_SOURCE_URL:=http://www.mpfr.org/mpfr-$(PKG_VERSION) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 -PKG_MD5SUM:=f45bac3584922c8004a10060ab1a8f9f +PKG_MD5SUM:=e90e0075bb1b5f626c6e31aaa9c64e3b +HOST_BUILD_PARALLEL:=1 HOST_FIXUP:=autoreconf include $(INCLUDE_DIR)/host-build.mk @@ -22,9 +23,4 @@ HOST_CONFIGURE_ARGS += \ --disable-shared \ --with-gmp=$(STAGING_DIR_HOST) -define Host/Configure - echo "PATH=$(shell echo $$PATH)" - $(call Host/Configure/Default) -endef - $(eval $(call HostBuild)) diff --git a/tools/mpfr/patches/000-upstream_cumulative.patch b/tools/mpfr/patches/000-upstream_cumulative.patch deleted file mode 100644 index e21571b52..000000000 --- a/tools/mpfr/patches/000-upstream_cumulative.patch +++ /dev/null @@ -1,1945 +0,0 @@ -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES ---- mpfr-3.0.0-a/PATCHES 2010-06-23 11:02:49.000000000 +0000 -+++ mpfr-3.0.0-b/PATCHES 2010-06-23 11:03:36.000000000 +0000 -@@ -0,0 +1 @@ -+mpfr_out_str -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION ---- mpfr-3.0.0-a/VERSION 2010-06-10 11:00:14.000000000 +0000 -+++ mpfr-3.0.0-b/VERSION 2010-06-23 11:03:20.000000000 +0000 -@@ -1 +1 @@ --3.0.0 -+3.0.0-p1 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h ---- mpfr-3.0.0-a/mpfr.h 2010-06-10 11:00:14.000000000 +0000 -+++ mpfr-3.0.0-b/mpfr.h 2010-06-23 11:03:20.000000000 +0000 -@@ -27,7 +27,7 @@ - #define MPFR_VERSION_MAJOR 3 - #define MPFR_VERSION_MINOR 0 - #define MPFR_VERSION_PATCHLEVEL 0 --#define MPFR_VERSION_STRING "3.0.0" -+#define MPFR_VERSION_STRING "3.0.0-p1" - - /* Macros dealing with MPFR VERSION */ - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -diff -Naurd mpfr-3.0.0-a/mpfr.texi mpfr-3.0.0-b/mpfr.texi ---- mpfr-3.0.0-a/mpfr.texi 2010-06-10 11:00:14.000000000 +0000 -+++ mpfr-3.0.0-b/mpfr.texi 2010-06-23 11:03:12.000000000 +0000 -@@ -2050,7 +2050,7 @@ - are printed. If @var{base} is greater than 10, @samp{@@} will be used - instead of @samp{e} as exponent delimiter. - --Return the number of bytes written, or if an error occurred, return 0. -+Return the number of characters written, or if an error occurred, return 0. - @end deftypefun - - @deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mpfr_rnd_t @var{rnd}) -diff -Naurd mpfr-3.0.0-a/out_str.c mpfr-3.0.0-b/out_str.c ---- mpfr-3.0.0-a/out_str.c 2010-06-10 11:00:14.000000000 +0000 -+++ mpfr-3.0.0-b/out_str.c 2010-06-23 11:03:12.000000000 +0000 -@@ -22,6 +22,16 @@ - - #include "mpfr-impl.h" - -+/* Warning! S should not contain "%". */ -+#define OUT_STR_RET(S) \ -+ do \ -+ { \ -+ int r; \ -+ r = fprintf (stream, (S)); \ -+ return r < 0 ? 0 : r; \ -+ } \ -+ while (0) -+ - size_t - mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op, - mpfr_rnd_t rnd_mode) -@@ -29,6 +39,7 @@ - char *s, *s0; - size_t l; - mpfr_exp_t e; -+ int err; - - MPFR_ASSERTN (base >= 2 && base <= 62); - -@@ -36,37 +47,16 @@ - if (stream == NULL) - stream = stdout; - -- if (MPFR_IS_NAN(op)) -- { -- fprintf (stream, "@NaN@"); -- return 3; -- } -- -- if (MPFR_IS_INF(op)) -- { -- if (MPFR_SIGN(op) > 0) -- { -- fprintf (stream, "@Inf@"); -- return 3; -- } -- else -- { -- fprintf (stream, "-@Inf@"); -- return 4; -- } -- } -- -- if (MPFR_IS_ZERO(op)) -+ if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (op))) - { -- if (MPFR_SIGN(op) > 0) -- { -- fprintf(stream, "0"); -- return 1; -- } -+ if (MPFR_IS_NAN (op)) -+ OUT_STR_RET ("@NaN@"); -+ else if (MPFR_IS_INF (op)) -+ OUT_STR_RET (MPFR_IS_POS (op) ? "@Inf@" : "-@Inf@"); - else - { -- fprintf(stream, "-0"); -- return 2; -+ MPFR_ASSERTD (MPFR_IS_ZERO (op)); -+ OUT_STR_RET (MPFR_IS_POS (op) ? "0" : "-0"); - } - } - -@@ -77,21 +67,31 @@ - - l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str - - may be incorrect, as only an upper bound? */ -- if (*s == '-') -- fputc (*s++, stream); - -- /* outputs mantissa */ -- fputc (*s++, stream); e--; /* leading digit */ -- fputc ((unsigned char) MPFR_DECIMAL_POINT, stream); -- fputs (s, stream); /* rest of mantissa */ -+ /* outputs possible sign and significand */ -+ err = (*s == '-' && fputc (*s++, stream) == EOF) -+ || fputc (*s++, stream) == EOF /* leading digit */ -+ || fputc ((unsigned char) MPFR_DECIMAL_POINT, stream) == EOF -+ || fputs (s, stream) == EOF; /* trailing significand */ - (*__gmp_free_func) (s0, l); -+ if (MPFR_UNLIKELY (err)) -+ return 0; -+ -+ e--; /* due to the leading digit */ - - /* outputs exponent */ - if (e) - { -+ int r; -+ - MPFR_ASSERTN(e >= LONG_MIN); - MPFR_ASSERTN(e <= LONG_MAX); -- l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e); -+ -+ r = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e); -+ if (MPFR_UNLIKELY (r < 0)) -+ return 0; -+ -+ l += r; - } - - return l; -diff -Naurd mpfr-3.0.0-a/tests/tout_str.c mpfr-3.0.0-b/tests/tout_str.c ---- mpfr-3.0.0-a/tests/tout_str.c 2010-06-10 11:00:13.000000000 +0000 -+++ mpfr-3.0.0-b/tests/tout_str.c 2010-06-23 11:03:12.000000000 +0000 -@@ -46,22 +46,54 @@ - special (void) - { - mpfr_t x; -+ unsigned int n; - - mpfr_init (x); - - mpfr_set_nan (x); -- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); -+ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); -+ if (n != 5) -+ { -+ printf ("Error: mpfr_out_str (file, 10, 0, NaN, MPFR_RNDN) wrote %u " -+ "characters instead of 5.\n", n); -+ exit (1); -+ } - - mpfr_set_inf (x, 1); -- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); -+ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); -+ if (n != 5) -+ { -+ printf ("Error: mpfr_out_str (file, 10, 0, +Inf, MPFR_RNDN) wrote %u " -+ "characters instead of 5.\n", n); -+ exit (1); -+ } - - mpfr_set_inf (x, -1); -- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); -+ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); -+ if (n != 6) -+ { -+ printf ("Error: mpfr_out_str (file, 10, 0, -Inf, MPFR_RNDN) wrote %u " -+ "characters instead of 6.\n", n); -+ exit (1); -+ } - - mpfr_set_ui (x, 0, MPFR_RNDN); -- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); -+ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); -+ if (n != 1) -+ { -+ printf ("Error: mpfr_out_str (file, 10, 0, +0, MPFR_RNDN) wrote %u " -+ "characters instead of 1.\n", n); -+ exit (1); -+ } -+ - mpfr_neg (x, x, MPFR_RNDN); -- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); -+ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN); -+ if (n != 2) -+ { -+ printf ("Error: mpfr_out_str (file, 10, 0, -0, MPFR_RNDN) wrote %u " -+ "characters instead of 2.\n", n); -+ exit (1); -+ } - - mpfr_clear (x); - } -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c ---- mpfr-3.0.0-a/version.c 2010-06-10 11:00:14.000000000 +0000 -+++ mpfr-3.0.0-b/version.c 2010-06-23 11:03:20.000000000 +0000 -@@ -25,5 +25,5 @@ - const char * - mpfr_get_version (void) - { -- return "3.0.0"; -+ return "3.0.0-p1"; - } -diff -Naurd mpfr-3.0.0-a/Makefile.in mpfr-3.0.0-b/Makefile.in ---- mpfr-3.0.0-a/Makefile.in 2010-06-10 11:00:52.000000000 +0000 -+++ mpfr-3.0.0-b/Makefile.in 2010-06-10 11:00:52.000000000 +0000 -@@ -239,6 +239,7 @@ - distuninstallcheck_listfiles = find . -type f -print - distcleancheck_listfiles = find . -type f -print - ACLOCAL = @ACLOCAL@ -+ALLOCA = @ALLOCA@ - AMTAR = @AMTAR@ - AR = @AR@ - AS = @AS@ -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES ---- mpfr-3.0.0-a/PATCHES 2010-06-23 11:03:36.000000000 +0000 -+++ mpfr-3.0.0-b/PATCHES 2010-06-25 13:23:13.000000000 +0000 -@@ -0,0 +1 @@ -+alloca -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION ---- mpfr-3.0.0-a/VERSION 2010-06-23 11:03:20.000000000 +0000 -+++ mpfr-3.0.0-b/VERSION 2010-06-25 13:23:13.000000000 +0000 -@@ -1 +1 @@ --3.0.0-p1 -+3.0.0-p2 -diff -Naurd mpfr-3.0.0-a/acinclude.m4 mpfr-3.0.0-b/acinclude.m4 ---- mpfr-3.0.0-a/acinclude.m4 2010-06-10 11:00:14.000000000 +0000 -+++ mpfr-3.0.0-b/acinclude.m4 2010-06-10 11:00:14.000000000 +0000 -@@ -59,6 +59,9 @@ - dnl sys/fpu.h - MIPS specific - AC_CHECK_HEADERS([sys/time.h sys/fpu.h]) - -+dnl Check how to get `alloca' -+AC_FUNC_ALLOCA -+ - dnl SIZE_MAX macro - gl_SIZE_MAX - -diff -Naurd mpfr-3.0.0-a/configure mpfr-3.0.0-b/configure ---- mpfr-3.0.0-a/configure 2010-06-10 11:00:51.000000000 +0000 -+++ mpfr-3.0.0-b/configure 2010-06-25 13:23:05.000000000 +0000 -@@ -783,6 +783,7 @@ - OBJDUMP - DLLTOOL - AS -+ALLOCA - MPFR_LIBM - ANSI2KNR - U -@@ -5622,6 +5623,197 @@ - done - - -+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -+# for constant arguments. Useless! -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 -+$as_echo_n "checking for working alloca.h... " >&6; } -+if test "${ac_cv_working_alloca_h+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#include <alloca.h> -+int -+main () -+{ -+char *p = (char *) alloca (2 * sizeof (int)); -+ if (p) return 0; -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_working_alloca_h=yes -+else -+ ac_cv_working_alloca_h=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 -+$as_echo "$ac_cv_working_alloca_h" >&6; } -+if test $ac_cv_working_alloca_h = yes; then -+ -+$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h -+ -+fi -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 -+$as_echo_n "checking for alloca... " >&6; } -+if test "${ac_cv_func_alloca_works+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#ifdef __GNUC__ -+# define alloca __builtin_alloca -+#else -+# ifdef _MSC_VER -+# include <malloc.h> -+# define alloca _alloca -+# else -+# ifdef HAVE_ALLOCA_H -+# include <alloca.h> -+# else -+# ifdef _AIX -+ #pragma alloca -+# else -+# ifndef alloca /* predefined by HP cc +Olibcalls */ -+char *alloca (); -+# endif -+# endif -+# endif -+# endif -+#endif -+ -+int -+main () -+{ -+char *p = (char *) alloca (1); -+ if (p) return 0; -+ ; -+ return 0; -+} -+_ACEOF -+if ac_fn_c_try_link "$LINENO"; then : -+ ac_cv_func_alloca_works=yes -+else -+ ac_cv_func_alloca_works=no -+fi -+rm -f core conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 -+$as_echo "$ac_cv_func_alloca_works" >&6; } -+ -+if test $ac_cv_func_alloca_works = yes; then -+ -+$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h -+ -+else -+ # The SVR3 libPW and SVR4 libucb both contain incompatible functions -+# that cause trouble. Some versions do not even contain alloca or -+# contain a buggy version. If you still want to use their alloca, -+# use ar to extract alloca.o from them instead of compiling alloca.c. -+ -+ALLOCA=\${LIBOBJDIR}alloca.$ac_objext -+ -+$as_echo "#define C_ALLOCA 1" >>confdefs.h -+ -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 -+$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } -+if test "${ac_cv_os_cray+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+#if defined CRAY && ! defined CRAY2 -+webecray -+#else -+wenotbecray -+#endif -+ -+_ACEOF -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | -+ $EGREP "webecray" >/dev/null 2>&1; then : -+ ac_cv_os_cray=yes -+else -+ ac_cv_os_cray=no -+fi -+rm -f conftest* -+ -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 -+$as_echo "$ac_cv_os_cray" >&6; } -+if test $ac_cv_os_cray = yes; then -+ for ac_func in _getb67 GETB67 getb67; do -+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -+eval as_val=\$$as_ac_var -+ if test "x$as_val" = x""yes; then : -+ -+cat >>confdefs.h <<_ACEOF -+#define CRAY_STACKSEG_END $ac_func -+_ACEOF -+ -+ break -+fi -+ -+ done -+fi -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 -+$as_echo_n "checking stack direction for C alloca... " >&6; } -+if test "${ac_cv_c_stack_direction+set}" = set; then : -+ $as_echo_n "(cached) " >&6 -+else -+ if test "$cross_compiling" = yes; then : -+ ac_cv_c_stack_direction=0 -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+$ac_includes_default -+int -+find_stack_direction () -+{ -+ static char *addr = 0; -+ auto char dummy; -+ if (addr == 0) -+ { -+ addr = &dummy; -+ return find_stack_direction (); -+ } -+ else -+ return (&dummy > addr) ? 1 : -1; -+} -+ -+int -+main () -+{ -+ return find_stack_direction () < 0; -+} -+_ACEOF -+if ac_fn_c_try_run "$LINENO"; then : -+ ac_cv_c_stack_direction=1 -+else -+ ac_cv_c_stack_direction=-1 -+fi -+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ -+ conftest.$ac_objext conftest.beam conftest.$ac_ext -+fi -+ -+fi -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 -+$as_echo "$ac_cv_c_stack_direction" >&6; } -+cat >>confdefs.h <<_ACEOF -+#define STACK_DIRECTION $ac_cv_c_stack_direction -+_ACEOF -+ -+ -+fi -+ -+ - - for ac_header in stdint.h - do : -@@ -7564,13 +7756,13 @@ - else - lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext -- (eval echo "\"\$as_me:7567: $ac_compile\"" >&5) -+ (eval echo "\"\$as_me:7759: $ac_compile\"" >&5) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&5 -- (eval echo "\"\$as_me:7570: $NM \\\"conftest.$ac_objext\\\"\"" >&5) -+ (eval echo "\"\$as_me:7762: $NM \\\"conftest.$ac_objext\\\"\"" >&5) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&5 -- (eval echo "\"\$as_me:7573: output\"" >&5) -+ (eval echo "\"\$as_me:7765: output\"" >&5) - cat conftest.out >&5 - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" -@@ -8772,7 +8964,7 @@ - ;; - *-*-irix6*) - # Find out which ABI we are using. -- echo '#line 8775 "configure"' > conftest.$ac_ext -+ echo '#line 8967 "configure"' > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 - (eval $ac_compile) 2>&5 - ac_status=$? -@@ -10032,11 +10224,11 @@ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` -- (eval echo "\"\$as_me:10035: $lt_compile\"" >&5) -+ (eval echo "\"\$as_me:10227: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 -- echo "$as_me:10039: \$? = $ac_status" >&5 -+ echo "$as_me:10231: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. -@@ -10371,11 +10563,11 @@ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` -- (eval echo "\"\$as_me:10374: $lt_compile\"" >&5) -+ (eval echo "\"\$as_me:10566: $lt_compile\"" >&5) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&5 -- echo "$as_me:10378: \$? = $ac_status" >&5 -+ echo "$as_me:10570: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. -@@ -10476,11 +10668,11 @@ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` -- (eval echo "\"\$as_me:10479: $lt_compile\"" >&5) -+ (eval echo "\"\$as_me:10671: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 -- echo "$as_me:10483: \$? = $ac_status" >&5 -+ echo "$as_me:10675: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized -@@ -10531,11 +10723,11 @@ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` -- (eval echo "\"\$as_me:10534: $lt_compile\"" >&5) -+ (eval echo "\"\$as_me:10726: $lt_compile\"" >&5) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&5 -- echo "$as_me:10538: \$? = $ac_status" >&5 -+ echo "$as_me:10730: \$? = $ac_status" >&5 - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized -@@ -12915,7 +13107,7 @@ - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF --#line 12918 "configure" -+#line 13110 "configure" - #include "confdefs.h" - - #if HAVE_DLFCN_H -@@ -13011,7 +13203,7 @@ - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF --#line 13014 "configure" -+#line 13206 "configure" - #include "confdefs.h" - - #if HAVE_DLFCN_H -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h ---- mpfr-3.0.0-a/mpfr.h 2010-06-23 11:03:20.000000000 +0000 -+++ mpfr-3.0.0-b/mpfr.h 2010-06-25 13:23:13.000000000 +0000 -@@ -27,7 +27,7 @@ - #define MPFR_VERSION_MAJOR 3 - #define MPFR_VERSION_MINOR 0 - #define MPFR_VERSION_PATCHLEVEL 0 --#define MPFR_VERSION_STRING "3.0.0-p1" -+#define MPFR_VERSION_STRING "3.0.0-p2" - - /* Macros dealing with MPFR VERSION */ - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -diff -Naurd mpfr-3.0.0-a/tests/Makefile.in mpfr-3.0.0-b/tests/Makefile.in ---- mpfr-3.0.0-a/tests/Makefile.in 2010-06-10 11:00:52.000000000 +0000 -+++ mpfr-3.0.0-b/tests/Makefile.in 2010-06-10 11:00:52.000000000 +0000 -@@ -960,6 +960,7 @@ - red=; grn=; lgn=; blu=; std= - DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) - ACLOCAL = @ACLOCAL@ -+ALLOCA = @ALLOCA@ - AMTAR = @AMTAR@ - AR = @AR@ - AS = @AS@ -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c ---- mpfr-3.0.0-a/version.c 2010-06-23 11:03:20.000000000 +0000 -+++ mpfr-3.0.0-b/version.c 2010-06-25 13:23:13.000000000 +0000 -@@ -25,5 +25,5 @@ - const char * - mpfr_get_version (void) - { -- return "3.0.0-p1"; -+ return "3.0.0-p2"; - } -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES ---- mpfr-3.0.0-a/PATCHES 2010-07-10 00:11:19.000000000 +0000 -+++ mpfr-3.0.0-b/PATCHES 2010-07-10 00:12:50.000000000 +0000 -@@ -0,0 +1 @@ -+gamma_underflow -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION ---- mpfr-3.0.0-a/VERSION 2010-06-25 13:23:13.000000000 +0000 -+++ mpfr-3.0.0-b/VERSION 2010-07-10 00:11:53.000000000 +0000 -@@ -1 +1 @@ --3.0.0-p2 -+3.0.0-p3 -diff -Naurd mpfr-3.0.0-a/gamma.c mpfr-3.0.0-b/gamma.c ---- mpfr-3.0.0-a/gamma.c 2010-06-10 11:00:14.000000000 +0000 -+++ mpfr-3.0.0-b/gamma.c 2010-07-10 00:11:46.000000000 +0000 -@@ -274,7 +274,7 @@ - /* we want an upper bound for x * [log(2-x)-1]. - since x < 0, we need a lower bound on log(2-x) */ - mpfr_ui_sub (xp, 2, x, MPFR_RNDD); -- mpfr_log (xp, xp, MPFR_RNDD); -+ mpfr_log2 (xp, xp, MPFR_RNDD); - mpfr_sub_ui (xp, xp, 1, MPFR_RNDD); - mpfr_mul (xp, xp, x, MPFR_RNDU); - -@@ -303,8 +303,8 @@ - { - mpfr_sub (tmp, tmp, tmp2, MPFR_RNDZ); /* low bnd on |sin(Pi*(2-x))| */ - mpfr_ui_div (tmp, 12, tmp, MPFR_RNDU); /* upper bound */ -- mpfr_log (tmp, tmp, MPFR_RNDU); -- mpfr_add (tmp, tmp, xp, MPFR_RNDU); -+ mpfr_log2 (tmp, tmp, MPFR_RNDU); -+ mpfr_add (xp, tmp, xp, MPFR_RNDU); - underflow = mpfr_cmp_si (xp, expo.saved_emin - 2) <= 0; - } - -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h ---- mpfr-3.0.0-a/mpfr.h 2010-06-25 13:23:13.000000000 +0000 -+++ mpfr-3.0.0-b/mpfr.h 2010-07-10 00:11:53.000000000 +0000 -@@ -27,7 +27,7 @@ - #define MPFR_VERSION_MAJOR 3 - #define MPFR_VERSION_MINOR 0 - #define MPFR_VERSION_PATCHLEVEL 0 --#define MPFR_VERSION_STRING "3.0.0-p2" -+#define MPFR_VERSION_STRING "3.0.0-p3" - - /* Macros dealing with MPFR VERSION */ - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -diff -Naurd mpfr-3.0.0-a/tests/tgamma.c mpfr-3.0.0-b/tests/tgamma.c ---- mpfr-3.0.0-a/tests/tgamma.c 2010-06-10 11:00:13.000000000 +0000 -+++ mpfr-3.0.0-b/tests/tgamma.c 2010-07-10 00:11:46.000000000 +0000 -@@ -461,6 +461,20 @@ - mpfr_clear (x); - } - -+/* bug found by Stathis, only occurs on 32-bit machines */ -+static void -+test20100709 (void) -+{ -+ mpfr_t x; -+ int inex; -+ -+ mpfr_init2 (x, 100); -+ mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN); -+ inex = mpfr_gamma (x, x, MPFR_RNDN); -+ MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0); -+ mpfr_clear (x); -+} -+ - int - main (int argc, char *argv[]) - { -@@ -471,6 +485,7 @@ - test_generic (2, 100, 2); - gamma_integer (); - test20071231 (); -+ test20100709 (); - - data_check ("data/gamma", mpfr_gamma, "mpfr_gamma"); - -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c ---- mpfr-3.0.0-a/version.c 2010-06-25 13:23:13.000000000 +0000 -+++ mpfr-3.0.0-b/version.c 2010-07-10 00:11:53.000000000 +0000 -@@ -25,5 +25,5 @@ - const char * - mpfr_get_version (void) - { -- return "3.0.0-p2"; -+ return "3.0.0-p3"; - } -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES ---- mpfr-3.0.0-a/PATCHES 2010-09-07 08:44:01.000000000 +0000 -+++ mpfr-3.0.0-b/PATCHES 2010-09-07 08:48:46.000000000 +0000 -@@ -0,0 +1 @@ -+mpfr_cmp/set_ui/si -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION ---- mpfr-3.0.0-a/VERSION 2010-07-10 00:11:53.000000000 +0000 -+++ mpfr-3.0.0-b/VERSION 2010-09-07 08:46:06.000000000 +0000 -@@ -1 +1 @@ --3.0.0-p3 -+3.0.0-p4 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h ---- mpfr-3.0.0-a/mpfr.h 2010-07-10 00:11:53.000000000 +0000 -+++ mpfr-3.0.0-b/mpfr.h 2010-09-07 08:46:06.000000000 +0000 -@@ -27,7 +27,7 @@ - #define MPFR_VERSION_MAJOR 3 - #define MPFR_VERSION_MINOR 0 - #define MPFR_VERSION_PATCHLEVEL 0 --#define MPFR_VERSION_STRING "3.0.0-p3" -+#define MPFR_VERSION_STRING "3.0.0-p4" - - /* Macros dealing with MPFR VERSION */ - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -@@ -798,35 +798,45 @@ - anyway. Checking with other ICC versions is needed. Possibly detect - whether warnings are produced or not with a configure test. - + Remove C++ too, since it complains too much. */ -+/* Added casts to improve robustness in case of undefined behavior and -+ compiler extensions based on UB (in particular -fwrapv). MPFR doesn't -+ use such extensions, but these macros will be used by 3rd-party code, -+ where such extensions may be required. -+ Moreover casts to unsigned long have been added to avoid warnings in -+ programs that use MPFR and are compiled with -Wconversion; such casts -+ are OK since if X is a constant expression, then (unsigned long) X is -+ also a constant expression, so that the optimizations still work. */ - #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus) - #if (__GNUC__ >= 2) - #undef mpfr_cmp_ui --/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */ --#define mpfr_cmp_ui(_f,_u) \ -- (__builtin_constant_p (_u) && (_u) == 0 ? \ -- mpfr_sgn (_f) : \ -- mpfr_cmp_ui_2exp ((_f),(_u),0)) -+/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. -+ But warning! mpfr_sgn is specified as a macro in the API, thus the macro -+ mustn't be used if side effects are possible, like here. */ -+#define mpfr_cmp_ui(_f,_u) \ -+ (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \ -+ (mpfr_sgn) (_f) : \ -+ mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0)) - #undef mpfr_cmp_si --#define mpfr_cmp_si(_f,_s) \ -- (__builtin_constant_p (_s) && (_s) >= 0 ? \ -- mpfr_cmp_ui ((_f), (_s)) : \ -- mpfr_cmp_si_2exp ((_f), (_s), 0)) -+#define mpfr_cmp_si(_f,_s) \ -+ (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \ -+ mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) : \ -+ mpfr_cmp_si_2exp ((_f), (long) (_s), 0)) - #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95 - #undef mpfr_set_ui --#define mpfr_set_ui(_f,_u,_r) \ -- (__builtin_constant_p (_u) && (_u) == 0 ? \ -- __extension__ ({ \ -- mpfr_ptr _p = (_f); \ -- _p->_mpfr_sign = 1; \ -- _p->_mpfr_exp = __MPFR_EXP_ZERO; \ -- (void) (_r); 0; }) : \ -- mpfr_set_ui_2exp ((_f), (_u), 0, (_r))) -+#define mpfr_set_ui(_f,_u,_r) \ -+ (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \ -+ __extension__ ({ \ -+ mpfr_ptr _p = (_f); \ -+ _p->_mpfr_sign = 1; \ -+ _p->_mpfr_exp = __MPFR_EXP_ZERO; \ -+ (void) (_r); 0; }) : \ -+ mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r))) - #endif - #undef mpfr_set_si --#define mpfr_set_si(_f,_s,_r) \ -- (__builtin_constant_p (_s) && (_s) >= 0 ? \ -- mpfr_set_ui ((_f), (_s), (_r)) : \ -- mpfr_set_si_2exp ((_f), (_s), 0, (_r))) -+#define mpfr_set_si(_f,_s,_r) \ -+ (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \ -+ mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) : \ -+ mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r))) - #endif - #endif - -diff -Naurd mpfr-3.0.0-a/tests/tcmp_ui.c mpfr-3.0.0-b/tests/tcmp_ui.c ---- mpfr-3.0.0-a/tests/tcmp_ui.c 2010-06-10 11:00:13.000000000 +0000 -+++ mpfr-3.0.0-b/tests/tcmp_ui.c 2010-09-07 08:45:12.000000000 +0000 -@@ -88,6 +88,126 @@ - mpfr_clear (x); - } - -+/* Since mpfr_cmp_ui and mpfr_cmp_si are also implemented by a macro -+ with __builtin_constant_p for GCC, check that side effects are -+ handled correctly. */ -+static void -+check_macros (void) -+{ -+ mpfr_t x; -+ int c; -+ -+ mpfr_init2 (x, 32); -+ -+ c = 0; -+ mpfr_set_ui (x, 17, MPFR_RNDN); -+ if (mpfr_cmp_ui (x, 17) != 0) -+ { -+ printf ("Error 1 on mpfr_cmp_ui(x,17) in check_macros\n"); -+ exit (1); -+ } -+ if (mpfr_cmp_ui (x, (c++, 17)) != 0) -+ { -+ printf ("Error 2 on mpfr_cmp_ui(x,17) in check_macros\n"); -+ exit (1); -+ } -+ if (c != 1) -+ { -+ printf ("Error 3 on mpfr_cmp_ui(x,17) in check_macros\n" -+ "(c = %d instead of 1)\n", c); -+ exit (1); -+ } -+ if (mpfr_cmp_si (x, 17) != 0) -+ { -+ printf ("Error 1 on mpfr_cmp_si(x,17) in check_macros\n"); -+ exit (1); -+ } -+ if (mpfr_cmp_si (x, (c++, 17)) != 0) -+ { -+ printf ("Error 2 on mpfr_cmp_si(x,17) in check_macros\n"); -+ exit (1); -+ } -+ if (c != 2) -+ { -+ printf ("Error 3 on mpfr_cmp_si(x,17) in check_macros\n" -+ "(c = %d instead of 2)\n", c); -+ exit (1); -+ } -+ -+ c = 0; -+ mpfr_set_ui (x, 0, MPFR_RNDN); -+ if (mpfr_cmp_ui (x, 0) != 0) -+ { -+ printf ("Error 1 on mpfr_cmp_ui(x,0) in check_macros\n"); -+ exit (1); -+ } -+ if (mpfr_cmp_ui (x, (c++, 0)) != 0) -+ { -+ printf ("Error 2 on mpfr_cmp_ui(x,0) in check_macros\n"); -+ exit (1); -+ } -+ if (c != 1) -+ { -+ printf ("Error 3 on mpfr_cmp_ui(x,0) in check_macros\n" -+ "(c = %d instead of 1)\n", c); -+ exit (1); -+ } -+ if (mpfr_cmp_si (x, 0) != 0) -+ { -+ printf ("Error 1 on mpfr_cmp_si(x,0) in check_macros\n"); -+ exit (1); -+ } -+ if (mpfr_cmp_si (x, (c++, 0)) != 0) -+ { -+ printf ("Error 2 on mpfr_cmp_si(x,0) in check_macros\n"); -+ exit (1); -+ } -+ if (c != 2) -+ { -+ printf ("Error 3 on mpfr_cmp_si(x,0) in check_macros\n" -+ "(c = %d instead of 2)\n", c); -+ exit (1); -+ } -+ -+ mpfr_clear (x); -+} -+ -+/* Bug in r7114 */ -+static void -+test_macros (void) -+{ -+ mpfr_t x[3]; -+ mpfr_ptr p; -+ -+ mpfr_inits (x[0], x[1], x[2], (mpfr_ptr) 0); -+ mpfr_set_ui (x[0], 0, MPFR_RNDN); -+ p = x[0]; -+ if (mpfr_cmp_ui (p++, 0) != 0) -+ { -+ printf ("Error in mpfr_cmp_ui macro: result should be 0.\n"); -+ exit (1); -+ } -+ if (p != x[1]) -+ { -+ printf ("Error in mpfr_cmp_ui macro: p - x[0] = %d (expecting 1)\n", -+ (int) (p - x[0])); -+ exit (1); -+ } -+ p = x[0]; -+ if (mpfr_cmp_si (p++, 0) != 0) -+ { -+ printf ("Error in mpfr_cmp_si macro: result should be 0.\n"); -+ exit (1); -+ } -+ if (p != x[1]) -+ { -+ printf ("Error in mpfr_cmp_si macro: p - x[0] = %d (expecting 1)\n", -+ (int) (p - x[0])); -+ exit (1); -+ } -+ mpfr_clears (x[0], x[1], x[2], (mpfr_ptr) 0); -+} -+ - int - main (void) - { -@@ -216,6 +336,8 @@ - mpfr_clear (x); - - check_nan (); -+ check_macros (); -+ test_macros (); - - tests_end_mpfr (); - return 0; -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c ---- mpfr-3.0.0-a/version.c 2010-07-10 00:11:53.000000000 +0000 -+++ mpfr-3.0.0-b/version.c 2010-09-07 08:46:06.000000000 +0000 -@@ -25,5 +25,5 @@ - const char * - mpfr_get_version (void) - { -- return "3.0.0-p3"; -+ return "3.0.0-p4"; - } -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES ---- mpfr-3.0.0-a/PATCHES 2010-10-21 20:28:38.000000000 +0000 -+++ mpfr-3.0.0-b/PATCHES 2010-10-21 20:28:38.000000000 +0000 -@@ -0,0 +1 @@ -+tcan_round -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION ---- mpfr-3.0.0-a/VERSION 2010-09-07 08:46:06.000000000 +0000 -+++ mpfr-3.0.0-b/VERSION 2010-10-21 20:28:38.000000000 +0000 -@@ -1 +1 @@ --3.0.0-p4 -+3.0.0-p5 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h ---- mpfr-3.0.0-a/mpfr.h 2010-09-07 08:46:06.000000000 +0000 -+++ mpfr-3.0.0-b/mpfr.h 2010-10-21 20:28:38.000000000 +0000 -@@ -27,7 +27,7 @@ - #define MPFR_VERSION_MAJOR 3 - #define MPFR_VERSION_MINOR 0 - #define MPFR_VERSION_PATCHLEVEL 0 --#define MPFR_VERSION_STRING "3.0.0-p4" -+#define MPFR_VERSION_STRING "3.0.0-p5" - - /* Macros dealing with MPFR VERSION */ - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -diff -Naurd mpfr-3.0.0-a/tests/tcan_round.c mpfr-3.0.0-b/tests/tcan_round.c ---- mpfr-3.0.0-a/tests/tcan_round.c 2010-06-10 11:00:13.000000000 +0000 -+++ mpfr-3.0.0-b/tests/tcan_round.c 2010-10-21 20:28:38.000000000 +0000 -@@ -41,7 +41,7 @@ - /* avoid mpn_random which leaks memory */ - for (i = 0; i < n; i++) - buf[i] = randlimb (); -- p = (mpfr_prec_t) randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN; -+ p = randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN; - err = p + randlimb () % GMP_NUMB_BITS; - r1 = mpfr_round_p (buf, n, err, p); - r2 = mpfr_can_round_raw (buf, n, MPFR_SIGN_POS, err, -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c ---- mpfr-3.0.0-a/version.c 2010-09-07 08:46:06.000000000 +0000 -+++ mpfr-3.0.0-b/version.c 2010-10-21 20:28:38.000000000 +0000 -@@ -25,5 +25,5 @@ - const char * - mpfr_get_version (void) - { -- return "3.0.0-p4"; -+ return "3.0.0-p5"; - } -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES ---- mpfr-3.0.0-a/PATCHES 2010-10-21 20:59:32.000000000 +0000 -+++ mpfr-3.0.0-b/PATCHES 2010-10-21 20:59:32.000000000 +0000 -@@ -0,0 +1 @@ -+mpfr_sub1 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION ---- mpfr-3.0.0-a/VERSION 2010-10-21 20:28:38.000000000 +0000 -+++ mpfr-3.0.0-b/VERSION 2010-10-21 20:59:32.000000000 +0000 -@@ -1 +1 @@ --3.0.0-p5 -+3.0.0-p6 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h ---- mpfr-3.0.0-a/mpfr.h 2010-10-21 20:28:38.000000000 +0000 -+++ mpfr-3.0.0-b/mpfr.h 2010-10-21 20:59:32.000000000 +0000 -@@ -27,7 +27,7 @@ - #define MPFR_VERSION_MAJOR 3 - #define MPFR_VERSION_MINOR 0 - #define MPFR_VERSION_PATCHLEVEL 0 --#define MPFR_VERSION_STRING "3.0.0-p5" -+#define MPFR_VERSION_STRING "3.0.0-p6" - - /* Macros dealing with MPFR VERSION */ - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -diff -Naurd mpfr-3.0.0-a/sub1.c mpfr-3.0.0-b/sub1.c ---- mpfr-3.0.0-a/sub1.c 2010-06-10 11:00:14.000000000 +0000 -+++ mpfr-3.0.0-b/sub1.c 2010-10-21 20:59:32.000000000 +0000 -@@ -37,7 +37,9 @@ - mp_size_t cancel2, an, bn, cn, cn0; - mp_limb_t *ap, *bp, *cp; - mp_limb_t carry, bb, cc, borrow = 0; -- int inexact, shift_b, shift_c, is_exact = 1, down = 0, add_exp = 0; -+ int inexact, shift_b, shift_c, add_exp = 0; -+ int cmp_low = 0; /* used for rounding to nearest: 0 if low(b) = low(c), -+ negative if low(b) < low(c), positive if low(b)>low(c) */ - int sh, k; - MPFR_TMP_DECL(marker); - -@@ -196,7 +198,8 @@ - } - - #ifdef DEBUG -- printf ("shift_b=%d shift_c=%d diffexp=%lu\n", shift_b, shift_c, -+ printf ("rnd=%s shift_b=%d shift_c=%d diffexp=%lu\n", -+ mpfr_print_rnd_mode (rnd_mode), shift_b, shift_c, - (unsigned long) diff_exp); - #endif - -@@ -307,17 +310,18 @@ - { - if (MPFR_LIKELY(sh)) - { -- is_exact = (carry == 0); - /* can decide except when carry = 2^(sh-1) [middle] - or carry = 0 [truncate, but cannot decide inexact flag] */ -- down = (carry < (MPFR_LIMB_ONE << (sh - 1))); - if (carry > (MPFR_LIMB_ONE << (sh - 1))) - goto add_one_ulp; -- else if ((0 < carry) && down) -+ else if ((0 < carry) && (carry < (MPFR_LIMB_ONE << (sh - 1)))) - { - inexact = -1; /* result if smaller than exact value */ - goto truncate; - } -+ /* now carry = 2^(sh-1), in which case cmp_low=2, -+ or carry = 0, in which case cmp_low=0 */ -+ cmp_low = (carry == 0) ? 0 : 2; - } - } - else /* directed rounding: set rnd_mode to RNDZ iff toward zero */ -@@ -344,12 +348,32 @@ - cn -= (long int) an + cancel2; - - #ifdef DEBUG -- printf ("last %d bits from a are %lu, bn=%ld, cn=%ld\n", -+ printf ("last sh=%d bits from a are %lu, bn=%ld, cn=%ld\n", - sh, (unsigned long) carry, (long) bn, (long) cn); - #endif - -+ /* for rounding to nearest, we couldn't conclude up to here in the following -+ cases: -+ 1. sh = 0, then cmp_low=0: we can either truncate, subtract one ulp -+ or add one ulp: -1 ulp < low(b)-low(c) < 1 ulp -+ 2. sh > 0 but the low sh bits from high(b)-high(c) equal 2^(sh-1): -+ -0.5 ulp <= -1/2^sh < low(b)-low(c)-0.5 < 1/2^sh <= 0.5 ulp -+ we can't decide the rounding, in that case cmp_low=2: -+ either we truncate and flag=-1, or we add one ulp and flag=1 -+ 3. the low sh>0 bits from high(b)-high(c) equal 0: we know we have to -+ truncate but we can't decide the ternary value, here cmp_low=0: -+ -0.5 ulp <= -1/2^sh < low(b)-low(c) < 1/2^sh <= 0.5 ulp -+ we always truncate and inexact can be any of -1,0,1 -+ */ -+ -+ /* note: here cn might exceed cn0, in which case we consider a zero limb */ - for (k = 0; (bn > 0) || (cn > 0); k = 1) - { -+ /* if cmp_low < 0, we know low(b) - low(c) < 0 -+ if cmp_low > 0, we know low(b) - low(c) > 0 -+ (more precisely if cmp_low = 2, low(b) - low(c) = 0.5 ulp so far) -+ if cmp_low = 0, so far low(b) - low(c) = 0 */ -+ - /* get next limbs */ - bb = (bn > 0) ? bp[--bn] : 0; - if ((cn > 0) && (cn-- <= cn0)) -@@ -357,76 +381,115 @@ - else - cc = 0; - -- /* down is set when low(b) < low(c) */ -- if (down == 0) -- down = (bb < cc); -+ /* cmp_low compares low(b) and low(c) */ -+ if (cmp_low == 0) /* case 1 or 3 */ -+ cmp_low = (bb < cc) ? -2+k : (bb > cc) ? 1 : 0; -+ -+ /* Case 1 for k=0 splits into 7 subcases: -+ 1a: bb > cc + half -+ 1b: bb = cc + half -+ 1c: 0 < bb - cc < half -+ 1d: bb = cc -+ 1e: -half < bb - cc < 0 -+ 1f: bb - cc = -half -+ 1g: bb - cc < -half -+ -+ Case 2 splits into 3 subcases: -+ 2a: bb > cc -+ 2b: bb = cc -+ 2c: bb < cc -+ -+ Case 3 splits into 3 subcases: -+ 3a: bb > cc -+ 3b: bb = cc -+ 3c: bb < cc -+ */ - - /* the case rounding to nearest with sh=0 is special since one couldn't - subtract above 1/2 ulp in the trailing limb of the result */ -- if ((rnd_mode == MPFR_RNDN) && sh == 0 && k == 0) -+ if (rnd_mode == MPFR_RNDN && sh == 0 && k == 0) /* case 1 for k=0 */ - { - mp_limb_t half = MPFR_LIMB_HIGHBIT; - -- is_exact = (bb == cc); -- - /* add one ulp if bb > cc + half - truncate if cc - half < bb < cc + half - sub one ulp if bb < cc - half - */ - -- if (down) -+ if (cmp_low < 0) /* bb < cc: -1 ulp < low(b) - low(c) < 0, -+ cases 1e, 1f and 1g */ - { - if (cc >= half) - cc -= half; -- else -+ else /* since bb < cc < half, bb+half < 2*half */ - bb += half; -+ /* now we have bb < cc + half: -+ we have to subtract one ulp if bb < cc, -+ and truncate if bb > cc */ - } -- else /* bb >= cc */ -+ else if (cmp_low >= 0) /* bb >= cc, cases 1a to 1d */ - { - if (cc < half) - cc += half; -- else -+ else /* since bb >= cc >= half, bb - half >= 0 */ - bb -= half; -+ /* now we have bb > cc - half: we have to add one ulp if bb > cc, -+ and truncate if bb < cc */ -+ if (cmp_low > 0) -+ cmp_low = 2; - } - } - - #ifdef DEBUG -- printf (" bb=%lu cc=%lu down=%d is_exact=%d\n", -- (unsigned long) bb, (unsigned long) cc, down, is_exact); -+ printf ("k=%u bb=%lu cc=%lu cmp_low=%d\n", k, -+ (unsigned long) bb, (unsigned long) cc, cmp_low); - #endif -- if (bb < cc) -+ if (cmp_low < 0) /* low(b) - low(c) < 0: either truncate or subtract -+ one ulp */ - { - if (rnd_mode == MPFR_RNDZ) -- goto sub_one_ulp; -+ goto sub_one_ulp; /* set inexact=-1 */ - else if (rnd_mode != MPFR_RNDN) /* round away */ - { - inexact = 1; - goto truncate; - } -- else /* round to nearest: special case here since for sh=k=0 -- bb = bb0 - MPFR_LIMB_HIGHBIT */ -+ else /* round to nearest */ - { -- if (is_exact && sh == 0) -- { -- /* For k=0 we can't decide exactness since it may depend -- from low order bits. -- For k=1, the first low limbs matched: low(b)-low(c)<0. */ -- if (k) -- { -- inexact = 1; -- goto truncate; -- } -- } -- else if (down && sh == 0) -- goto sub_one_ulp; -- else -- { -- inexact = (is_exact) ? 1 : -1; -+ /* If cmp_low < 0 and bb > cc, then -0.5 ulp < low(b)-low(c) < 0, -+ whatever the value of sh. -+ If sh>0, then cmp_low < 0 implies that the initial neglected -+ sh bits were 0 (otherwise cmp_low=2 initially), thus the -+ weight of the new bits is less than 0.5 ulp too. -+ If k > 0 (and sh=0) this means that either the first neglected -+ limbs bb and cc were equal (thus cmp_low was 0 for k=0), -+ or we had bb - cc = -0.5 ulp or 0.5 ulp. -+ The last case is not possible here since we would have -+ cmp_low > 0 which is sticky. -+ In the first case (where we have cmp_low = -1), we truncate, -+ whereas in the 2nd case we have cmp_low = -2 and we subtract -+ one ulp. -+ */ -+ if (bb > cc || sh > 0 || cmp_low == -1) -+ { /* -0.5 ulp < low(b)-low(c) < 0, -+ bb > cc corresponds to cases 1e and 1f1 -+ sh > 0 corresponds to cases 3c and 3b3 -+ cmp_low = -1 corresponds to case 1d3 (also 3b3) */ -+ inexact = 1; - goto truncate; - } -+ else if (bb < cc) /* here sh = 0 and low(b)-low(c) < -0.5 ulp, -+ this corresponds to cases 1g and 1f3 */ -+ goto sub_one_ulp; -+ /* the only case where we can't conclude is sh=0 and bb=cc, -+ i.e., we have low(b) - low(c) = -0.5 ulp (up to now), thus -+ we don't know if we must truncate or subtract one ulp. -+ Note: for sh=0 we can't have low(b) - low(c) = -0.5 ulp up to -+ now, since low(b) - low(c) > 1/2^sh */ - } - } -- else if (bb > cc) -+ else if (cmp_low > 0) /* 0 < low(b) - low(c): either truncate or -+ add one ulp */ - { - if (rnd_mode == MPFR_RNDZ) - { -@@ -437,34 +500,70 @@ - goto add_one_ulp; - else /* round to nearest */ - { -- if (is_exact) -+ if (bb > cc) - { -- inexact = -1; -- goto truncate; -+ /* if sh=0, then bb>cc means that low(b)-low(c) > 0.5 ulp, -+ and similarly when cmp_low=2 */ -+ if (cmp_low == 2) /* cases 1a, 1b1, 2a and 2b1 */ -+ goto add_one_ulp; -+ /* sh > 0 and cmp_low > 0: this implies that the sh initial -+ neglected bits were 0, and the remaining low(b)-low(c)>0, -+ but its weight is less than 0.5 ulp */ -+ else /* 0 < low(b) - low(c) < 0.5 ulp, this corresponds to -+ cases 3a, 1d1 and 3b1 */ -+ { -+ inexact = -1; -+ goto truncate; -+ } - } -- else if (down) -+ else if (bb < cc) /* 0 < low(b) - low(c) < 0.5 ulp, cases 1c, -+ 1b3, 2b3 and 2c */ - { -- inexact = 1; -+ inexact = -1; - goto truncate; - } -- else -- goto add_one_ulp; -+ /* the only case where we can't conclude is bb=cc, i.e., -+ low(b) - low(c) = 0.5 ulp (up to now), thus we don't know -+ if we must truncate or add one ulp. */ - } - } -+ /* after k=0, we cannot conclude in the following cases, we split them -+ according to the values of bb and cc for k=1: -+ 1b. sh=0 and cmp_low = 1 and bb-cc = half [around 0.5 ulp] -+ 1b1. bb > cc: add one ulp, inex = 1 -+ 1b2: bb = cc: cannot conclude -+ 1b3: bb < cc: truncate, inex = -1 -+ 1d. sh=0 and cmp_low = 0 and bb-cc = 0 [around 0] -+ 1d1: bb > cc: truncate, inex = -1 -+ 1d2: bb = cc: cannot conclude -+ 1d3: bb < cc: truncate, inex = +1 -+ 1f. sh=0 and cmp_low = -1 and bb-cc = -half [around -0.5 ulp] -+ 1f1: bb > cc: truncate, inex = +1 -+ 1f2: bb = cc: cannot conclude -+ 1f3: bb < cc: sub one ulp, inex = -1 -+ 2b. sh > 0 and cmp_low = 2 and bb=cc [around 0.5 ulp] -+ 2b1. bb > cc: add one ulp, inex = 1 -+ 2b2: bb = cc: cannot conclude -+ 2b3: bb < cc: truncate, inex = -1 -+ 3b. sh > 0 and cmp_low = 0 [around 0] -+ 3b1. bb > cc: truncate, inex = -1 -+ 3b2: bb = cc: cannot conclude -+ 3b3: bb < cc: truncate, inex = +1 -+ */ - } - -- if ((rnd_mode == MPFR_RNDN) && !is_exact) -+ if ((rnd_mode == MPFR_RNDN) && cmp_low != 0) - { - /* even rounding rule */ - if ((ap[0] >> sh) & 1) - { -- if (down) -+ if (cmp_low < 0) - goto sub_one_ulp; - else - goto add_one_ulp; - } - else -- inexact = (down) ? 1 : -1; -+ inexact = (cmp_low > 0) ? -1 : 1; - } - else - inexact = 0; -diff -Naurd mpfr-3.0.0-a/tests/tfma.c mpfr-3.0.0-b/tests/tfma.c ---- mpfr-3.0.0-a/tests/tfma.c 2010-06-10 11:00:13.000000000 +0000 -+++ mpfr-3.0.0-b/tests/tfma.c 2010-10-21 20:59:32.000000000 +0000 -@@ -337,6 +337,94 @@ - mpfr_clears (x, y, z, r, (mpfr_ptr) 0); - } - -+static void -+bug20101018 (void) -+{ -+ mpfr_t x, y, z, t, u; -+ int i; -+ -+ mpfr_init2 (x, 64); -+ mpfr_init2 (y, 64); -+ mpfr_init2 (z, 64); -+ mpfr_init2 (t, 64); -+ mpfr_init2 (u, 64); -+ -+ mpfr_set_str (x, "0xf.fffffffffffffffp-14766", 16, MPFR_RNDN); -+ mpfr_set_str (y, "-0xf.fffffffffffffffp+317", 16, MPFR_RNDN); -+ mpfr_set_str (z, "0x8.3ffffffffffe3ffp-14443", 16, MPFR_RNDN); -+ mpfr_set_str (t, "0x8.7ffffffffffc7ffp-14444", 16, MPFR_RNDN); -+ i = mpfr_fma (u, x, y, z, MPFR_RNDN); -+ if (mpfr_cmp (u, t) != 0) -+ { -+ printf ("Wrong result in bug20101018 (a)\n"); -+ printf ("Expected "); -+ mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN); -+ printf ("\nGot "); -+ mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN); -+ printf ("\n"); -+ exit (1); -+ } -+ if (i <= 0) -+ { -+ printf ("Wrong ternary value in bug20101018 (a)\n"); -+ printf ("Expected > 0\n"); -+ printf ("Got %d\n", i); -+ exit (1); -+ } -+ -+ mpfr_set_str (x, "-0xf.fffffffffffffffp-11420", 16, MPFR_RNDN); -+ mpfr_set_str (y, "0xf.fffffffffffffffp+9863", 16, MPFR_RNDN); -+ mpfr_set_str (z, "0x8.fffff80ffffffffp-1551", 16, MPFR_RNDN); -+ mpfr_set_str (t, "0x9.fffff01ffffffffp-1552", 16, MPFR_RNDN); -+ i = mpfr_fma (u, x, y, z, MPFR_RNDN); -+ if (mpfr_cmp (u, t) != 0) -+ { -+ printf ("Wrong result in bug20101018 (b)\n"); -+ printf ("Expected "); -+ mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN); -+ printf ("\nGot "); -+ mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN); -+ printf ("\n"); -+ exit (1); -+ } -+ if (i <= 0) -+ { -+ printf ("Wrong ternary value in bug20101018 (b)\n"); -+ printf ("Expected > 0\n"); -+ printf ("Got %d\n", i); -+ exit (1); -+ } -+ -+ mpfr_set_str (x, "0xf.fffffffffffffffp-2125", 16, MPFR_RNDN); -+ mpfr_set_str (y, "-0xf.fffffffffffffffp-6000", 16, MPFR_RNDN); -+ mpfr_set_str (z, "0x8p-8119", 16, MPFR_RNDN); -+ mpfr_set_str (t, "0x8.000000000000001p-8120", 16, MPFR_RNDN); -+ i = mpfr_fma (u, x, y, z, MPFR_RNDN); -+ if (mpfr_cmp (u, t) != 0) -+ { -+ printf ("Wrong result in bug20101018 (c)\n"); -+ printf ("Expected "); -+ mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN); -+ printf ("\nGot "); -+ mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN); -+ printf ("\n"); -+ exit (1); -+ } -+ if (i <= 0) -+ { -+ printf ("Wrong ternary value in bug20101018 (c)\n"); -+ printf ("Expected > 0\n"); -+ printf ("Got %d\n", i); -+ exit (1); -+ } -+ -+ mpfr_clear (x); -+ mpfr_clear (y); -+ mpfr_clear (z); -+ mpfr_clear (t); -+ mpfr_clear (u); -+} -+ - int - main (int argc, char *argv[]) - { -@@ -345,6 +433,8 @@ - - tests_start_mpfr (); - -+ bug20101018 (); -+ - mpfr_init (x); - mpfr_init (s); - mpfr_init (y); -diff -Naurd mpfr-3.0.0-a/tests/tsub.c mpfr-3.0.0-b/tests/tsub.c ---- mpfr-3.0.0-a/tests/tsub.c 2010-06-10 11:00:13.000000000 +0000 -+++ mpfr-3.0.0-b/tests/tsub.c 2010-10-21 20:59:32.000000000 +0000 -@@ -201,6 +201,8 @@ - if (mpfr_cmp (z, x)) - { - printf ("Error in mpfr_sub (2)\n"); -+ printf ("Expected "); mpfr_print_binary (x); puts (""); -+ printf ("Got "); mpfr_print_binary (z); puts (""); - exit (1); - } - mpfr_set_str_binary (x, "1.1110111011110001110111011111111111101000011001011100101100101101"); -@@ -478,6 +480,156 @@ - mpfr_clear (u); - } - -+/* Bug found by Jakub Jelinek -+ * http://bugzilla.redhat.com/643657 -+ * https://gforge.inria.fr/tracker/index.php?func=detail&aid=11301 -+ * The consequence can be either an assertion failure (i = 2 in the -+ * testcase below, in debug mode) or an incorrectly rounded value. -+ */ -+static void -+bug20101017 (void) -+{ -+ mpfr_t a, b, c; -+ int inex; -+ int i; -+ -+ mpfr_init2 (a, GMP_NUMB_BITS * 2); -+ mpfr_init2 (b, GMP_NUMB_BITS); -+ mpfr_init2 (c, GMP_NUMB_BITS); -+ -+ /* a = 2^(2N) + k.2^(2N-1) + 2^N and b = 1 -+ with N = GMP_NUMB_BITS and k = 0 or 1. -+ c = a - b should round to the same value as a. */ -+ -+ for (i = 2; i <= 3; i++) -+ { -+ mpfr_set_ui_2exp (a, i, GMP_NUMB_BITS - 1, MPFR_RNDN); -+ mpfr_add_ui (a, a, 1, MPFR_RNDN); -+ mpfr_mul_2ui (a, a, GMP_NUMB_BITS, MPFR_RNDN); -+ mpfr_set_ui (b, 1, MPFR_RNDN); -+ inex = mpfr_sub (c, a, b, MPFR_RNDN); -+ mpfr_set (b, a, MPFR_RNDN); -+ if (! mpfr_equal_p (c, b)) -+ { -+ printf ("Error in bug20101017 for i = %d.\n", i); -+ printf ("Expected "); -+ mpfr_out_str (stdout, 16, 0, b, MPFR_RNDN); -+ putchar ('\n'); -+ printf ("Got "); -+ mpfr_out_str (stdout, 16, 0, c, MPFR_RNDN); -+ putchar ('\n'); -+ exit (1); -+ } -+ if (inex >= 0) -+ { -+ printf ("Error in bug20101017 for i = %d: bad inex value.\n", i); -+ printf ("Expected negative, got %d.\n", inex); -+ exit (1); -+ } -+ } -+ -+ mpfr_set_prec (a, 64); -+ mpfr_set_prec (b, 129); -+ mpfr_set_prec (c, 2); -+ mpfr_set_str_binary (b, "0.100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001E65"); -+ mpfr_set_str_binary (c, "0.10E1"); -+ inex = mpfr_sub (a, b, c, MPFR_RNDN); -+ if (mpfr_cmp_ui_2exp (a, 1, 64) != 0 || inex >= 0) -+ { -+ printf ("Error in mpfr_sub for b-c for b=2^64+1+2^(-64), c=1\n"); -+ printf ("Expected result 2^64 with inex < 0\n"); -+ printf ("Got "); mpfr_print_binary (a); -+ printf (" with inex=%d\n", inex); -+ exit (1); -+ } -+ -+ mpfr_clears (a, b, c, (mpfr_ptr) 0); -+} -+ -+/* hard test of rounding */ -+static void -+check_rounding (void) -+{ -+ mpfr_t a, b, c, res; -+ mpfr_prec_t p; -+ long k, l; -+ int i; -+ -+#define MAXKL (2 * GMP_NUMB_BITS) -+ for (p = MPFR_PREC_MIN; p <= GMP_NUMB_BITS; p++) -+ { -+ mpfr_init2 (a, p); -+ mpfr_init2 (res, p); -+ mpfr_init2 (b, p + 1 + MAXKL); -+ mpfr_init2 (c, MPFR_PREC_MIN); -+ -+ /* b = 2^p + 1 + 2^(-k), c = 2^(-l) */ -+ for (k = 0; k <= MAXKL; k++) -+ for (l = 0; l <= MAXKL; l++) -+ { -+ mpfr_set_ui_2exp (b, 1, p, MPFR_RNDN); -+ mpfr_add_ui (b, b, 1, MPFR_RNDN); -+ mpfr_mul_2ui (b, b, k, MPFR_RNDN); -+ mpfr_add_ui (b, b, 1, MPFR_RNDN); -+ mpfr_div_2ui (b, b, k, MPFR_RNDN); -+ mpfr_set_ui_2exp (c, 1, -l, MPFR_RNDN); -+ i = mpfr_sub (a, b, c, MPFR_RNDN); -+ /* b - c = 2^p + 1 + 2^(-k) - 2^(-l), should be rounded to -+ 2^p for l <= k, and 2^p+2 for l < k */ -+ if (l <= k) -+ { -+ if (mpfr_cmp_ui_2exp (a, 1, p) != 0) -+ { -+ printf ("Wrong result in check_rounding\n"); -+ printf ("p=%lu k=%ld l=%ld\n", p, k, l); -+ printf ("b="); mpfr_print_binary (b); puts (""); -+ printf ("c="); mpfr_print_binary (c); puts (""); -+ printf ("Expected 2^%lu\n", p); -+ printf ("Got "); mpfr_print_binary (a); puts (""); -+ exit (1); -+ } -+ if (i >= 0) -+ { -+ printf ("Wrong ternary value in check_rounding\n"); -+ printf ("p=%lu k=%ld l=%ld\n", p, k, l); -+ printf ("b="); mpfr_print_binary (b); puts (""); -+ printf ("c="); mpfr_print_binary (c); puts (""); -+ printf ("a="); mpfr_print_binary (a); puts (""); -+ printf ("Expected < 0, got %d\n", i); -+ exit (1); -+ } -+ } -+ else /* l < k */ -+ { -+ mpfr_set_ui_2exp (res, 1, p, MPFR_RNDN); -+ mpfr_add_ui (res, res, 2, MPFR_RNDN); -+ if (mpfr_cmp (a, res) != 0) -+ { -+ printf ("Wrong result in check_rounding\n"); -+ printf ("b="); mpfr_print_binary (b); puts (""); -+ printf ("c="); mpfr_print_binary (c); puts (""); -+ printf ("Expected "); mpfr_print_binary (res); puts (""); -+ printf ("Got "); mpfr_print_binary (a); puts (""); -+ exit (1); -+ } -+ if (i <= 0) -+ { -+ printf ("Wrong ternary value in check_rounding\n"); -+ printf ("b="); mpfr_print_binary (b); puts (""); -+ printf ("c="); mpfr_print_binary (c); puts (""); -+ printf ("Expected > 0, got %d\n", i); -+ exit (1); -+ } -+ } -+ } -+ -+ mpfr_clear (a); -+ mpfr_clear (res); -+ mpfr_clear (b); -+ mpfr_clear (c); -+ } -+} -+ - #define TEST_FUNCTION test_sub - #define TWO_ARGS - #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS) -@@ -491,6 +643,8 @@ - - tests_start_mpfr (); - -+ bug20101017 (); -+ check_rounding (); - check_diverse (); - check_inexact (); - bug_ddefour (); -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c ---- mpfr-3.0.0-a/version.c 2010-10-21 20:28:38.000000000 +0000 -+++ mpfr-3.0.0-b/version.c 2010-10-21 20:59:32.000000000 +0000 -@@ -25,5 +25,5 @@ - const char * - mpfr_get_version (void) - { -- return "3.0.0-p5"; -+ return "3.0.0-p6"; - } -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES ---- mpfr-3.0.0-a/PATCHES 2010-10-21 21:18:26.000000000 +0000 -+++ mpfr-3.0.0-b/PATCHES 2010-10-21 21:18:26.000000000 +0000 -@@ -0,0 +1 @@ -+mpfr_set_ld -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION ---- mpfr-3.0.0-a/VERSION 2010-10-21 20:59:32.000000000 +0000 -+++ mpfr-3.0.0-b/VERSION 2010-10-21 21:18:26.000000000 +0000 -@@ -1 +1 @@ --3.0.0-p6 -+3.0.0-p7 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h ---- mpfr-3.0.0-a/mpfr.h 2010-10-21 20:59:32.000000000 +0000 -+++ mpfr-3.0.0-b/mpfr.h 2010-10-21 21:18:26.000000000 +0000 -@@ -27,7 +27,7 @@ - #define MPFR_VERSION_MAJOR 3 - #define MPFR_VERSION_MINOR 0 - #define MPFR_VERSION_PATCHLEVEL 0 --#define MPFR_VERSION_STRING "3.0.0-p6" -+#define MPFR_VERSION_STRING "3.0.0-p7" - - /* Macros dealing with MPFR VERSION */ - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -diff -Naurd mpfr-3.0.0-a/set_ld.c mpfr-3.0.0-b/set_ld.c ---- mpfr-3.0.0-a/set_ld.c 2010-06-10 11:00:14.000000000 +0000 -+++ mpfr-3.0.0-b/set_ld.c 2010-10-21 21:18:26.000000000 +0000 -@@ -102,21 +102,25 @@ - { - x /= div13; /* exact */ - shift_exp += 8192; -+ mpfr_div_2si (t, t, 8192, MPFR_RNDZ); - } - if (ABS (x) >= div12) - { - x /= div12; /* exact */ - shift_exp += 4096; -+ mpfr_div_2si (t, t, 4096, MPFR_RNDZ); - } - if (ABS (x) >= div11) - { - x /= div11; /* exact */ - shift_exp += 2048; -+ mpfr_div_2si (t, t, 2048, MPFR_RNDZ); - } - if (ABS (x) >= div10) - { - x /= div10; /* exact */ - shift_exp += 1024; -+ mpfr_div_2si (t, t, 1024, MPFR_RNDZ); - } - /* warning: we may have DBL_MAX=2^1024*(1-2^(-53)) < x < 2^1024, - therefore we have one extra exponent reduction step */ -@@ -124,9 +128,10 @@ - { - x /= div9; /* exact */ - shift_exp += 512; -+ mpfr_div_2si (t, t, 512, MPFR_RNDZ); - } - } /* Check overflow of double */ -- else -+ else /* no overflow on double */ - { - long double div9, div10, div11; - -@@ -149,29 +154,34 @@ - { - x /= div13; /* exact */ - shift_exp -= 8192; -+ mpfr_mul_2si (t, t, 8192, MPFR_RNDZ); - } - if (ABS (x) <= div12) - { - x /= div12; /* exact */ - shift_exp -= 4096; -+ mpfr_mul_2si (t, t, 4096, MPFR_RNDZ); - } - if (ABS (x) <= div11) - { - x /= div11; /* exact */ - shift_exp -= 2048; -+ mpfr_mul_2si (t, t, 2048, MPFR_RNDZ); - } - if (ABS (x) <= div10) - { - x /= div10; /* exact */ - shift_exp -= 1024; -+ mpfr_mul_2si (t, t, 1024, MPFR_RNDZ); - } - if (ABS(x) <= div9) - { - x /= div9; /* exact */ - shift_exp -= 512; -+ mpfr_mul_2si (t, t, 512, MPFR_RNDZ); - } - } -- else -+ else /* no underflow */ - { - inexact = mpfr_set_d (u, (double) x, MPFR_RNDZ); - MPFR_ASSERTD (inexact == 0); -diff -Naurd mpfr-3.0.0-a/tests/tset_ld.c mpfr-3.0.0-b/tests/tset_ld.c ---- mpfr-3.0.0-a/tests/tset_ld.c 2010-06-10 11:00:13.000000000 +0000 -+++ mpfr-3.0.0-b/tests/tset_ld.c 2010-10-21 21:18:26.000000000 +0000 -@@ -147,12 +147,39 @@ - test_fixed_bugs (void) - { - mpfr_t x; -- long double d; -+ long double l, m; - - /* bug found by Steve Kargl (2009-03-14) */ - mpfr_init2 (x, 64); - mpfr_set_ui_2exp (x, 1, -16447, MPFR_RNDN); -- d = mpfr_get_ld (x, MPFR_RNDN); /* an assertion failed in init2.c:50 */ -+ mpfr_get_ld (x, MPFR_RNDN); /* an assertion failed in init2.c:50 */ -+ -+ /* bug reported by Jakub Jelinek (2010-10-17) -+ https://gforge.inria.fr/tracker/?func=detail&aid=11300 */ -+ mpfr_set_prec (x, MPFR_LDBL_MANT_DIG); -+ /* l = 0x1.23456789abcdef0123456789abcdp-914L; */ -+ l = 8.215640181713713164092636634579e-276; -+ mpfr_set_ld (x, l, MPFR_RNDN); -+ m = mpfr_get_ld (x, MPFR_RNDN); -+ if (m != l) -+ { -+ printf ("Error in get_ld o set_ld for l=%Le\n", l); -+ printf ("Got m=%Le instead of l\n", m); -+ exit (1); -+ } -+ -+ /* another similar test which failed with extended double precision and the -+ generic code for mpfr_set_ld */ -+ /* l = 0x1.23456789abcdef0123456789abcdp-968L; */ -+ l = 4.560596445887084662336528403703e-292; -+ mpfr_set_ld (x, l, MPFR_RNDN); -+ m = mpfr_get_ld (x, MPFR_RNDN); -+ if (m != l) -+ { -+ printf ("Error in get_ld o set_ld for l=%Le\n", l); -+ printf ("Got m=%Le instead of l\n", m); -+ exit (1); -+ } - - mpfr_clear (x); - } -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c ---- mpfr-3.0.0-a/version.c 2010-10-21 20:59:32.000000000 +0000 -+++ mpfr-3.0.0-b/version.c 2010-10-21 21:18:26.000000000 +0000 -@@ -25,5 +25,5 @@ - const char * - mpfr_get_version (void) - { -- return "3.0.0-p6"; -+ return "3.0.0-p7"; - } -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES ---- mpfr-3.0.0-a/PATCHES 2010-11-09 15:15:07.000000000 +0000 -+++ mpfr-3.0.0-b/PATCHES 2010-11-09 15:15:07.000000000 +0000 -@@ -0,0 +1 @@ -+macros -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION ---- mpfr-3.0.0-a/VERSION 2010-10-21 21:18:26.000000000 +0000 -+++ mpfr-3.0.0-b/VERSION 2010-11-09 15:15:07.000000000 +0000 -@@ -1 +1 @@ --3.0.0-p7 -+3.0.0-p8 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h ---- mpfr-3.0.0-a/mpfr.h 2010-10-21 21:18:26.000000000 +0000 -+++ mpfr-3.0.0-b/mpfr.h 2010-11-09 15:15:07.000000000 +0000 -@@ -27,7 +27,7 @@ - #define MPFR_VERSION_MAJOR 3 - #define MPFR_VERSION_MINOR 0 - #define MPFR_VERSION_PATCHLEVEL 0 --#define MPFR_VERSION_STRING "3.0.0-p7" -+#define MPFR_VERSION_STRING "3.0.0-p8" - - /* Macros dealing with MPFR VERSION */ - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -@@ -67,6 +67,16 @@ - # define _MPFR_H_HAVE_INTMAX_T 1 - #endif - -+/* Avoid some problems with macro expansion if the user defines macros -+ with the same name as keywords. By convention, identifiers and macro -+ names starting with mpfr_ are reserved by MPFR. */ -+typedef void mpfr_void; -+typedef int mpfr_int; -+typedef unsigned int mpfr_uint; -+typedef long mpfr_long; -+typedef unsigned long mpfr_ulong; -+typedef size_t mpfr_size_t; -+ - /* Definition of rounding modes (DON'T USE MPFR_RNDNA!). - Warning! Changing the contents of this enum should be seen as an - interface change since the old and the new types are not compatible -@@ -136,7 +146,7 @@ - typedef mp_exp_t mpfr_exp_t; - - /* Definition of the standard exponent limits */ --#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((unsigned long) 1 << 30) - 1)) -+#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1)) - #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT)) - - /* Definition of the main structure */ -@@ -725,13 +735,13 @@ - unexpected results with future compilers and aggressive optimisations. - Why not working only with signed types, using INT_MIN and LONG_MIN? */ - #if __GMP_MP_SIZE_T_INT --#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+2)) --#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+1)) --#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+3)) -+#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+2)) -+#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+1)) -+#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+3)) - #else --#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+2)) --#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+1)) --#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+3)) -+#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+2)) -+#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+1)) -+#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+3)) - #endif - - /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */ -@@ -760,9 +770,9 @@ - #define mpfr_inf_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_INF) - #define mpfr_zero_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_ZERO) - #define mpfr_regular_p(_x) ((_x)->_mpfr_exp > __MPFR_EXP_INF) --#define mpfr_sgn(_x) \ -- ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \ -- (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \ -+#define mpfr_sgn(_x) \ -+ ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \ -+ (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \ - MPFR_SIGN (_x)) - - /* Prevent them from using as lvalues */ -@@ -805,7 +815,19 @@ - Moreover casts to unsigned long have been added to avoid warnings in - programs that use MPFR and are compiled with -Wconversion; such casts - are OK since if X is a constant expression, then (unsigned long) X is -- also a constant expression, so that the optimizations still work. */ -+ also a constant expression, so that the optimizations still work. The -+ warnings are probably related to the following two bugs: -+ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 -+ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant) -+ and the casts could be removed once these bugs are fixed. -+ Casts shouldn't be used on the generic calls (to the ..._2exp functions), -+ where implicit conversions are performed. Indeed, having at least one -+ implicit conversion in the macro allows the compiler to emit diagnostics -+ when normally expected, for instance in the following call: -+ mpfr_set_ui (x, "foo", MPFR_RNDN); -+ If this is not possible (for future macros), one of the tricks described -+ on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could -+ be used. */ - #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus) - #if (__GNUC__ >= 2) - #undef mpfr_cmp_ui -@@ -813,45 +835,45 @@ - But warning! mpfr_sgn is specified as a macro in the API, thus the macro - mustn't be used if side effects are possible, like here. */ - #define mpfr_cmp_ui(_f,_u) \ -- (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \ -+ (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \ - (mpfr_sgn) (_f) : \ -- mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0)) -+ mpfr_cmp_ui_2exp ((_f), (_u), 0)) - #undef mpfr_cmp_si --#define mpfr_cmp_si(_f,_s) \ -- (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \ -- mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) : \ -- mpfr_cmp_si_2exp ((_f), (long) (_s), 0)) -+#define mpfr_cmp_si(_f,_s) \ -+ (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ -+ mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) : \ -+ mpfr_cmp_si_2exp ((_f), (_s), 0)) - #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95 - #undef mpfr_set_ui - #define mpfr_set_ui(_f,_u,_r) \ -- (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ? \ -+ (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \ - __extension__ ({ \ - mpfr_ptr _p = (_f); \ - _p->_mpfr_sign = 1; \ - _p->_mpfr_exp = __MPFR_EXP_ZERO; \ -- (void) (_r); 0; }) : \ -- mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r))) -+ (mpfr_void) (_r); 0; }) : \ -+ mpfr_set_ui_2exp ((_f), (_u), 0, (_r))) - #endif - #undef mpfr_set_si - #define mpfr_set_si(_f,_s,_r) \ -- (__builtin_constant_p (_s) && (long) (_s) >= 0 ? \ -- mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) : \ -- mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r))) -+ (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \ -+ mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \ -+ mpfr_set_si_2exp ((_f), (_s), 0, (_r))) - #endif - #endif - - /* Macro version of mpfr_stack interface for fast access */ --#define mpfr_custom_get_size(p) ((size_t) \ -+#define mpfr_custom_get_size(p) ((mpfr_size_t) \ - (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t))) - #define mpfr_custom_init(m,p) do {} while (0) --#define mpfr_custom_get_significand(x) ((void*)((x)->_mpfr_d)) -+#define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d)) - #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp) - #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0) - #define mpfr_custom_init_set(x,k,e,p,m) do { \ - mpfr_ptr _x = (x); \ - mpfr_exp_t _e; \ - mpfr_kind_t _t; \ -- int _s, _k; \ -+ mpfr_int _s, _k; \ - _k = (k); \ - if (_k >= 0) { \ - _t = (mpfr_kind_t) _k; \ -@@ -868,11 +890,13 @@ - _x->_mpfr_exp = _e; \ - _x->_mpfr_d = (mp_limb_t*) (m); \ - } while (0) --#define mpfr_custom_get_kind(x) \ -- ( (x)->_mpfr_exp > __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \ -- : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x) \ -- : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND \ -- : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) ) -+#define mpfr_custom_get_kind(x) \ -+ ( (x)->_mpfr_exp > __MPFR_EXP_INF ? \ -+ (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x) \ -+ : (x)->_mpfr_exp == __MPFR_EXP_INF ? \ -+ (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x) \ -+ : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND \ -+ : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) ) - - - #endif /* MPFR_USE_NO_MACRO */ -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c ---- mpfr-3.0.0-a/version.c 2010-10-21 21:18:26.000000000 +0000 -+++ mpfr-3.0.0-b/version.c 2010-11-09 15:15:07.000000000 +0000 -@@ -25,5 +25,5 @@ - const char * - mpfr_get_version (void) - { -- return "3.0.0-p7"; -+ return "3.0.0-p8"; - } diff --git a/tools/mpfr/patches/001-no_tests.patch b/tools/mpfr/patches/001-no_tests.patch deleted file mode 100644 index 08c1a4ff4..000000000 --- a/tools/mpfr/patches/001-no_tests.patch +++ /dev/null @@ -1,26 +0,0 @@ -Index: mpfr-3.0.0/Makefile.am -=================================================================== ---- mpfr-3.0.0.orig/Makefile.am -+++ mpfr-3.0.0/Makefile.am -@@ -12,7 +12,7 @@ - AUTOMAKE_OPTIONS = gnu ansi2knr - ACLOCAL_AMFLAGS = -I m4 - --SUBDIRS = tests -+SUBDIRS = - - nobase_dist_doc_DATA = AUTHORS BUGS COPYING COPYING.LESSER FAQ.html NEWS TODO \ - examples/ReadMe examples/divworst.c examples/rndo-add.c examples/sample.c \ -Index: mpfr-3.0.0/Makefile.in -=================================================================== ---- mpfr-3.0.0.orig/Makefile.in -+++ mpfr-3.0.0/Makefile.in -@@ -357,7 +357,7 @@ top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ - AUTOMAKE_OPTIONS = gnu ansi2knr - ACLOCAL_AMFLAGS = -I m4 --SUBDIRS = tests -+SUBDIRS = - nobase_dist_doc_DATA = AUTHORS BUGS COPYING COPYING.LESSER FAQ.html NEWS TODO \ - examples/ReadMe examples/divworst.c examples/rndo-add.c examples/sample.c \ - examples/version.c diff --git a/tools/mpfr/patches/001-only_src.patch b/tools/mpfr/patches/001-only_src.patch new file mode 100644 index 000000000..e6579b211 --- /dev/null +++ b/tools/mpfr/patches/001-only_src.patch @@ -0,0 +1,22 @@ +--- a/Makefile.am ++++ b/Makefile.am +@@ -12,7 +12,7 @@ + AUTOMAKE_OPTIONS = gnu + ACLOCAL_AMFLAGS = -I m4 + +-SUBDIRS = doc src tests tune ++SUBDIRS = src + + nobase_dist_doc_DATA = AUTHORS BUGS COPYING COPYING.LESSER NEWS TODO \ + examples/ReadMe examples/divworst.c examples/rndo-add.c examples/sample.c \ +--- a/Makefile.in ++++ b/Makefile.in +@@ -294,7 +294,7 @@ top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + AUTOMAKE_OPTIONS = gnu + ACLOCAL_AMFLAGS = -I m4 +-SUBDIRS = doc src tests tune ++SUBDIRS = src + nobase_dist_doc_DATA = AUTHORS BUGS COPYING COPYING.LESSER NEWS TODO \ + examples/ReadMe examples/divworst.c examples/rndo-add.c examples/sample.c \ + examples/version.c diff --git a/tools/mtools/Makefile b/tools/mtools/Makefile index 8d227c147..12993458c 100644 --- a/tools/mtools/Makefile +++ b/tools/mtools/Makefile @@ -16,6 +16,9 @@ PKG_CAT:=zcat include $(INCLUDE_DIR)/host-build.mk +HOST_CONFIGURE_VARS += \ + ac_cv_header_iconv_h=no + HOST_LDFLAGS += $(HOST_STATIC_LINKING) define Host/Compile diff --git a/tools/patch-cmdline/Makefile b/tools/patch-image/Makefile index a9526397f..cd2df5c8a 100644 --- a/tools/patch-cmdline/Makefile +++ b/tools/patch-image/Makefile @@ -6,20 +6,23 @@ # include $(TOPDIR)/rules.mk -PKG_NAME:=patch-cmdline +PKG_NAME:=patch-image include $(INCLUDE_DIR)/host-build.mk define Host/Compile - $(HOSTCC) $(HOST_CFLAGS) -include endian.h $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/$(PKG_NAME) src/$(PKG_NAME).c + $(HOSTCC) $(HOST_CFLAGS) -include endian.h $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/patch-cmdline src/patch-cmdline.c + $(HOSTCC) $(HOST_CFLAGS) -include endian.h $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/patch-dtb src/patch-dtb.c endef define Host/Install $(CP) $(HOST_BUILD_DIR)/patch-cmdline $(STAGING_DIR_HOST)/bin/ + $(CP) $(HOST_BUILD_DIR)/patch-dtb $(STAGING_DIR_HOST)/bin/ endef define Host/Clean rm -f $(STAGING_DIR_HOST)/bin/patch-cmdline + rm -f $(STAGING_DIR_HOST)/bin/patch-dtb endef $(eval $(call HostBuild)) diff --git a/tools/patch-cmdline/src/patch-cmdline.c b/tools/patch-image/src/patch-cmdline.c index 571f848d8..571f848d8 100644 --- a/tools/patch-cmdline/src/patch-cmdline.c +++ b/tools/patch-image/src/patch-cmdline.c diff --git a/tools/patch-image/src/patch-dtb.c b/tools/patch-image/src/patch-dtb.c new file mode 100644 index 000000000..161e1dca2 --- /dev/null +++ b/tools/patch-image/src/patch-dtb.c @@ -0,0 +1,101 @@ +/* + * patch-dtb.c - patch a dtb into an image + * + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org> + * Copyright (C) 2012 John Crispin <blogic@openwrt.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * based on patch-cmdline.c + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stddef.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <string.h> + +#define SEARCH_SPACE (16 * 1024) +#define DTB_MAX (16 * 1024) + +int main(int argc, char **argv) +{ + int fd, fddtb, found = 0, len, ret = -1; + char *ptr, *ptrdtb, *p; + struct stat s; + + if (argc != 3) { + fprintf(stderr, "Usage: %s <file> <dtb>\n", argv[0]); + goto err1; + } + fddtb = open(argv[1], O_RDONLY); + if (!fddtb) + goto err1; + + if (stat(argv[2], &s)) { + fprintf(stderr, "DTB not found\n"); + goto err1; + } + + len = s.st_size; + if (len + 8 > DTB_MAX) { + fprintf(stderr, "DTB too big\n"); + goto err1; + } + + if (((fddtb = open(argv[2], O_RDONLY)) < 0) || + (ptrdtb = (char *) mmap(0, DTB_MAX, PROT_READ, MAP_SHARED, fddtb, 0)) == (void *) (-1)) { + fprintf(stderr, "Could not open DTB"); + goto err2; + } + + if (((fd = open(argv[1], O_RDWR)) < 0) || + (ptr = (char *) mmap(0, SEARCH_SPACE + DTB_MAX, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1)) { + fprintf(stderr, "Could not open kernel image"); + goto err3; + } + + for (p = ptr; p < (ptr + SEARCH_SPACE); p += 4) { + if (memcmp(p, "OWRTDTB:", 8) == 0) { + found = 1; + p += 8; + break; + } + } + if (!found) { + fprintf(stderr, "DTB marker not found!\n"); + goto err4; + } + + memset(p, 0, DTB_MAX - 8); + memcpy(p, ptrdtb, len); + msync(p, len, MS_SYNC|MS_INVALIDATE); + ret = 0; + +err4: + munmap((void *) ptr, len); +err3: + if (fd > 0) + close(fd); + munmap((void *) ptrdtb, len); +err2: + if (fddtb > 0) + close(fddtb); +err1: + return ret; +} diff --git a/tools/patch/Makefile b/tools/patch/Makefile new file mode 100644 index 000000000..def829909 --- /dev/null +++ b/tools/patch/Makefile @@ -0,0 +1,18 @@ +# +# Copyright (C) 2013 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +PKG_NAME:=patch +PKG_VERSION:=2.7.1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=ftp://ftp.gnu.org/gnu/patch +PKG_MD5SUM:=e9ae5393426d3ad783a300a338c09b72 + +include $(INCLUDE_DIR)/host-build.mk + +$(eval $(call HostBuild)) diff --git a/tools/pkg-config/Makefile b/tools/pkg-config/Makefile index 01bfdb0d6..b72f3ce45 100644 --- a/tools/pkg-config/Makefile +++ b/tools/pkg-config/Makefile @@ -13,6 +13,8 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://pkgconfig.freedesktop.org/releases/ PKG_MD5SUM:=a3270bab3f4b69b7dc6dbdacbcae9745 +HOST_BUILD_PARALLEL:=1 + include $(INCLUDE_DIR)/host-build.mk HOST_LDFLAGS += $(HOST_STATIC_LINKING) diff --git a/tools/quilt/Makefile b/tools/quilt/Makefile index 510d8f6fd..541e656af 100644 --- a/tools/quilt/Makefile +++ b/tools/quilt/Makefile @@ -15,12 +15,8 @@ PKG_MD5SUM:=f77adda60039ffa753f3c584a286f12b include $(INCLUDE_DIR)/host-build.mk -GETOPT:=$(shell which getopt) - HOST_CONFIGURE_ARGS += \ - --with-patch=$(PATCH) \ - --with-find=$(FIND) \ - --with-getopt=$(GETOPT) + --with-find=$(FIND) define Host/Configure cd $(HOST_BUILD_DIR) && autoconf diff --git a/tools/sed/Makefile b/tools/sed/Makefile index 522ae70d8..27169540b 100644 --- a/tools/sed/Makefile +++ b/tools/sed/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2006-2013 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -7,14 +7,16 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sed -PKG_VERSION:=4.2.1 +PKG_VERSION:=4.2.2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=@GNU/$(PKG_NAME) -PKG_MD5SUM:=7d310fbd76e01a01115075c1fd3f455a +PKG_MD5SUM:=7ffe1c7cdc3233e1e0c4b502df253974 PKG_CAT:=bzcat export SED:= +HOST_BUILD_PARALLEL:=1 + include $(INCLUDE_DIR)/host-build.mk HOST_CONFIGURE_ARGS += \ @@ -27,7 +29,7 @@ HOST_CONFIGURE_VARS += \ ac_cv_header_selinux_selinux_h=no \ define Host/Compile - $(MAKE) -C $(HOST_BUILD_DIR) SHELL="$(BASH)" LDFLAGS="$(HOST_STATIC_LINKING)" + +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) SHELL="$(BASH)" LDFLAGS="$(HOST_STATIC_LINKING)" endef define Host/Install diff --git a/tools/squashfs4/patches/180-openbsd_compat.patch b/tools/squashfs4/patches/180-openbsd_compat.patch new file mode 100644 index 000000000..6d7a857a0 --- /dev/null +++ b/tools/squashfs4/patches/180-openbsd_compat.patch @@ -0,0 +1,26 @@ +diff -Nur squashfs4.2.orig/squashfs-tools/mksquashfs.c squashfs4.2/squashfs-tools/mksquashfs.c +--- squashfs4.2.orig/squashfs-tools/mksquashfs.c Tue Mar 5 16:20:49 2013 ++++ squashfs4.2/squashfs-tools/mksquashfs.c Tue Mar 5 16:25:10 2013 +@@ -32,6 +32,9 @@ + #include <stdio.h> + #include <stddef.h> + #include <sys/time.h> ++#if defined(__OpenBSD__) ++#include <sys/param.h> ++#endif + #include <sys/types.h> + #include <sys/stat.h> + #include <fcntl.h> +diff -Nur squashfs4.2.orig/squashfs-tools/unsquashfs.h squashfs4.2/squashfs-tools/unsquashfs.h +--- squashfs4.2.orig/squashfs-tools/unsquashfs.h Tue Mar 5 16:20:49 2013 ++++ squashfs4.2/squashfs-tools/unsquashfs.h Tue Mar 5 16:25:57 2013 +@@ -25,6 +25,9 @@ + #define TRUE 1 + #define FALSE 0 + #include <stdio.h> ++#if defined(__OpenBSD__) ++#include <sys/param.h> ++#endif + #include <sys/types.h> + #include <unistd.h> + #include <stdlib.h> diff --git a/tools/sstrip/Makefile b/tools/sstrip/Makefile index ea4c3e880..045d08078 100644 --- a/tools/sstrip/Makefile +++ b/tools/sstrip/Makefile @@ -11,7 +11,7 @@ PKG_NAME:=sstrip include $(INCLUDE_DIR)/host-build.mk define Host/Compile - $(HOSTCC) $(HOST_CFLAGS) -I./include -include endian.h $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/sstrip src/sstrip.c + $(HOSTCC) $(HOST_CFLAGS) -include endian.h $(HOST_STATIC_LINKING) -o $(HOST_BUILD_DIR)/sstrip src/sstrip.c endef define Host/Install diff --git a/tools/sstrip/include/elf.h b/tools/sstrip/include/elf.h deleted file mode 100644 index eae96d000..000000000 --- a/tools/sstrip/include/elf.h +++ /dev/null @@ -1,2445 +0,0 @@ -/* This file defines standard ELF types, structures, and macros. - Copyright (C) 1995-1999,2000,2001,2002,2003 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 - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _ELF_H -#define _ELF_H 1 - -__BEGIN_DECLS - -/* Standard ELF types. */ - -#include <stdint.h> - -/* Type for a 16-bit quantity. */ -typedef uint16_t Elf32_Half; -typedef uint16_t Elf64_Half; - -/* Types for signed and unsigned 32-bit quantities. */ -typedef uint32_t Elf32_Word; -typedef int32_t Elf32_Sword; -typedef uint32_t Elf64_Word; -typedef int32_t Elf64_Sword; - -/* Types for signed and unsigned 64-bit quantities. */ -typedef uint64_t Elf32_Xword; -typedef int64_t Elf32_Sxword; -typedef uint64_t Elf64_Xword; -typedef int64_t Elf64_Sxword; - -/* Type of addresses. */ -typedef uint32_t Elf32_Addr; -typedef uint64_t Elf64_Addr; - -/* Type of file offsets. */ -typedef uint32_t Elf32_Off; -typedef uint64_t Elf64_Off; - -/* Type for section indices, which are 16-bit quantities. */ -typedef uint16_t Elf32_Section; -typedef uint16_t Elf64_Section; - -/* Type for version symbol information. */ -typedef Elf32_Half Elf32_Versym; -typedef Elf64_Half Elf64_Versym; - - -/* The ELF file header. This appears at the start of every ELF file. */ - -#define EI_NIDENT (16) - -typedef struct -{ - unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf32_Half e_type; /* Object file type */ - Elf32_Half e_machine; /* Architecture */ - Elf32_Word e_version; /* Object file version */ - Elf32_Addr e_entry; /* Entry point virtual address */ - Elf32_Off e_phoff; /* Program header table file offset */ - Elf32_Off e_shoff; /* Section header table file offset */ - Elf32_Word e_flags; /* Processor-specific flags */ - Elf32_Half e_ehsize; /* ELF header size in bytes */ - Elf32_Half e_phentsize; /* Program header table entry size */ - Elf32_Half e_phnum; /* Program header table entry count */ - Elf32_Half e_shentsize; /* Section header table entry size */ - Elf32_Half e_shnum; /* Section header table entry count */ - Elf32_Half e_shstrndx; /* Section header string table index */ -} Elf32_Ehdr; - -typedef struct -{ - unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ - Elf64_Half e_type; /* Object file type */ - Elf64_Half e_machine; /* Architecture */ - Elf64_Word e_version; /* Object file version */ - Elf64_Addr e_entry; /* Entry point virtual address */ - Elf64_Off e_phoff; /* Program header table file offset */ - Elf64_Off e_shoff; /* Section header table file offset */ - Elf64_Word e_flags; /* Processor-specific flags */ - Elf64_Half e_ehsize; /* ELF header size in bytes */ - Elf64_Half e_phentsize; /* Program header table entry size */ - Elf64_Half e_phnum; /* Program header table entry count */ - Elf64_Half e_shentsize; /* Section header table entry size */ - Elf64_Half e_shnum; /* Section header table entry count */ - Elf64_Half e_shstrndx; /* Section header string table index */ -} Elf64_Ehdr; - -/* Fields in the e_ident array. The EI_* macros are indices into the - array. The macros under each EI_* macro are the values the byte - may have. */ - -#define EI_MAG0 0 /* File identification byte 0 index */ -#define ELFMAG0 0x7f /* Magic number byte 0 */ - -#define EI_MAG1 1 /* File identification byte 1 index */ -#define ELFMAG1 'E' /* Magic number byte 1 */ - -#define EI_MAG2 2 /* File identification byte 2 index */ -#define ELFMAG2 'L' /* Magic number byte 2 */ - -#define EI_MAG3 3 /* File identification byte 3 index */ -#define ELFMAG3 'F' /* Magic number byte 3 */ - -/* Conglomeration of the identification bytes, for easy testing as a word. */ -#define ELFMAG "\177ELF" -#define SELFMAG 4 - -#define EI_CLASS 4 /* File class byte index */ -#define ELFCLASSNONE 0 /* Invalid class */ -#define ELFCLASS32 1 /* 32-bit objects */ -#define ELFCLASS64 2 /* 64-bit objects */ -#define ELFCLASSNUM 3 - -#define EI_DATA 5 /* Data encoding byte index */ -#define ELFDATANONE 0 /* Invalid data encoding */ -#define ELFDATA2LSB 1 /* 2's complement, little endian */ -#define ELFDATA2MSB 2 /* 2's complement, big endian */ -#define ELFDATANUM 3 - -#define EI_VERSION 6 /* File version byte index */ - /* Value must be EV_CURRENT */ - -#define EI_OSABI 7 /* OS ABI identification */ -#define ELFOSABI_NONE 0 /* UNIX System V ABI */ -#define ELFOSABI_SYSV 0 /* Alias. */ -#define ELFOSABI_HPUX 1 /* HP-UX */ -#define ELFOSABI_NETBSD 2 /* NetBSD. */ -#define ELFOSABI_LINUX 3 /* Linux. */ -#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */ -#define ELFOSABI_AIX 7 /* IBM AIX. */ -#define ELFOSABI_IRIX 8 /* SGI Irix. */ -#define ELFOSABI_FREEBSD 9 /* FreeBSD. */ -#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */ -#define ELFOSABI_MODESTO 11 /* Novell Modesto. */ -#define ELFOSABI_OPENBSD 12 /* OpenBSD. */ -#define ELFOSABI_ARM 97 /* ARM */ -#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ - -#define EI_ABIVERSION 8 /* ABI version */ - -#define EI_PAD 9 /* Byte index of padding bytes */ - -/* Legal values for e_type (object file type). */ - -#define ET_NONE 0 /* No file type */ -#define ET_REL 1 /* Relocatable file */ -#define ET_EXEC 2 /* Executable file */ -#define ET_DYN 3 /* Shared object file */ -#define ET_CORE 4 /* Core file */ -#define ET_NUM 5 /* Number of defined types */ -#define ET_LOOS 0xfe00 /* OS-specific range start */ -#define ET_HIOS 0xfeff /* OS-specific range end */ -#define ET_LOPROC 0xff00 /* Processor-specific range start */ -#define ET_HIPROC 0xffff /* Processor-specific range end */ - -/* Legal values for e_machine (architecture). */ - -#define EM_NONE 0 /* No machine */ -#define EM_M32 1 /* AT&T WE 32100 */ -#define EM_SPARC 2 /* SUN SPARC */ -#define EM_386 3 /* Intel 80386 */ -#define EM_68K 4 /* Motorola m68k family */ -#define EM_88K 5 /* Motorola m88k family */ -#define EM_860 7 /* Intel 80860 */ -#define EM_MIPS 8 /* MIPS R3000 big-endian */ -#define EM_S370 9 /* IBM System/370 */ -#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ - -#define EM_PARISC 15 /* HPPA */ -#define EM_VPP500 17 /* Fujitsu VPP500 */ -#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ -#define EM_960 19 /* Intel 80960 */ -#define EM_PPC 20 /* PowerPC */ -#define EM_PPC64 21 /* PowerPC 64-bit */ -#define EM_S390 22 /* IBM S390 */ - -#define EM_V800 36 /* NEC V800 series */ -#define EM_FR20 37 /* Fujitsu FR20 */ -#define EM_RH32 38 /* TRW RH-32 */ -#define EM_RCE 39 /* Motorola RCE */ -#define EM_ARM 40 /* ARM */ -#define EM_FAKE_ALPHA 41 /* Digital Alpha */ -#define EM_SH 42 /* Hitachi SH */ -#define EM_SPARCV9 43 /* SPARC v9 64-bit */ -#define EM_TRICORE 44 /* Siemens Tricore */ -#define EM_ARC 45 /* Argonaut RISC Core */ -#define EM_H8_300 46 /* Hitachi H8/300 */ -#define EM_H8_300H 47 /* Hitachi H8/300H */ -#define EM_H8S 48 /* Hitachi H8S */ -#define EM_H8_500 49 /* Hitachi H8/500 */ -#define EM_IA_64 50 /* Intel Merced */ -#define EM_MIPS_X 51 /* Stanford MIPS-X */ -#define EM_COLDFIRE 52 /* Motorola Coldfire */ -#define EM_68HC12 53 /* Motorola M68HC12 */ -#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ -#define EM_PCP 55 /* Siemens PCP */ -#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ -#define EM_NDR1 57 /* Denso NDR1 microprocessor */ -#define EM_STARCORE 58 /* Motorola Start*Core processor */ -#define EM_ME16 59 /* Toyota ME16 processor */ -#define EM_ST100 60 /* STMicroelectronic ST100 processor */ -#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ -#define EM_X86_64 62 /* AMD x86-64 architecture */ -#define EM_PDSP 63 /* Sony DSP Processor */ - -#define EM_FX66 66 /* Siemens FX66 microcontroller */ -#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ -#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ -#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ -#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ -#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ -#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ -#define EM_SVX 73 /* Silicon Graphics SVx */ -#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ -#define EM_VAX 75 /* Digital VAX */ -#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ -#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ -#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ -#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ -#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ -#define EM_HUANY 81 /* Harvard University machine-independent object files */ -#define EM_PRISM 82 /* SiTera Prism */ -#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ -#define EM_FR30 84 /* Fujitsu FR30 */ -#define EM_D10V 85 /* Mitsubishi D10V */ -#define EM_D30V 86 /* Mitsubishi D30V */ -#define EM_V850 87 /* NEC v850 */ -#define EM_M32R 88 /* Mitsubishi M32R */ -#define EM_MN10300 89 /* Matsushita MN10300 */ -#define EM_MN10200 90 /* Matsushita MN10200 */ -#define EM_PJ 91 /* picoJava */ -#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ -#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ -#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ -#define EM_NUM 95 - -/* If it is necessary to assign new unofficial EM_* values, please - pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the - chances of collision with official or non-GNU unofficial values. */ - -#define EM_ALPHA 0x9026 - -/* Legal values for e_version (version). */ - -#define EV_NONE 0 /* Invalid ELF version */ -#define EV_CURRENT 1 /* Current version */ -#define EV_NUM 2 - -/* Section header. */ - -typedef struct -{ - Elf32_Word sh_name; /* Section name (string tbl index) */ - Elf32_Word sh_type; /* Section type */ - Elf32_Word sh_flags; /* Section flags */ - Elf32_Addr sh_addr; /* Section virtual addr at execution */ - Elf32_Off sh_offset; /* Section file offset */ - Elf32_Word sh_size; /* Section size in bytes */ - Elf32_Word sh_link; /* Link to another section */ - Elf32_Word sh_info; /* Additional section information */ - Elf32_Word sh_addralign; /* Section alignment */ - Elf32_Word sh_entsize; /* Entry size if section holds table */ -} Elf32_Shdr; - -typedef struct -{ - Elf64_Word sh_name; /* Section name (string tbl index) */ - Elf64_Word sh_type; /* Section type */ - Elf64_Xword sh_flags; /* Section flags */ - Elf64_Addr sh_addr; /* Section virtual addr at execution */ - Elf64_Off sh_offset; /* Section file offset */ - Elf64_Xword sh_size; /* Section size in bytes */ - Elf64_Word sh_link; /* Link to another section */ - Elf64_Word sh_info; /* Additional section information */ - Elf64_Xword sh_addralign; /* Section alignment */ - Elf64_Xword sh_entsize; /* Entry size if section holds table */ -} Elf64_Shdr; - -/* Special section indices. */ - -#define SHN_UNDEF 0 /* Undefined section */ -#define SHN_LORESERVE 0xff00 /* Start of reserved indices */ -#define SHN_LOPROC 0xff00 /* Start of processor-specific */ -#define SHN_HIPROC 0xff1f /* End of processor-specific */ -#define SHN_LOOS 0xff20 /* Start of OS-specific */ -#define SHN_HIOS 0xff3f /* End of OS-specific */ -#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ -#define SHN_COMMON 0xfff2 /* Associated symbol is common */ -#define SHN_XINDEX 0xffff /* Index is in extra table. */ -#define SHN_HIRESERVE 0xffff /* End of reserved indices */ - -/* Legal values for sh_type (section type). */ - -#define SHT_NULL 0 /* Section header table entry unused */ -#define SHT_PROGBITS 1 /* Program data */ -#define SHT_SYMTAB 2 /* Symbol table */ -#define SHT_STRTAB 3 /* String table */ -#define SHT_RELA 4 /* Relocation entries with addends */ -#define SHT_HASH 5 /* Symbol hash table */ -#define SHT_DYNAMIC 6 /* Dynamic linking information */ -#define SHT_NOTE 7 /* Notes */ -#define SHT_NOBITS 8 /* Program space with no data (bss) */ -#define SHT_REL 9 /* Relocation entries, no addends */ -#define SHT_SHLIB 10 /* Reserved */ -#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ -#define SHT_INIT_ARRAY 14 /* Array of constructors */ -#define SHT_FINI_ARRAY 15 /* Array of destructors */ -#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ -#define SHT_GROUP 17 /* Section group */ -#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ -#define SHT_NUM 19 /* Number of defined types. */ -#define SHT_LOOS 0x60000000 /* Start OS-specific */ -#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ -#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ -#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ -#define SHT_SUNW_move 0x6ffffffa -#define SHT_SUNW_COMDAT 0x6ffffffb -#define SHT_SUNW_syminfo 0x6ffffffc -#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ -#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ -#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ -#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ -#define SHT_HIOS 0x6fffffff /* End OS-specific type */ -#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ -#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ -#define SHT_LOUSER 0x80000000 /* Start of application-specific */ -#define SHT_HIUSER 0x8fffffff /* End of application-specific */ - -/* Legal values for sh_flags (section flags). */ - -#define SHF_WRITE (1 << 0) /* Writable */ -#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ -#define SHF_EXECINSTR (1 << 2) /* Executable */ -#define SHF_MERGE (1 << 4) /* Might be merged */ -#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ -#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ -#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ -#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling - required */ -#define SHF_GROUP (1 << 9) /* Section is member of a group. */ -#define SHF_TLS (1 << 10) /* Section hold thread-local data. */ -#define SHF_MASKOS 0x0ff00000 /* OS-specific. */ -#define SHF_MASKPROC 0xf0000000 /* Processor-specific */ - -/* Section group handling. */ -#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ - -/* Symbol table entry. */ - -typedef struct -{ - Elf32_Word st_name; /* Symbol name (string tbl index) */ - Elf32_Addr st_value; /* Symbol value */ - Elf32_Word st_size; /* Symbol size */ - unsigned char st_info; /* Symbol type and binding */ - unsigned char st_other; /* Symbol visibility */ - Elf32_Section st_shndx; /* Section index */ -} Elf32_Sym; - -typedef struct -{ - Elf64_Word st_name; /* Symbol name (string tbl index) */ - unsigned char st_info; /* Symbol type and binding */ - unsigned char st_other; /* Symbol visibility */ - Elf64_Section st_shndx; /* Section index */ - Elf64_Addr st_value; /* Symbol value */ - Elf64_Xword st_size; /* Symbol size */ -} Elf64_Sym; - -/* The syminfo section if available contains additional information about - every dynamic symbol. */ - -typedef struct -{ - Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ - Elf32_Half si_flags; /* Per symbol flags */ -} Elf32_Syminfo; - -typedef struct -{ - Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ - Elf64_Half si_flags; /* Per symbol flags */ -} Elf64_Syminfo; - -/* Possible values for si_boundto. */ -#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */ -#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */ -#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */ - -/* Possible bitmasks for si_flags. */ -#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */ -#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */ -#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */ -#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy - loaded */ -/* Syminfo version values. */ -#define SYMINFO_NONE 0 -#define SYMINFO_CURRENT 1 -#define SYMINFO_NUM 2 - - -/* How to extract and insert information held in the st_info field. */ - -#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) -#define ELF32_ST_TYPE(val) ((val) & 0xf) -#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) - -/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ -#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) -#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) -#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) - -/* Legal values for ST_BIND subfield of st_info (symbol binding). */ - -#define STB_LOCAL 0 /* Local symbol */ -#define STB_GLOBAL 1 /* Global symbol */ -#define STB_WEAK 2 /* Weak symbol */ -#define STB_NUM 3 /* Number of defined types. */ -#define STB_LOOS 10 /* Start of OS-specific */ -#define STB_HIOS 12 /* End of OS-specific */ -#define STB_LOPROC 13 /* Start of processor-specific */ -#define STB_HIPROC 15 /* End of processor-specific */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_NOTYPE 0 /* Symbol type is unspecified */ -#define STT_OBJECT 1 /* Symbol is a data object */ -#define STT_FUNC 2 /* Symbol is a code object */ -#define STT_SECTION 3 /* Symbol associated with a section */ -#define STT_FILE 4 /* Symbol's name is file name */ -#define STT_COMMON 5 /* Symbol is a common data object */ -#define STT_TLS 6 /* Symbol is thread-local data object*/ -#define STT_NUM 7 /* Number of defined types. */ -#define STT_LOOS 10 /* Start of OS-specific */ -#define STT_HIOS 12 /* End of OS-specific */ -#define STT_LOPROC 13 /* Start of processor-specific */ -#define STT_HIPROC 15 /* End of processor-specific */ - - -/* Symbol table indices are found in the hash buckets and chain table - of a symbol hash table section. This special index value indicates - the end of a chain, meaning no further symbols are found in that bucket. */ - -#define STN_UNDEF 0 /* End of a chain. */ - - -/* How to extract and insert information held in the st_other field. */ - -#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) - -/* For ELF64 the definitions are the same. */ -#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) - -/* Symbol visibility specification encoded in the st_other field. */ -#define STV_DEFAULT 0 /* Default symbol visibility rules */ -#define STV_INTERNAL 1 /* Processor specific hidden class */ -#define STV_HIDDEN 2 /* Sym unavailable in other modules */ -#define STV_PROTECTED 3 /* Not preemptible, not exported */ - - -/* Relocation table entry without addend (in section of type SHT_REL). */ - -typedef struct -{ - Elf32_Addr r_offset; /* Address */ - Elf32_Word r_info; /* Relocation type and symbol index */ -} Elf32_Rel; - -/* I have seen two different definitions of the Elf64_Rel and - Elf64_Rela structures, so we'll leave them out until Novell (or - whoever) gets their act together. */ -/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ - -typedef struct -{ - Elf64_Addr r_offset; /* Address */ - Elf64_Xword r_info; /* Relocation type and symbol index */ -} Elf64_Rel; - -/* Relocation table entry with addend (in section of type SHT_RELA). */ - -typedef struct -{ - Elf32_Addr r_offset; /* Address */ - Elf32_Word r_info; /* Relocation type and symbol index */ - Elf32_Sword r_addend; /* Addend */ -} Elf32_Rela; - -typedef struct -{ - Elf64_Addr r_offset; /* Address */ - Elf64_Xword r_info; /* Relocation type and symbol index */ - Elf64_Sxword r_addend; /* Addend */ -} Elf64_Rela; - -/* How to extract and insert information held in the r_info field. */ - -#define ELF32_R_SYM(val) ((val) >> 8) -#define ELF32_R_TYPE(val) ((val) & 0xff) -#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) - -#define ELF64_R_SYM(i) ((i) >> 32) -#define ELF64_R_TYPE(i) ((i) & 0xffffffff) -#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) - -/* Program segment header. */ - -typedef struct -{ - Elf32_Word p_type; /* Segment type */ - Elf32_Off p_offset; /* Segment file offset */ - Elf32_Addr p_vaddr; /* Segment virtual address */ - Elf32_Addr p_paddr; /* Segment physical address */ - Elf32_Word p_filesz; /* Segment size in file */ - Elf32_Word p_memsz; /* Segment size in memory */ - Elf32_Word p_flags; /* Segment flags */ - Elf32_Word p_align; /* Segment alignment */ -} Elf32_Phdr; - -typedef struct -{ - Elf64_Word p_type; /* Segment type */ - Elf64_Word p_flags; /* Segment flags */ - Elf64_Off p_offset; /* Segment file offset */ - Elf64_Addr p_vaddr; /* Segment virtual address */ - Elf64_Addr p_paddr; /* Segment physical address */ - Elf64_Xword p_filesz; /* Segment size in file */ - Elf64_Xword p_memsz; /* Segment size in memory */ - Elf64_Xword p_align; /* Segment alignment */ -} Elf64_Phdr; - -/* Legal values for p_type (segment type). */ - -#define PT_NULL 0 /* Program header table entry unused */ -#define PT_LOAD 1 /* Loadable program segment */ -#define PT_DYNAMIC 2 /* Dynamic linking information */ -#define PT_INTERP 3 /* Program interpreter */ -#define PT_NOTE 4 /* Auxiliary information */ -#define PT_SHLIB 5 /* Reserved */ -#define PT_PHDR 6 /* Entry for header table itself */ -#define PT_TLS 7 /* Thread-local storage segment */ -#define PT_NUM 8 /* Number of defined types */ -#define PT_LOOS 0x60000000 /* Start of OS-specific */ -#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */ -#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ -#define PT_LOSUNW 0x6ffffffa -#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ -#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */ -#define PT_HISUNW 0x6fffffff -#define PT_HIOS 0x6fffffff /* End of OS-specific */ -#define PT_LOPROC 0x70000000 /* Start of processor-specific */ -#define PT_HIPROC 0x7fffffff /* End of processor-specific */ - -/* Legal values for p_flags (segment flags). */ - -#define PF_X (1 << 0) /* Segment is executable */ -#define PF_W (1 << 1) /* Segment is writable */ -#define PF_R (1 << 2) /* Segment is readable */ -#define PF_MASKOS 0x0ff00000 /* OS-specific */ -#define PF_MASKPROC 0xf0000000 /* Processor-specific */ - -/* Legal values for note segment descriptor types for core files. */ - -#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ -#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ -#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ -#define NT_PRXREG 4 /* Contains copy of prxregset struct */ -#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ -#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ -#define NT_AUXV 6 /* Contains copy of auxv array */ -#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ -#define NT_ASRS 8 /* Contains copy of asrset struct */ -#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ -#define NT_PSINFO 13 /* Contains copy of psinfo struct */ -#define NT_PRCRED 14 /* Contains copy of prcred struct */ -#define NT_UTSNAME 15 /* Contains copy of utsname struct */ -#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ -#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ -#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/ - -/* Legal values for the note segment descriptor types for object files. */ - -#define NT_VERSION 1 /* Contains a version string. */ - - -/* Dynamic section entry. */ - -typedef struct -{ - Elf32_Sword d_tag; /* Dynamic entry type */ - union - { - Elf32_Word d_val; /* Integer value */ - Elf32_Addr d_ptr; /* Address value */ - } d_un; -} Elf32_Dyn; - -typedef struct -{ - Elf64_Sxword d_tag; /* Dynamic entry type */ - union - { - Elf64_Xword d_val; /* Integer value */ - Elf64_Addr d_ptr; /* Address value */ - } d_un; -} Elf64_Dyn; - -/* Legal values for d_tag (dynamic entry type). */ - -#define DT_NULL 0 /* Marks end of dynamic section */ -#define DT_NEEDED 1 /* Name of needed library */ -#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ -#define DT_PLTGOT 3 /* Processor defined value */ -#define DT_HASH 4 /* Address of symbol hash table */ -#define DT_STRTAB 5 /* Address of string table */ -#define DT_SYMTAB 6 /* Address of symbol table */ -#define DT_RELA 7 /* Address of Rela relocs */ -#define DT_RELASZ 8 /* Total size of Rela relocs */ -#define DT_RELAENT 9 /* Size of one Rela reloc */ -#define DT_STRSZ 10 /* Size of string table */ -#define DT_SYMENT 11 /* Size of one symbol table entry */ -#define DT_INIT 12 /* Address of init function */ -#define DT_FINI 13 /* Address of termination function */ -#define DT_SONAME 14 /* Name of shared object */ -#define DT_RPATH 15 /* Library search path (deprecated) */ -#define DT_SYMBOLIC 16 /* Start symbol search here */ -#define DT_REL 17 /* Address of Rel relocs */ -#define DT_RELSZ 18 /* Total size of Rel relocs */ -#define DT_RELENT 19 /* Size of one Rel reloc */ -#define DT_PLTREL 20 /* Type of reloc in PLT */ -#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_BIND_NOW 24 /* Process relocations of object */ -#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ -#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ -#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ -#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ -#define DT_RUNPATH 29 /* Library search path */ -#define DT_FLAGS 30 /* Flags for the object being loaded */ -#define DT_ENCODING 32 /* Start of encoded range */ -#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ -#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ -#define DT_NUM 34 /* Number used */ -#define DT_LOOS 0x6000000d /* Start of OS-specific */ -#define DT_HIOS 0x6ffff000 /* End of OS-specific */ -#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 */ - -/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the - Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's - approach. */ -#define DT_VALRNGLO 0x6ffffd00 -#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */ -#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */ -#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */ -#define DT_CHECKSUM 0x6ffffdf8 -#define DT_PLTPADSZ 0x6ffffdf9 -#define DT_MOVEENT 0x6ffffdfa -#define DT_MOVESZ 0x6ffffdfb -#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ -#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting - the following DT_* entry. */ -#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ -#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ -#define DT_VALRNGHI 0x6ffffdff -#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */ -#define DT_VALNUM 12 - -/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the - Dyn.d_un.d_ptr field of the Elf*_Dyn structure. - - If any adjustment is made to the ELF object after it has been - built these entries will need to be adjusted. */ -#define DT_ADDRRNGLO 0x6ffffe00 -#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */ -#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */ -#define DT_CONFIG 0x6ffffefa /* Configuration information. */ -#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ -#define DT_AUDIT 0x6ffffefc /* Object auditing. */ -#define DT_PLTPAD 0x6ffffefd /* PLT padding. */ -#define DT_MOVETAB 0x6ffffefe /* Move table. */ -#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */ -#define DT_ADDRRNGHI 0x6ffffeff -#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ -#define DT_ADDRNUM 10 - -/* The versioning entry types. The next are defined as part of the - GNU extension. */ -#define DT_VERSYM 0x6ffffff0 - -#define DT_RELACOUNT 0x6ffffff9 -#define DT_RELCOUNT 0x6ffffffa - -/* These were chosen by Sun. */ -#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ -#define DT_VERDEF 0x6ffffffc /* Address of version definition - table */ -#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ -#define DT_VERNEED 0x6ffffffe /* Address of table with needed - versions */ -#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ -#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ -#define DT_VERSIONTAGNUM 16 - -/* Sun added these machine-independent extensions in the "processor-specific" - range. Be compatible. */ -#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ -#define DT_FILTER 0x7fffffff /* Shared object to get values from */ -#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) -#define DT_EXTRANUM 3 - -/* Values of `d_un.d_val' in the DT_FLAGS entry. */ -#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ -#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ -#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ -#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ -#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */ - -/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 - entry in the dynamic section. */ -#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ -#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ -#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ -#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ -#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ -#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ -#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ -#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ -#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ -#define DF_1_TRANS 0x00000200 -#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ -#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ -#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ -#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/ -#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ -#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ -#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ - -/* Flags for the feature selection in DT_FEATURE_1. */ -#define DTF_1_PARINIT 0x00000001 -#define DTF_1_CONFEXP 0x00000002 - -/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ -#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ -#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not - generally available. */ - -/* Version definition sections. */ - -typedef struct -{ - Elf32_Half vd_version; /* Version revision */ - Elf32_Half vd_flags; /* Version information */ - Elf32_Half vd_ndx; /* Version Index */ - Elf32_Half vd_cnt; /* Number of associated aux entries */ - Elf32_Word vd_hash; /* Version name hash value */ - Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf32_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf32_Verdef; - -typedef struct -{ - Elf64_Half vd_version; /* Version revision */ - Elf64_Half vd_flags; /* Version information */ - Elf64_Half vd_ndx; /* Version Index */ - Elf64_Half vd_cnt; /* Number of associated aux entries */ - Elf64_Word vd_hash; /* Version name hash value */ - Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf64_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf64_Verdef; - - -/* Legal values for vd_version (version revision). */ -#define VER_DEF_NONE 0 /* No version */ -#define VER_DEF_CURRENT 1 /* Current version */ -#define VER_DEF_NUM 2 /* Given version number */ - -/* Legal values for vd_flags (version information flags). */ -#define VER_FLG_BASE 0x1 /* Version definition of file itself */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - -/* Versym symbol index values. */ -#define VER_NDX_LOCAL 0 /* Symbol is local. */ -#define VER_NDX_GLOBAL 1 /* Symbol is global. */ -#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ -#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ - -/* Auxialiary version information. */ - -typedef struct -{ - Elf32_Word vda_name; /* Version or dependency names */ - Elf32_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf32_Verdaux; - -typedef struct -{ - Elf64_Word vda_name; /* Version or dependency names */ - Elf64_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf64_Verdaux; - - -/* Version dependency section. */ - -typedef struct -{ - Elf32_Half vn_version; /* Version of structure */ - Elf32_Half vn_cnt; /* Number of associated aux entries */ - Elf32_Word vn_file; /* Offset of filename for this - dependency */ - Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf32_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf32_Verneed; - -typedef struct -{ - Elf64_Half vn_version; /* Version of structure */ - Elf64_Half vn_cnt; /* Number of associated aux entries */ - Elf64_Word vn_file; /* Offset of filename for this - dependency */ - Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf64_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf64_Verneed; - - -/* Legal values for vn_version (version revision). */ -#define VER_NEED_NONE 0 /* No version */ -#define VER_NEED_CURRENT 1 /* Current version */ -#define VER_NEED_NUM 2 /* Given version number */ - -/* Auxiliary needed version information. */ - -typedef struct -{ - Elf32_Word vna_hash; /* Hash value of dependency name */ - Elf32_Half vna_flags; /* Dependency specific information */ - Elf32_Half vna_other; /* Unused */ - Elf32_Word vna_name; /* Dependency name string offset */ - Elf32_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf32_Vernaux; - -typedef struct -{ - Elf64_Word vna_hash; /* Hash value of dependency name */ - Elf64_Half vna_flags; /* Dependency specific information */ - Elf64_Half vna_other; /* Unused */ - Elf64_Word vna_name; /* Dependency name string offset */ - Elf64_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf64_Vernaux; - - -/* Legal values for vna_flags. */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - - -/* Auxiliary vector. */ - -/* This vector is normally only used by the program interpreter. The - usual definition in an ABI supplement uses the name auxv_t. The - vector is not usually defined in a standard <elf.h> file, but it - can't hurt. We rename it to avoid conflicts. The sizes of these - types are an arrangement between the exec server and the program - interpreter, so we don't fully specify them here. */ - -typedef struct -{ - int a_type; /* Entry type */ - union - { - long int a_val; /* Integer value */ - void *a_ptr; /* Pointer value */ - void (*a_fcn) (void); /* Function pointer value */ - } a_un; -} Elf32_auxv_t; - -typedef struct -{ - long int a_type; /* Entry type */ - union - { - long int a_val; /* Integer value */ - void *a_ptr; /* Pointer value */ - void (*a_fcn) (void); /* Function pointer value */ - } a_un; -} Elf64_auxv_t; - -/* Legal values for a_type (entry type). */ - -#define AT_NULL 0 /* End of vector */ -#define AT_IGNORE 1 /* Entry should be ignored */ -#define AT_EXECFD 2 /* File descriptor of program */ -#define AT_PHDR 3 /* Program headers for program */ -#define AT_PHENT 4 /* Size of program header entry */ -#define AT_PHNUM 5 /* Number of program headers */ -#define AT_PAGESZ 6 /* System page size */ -#define AT_BASE 7 /* Base address of interpreter */ -#define AT_FLAGS 8 /* Flags */ -#define AT_ENTRY 9 /* Entry point of program */ -#define AT_NOTELF 10 /* Program is not ELF */ -#define AT_UID 11 /* Real uid */ -#define AT_EUID 12 /* Effective uid */ -#define AT_GID 13 /* Real gid */ -#define AT_EGID 14 /* Effective gid */ -#define AT_CLKTCK 17 /* Frequency of times() */ - -/* Some more special a_type values describing the hardware. */ -#define AT_PLATFORM 15 /* String identifying platform. */ -#define AT_HWCAP 16 /* Machine dependent hints about - processor capabilities. */ - -/* This entry gives some information about the FPU initialization - performed by the kernel. */ -#define AT_FPUCW 18 /* Used FPU control word. */ - -/* Cache block sizes. */ -#define AT_DCACHEBSIZE 19 /* Data cache block size. */ -#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */ -#define AT_UCACHEBSIZE 21 /* Unified cache block size. */ - -/* A special ignored value for PPC, used by the kernel to control the - interpretation of the AUXV. Must be > 16. */ -#define AT_IGNOREPPC 22 /* Entry should be ignored. */ - -#define AT_SECURE 23 /* Boolean, was exec setuid-like? */ - -/* Pointer to the global system page used for system calls and other - nice things. */ -#define AT_SYSINFO 32 -#define AT_SYSINFO_EHDR 33 - - -/* Note section contents. Each entry in the note section begins with - a header of a fixed form. */ - -typedef struct -{ - Elf32_Word n_namesz; /* Length of the note's name. */ - Elf32_Word n_descsz; /* Length of the note's descriptor. */ - Elf32_Word n_type; /* Type of the note. */ -} Elf32_Nhdr; - -typedef struct -{ - Elf64_Word n_namesz; /* Length of the note's name. */ - Elf64_Word n_descsz; /* Length of the note's descriptor. */ - Elf64_Word n_type; /* Type of the note. */ -} Elf64_Nhdr; - -/* Known names of notes. */ - -/* Solaris entries in the note section have this name. */ -#define ELF_NOTE_SOLARIS "SUNW Solaris" - -/* Note entries for GNU systems have this name. */ -#define ELF_NOTE_GNU "GNU" - - -/* Defined types of notes for Solaris. */ - -/* Value of descriptor (one word) is desired pagesize for the binary. */ -#define ELF_NOTE_PAGESIZE_HINT 1 - - -/* Defined note types for GNU systems. */ - -/* ABI information. The descriptor consists of words: - word 0: OS descriptor - word 1: major version of the ABI - word 2: minor version of the ABI - word 3: subminor version of the ABI -*/ -#define ELF_NOTE_ABI 1 - -/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI - note section entry. */ -#define ELF_NOTE_OS_LINUX 0 -#define ELF_NOTE_OS_GNU 1 -#define ELF_NOTE_OS_SOLARIS2 2 -#define ELF_NOTE_OS_FREEBSD 3 - - -/* Move records. */ -typedef struct -{ - Elf32_Xword m_value; /* Symbol value. */ - Elf32_Word m_info; /* Size and index. */ - Elf32_Word m_poffset; /* Symbol offset. */ - Elf32_Half m_repeat; /* Repeat count. */ - Elf32_Half m_stride; /* Stride info. */ -} Elf32_Move; - -typedef struct -{ - Elf64_Xword m_value; /* Symbol value. */ - Elf64_Xword m_info; /* Size and index. */ - Elf64_Xword m_poffset; /* Symbol offset. */ - Elf64_Half m_repeat; /* Repeat count. */ - Elf64_Half m_stride; /* Stride info. */ -} Elf64_Move; - -/* Macro to construct move records. */ -#define ELF32_M_SYM(info) ((info) >> 8) -#define ELF32_M_SIZE(info) ((unsigned char) (info)) -#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) - -#define ELF64_M_SYM(info) ELF32_M_SYM (info) -#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) -#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) - - -/* Motorola 68k specific definitions. */ - -/* Values for Elf32_Ehdr.e_flags. */ -#define EF_CPU32 0x00810000 - -/* m68k relocs. */ - -#define R_68K_NONE 0 /* No reloc */ -#define R_68K_32 1 /* Direct 32 bit */ -#define R_68K_16 2 /* Direct 16 bit */ -#define R_68K_8 3 /* Direct 8 bit */ -#define R_68K_PC32 4 /* PC relative 32 bit */ -#define R_68K_PC16 5 /* PC relative 16 bit */ -#define R_68K_PC8 6 /* PC relative 8 bit */ -#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ -#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ -#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ -#define R_68K_GOT32O 10 /* 32 bit GOT offset */ -#define R_68K_GOT16O 11 /* 16 bit GOT offset */ -#define R_68K_GOT8O 12 /* 8 bit GOT offset */ -#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ -#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ -#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ -#define R_68K_PLT32O 16 /* 32 bit PLT offset */ -#define R_68K_PLT16O 17 /* 16 bit PLT offset */ -#define R_68K_PLT8O 18 /* 8 bit PLT offset */ -#define R_68K_COPY 19 /* Copy symbol at runtime */ -#define R_68K_GLOB_DAT 20 /* Create GOT entry */ -#define R_68K_JMP_SLOT 21 /* Create PLT entry */ -#define R_68K_RELATIVE 22 /* Adjust by program base */ -/* Keep this the last entry. */ -#define R_68K_NUM 23 - -/* Intel 80386 specific definitions. */ - -/* i386 relocs. */ - -#define R_386_NONE 0 /* No reloc */ -#define R_386_32 1 /* Direct 32 bit */ -#define R_386_PC32 2 /* PC relative 32 bit */ -#define R_386_GOT32 3 /* 32 bit GOT entry */ -#define R_386_PLT32 4 /* 32 bit PLT address */ -#define R_386_COPY 5 /* Copy symbol at runtime */ -#define R_386_GLOB_DAT 6 /* Create GOT entry */ -#define R_386_JMP_SLOT 7 /* Create PLT entry */ -#define R_386_RELATIVE 8 /* Adjust by program base */ -#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ -#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ -#define R_386_32PLT 11 -#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */ -#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS - block offset */ -#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block - offset */ -#define R_386_TLS_LE 17 /* Offset relative to static TLS - block */ -#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of - general dynamic thread local data */ -#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of - local dynamic thread local data - in LE code */ -#define R_386_16 20 -#define R_386_PC16 21 -#define R_386_8 22 -#define R_386_PC8 23 -#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic - thread local data */ -#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */ -#define R_386_TLS_GD_CALL 26 /* Relocation for call to - __tls_get_addr() */ -#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */ -#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic - thread local data in LE code */ -#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */ -#define R_386_TLS_LDM_CALL 30 /* Relocation for call to - __tls_get_addr() in LDM code */ -#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */ -#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */ -#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS - block offset */ -#define R_386_TLS_LE_32 34 /* Negated offset relative to static - TLS block */ -#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */ -#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */ -#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */ -/* Keep this the last entry. */ -#define R_386_NUM 38 - -/* SUN SPARC specific definitions. */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_REGISTER 13 /* Global register reserved to app. */ - -/* Values for Elf64_Ehdr.e_flags. */ - -#define EF_SPARCV9_MM 3 -#define EF_SPARCV9_TSO 0 -#define EF_SPARCV9_PSO 1 -#define EF_SPARCV9_RMO 2 -#define EF_SPARC_LEDATA 0x800000 /* little endian data */ -#define EF_SPARC_EXT_MASK 0xFFFF00 -#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ -#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ -#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ -#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ - -/* SPARC relocs. */ - -#define R_SPARC_NONE 0 /* No reloc */ -#define R_SPARC_8 1 /* Direct 8 bit */ -#define R_SPARC_16 2 /* Direct 16 bit */ -#define R_SPARC_32 3 /* Direct 32 bit */ -#define R_SPARC_DISP8 4 /* PC relative 8 bit */ -#define R_SPARC_DISP16 5 /* PC relative 16 bit */ -#define R_SPARC_DISP32 6 /* PC relative 32 bit */ -#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ -#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ -#define R_SPARC_HI22 9 /* High 22 bit */ -#define R_SPARC_22 10 /* Direct 22 bit */ -#define R_SPARC_13 11 /* Direct 13 bit */ -#define R_SPARC_LO10 12 /* Truncated 10 bit */ -#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ -#define R_SPARC_GOT13 14 /* 13 bit GOT entry */ -#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ -#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ -#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ -#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ -#define R_SPARC_COPY 19 /* Copy symbol at runtime */ -#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ -#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ -#define R_SPARC_RELATIVE 22 /* Adjust by program base */ -#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ - -/* Additional Sparc64 relocs. */ - -#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */ -#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */ -#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */ -#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */ -#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */ -#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */ -#define R_SPARC_10 30 /* Direct 10 bit */ -#define R_SPARC_11 31 /* Direct 11 bit */ -#define R_SPARC_64 32 /* Direct 64 bit */ -#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */ -#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */ -#define R_SPARC_HM10 35 /* High middle 10 bits of ... */ -#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */ -#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */ -#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */ -#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */ -#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */ -#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */ -#define R_SPARC_7 43 /* Direct 7 bit */ -#define R_SPARC_5 44 /* Direct 5 bit */ -#define R_SPARC_6 45 /* Direct 6 bit */ -#define R_SPARC_DISP64 46 /* PC relative 64 bit */ -#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */ -#define R_SPARC_HIX22 48 /* High 22 bit complemented */ -#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */ -#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */ -#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */ -#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */ -#define R_SPARC_REGISTER 53 /* Global register usage */ -#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */ -#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */ -#define R_SPARC_TLS_GD_HI22 56 -#define R_SPARC_TLS_GD_LO10 57 -#define R_SPARC_TLS_GD_ADD 58 -#define R_SPARC_TLS_GD_CALL 59 -#define R_SPARC_TLS_LDM_HI22 60 -#define R_SPARC_TLS_LDM_LO10 61 -#define R_SPARC_TLS_LDM_ADD 62 -#define R_SPARC_TLS_LDM_CALL 63 -#define R_SPARC_TLS_LDO_HIX22 64 -#define R_SPARC_TLS_LDO_LOX10 65 -#define R_SPARC_TLS_LDO_ADD 66 -#define R_SPARC_TLS_IE_HI22 67 -#define R_SPARC_TLS_IE_LO10 68 -#define R_SPARC_TLS_IE_LD 69 -#define R_SPARC_TLS_IE_LDX 70 -#define R_SPARC_TLS_IE_ADD 71 -#define R_SPARC_TLS_LE_HIX22 72 -#define R_SPARC_TLS_LE_LOX10 73 -#define R_SPARC_TLS_DTPMOD32 74 -#define R_SPARC_TLS_DTPMOD64 75 -#define R_SPARC_TLS_DTPOFF32 76 -#define R_SPARC_TLS_DTPOFF64 77 -#define R_SPARC_TLS_TPOFF32 78 -#define R_SPARC_TLS_TPOFF64 79 -/* Keep this the last entry. */ -#define R_SPARC_NUM 80 - -/* For Sparc64, legal values for d_tag of Elf64_Dyn. */ - -#define DT_SPARC_REGISTER 0x70000001 -#define DT_SPARC_NUM 2 - -/* Bits present in AT_HWCAP, primarily for Sparc32. */ - -#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */ -#define HWCAP_SPARC_STBAR 2 -#define HWCAP_SPARC_SWAP 4 -#define HWCAP_SPARC_MULDIV 8 -#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */ -#define HWCAP_SPARC_ULTRA3 32 - -/* MIPS R3000 specific definitions. */ - -/* Legal values for e_flags field of Elf32_Ehdr. */ - -#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */ -#define EF_MIPS_PIC 2 /* Contains PIC code */ -#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */ -#define EF_MIPS_XGOT 8 -#define EF_MIPS_64BIT_WHIRL 16 -#define EF_MIPS_ABI2 32 -#define EF_MIPS_ABI_ON32 64 -#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */ - -/* Legal values for MIPS architecture level. */ - -#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ -#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ -#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ -#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ -#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ -#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ -#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ - -/* The following are non-official names and should not be used. */ - -#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ -#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ -#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ -#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ -#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ -#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ -#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ - -/* Special section indices. */ - -#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */ -#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ -#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ -#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ -#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ - -/* Legal values for sh_type field of Elf32_Shdr. */ - -#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */ -#define SHT_MIPS_MSYM 0x70000001 -#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */ -#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */ -#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ -#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/ -#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */ -#define SHT_MIPS_PACKAGE 0x70000007 -#define SHT_MIPS_PACKSYM 0x70000008 -#define SHT_MIPS_RELD 0x70000009 -#define SHT_MIPS_IFACE 0x7000000b -#define SHT_MIPS_CONTENT 0x7000000c -#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ -#define SHT_MIPS_SHDR 0x70000010 -#define SHT_MIPS_FDESC 0x70000011 -#define SHT_MIPS_EXTSYM 0x70000012 -#define SHT_MIPS_DENSE 0x70000013 -#define SHT_MIPS_PDESC 0x70000014 -#define SHT_MIPS_LOCSYM 0x70000015 -#define SHT_MIPS_AUXSYM 0x70000016 -#define SHT_MIPS_OPTSYM 0x70000017 -#define SHT_MIPS_LOCSTR 0x70000018 -#define SHT_MIPS_LINE 0x70000019 -#define SHT_MIPS_RFDESC 0x7000001a -#define SHT_MIPS_DELTASYM 0x7000001b -#define SHT_MIPS_DELTAINST 0x7000001c -#define SHT_MIPS_DELTACLASS 0x7000001d -#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ -#define SHT_MIPS_DELTADECL 0x7000001f -#define SHT_MIPS_SYMBOL_LIB 0x70000020 -#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ -#define SHT_MIPS_TRANSLATE 0x70000022 -#define SHT_MIPS_PIXIE 0x70000023 -#define SHT_MIPS_XLATE 0x70000024 -#define SHT_MIPS_XLATE_DEBUG 0x70000025 -#define SHT_MIPS_WHIRL 0x70000026 -#define SHT_MIPS_EH_REGION 0x70000027 -#define SHT_MIPS_XLATE_OLD 0x70000028 -#define SHT_MIPS_PDR_EXCEPTION 0x70000029 - -/* Legal values for sh_flags field of Elf32_Shdr. */ - -#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */ -#define SHF_MIPS_MERGE 0x20000000 -#define SHF_MIPS_ADDR 0x40000000 -#define SHF_MIPS_STRINGS 0x80000000 -#define SHF_MIPS_NOSTRIP 0x08000000 -#define SHF_MIPS_LOCAL 0x04000000 -#define SHF_MIPS_NAMES 0x02000000 -#define SHF_MIPS_NODUPE 0x01000000 - - -/* Symbol tables. */ - -/* MIPS specific values for `st_other'. */ -#define STO_MIPS_DEFAULT 0x0 -#define STO_MIPS_INTERNAL 0x1 -#define STO_MIPS_HIDDEN 0x2 -#define STO_MIPS_PROTECTED 0x3 -#define STO_MIPS_SC_ALIGN_UNUSED 0xff - -/* MIPS specific values for `st_info'. */ -#define STB_MIPS_SPLIT_COMMON 13 - -/* Entries found in sections of type SHT_MIPS_GPTAB. */ - -typedef union -{ - struct - { - Elf32_Word gt_current_g_value; /* -G value used for compilation */ - Elf32_Word gt_unused; /* Not used */ - } gt_header; /* First entry in section */ - struct - { - Elf32_Word gt_g_value; /* If this value were used for -G */ - Elf32_Word gt_bytes; /* This many bytes would be used */ - } gt_entry; /* Subsequent entries in section */ -} Elf32_gptab; - -/* Entry found in sections of type SHT_MIPS_REGINFO. */ - -typedef struct -{ - Elf32_Word ri_gprmask; /* General registers used */ - Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */ - Elf32_Sword ri_gp_value; /* $gp register value */ -} Elf32_RegInfo; - -/* Entries found in sections of type SHT_MIPS_OPTIONS. */ - -typedef struct -{ - unsigned char kind; /* Determines interpretation of the - variable part of descriptor. */ - unsigned char size; /* Size of descriptor, including header. */ - Elf32_Section section; /* Section header index of section affected, - 0 for global options. */ - Elf32_Word info; /* Kind-specific information. */ -} Elf_Options; - -/* Values for `kind' field in Elf_Options. */ - -#define ODK_NULL 0 /* Undefined. */ -#define ODK_REGINFO 1 /* Register usage information. */ -#define ODK_EXCEPTIONS 2 /* Exception processing options. */ -#define ODK_PAD 3 /* Section padding options. */ -#define ODK_HWPATCH 4 /* Hardware workarounds performed */ -#define ODK_FILL 5 /* record the fill value used by the linker. */ -#define ODK_TAGS 6 /* reserve space for desktop tools to write. */ -#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */ -#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */ - -/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */ - -#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */ -#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */ -#define OEX_PAGE0 0x10000 /* page zero must be mapped. */ -#define OEX_SMM 0x20000 /* Force sequential memory mode? */ -#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */ -#define OEX_PRECISEFP OEX_FPDBUG -#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */ - -#define OEX_FPU_INVAL 0x10 -#define OEX_FPU_DIV0 0x08 -#define OEX_FPU_OFLO 0x04 -#define OEX_FPU_UFLO 0x02 -#define OEX_FPU_INEX 0x01 - -/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */ - -#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */ -#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */ -#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */ -#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */ - -#define OPAD_PREFIX 0x1 -#define OPAD_POSTFIX 0x2 -#define OPAD_SYMBOL 0x4 - -/* Entry found in `.options' section. */ - -typedef struct -{ - Elf32_Word hwp_flags1; /* Extra flags. */ - Elf32_Word hwp_flags2; /* Extra flags. */ -} Elf_Options_Hw; - -/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */ - -#define OHWA0_R4KEOP_CHECKED 0x00000001 -#define OHWA1_R4KEOP_CLEAN 0x00000002 - -/* MIPS relocs. */ - -#define R_MIPS_NONE 0 /* No reloc */ -#define R_MIPS_16 1 /* Direct 16 bit */ -#define R_MIPS_32 2 /* Direct 32 bit */ -#define R_MIPS_REL32 3 /* PC relative 32 bit */ -#define R_MIPS_26 4 /* Direct 26 bit shifted */ -#define R_MIPS_HI16 5 /* High 16 bit */ -#define R_MIPS_LO16 6 /* Low 16 bit */ -#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ -#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ -#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ -#define R_MIPS_PC16 10 /* PC relative 16 bit */ -#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ -#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ - -#define R_MIPS_SHIFT5 16 -#define R_MIPS_SHIFT6 17 -#define R_MIPS_64 18 -#define R_MIPS_GOT_DISP 19 -#define R_MIPS_GOT_PAGE 20 -#define R_MIPS_GOT_OFST 21 -#define R_MIPS_GOT_HI16 22 -#define R_MIPS_GOT_LO16 23 -#define R_MIPS_SUB 24 -#define R_MIPS_INSERT_A 25 -#define R_MIPS_INSERT_B 26 -#define R_MIPS_DELETE 27 -#define R_MIPS_HIGHER 28 -#define R_MIPS_HIGHEST 29 -#define R_MIPS_CALL_HI16 30 -#define R_MIPS_CALL_LO16 31 -#define R_MIPS_SCN_DISP 32 -#define R_MIPS_REL16 33 -#define R_MIPS_ADD_IMMEDIATE 34 -#define R_MIPS_PJUMP 35 -#define R_MIPS_RELGOT 36 -#define R_MIPS_JALR 37 -/* Keep this the last entry. */ -#define R_MIPS_NUM 38 - -/* Legal values for p_type field of Elf32_Phdr. */ - -#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */ -#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */ -#define PT_MIPS_OPTIONS 0x70000002 - -/* Special program header types. */ - -#define PF_MIPS_LOCAL 0x10000000 - -/* Legal values for d_tag field of Elf32_Dyn. */ - -#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ -#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ -#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ -#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ -#define DT_MIPS_FLAGS 0x70000005 /* Flags */ -#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ -#define DT_MIPS_MSYM 0x70000007 -#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ -#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ -#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ -#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ -#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ -#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ -#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_RLD_MAP 0x70000016 /* Address of run time loader map. */ -#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ -#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in - DT_MIPS_DELTA_CLASS. */ -#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ -#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in - DT_MIPS_DELTA_INSTANCE. */ -#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ -#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in - DT_MIPS_DELTA_RELOC. */ -#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta - relocations refer to. */ -#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in - DT_MIPS_DELTA_SYM. */ -#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the - class declaration. */ -#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in - DT_MIPS_DELTA_CLASSSYM. */ -#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ -#define DT_MIPS_PIXIE_INIT 0x70000023 -#define DT_MIPS_SYMBOL_LIB 0x70000024 -#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 -#define DT_MIPS_LOCAL_GOTIDX 0x70000026 -#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 -#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 -#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ -#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ -#define DT_MIPS_DYNSTR_ALIGN 0x7000002b -#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ -#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve - function stored in GOT. */ -#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added - by rld on dlopen() calls. */ -#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ -#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ -#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ -#define DT_MIPS_NUM 0x32 - -/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ - -#define RHF_NONE 0 /* No flags */ -#define RHF_QUICKSTART (1 << 0) /* Use quickstart */ -#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ -#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ -#define RHF_NO_MOVE (1 << 3) -#define RHF_SGI_ONLY (1 << 4) -#define RHF_GUARANTEE_INIT (1 << 5) -#define RHF_DELTA_C_PLUS_PLUS (1 << 6) -#define RHF_GUARANTEE_START_INIT (1 << 7) -#define RHF_PIXIE (1 << 8) -#define RHF_DEFAULT_DELAY_LOAD (1 << 9) -#define RHF_REQUICKSTART (1 << 10) -#define RHF_REQUICKSTARTED (1 << 11) -#define RHF_CORD (1 << 12) -#define RHF_NO_UNRES_UNDEF (1 << 13) -#define RHF_RLD_ORDER_SAFE (1 << 14) - -/* Entries found in sections of type SHT_MIPS_LIBLIST. */ - -typedef struct -{ - Elf32_Word l_name; /* Name (string table index) */ - Elf32_Word l_time_stamp; /* Timestamp */ - Elf32_Word l_checksum; /* Checksum */ - Elf32_Word l_version; /* Interface version */ - Elf32_Word l_flags; /* Flags */ -} Elf32_Lib; - -typedef struct -{ - Elf64_Word l_name; /* Name (string table index) */ - Elf64_Word l_time_stamp; /* Timestamp */ - Elf64_Word l_checksum; /* Checksum */ - Elf64_Word l_version; /* Interface version */ - Elf64_Word l_flags; /* Flags */ -} Elf64_Lib; - - -/* Legal values for l_flags. */ - -#define LL_NONE 0 -#define LL_EXACT_MATCH (1 << 0) /* Require exact match */ -#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ -#define LL_REQUIRE_MINOR (1 << 2) -#define LL_EXPORTS (1 << 3) -#define LL_DELAY_LOAD (1 << 4) -#define LL_DELTA (1 << 5) - -/* Entries found in sections of type SHT_MIPS_CONFLICT. */ - -typedef Elf32_Addr Elf32_Conflict; - - -/* HPPA specific definitions. */ - -/* Legal values for e_flags field of Elf32_Ehdr. */ - -#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ -#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ -#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ -#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ -#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch - prediction. */ -#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ -#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ - -/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ - -#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ -#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ -#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ - -/* Additional section indeces. */ - -#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared - symbols in ANSI C. */ -#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ - -/* Legal values for sh_type field of Elf32_Shdr. */ - -#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ -#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ -#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ - -/* Legal values for sh_flags field of Elf32_Shdr. */ - -#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ -#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ -#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ - -#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ - -#define STT_HP_OPAQUE (STT_LOOS + 0x1) -#define STT_HP_STUB (STT_LOOS + 0x2) - -/* HPPA relocs. */ - -#define R_PARISC_NONE 0 /* No reloc. */ -#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ -#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ -#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ -#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ -#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ -#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ -#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ -#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ -#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ -#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ -#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ -#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ -#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ -#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ -#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ -#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ -#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ -#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ -#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ -#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ -#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ -#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ -#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ -#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ -#define R_PARISC_FPTR64 64 /* 64 bits function address. */ -#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ -#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ -#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ -#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ -#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ -#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ -#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ -#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ -#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ -#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ -#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ -#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ -#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ -#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ -#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ -#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ -#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ -#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ -#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ -#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ -#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ -#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ -#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ -#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ -#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ -#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ -#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ -#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ -#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ -#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ -#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ -#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ -#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ -#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ -#define R_PARISC_LORESERVE 128 -#define R_PARISC_COPY 128 /* Copy relocation. */ -#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ -#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ -#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ -#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ -#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ -#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ -#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ -#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ -#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ -#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ -#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ -#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ -#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ -#define R_PARISC_HIRESERVE 255 - -/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ - -#define PT_HP_TLS (PT_LOOS + 0x0) -#define PT_HP_CORE_NONE (PT_LOOS + 0x1) -#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) -#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) -#define PT_HP_CORE_COMM (PT_LOOS + 0x4) -#define PT_HP_CORE_PROC (PT_LOOS + 0x5) -#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) -#define PT_HP_CORE_STACK (PT_LOOS + 0x7) -#define PT_HP_CORE_SHM (PT_LOOS + 0x8) -#define PT_HP_CORE_MMF (PT_LOOS + 0x9) -#define PT_HP_PARALLEL (PT_LOOS + 0x10) -#define PT_HP_FASTBIND (PT_LOOS + 0x11) -#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) -#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) -#define PT_HP_STACK (PT_LOOS + 0x14) - -#define PT_PARISC_ARCHEXT 0x70000000 -#define PT_PARISC_UNWIND 0x70000001 - -/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ - -#define PF_PARISC_SBP 0x08000000 - -#define PF_HP_PAGE_SIZE 0x00100000 -#define PF_HP_FAR_SHARED 0x00200000 -#define PF_HP_NEAR_SHARED 0x00400000 -#define PF_HP_CODE 0x01000000 -#define PF_HP_MODIFY 0x02000000 -#define PF_HP_LAZYSWAP 0x04000000 -#define PF_HP_SBP 0x08000000 - - -/* Alpha specific definitions. */ - -/* Legal values for e_flags field of Elf64_Ehdr. */ - -#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */ -#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */ - -/* Legal values for sh_type field of Elf64_Shdr. */ - -/* These two are primerily concerned with ECOFF debugging info. */ -#define SHT_ALPHA_DEBUG 0x70000001 -#define SHT_ALPHA_REGINFO 0x70000002 - -/* Legal values for sh_flags field of Elf64_Shdr. */ - -#define SHF_ALPHA_GPREL 0x10000000 - -/* Legal values for st_other field of Elf64_Sym. */ -#define STO_ALPHA_NOPV 0x80 /* No PV required. */ -#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */ - -/* Alpha relocs. */ - -#define R_ALPHA_NONE 0 /* No reloc */ -#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ -#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ -#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ -#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ -#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ -#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ -#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ -#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ -#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ -#define R_ALPHA_SREL32 10 /* PC relative 32 bit */ -#define R_ALPHA_SREL64 11 /* PC relative 64 bit */ -#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */ -#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */ -#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */ -#define R_ALPHA_COPY 24 /* Copy symbol at runtime */ -#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ -#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ -#define R_ALPHA_RELATIVE 27 /* Adjust by program base */ -#define R_ALPHA_TLS_GD_HI 28 -#define R_ALPHA_TLSGD 29 -#define R_ALPHA_TLS_LDM 30 -#define R_ALPHA_DTPMOD64 31 -#define R_ALPHA_GOTDTPREL 32 -#define R_ALPHA_DTPREL64 33 -#define R_ALPHA_DTPRELHI 34 -#define R_ALPHA_DTPRELLO 35 -#define R_ALPHA_DTPREL16 36 -#define R_ALPHA_GOTTPREL 37 -#define R_ALPHA_TPREL64 38 -#define R_ALPHA_TPRELHI 39 -#define R_ALPHA_TPRELLO 40 -#define R_ALPHA_TPREL16 41 -/* Keep this the last entry. */ -#define R_ALPHA_NUM 46 - -/* Magic values of the LITUSE relocation addend. */ -#define LITUSE_ALPHA_ADDR 0 -#define LITUSE_ALPHA_BASE 1 -#define LITUSE_ALPHA_BYTOFF 2 -#define LITUSE_ALPHA_JSR 3 -#define LITUSE_ALPHA_TLS_GD 4 -#define LITUSE_ALPHA_TLS_LDM 5 - - -/* PowerPC specific declarations */ - -/* Values for Elf32/64_Ehdr.e_flags. */ -#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ - -/* Cygnus local bits below */ -#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ -#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib - flag */ - -/* PowerPC relocations defined by the ABIs */ -#define R_PPC_NONE 0 -#define R_PPC_ADDR32 1 /* 32bit absolute address */ -#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ -#define R_PPC_ADDR16 3 /* 16bit absolute address */ -#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ -#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ -#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ -#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ -#define R_PPC_ADDR14_BRTAKEN 8 -#define R_PPC_ADDR14_BRNTAKEN 9 -#define R_PPC_REL24 10 /* PC relative 26 bit */ -#define R_PPC_REL14 11 /* PC relative 16 bit */ -#define R_PPC_REL14_BRTAKEN 12 -#define R_PPC_REL14_BRNTAKEN 13 -#define R_PPC_GOT16 14 -#define R_PPC_GOT16_LO 15 -#define R_PPC_GOT16_HI 16 -#define R_PPC_GOT16_HA 17 -#define R_PPC_PLTREL24 18 -#define R_PPC_COPY 19 -#define R_PPC_GLOB_DAT 20 -#define R_PPC_JMP_SLOT 21 -#define R_PPC_RELATIVE 22 -#define R_PPC_LOCAL24PC 23 -#define R_PPC_UADDR32 24 -#define R_PPC_UADDR16 25 -#define R_PPC_REL32 26 -#define R_PPC_PLT32 27 -#define R_PPC_PLTREL32 28 -#define R_PPC_PLT16_LO 29 -#define R_PPC_PLT16_HI 30 -#define R_PPC_PLT16_HA 31 -#define R_PPC_SDAREL16 32 -#define R_PPC_SECTOFF 33 -#define R_PPC_SECTOFF_LO 34 -#define R_PPC_SECTOFF_HI 35 -#define R_PPC_SECTOFF_HA 36 - -/* PowerPC relocations defined for the TLS access ABI. */ -#define R_PPC_TLS 67 /* none (sym+add)@tls */ -#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */ -#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */ -#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ -#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ -#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ -#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */ -#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */ -#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ -#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ -#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ -#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */ -#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ -#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ -#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ -#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ -#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ -#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ -#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ -#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ -#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */ -#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */ -#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ -#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ -#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */ -#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */ -#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ -#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ - -/* Keep this the last entry. */ -#define R_PPC_NUM 95 - -/* The remaining relocs are from the Embedded ELF ABI, and are not - in the SVR4 ELF ABI. */ -#define R_PPC_EMB_NADDR32 101 -#define R_PPC_EMB_NADDR16 102 -#define R_PPC_EMB_NADDR16_LO 103 -#define R_PPC_EMB_NADDR16_HI 104 -#define R_PPC_EMB_NADDR16_HA 105 -#define R_PPC_EMB_SDAI16 106 -#define R_PPC_EMB_SDA2I16 107 -#define R_PPC_EMB_SDA2REL 108 -#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ -#define R_PPC_EMB_MRKREF 110 -#define R_PPC_EMB_RELSEC16 111 -#define R_PPC_EMB_RELST_LO 112 -#define R_PPC_EMB_RELST_HI 113 -#define R_PPC_EMB_RELST_HA 114 -#define R_PPC_EMB_BIT_FLD 115 -#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ - -/* Diab tool relocations. */ -#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ -#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ -#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ -#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ -#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ -#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ - -/* This is a phony reloc to handle any old fashioned TOC16 references - that may still be in object files. */ -#define R_PPC_TOC16 255 - - -/* PowerPC64 relocations defined by the ABIs */ -#define R_PPC64_NONE R_PPC_NONE -#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */ -#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */ -#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */ -#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */ -#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */ -#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */ -#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */ -#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN -#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN -#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */ -#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */ -#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN -#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN -#define R_PPC64_GOT16 R_PPC_GOT16 -#define R_PPC64_GOT16_LO R_PPC_GOT16_LO -#define R_PPC64_GOT16_HI R_PPC_GOT16_HI -#define R_PPC64_GOT16_HA R_PPC_GOT16_HA - -#define R_PPC64_COPY R_PPC_COPY -#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT -#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT -#define R_PPC64_RELATIVE R_PPC_RELATIVE - -#define R_PPC64_UADDR32 R_PPC_UADDR32 -#define R_PPC64_UADDR16 R_PPC_UADDR16 -#define R_PPC64_REL32 R_PPC_REL32 -#define R_PPC64_PLT32 R_PPC_PLT32 -#define R_PPC64_PLTREL32 R_PPC_PLTREL32 -#define R_PPC64_PLT16_LO R_PPC_PLT16_LO -#define R_PPC64_PLT16_HI R_PPC_PLT16_HI -#define R_PPC64_PLT16_HA R_PPC_PLT16_HA - -#define R_PPC64_SECTOFF R_PPC_SECTOFF -#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO -#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI -#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA -#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */ -#define R_PPC64_ADDR64 38 /* doubleword64 S + A */ -#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */ -#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */ -#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */ -#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */ -#define R_PPC64_UADDR64 43 /* doubleword64 S + A */ -#define R_PPC64_REL64 44 /* doubleword64 S + A - P */ -#define R_PPC64_PLT64 45 /* doubleword64 L + A */ -#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */ -#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */ -#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */ -#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */ -#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */ -#define R_PPC64_TOC 51 /* doubleword64 .TOC */ -#define R_PPC64_PLTGOT16 52 /* half16* M + A */ -#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */ -#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */ -#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */ - -#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */ -#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */ -#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */ -#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */ -#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */ -#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */ -#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */ -#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */ -#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */ -#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */ -#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */ - -/* PowerPC64 relocations defined for the TLS access ABI. */ -#define R_PPC64_TLS 67 /* none (sym+add)@tls */ -#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */ -#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */ -#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ -#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ -#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ -#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */ -#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */ -#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ -#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ -#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ -#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */ -#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ -#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ -#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ -#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ -#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ -#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ -#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ -#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ -#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */ -#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */ -#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ -#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ -#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */ -#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */ -#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */ -#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */ -#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */ -#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */ -#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */ -#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */ -#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */ -#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */ -#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */ -#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */ -#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */ -#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */ -#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ -#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ - -/* Keep this the last entry. */ -#define R_PPC64_NUM 107 - -/* PowerPC64 specific values for the Dyn d_tag field. */ -#define DT_PPC64_GLINK (DT_LOPROC + 0) -#define DT_PPC64_NUM 1 - - -/* ARM specific declarations */ - -/* Processor specific flags for the ELF header e_flags field. */ -#define EF_ARM_RELEXEC 0x01 -#define EF_ARM_HASENTRY 0x02 -#define EF_ARM_INTERWORK 0x04 -#define EF_ARM_APCS_26 0x08 -#define EF_ARM_APCS_FLOAT 0x10 -#define EF_ARM_PIC 0x20 -#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */ -#define EF_ARM_NEW_ABI 0x80 -#define EF_ARM_OLD_ABI 0x100 - -/* Other constants defined in the ARM ELF spec. version B-01. */ -/* NB. These conflict with values defined above. */ -#define EF_ARM_SYMSARESORTED 0x04 -#define EF_ARM_DYNSYMSUSESEGIDX 0x08 -#define EF_ARM_MAPSYMSFIRST 0x10 -#define EF_ARM_EABIMASK 0XFF000000 - -#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) -#define EF_ARM_EABI_UNKNOWN 0x00000000 -#define EF_ARM_EABI_VER1 0x01000000 -#define EF_ARM_EABI_VER2 0x02000000 - -/* Additional symbol types for Thumb */ -#define STT_ARM_TFUNC 0xd - -/* ARM-specific values for sh_flags */ -#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */ -#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined - in the input to a link step */ - -/* ARM-specific program header flags */ -#define PF_ARM_SB 0x10000000 /* Segment contains the location - addressed by the static base */ - -/* ARM relocs. */ -#define R_ARM_NONE 0 /* No reloc */ -#define R_ARM_PC24 1 /* PC relative 26 bit branch */ -#define R_ARM_ABS32 2 /* Direct 32 bit */ -#define R_ARM_REL32 3 /* PC relative 32 bit */ -#define R_ARM_PC13 4 -#define R_ARM_ABS16 5 /* Direct 16 bit */ -#define R_ARM_ABS12 6 /* Direct 12 bit */ -#define R_ARM_THM_ABS5 7 -#define R_ARM_ABS8 8 /* Direct 8 bit */ -#define R_ARM_SBREL32 9 -#define R_ARM_THM_PC22 10 -#define R_ARM_THM_PC8 11 -#define R_ARM_AMP_VCALL9 12 -#define R_ARM_SWI24 13 -#define R_ARM_THM_SWI8 14 -#define R_ARM_XPC25 15 -#define R_ARM_THM_XPC22 16 -#define R_ARM_COPY 20 /* Copy symbol at runtime */ -#define R_ARM_GLOB_DAT 21 /* Create GOT entry */ -#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */ -#define R_ARM_RELATIVE 23 /* Adjust by program base */ -#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */ -#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */ -#define R_ARM_GOT32 26 /* 32 bit GOT entry */ -#define R_ARM_PLT32 27 /* 32 bit PLT address */ -#define R_ARM_ALU_PCREL_7_0 32 -#define R_ARM_ALU_PCREL_15_8 33 -#define R_ARM_ALU_PCREL_23_15 34 -#define R_ARM_LDR_SBREL_11_0 35 -#define R_ARM_ALU_SBREL_19_12 36 -#define R_ARM_ALU_SBREL_27_20 37 -#define R_ARM_GNU_VTENTRY 100 -#define R_ARM_GNU_VTINHERIT 101 -#define R_ARM_THM_PC11 102 /* thumb unconditional branch */ -#define R_ARM_THM_PC9 103 /* thumb conditional branch */ -#define R_ARM_RXPC25 249 -#define R_ARM_RSBREL32 250 -#define R_ARM_THM_RPC22 251 -#define R_ARM_RREL32 252 -#define R_ARM_RABS22 253 -#define R_ARM_RPC24 254 -#define R_ARM_RBASE 255 -/* Keep this the last entry. */ -#define R_ARM_NUM 256 - -/* IA-64 specific declarations. */ - -/* Processor specific flags for the Ehdr e_flags field. */ -#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */ -#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */ -#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */ - -/* Processor specific values for the Phdr p_type field. */ -#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ -#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ - -/* Processor specific flags for the Phdr p_flags field. */ -#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */ - -/* Processor specific values for the Shdr sh_type field. */ -#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ -#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ - -/* Processor specific flags for the Shdr sh_flags field. */ -#define SHF_IA_64_SHORT 0x10000000 /* section near gp */ -#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */ - -/* Processor specific values for the Dyn d_tag field. */ -#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) -#define DT_IA_64_NUM 1 - -/* IA-64 relocations. */ -#define R_IA64_NONE 0x00 /* none */ -#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ -#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ -#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ -#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ -#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ -#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ -#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ -#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ -#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ -#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ -#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ -#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ -#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ -#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ -#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ -#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ -#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ -#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ -#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ -#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ -#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ -#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ -#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ -#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ -#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ -#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ -#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ -#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ -#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ -#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ -#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ -#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ -#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ -#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ -#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ -#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ -#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ -#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ -#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ -#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ -#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ -#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ -#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ -#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ -#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ -#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ -#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ -#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ -#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ -#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ -#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ -#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ -#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ -#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ -#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ -#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ -#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ -#define R_IA64_COPY 0x84 /* copy relocation */ -#define R_IA64_SUB 0x85 /* Addend and symbol difference */ -#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ -#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ -#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ -#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ -#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ -#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ -#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ -#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ -#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ -#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ -#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ -#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ -#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ -#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ -#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ -#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ -#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ -#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ - -/* SH specific declarations */ - -/* SH relocs. */ -#define R_SH_NONE 0 -#define R_SH_DIR32 1 -#define R_SH_REL32 2 -#define R_SH_DIR8WPN 3 -#define R_SH_IND12W 4 -#define R_SH_DIR8WPL 5 -#define R_SH_DIR8WPZ 6 -#define R_SH_DIR8BP 7 -#define R_SH_DIR8W 8 -#define R_SH_DIR8L 9 -#define R_SH_SWITCH16 25 -#define R_SH_SWITCH32 26 -#define R_SH_USES 27 -#define R_SH_COUNT 28 -#define R_SH_ALIGN 29 -#define R_SH_CODE 30 -#define R_SH_DATA 31 -#define R_SH_LABEL 32 -#define R_SH_SWITCH8 33 -#define R_SH_GNU_VTINHERIT 34 -#define R_SH_GNU_VTENTRY 35 -#define R_SH_TLS_GD_32 144 -#define R_SH_TLS_LD_32 145 -#define R_SH_TLS_LDO_32 146 -#define R_SH_TLS_IE_32 147 -#define R_SH_TLS_LE_32 148 -#define R_SH_TLS_DTPMOD32 149 -#define R_SH_TLS_DTPOFF32 150 -#define R_SH_TLS_TPOFF32 151 -#define R_SH_GOT32 160 -#define R_SH_PLT32 161 -#define R_SH_COPY 162 -#define R_SH_GLOB_DAT 163 -#define R_SH_JMP_SLOT 164 -#define R_SH_RELATIVE 165 -#define R_SH_GOTOFF 166 -#define R_SH_GOTPC 167 -/* Keep this the last entry. */ -#define R_SH_NUM 256 - -/* Additional s390 relocs */ - -#define R_390_NONE 0 /* No reloc. */ -#define R_390_8 1 /* Direct 8 bit. */ -#define R_390_12 2 /* Direct 12 bit. */ -#define R_390_16 3 /* Direct 16 bit. */ -#define R_390_32 4 /* Direct 32 bit. */ -#define R_390_PC32 5 /* PC relative 32 bit. */ -#define R_390_GOT12 6 /* 12 bit GOT offset. */ -#define R_390_GOT32 7 /* 32 bit GOT offset. */ -#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */ -#define R_390_COPY 9 /* Copy symbol at runtime. */ -#define R_390_GLOB_DAT 10 /* Create GOT entry. */ -#define R_390_JMP_SLOT 11 /* Create PLT entry. */ -#define R_390_RELATIVE 12 /* Adjust by program base. */ -#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */ -#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */ -#define R_390_GOT16 15 /* 16 bit GOT offset. */ -#define R_390_PC16 16 /* PC relative 16 bit. */ -#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */ -#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */ -#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */ -#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */ -#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */ -#define R_390_64 22 /* Direct 64 bit. */ -#define R_390_PC64 23 /* PC relative 64 bit. */ -#define R_390_GOT64 24 /* 64 bit GOT offset. */ -#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */ -#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */ -#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */ -#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */ -#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */ -#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */ -#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */ -#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */ -#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */ -#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */ -#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */ -#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */ -#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */ -#define R_390_TLS_GDCALL 38 /* Tag for function call in general - dynamic TLS code. */ -#define R_390_TLS_LDCALL 39 /* Tag for function call in local - dynamic TLS code. */ -#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic - thread local data. */ -#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic - thread local data. */ -#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS - block offset. */ -#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS - block offset. */ -#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS - block offset. */ -#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic - thread local data in LE code. */ -#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic - thread local data in LE code. */ -#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for - negated static TLS block offset. */ -#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for - negated static TLS block offset. */ -#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for - negated static TLS block offset. */ -#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to - static TLS block. */ -#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to - static TLS block. */ -#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS - block. */ -#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS - block. */ -#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */ -#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */ -#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS - block. */ - -/* Keep this the last entry. */ -#define R_390_NUM 57 - -/* CRIS relocations. */ -#define R_CRIS_NONE 0 -#define R_CRIS_8 1 -#define R_CRIS_16 2 -#define R_CRIS_32 3 -#define R_CRIS_8_PCREL 4 -#define R_CRIS_16_PCREL 5 -#define R_CRIS_32_PCREL 6 -#define R_CRIS_GNU_VTINHERIT 7 -#define R_CRIS_GNU_VTENTRY 8 -#define R_CRIS_COPY 9 -#define R_CRIS_GLOB_DAT 10 -#define R_CRIS_JUMP_SLOT 11 -#define R_CRIS_RELATIVE 12 -#define R_CRIS_16_GOT 13 -#define R_CRIS_32_GOT 14 -#define R_CRIS_16_GOTPLT 15 -#define R_CRIS_32_GOTPLT 16 -#define R_CRIS_32_GOTREL 17 -#define R_CRIS_32_PLT_GOTREL 18 -#define R_CRIS_32_PLT_PCREL 19 - -#define R_CRIS_NUM 20 - -/* AMD x86-64 relocations. */ -#define R_X86_64_NONE 0 /* No reloc */ -#define R_X86_64_64 1 /* Direct 64 bit */ -#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ -#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ -#define R_X86_64_PLT32 4 /* 32 bit PLT address */ -#define R_X86_64_COPY 5 /* Copy symbol at runtime */ -#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ -#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ -#define R_X86_64_RELATIVE 8 /* Adjust by program base */ -#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative - offset to GOT */ -#define R_X86_64_32 10 /* Direct 32 bit zero extended */ -#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ -#define R_X86_64_16 12 /* Direct 16 bit zero extended */ -#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ -#define R_X86_64_8 14 /* Direct 8 bit sign extended */ -#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ -#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ -#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */ -#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */ -#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset - to two GOT entries for GD symbol */ -#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset - to two GOT entries for LD symbol */ -#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ -#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset - to GOT entry for IE symbol */ -#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */ - -#define R_X86_64_NUM 24 - -__END_DECLS - -#endif /* elf.h */ diff --git a/tools/upx/Makefile b/tools/upx/Makefile index 3e7623201..c162e557c 100644 --- a/tools/upx/Makefile +++ b/tools/upx/Makefile @@ -21,7 +21,8 @@ include $(INCLUDE_DIR)/host-build.mk define Host/Compile rm -f $(HOST_BUILD_DIR)/src/.depend $(MAKE) UPX_LZMADIR="$(BUILD_DIR_HOST)/lzma-4.65" -C $(HOST_BUILD_DIR)/src \ - CXXFLAGS_WERROR="" LDFLAGS="$(HOST_LDFLAGS) $(HOST_STATIC_LINKING)" + CXXFLAGS_WERROR="" LDFLAGS="$(HOST_LDFLAGS) $(HOST_STATIC_LINKING)" \ + CXX="$(HOSTCXX)" endef define Host/Install diff --git a/tools/xz/Makefile b/tools/xz/Makefile index 729863088..9999006d4 100644 --- a/tools/xz/Makefile +++ b/tools/xz/Makefile @@ -13,12 +13,14 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=http://tukaani.org/xz PKG_MD5SUM:=741cd3a5f64b23b7bac56ec5b2258715 +HOST_BUILD_PARALLEL:=1 + include $(INCLUDE_DIR)/host-build.mk HOST_LDFLAGS += $(HOST_STATIC_LINKING) define Host/Install - $(MAKE) -C $(HOST_BUILD_DIR) install xzlinks="unxz xzcat" \ + +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) install xzlinks="unxz xzcat" \ AM_LDFLAGS="$(if $(HOST_STATIC_LINKING),-all-static)" endef diff --git a/tools/yaffs2/patches/110-openbsd-compat.patch b/tools/yaffs2/patches/110-openbsd-compat.patch new file mode 100644 index 000000000..cfafc1ca7 --- /dev/null +++ b/tools/yaffs2/patches/110-openbsd-compat.patch @@ -0,0 +1,14 @@ +diff -Nur yaffs2_android.orig/yaffs2/yaffs_guts.h yaffs2_android/yaffs2/yaffs_guts.h +--- yaffs2_android.orig/yaffs2/yaffs_guts.h Sun Feb 15 16:23:50 2009 ++++ yaffs2_android/yaffs2/yaffs_guts.h Tue Mar 5 15:45:21 2013 +@@ -823,6 +823,10 @@ + int yaffs_SetAttributes(yaffs_Object * obj, struct iattr *attr); + int yaffs_GetAttributes(yaffs_Object * obj, struct iattr *attr); + ++#if defined(__OpenBSD__) ++#define loff_t off_t ++#endif ++ + /* File operations */ + int yaffs_ReadDataFromFile(yaffs_Object * obj, __u8 * buffer, loff_t offset, + int nBytes); |