--- binutils-2.22.orig/debian/copyright +++ binutils-2.22/debian/copyright @@ -0,0 +1,44 @@ +This is the Debian GNU/Linux prepackaged version of the GNU assembler, +linker, and binary utilities. + +This package was put together by me, James Troup , +from sources, which I obtained from: + + ftp://ftp.gnu.org/pub/gnu/binutils/ + +and: + + cvs://:pserver:anoncvs@sources.redhat.com:/cvs/src + +It was previously maintained by Christopher C. Chimelis + +GNU Binutils is Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, +1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software +Foundation, Inc. + + 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 3 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., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL' +and `/usr/share/common-licenses/LGPL'. + +The binutils manuals and associated documentation are also Copyright +(C) Free Software Foundation, Inc. They are distributed under the GNU +Free Documentation License Version 1.3 or any later version published +by the Free Software Foundation, with no Invariant Sections, with no +with no Front-Cover Texts, and with no Back-Cover Texts. +On Debian GNU/Linux systems, the complete text of the GFDL can be found +in `/usr/share/common-licenses/GFDL'. --- binutils-2.22.orig/debian/binutils.postrm +++ binutils-2.22/debian/binutils.postrm @@ -0,0 +1,7 @@ +#! /bin/sh + +set -e + +if [ "$1" = "remove" ]; then + ldconfig +fi --- binutils-2.22.orig/debian/binutils-multiarch.overrides +++ binutils-2.22/debian/binutils-multiarch.overrides @@ -0,0 +1,10 @@ +# don't warn about missing man pages for diverted binaries +binutils-multiarch binary: binary-without-manpage + +# the API of the shared libs is not public, don't care about the name +binutils-multiarch binary: package-name-doesnt-match-sonames + +# not in binutils-multiarch, just move these away +binutils-multiarch: diversion-for-unknown-file usr/lib/libopcodes.a preinst:19 +binutils-multiarch: diversion-for-unknown-file usr/lib/libbfd.a preinst:16 + --- binutils-2.22.orig/debian/binutils.postinst +++ binutils-2.22/debian/binutils.postinst @@ -0,0 +1,7 @@ +#! /bin/sh + +set -e + +if [ "$1" = "configure" ]; then + ldconfig +fi --- binutils-2.22.orig/debian/binutils-gold.preinst +++ binutils-2.22/debian/binutils-gold.preinst @@ -0,0 +1,25 @@ +#! /bin/sh + +set -e + +if [ install = "$1" -o upgrade = "$1" ]; then + if [ -n "$2" ] && dpkg --compare-versions $2 lt 2.20-3; then + case "$(dpkg-divert --list /usr/bin/ld)" in + *ld.single*) + rm -f /usr/bin/ld + dpkg-divert \ + --package binutils-gold \ + --remove --rename \ + --divert /usr/bin/ld.single /usr/bin/ld + esac + fi + + dpkg-divert \ + --package binutils-gold \ + --add --rename \ + --divert /usr/bin/ld.bfd-link /usr/bin/ld + dpkg-divert \ + --package binutils-gold \ + --add --rename \ + --divert /usr/share/man/man1/ld.bfd-link.1.gz /usr/share/man/man1/ld.1.gz +fi --- binutils-2.22.orig/debian/binutils-hppa64.postinst +++ binutils-2.22/debian/binutils-hppa64.postinst @@ -0,0 +1,7 @@ +#! /bin/sh + +set -e + +if [ "$1" = "configure" ]; then + ldconfig +fi --- binutils-2.22.orig/debian/binutils-spu.postinst +++ binutils-2.22/debian/binutils-spu.postinst @@ -0,0 +1,7 @@ +#! /bin/sh + +set -e + +if [ "$1" = "configure" ]; then + ldconfig +fi --- binutils-2.22.orig/debian/binutils-gold.postrm +++ binutils-2.22/debian/binutils-gold.postrm @@ -0,0 +1,15 @@ +#! /bin/sh + +set -e + +if [ "$1" = "remove" -o "$1" = "abort-install" ]; then + dpkg-divert \ + --package binutils-gold \ + --remove --rename \ + --divert /usr/bin/ld.bfd-link /usr/bin/ld + dpkg-divert \ + --package binutils-gold \ + --remove --rename \ + --divert /usr/share/man/man1/ld.bfd-link.1.gz /usr/share/man/man1/ld.1.gz + +fi --- binutils-2.22.orig/debian/binutils-static.preinst +++ binutils-2.22/debian/binutils-static.preinst @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +if [ -L /usr/share/doc/binutils-static ]; then + # We must be upgrading from a version that depended on binutils + rm -f /usr/share/doc/binutils-static +fi + +exit 0 --- binutils-2.22.orig/debian/binutils-multiarch.shlibs.in +++ binutils-2.22/debian/binutils-multiarch.shlibs.in @@ -0,0 +1,2 @@ +libbfd @VER@-multiarch@DATE_EXT@ binutils-multiarch +libopcodes @VER@-multiarch@DATE_EXT@ binutils-multiarch --- binutils-2.22.orig/debian/binutils.presubj +++ binutils-2.22/debian/binutils.presubj @@ -0,0 +1,25 @@ +When reporting binutils errors, please provide the actual input files +and options given to the tool (gas, objcopy, ld, etc.) at run time. +This can mean the difference between a pleasant debugging experience +and a heisenbug that becomes unreproducible when gcc's code generation +changes. + +For example, to create a testcase for an "ld" problem, first find the +"gcc" command line that triggers the error: + + $ make + ... output ending in an error ... + $ make V=1 VERBOSE=1 2>&1 | head -1 + +Add "-v" after gcc and run it again. One of the early output lines +will be an invocation of collect2. Replace collect2 with "ld" and +it should reproduce the same error. If you collect all the objects +(including system libraries) mentioned on the "ld" command line in a +tarball and send it along with the ld command line then that is a +testcase. + +A possible step after that is to try omitting some objects from the +ld command line and see if it still triggers the same error, but +that's just icing on the cake. + +Happy debugging! --- binutils-2.22.orig/debian/README.cross +++ binutils-2.22/debian/README.cross @@ -0,0 +1,26 @@ +Cross-binutils debian packages can be built directly from the binutils +source package. + +To build a cross-binutils package: + + o Download and unpack the binutils source package: + + apt-get source binutils + + o Ensure you have the binutils build-dependencies installed: + + apt-get build-dep binutils + + o Then build the cross-binutils package: + + TARGET= dpkg-buildpackage -b -uc -us + or + echo arm >debian/target; dpkg-buildpackage -b -uc -us + + (substitute your target name, e.g. "arm" or "m68k", instead of + "") + +--- +Nikita Youshchenko +Hector Oron +Marcin Juszkiewicz --- binutils-2.22.orig/debian/control +++ binutils-2.22/debian/control @@ -0,0 +1,121 @@ +Source: binutils +Section: devel +Priority: optional +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Matthias Klose +Uploaders: James Troup , Daniel Jacobowitz +Standards-Version: 3.9.2 +Build-Depends: dpkg-dev (>= 1.13.9), autoconf (>= 2.64), bison, flex, gettext, texinfo, dejagnu (>= 1.4.2-1.1), quilt, file, xz-utils, lsb-release, zlib1g-dev, g++ +Vcs-Browser: https://code.launchpad.net/~ubuntu-core-dev/binutils/pkg-ubuntu +Vcs-Bzr: http://bazaar.launchpad.net/~ubuntu-core-dev/binutils/pkg-ubuntu + +Package: binutils +Architecture: any +Depends: ${shlibs:Depends} +Conflicts: gas, elf-binutils, modutils (<< 2.4.19-1), ${extraConflicts}, binutils-gold (<< 2.20.51.20100415) +Replaces: binutils-gold (<< 2.20.51.20100415) +Provides: elf-binutils +Suggests: binutils-doc (>= ${source:Version}) +Description: GNU assembler, linker and binary utilities + The programs in this package are used to assemble, link and manipulate + binary and object files. They may be used in conjunction with a compiler + and various libraries to build programs. + +Package: binutils-dev +Architecture: any +Priority: extra +Depends: binutils (= ${binary:Version}) +Conflicts: libbfd-dev +Provides: libbfd-dev +Replaces: libbfd-dev, libc5-dev +Description: GNU binary utilities (BFD development files) + This package includes header files and static libraries necessary to build + programs which use the GNU BFD library, which is part of binutils. Note + that building Debian packages which depend on the shared libbfd is Not + Allowed. + +Package: binutils-multiarch +Architecture: any +Priority: extra +Depends: ${shlibs:Depends}, binutils (= ${binary:Version}) +Provides: multiarch-binutils +Description: Binary utilities that support multi-arch targets + The programs in this package are used to manipulate binary and object + files that may have been created on other architectures. This package + is primarily for multi-architecture developers and cross-compilers and + is not needed by normal users or developers. Note that a cross-assembling + version of gas is not included in this package, just the binary utilities. + NORMAL USERS SHOULD NOT INSTALL THIS PACKAGE. It's meant only for those + requiring support for reading info from binaries from other architectures. + +Package: binutils-gold +Architecture: amd64 armel armhf i386 powerpc powerpcspe ppc64 sparc sparc64 +Priority: extra +Depends: ${shlibs:Depends}, binutils (= ${binary:Version}) +Description: GNU gold linker utility + Gold is a new linker, which is faster than the current linker included + in binutils. + . + This package diverts the GNU linker (ld) with the gold linker. + +Package: binutils-static +Architecture: any +Description: statically linked binutils tools + This package contains statically linked binutils tools used + for linking kernel modules needed to mount /usr or /. At the moment, + it only contains ld. + +Package: binutils-static-udeb +Section: debian-installer +Architecture: any +Description: statically linked binutils tools for for the Debian installer + This package contains statically linked binutils tools used + for linking kernel modules needed to mount /usr or /. At the moment, + it only contains ld. + +Package: binutils-hppa64 +Architecture: any +Depends: ${shlibs:Depends}, binutils (= ${binary:Version}) +Recommends: libc6-dev +Suggests: binutils-doc (>= ${source:Version}) +Description: GNU assembler, linker and binary utilities targeted for hppa64-linux + The programs in this package are used to assemble, link and manipulate + binary and object files. They may be used in conjunction with a compiler + and various libraries to build programs. + . + This package is needed to build an 64-bit kernel for 64-bit hppa machines. + +Package: binutils-spu +Architecture: powerpc ppc64 +Depends: ${shlibs:Depends}, binutils (= ${binary:Version}) +Recommends: libc6-dev +Conflicts: spu-binutils +Replaces: spu-binutils +Provides: spu-binutils +Suggests: binutils-doc (>= ${source:Version}) +Description: GNU assembler, linker and binary utilities targeted for spu-elf + The programs in this package are used to assemble, link and manipulate + binary and object files. They may be used in conjunction with a compiler + and various libraries to build programs. + . + This package is needed to build programs for Cell Broadband Engine SPU + processors. + +Package: binutils-doc +Section: doc +Architecture: all +Priority: optional +Depends: dpkg (>= 1.15.4) | install-info +Conflicts: binutils (<< 2.9.1.0.25-3) +Suggests: binutils (= ${binary:Version}) +Description: Documentation for the GNU assembler, linker and binary utilities + This package consists of the documentation for the GNU assembler, + linker and binary utilities in info format. + +Package: binutils-source +Architecture: all +Priority: optional +Depends: texinfo, zlib1g-dev, make, python +Description: GNU assembler, linker and binary utilities (source) + This package contains the sources and patches which are needed to + build binutils. --- binutils-2.22.orig/debian/binutils-hppa64.postrm +++ binutils-2.22/debian/binutils-hppa64.postrm @@ -0,0 +1,7 @@ +#! /bin/sh + +set -e + +if [ "$1" = "remove" ]; then + ldconfig +fi --- binutils-2.22.orig/debian/binutils.overrides +++ binutils-2.22/debian/binutils.overrides @@ -0,0 +1,5 @@ +# the API of the shared libs is not public, don't care about the name +binutils binary: package-name-doesnt-match-sonames + +# big tables +binutils binary: manpage-has-errors-from-man --- binutils-2.22.orig/debian/README.source +++ binutils-2.22/debian/README.source @@ -0,0 +1,2 @@ +The package uses dpatch to apply patches on top of the upstream source. +See /usr/share/doc/dpatch/README.source.gz. --- binutils-2.22.orig/debian/binutils-multiarch.postrm.in +++ binutils-2.22/debian/binutils-multiarch.postrm.in @@ -0,0 +1,49 @@ +#! /bin/sh +set -e +this_ver=@DEB_VER@; # this version +# action: upgrade, abort-upgrade, remove, abort-install, disappear, +# purge, or failed-upgrade. +context=$1 +if + test "$context" = failed-upgrade && + dpkg --compare-versions "$this_ver" lt "$2" +then + # postrm of the future failed. + # Who knows what it was supposed to do? Abort. + exit 1 +fi +new_ver=; # version replacing this one, if any. +case "$context" in +failed-upgrade) + new_ver=$this_ver ;; +abort-install|disappear) + new_ver= ;; +*) + new_ver=$2 ;; +esac + +diversion() { + local added_ver divertto file + added_ver=$1 + file=$2 + divertto=${3-$file.single} + + if + test "$context" != purge && + dpkg --compare-versions "$new_ver" lt "$added_ver" + then + dpkg-divert --package binutils-multiarch \ + --remove --rename --divert "$divertto" "$file" + fi +} + + +for prog in nm objdump objcopy strings strip size \ + ar ranlib addr2line gprof readelf +do + diversion 2.9.5.0.16-1 "/usr/bin/$prog" +done + +if [ "$1" = "remove" ]; then + ldconfig +fi --- binutils-2.22.orig/debian/binutils-multiarch.preinst.in +++ binutils-2.22/debian/binutils-multiarch.preinst.in @@ -0,0 +1,27 @@ +#! /bin/sh +set -e +new_ver=@DEB_VER@; # this version +context=$1; # why to install (install, upgrade, or abort-upgrade) +old_ver=$2; # version being replaced, if any + +diversion() { + local added_ver divertto file + added_ver=$1 + file=$2 + divertto=${3-$file.single} + + if + test "$context" = install || + dpkg --compare-versions "$old_ver" lt "$added_ver" || + dpkg --compare-versions "$new_ver" le "$old_ver" + then + dpkg-divert --package binutils-multiarch \ + --add --rename --divert "$divertto" "$file" + fi +} + +for prog in nm objdump objcopy strings strip size \ + ar ranlib addr2line gprof readelf +do + diversion 2.9.5.0.16-1 "/usr/bin/$prog" +done --- binutils-2.22.orig/debian/binutils-gold.overrides +++ binutils-2.22/debian/binutils-gold.overrides @@ -0,0 +1,5 @@ +# don't warn about missing man pages for diverted binaries +binutils-gold binary: binary-without-manpage + +# the API of the shared libs is not public, don't care about the name +binutils-multiarch binary: package-name-doesnt-match-sonames --- binutils-2.22.orig/debian/binutils-multiarch.postinst +++ binutils-2.22/debian/binutils-multiarch.postinst @@ -0,0 +1,52 @@ +#! /bin/sh +# Update .so symlinks and remove obsolete diversions. +# +# Removing a diversion requires a guarantee that the conflicting +# file is not present any more, and we cannot guarantee that if +# some other version of binutils-multiarch is installed. +# So we remove the diversions in postinst, not preinst. +set -e +old_diversion() { + local divertto file + file=$1 + divertto=${2-$file.single} + if + dpkg-divert --package binutils-multiarch --list | + grep -q -F "$divertto" + then + dpkg-divert --package binutils-multiarch \ + --remove --rename \ + --divert "$divertto" "$file" + fi +} + +# remove obsolete diversions +old_diversion /usr/bin/ld.bfd +old_diversion /usr/bin/c++filt +old_diversion /usr/lib/libbfd.a /usr/lib/libbfd-single.a +old_diversion /usr/lib/libopcodes.a /usr/lib/libopcodes-single.a +old_diversion /usr/bin/ld +old_diversion /usr/bin/elfedit +for f in elf32_sparc elf32ppc elf64alpha elf_i386 m68kelf \ + alpha i386linux m68klinux sparclinux sun4 +do + for ext in x xbn xn xr xs xu + do + old_diversion /usr/lib/ldscripts/$f.$ext + done +done +old_diversion /usr/lib/libbfd-2.9.1.0.15.so.0.0.0 \ + /usr/lib/libbfd-single-2.9.1.0.15.so.0.0.0 +old_diversion /usr/lib/libopcodes-2.9.1.0.15.so.0.0.0 \ + /usr/lib/libopcodes-single-2.9.1.0.15.so.0.0.0 +old_diversion /usr/lib/libbfd.la /usr/lib/libbfd-single.la +old_diversion /usr/lib/libopcodes.la /usr/lib/libopcodes-single.la +old_diversion /usr/include/bfd.h /usr/include/bfd.single.h +old_diversion /usr/lib/ldscripts + +rm -f /usr/lib/libbfd-*-multiarch.so.0 +rm -f /usr/lib/libopcodes-*-multiarch.so.0 + +if [ "$1" = "configure" ]; then + ldconfig +fi --- binutils-2.22.orig/debian/binutils.shlibs.in +++ binutils-2.22/debian/binutils.shlibs.in @@ -0,0 +1,2 @@ +libbfd @VER@-system@DATE_EXT@ binutils (>= @DEB_UVER@), binutils (<< @DEB_NVER@) +libopcodes @VER@-system@DATE_EXT@ binutils (>= @DEB_UVER@), binutils (<< @DEB_NVER@) --- binutils-2.22.orig/debian/watch +++ binutils-2.22/debian/watch @@ -0,0 +1,2 @@ +version=2 +http://ftp.gnu.org/gnu/binutils/binutils-([\d\.]*).tar.gz --- binutils-2.22.orig/debian/test-suite-compare.py +++ binutils-2.22/debian/test-suite-compare.py @@ -0,0 +1,230 @@ +#!/usr/bin/env python + +# Quick'n'dirty regression check for dejagnu testsuites +# Copyright (C) 2003, 2004, 2005, 2006, 2007 James Troup + +# 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;5B 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 + +################################################################################ + +import optparse +import os +import sys + +################################################################################ + +def fubar(msg, exit_code=1): + sys.stderr.write("E: %s\n" % (msg)) + sys.exit(exit_code) + +def warn(msg): + sys.stderr.write("W: %s\n" % (msg)) + +def info(msg): + sys.stderr.write("I: %s\n" % (msg)) + +################################################################################ + +def read_testsummary(filename): + results = {} + file = open(filename) + for line in file.readlines(): + if not line: + continue + if line.startswith("Running"): + s = line.split() + if "/" in s[1]: + x = s[1] + if x.find("/testsuite/") == -1: + fubar("Can't find /testsuite/ in '%s'." % (x)) + # 'Running /home/james/debian/packages/binutils/binutils-2.14.90.0.7/gas/testsuite/gas/hppa/unsorted/unsorted.exp ...' -> 'gas/hppa/unsorted/unsorted.exp' + # ... since using basename() isn't dupe safe. + section = x[x.find("/testsuite/"):].replace("/testsuite/","").split()[0] + + # Tests can be duplicated, e.g. hppa/basic/basic.exp + # is run twice, once for hppa-linux and once for + # hppa64-linux. This is of course a horrible bodge, + # but I can't think of anything trivial and better off + # hand. + + if results.has_key(section): + extra = 1 + too_many = 10 + while results.has_key(section) and extra < too_many: + section = "%s.%s" % (section, extra) + extra += 1 + if extra >= too_many: + fubar("gave up trying to unduplicate %s." % (section)) + + results[section] = {} + continue + + got_state = 0 + for state in [ "PASS", "XPASS", "FAIL", "XFAIL", "UNRESOLVED", + "UNTESTED", "UNSUPPORTED" ]: + if line.startswith(state): + s = line.split(':') + state = s[0] + test = ':'.join(s[1:]).strip() + if results.has_key(test): + warn("%s/%s is duplicated." % (section, test)) + results[section][test] = state + got_state = 1 + break + + if got_state: + continue + + return results + +################################################################################ + +def compare_results(old, new): + total_num = 0 + pass_count = 0 + fail_count = 0 + xfail_count = 0 + untested_count = 0 + regression_count = 0 + progression_count = 0 + change_count = 0 + + for section in new.keys(): + for test in new[section].keys(): + state = new[section][test] + + # Stats pr0n + total_num += 1 + if state == "PASS" or state == "XPASS": + pass_count += 1 + elif state == "FAIL" or state == "UNRESOLVED": + fail_count += 1 + elif state == "XFAIL": + xfail_count += 1 + elif state == "UNTESTED": + untested_count += 1 + + # Compare to old + if not old.has_key(section): + continue + if not old[section].has_key(test): + continue + old_state = old[section][test] + if state == "PASS": + if old_state != "PASS": + progression_count += 1 + info("[%s] progression (%s -> %s): %s" % (section, old_state, state, test)) + elif state == "XPASS": + if old_state != "XPASS" and old_state != "PASS": + progression_count += 1 + warn("[%s] %s: %s" % (section, state, test)) + elif state == "FAIL": + if old_state != "FAIL": + regression_count += 1 + warn("[%s] REGRESSION (%s -> %s): %s" % (section, old_state, state, test)) + elif state == "XFAIL": + if old_state != "XFAIL": + change_count += 1 + info("[%s] change (%s -> %s): %s" % (section, old_state, state, test)) + elif state == "UNRESOLVED": + if old_state != "UNRESOLVED" and old_state != "FAIL": + regression_count += 1 + warn("[%s] REGRESSION (%s -> %s): %s" % (section, old_state, state, test)) + if old_state == "FAIL": + change_count += 1 + info("[%s] change (%s -> %s): %s" % (section, old_state, state, test)) + elif state == "UNTESTED": + if old_state != "UNTESTED": + change_count += 1 + warn("[%s] REGRESSION (%s -> %s): %s" % (section, old_state, state, test)) + + if regression_count: + print "%d REGRESSIONS (%.2f%%)." % (regression_count, (float(regression_count)/total_num)*100) + if progression_count: + print "%d progressions (%.2f%%)." % (progression_count, (float(progression_count)/total_num)*100) + + if change_count: + print "%d changes (%.2f%%)." % (change_count, (float(change_count)/total_num)*100) + + print "%d tests: %d pass (%.2f%%), %d fail (%.2f%%), %d xfail (%.2f%%) %d untested (%.2f%%)." \ + % (total_num, pass_count, (float(pass_count)/total_num)*100, + fail_count, (float(fail_count)/total_num)*100, + xfail_count, (float(xfail_count)/total_num)*100, + untested_count, (float(untested_count)/total_num)*100) + + if regression_count: + sys.exit(1) + +################################################################################ + +def compare_multiple(directory, first_version, second_version): + architectures = [ "alpha", "arm", "hppa", "i386", "ia64", "mips", + "m68k", "mipsel", "powerpc", "s390", "sparc" ] + + for arch in architectures: + print "*********************************** %s ******************************" % (arch) + second_filename = "%s/%s_%s" % (directory, second_version, arch) + if not os.path.exists(second_filename): + print " -- NOT AVAILABLE --" + continue + + new = read_testsummary(second_filename) + first_filename = "%s/%s_%s" % (directory, first_version, arch) + old = read_testsummary(first_filename) + compare_results(old, new) + +################################################################################ + +def init(): + """Initalization, including parsing of options.""" + + usage = """usage: %prog [OPTIONS] +compare (binutils) dejagnu testsuite results. + +Example usage: + + test-suite-compare.py binutils-2.17/test-summary binutils-2.18/test-summary + +Or to compare across all architectures (with test results stored in a +'test-summary' directory): + + test-suite-compare.py -mtest-summary 2.17-3 2.18-1""" + parser = optparse.OptionParser(usage) + parser.add_option("-m", "--multiple", dest="multiple", + nargs=1, type="string", + help="compare multiple architectures") + (options, args) = parser.parse_args() + + if len(args) > 2 or len(args) < 2: + parser.error("takes 2 arguments (old and new)") + (old_version, new_version) = args + + return options, old_version, new_version + +################################################################################ + +def main(): + (options, old_version, new_version) = init() + if options.multiple: + compare_multiple(options.multiple, old_version, new_version) + else: + old = read_testsummary(old_version) + new = read_testsummary(new_version) + compare_results(old, new) + +################################################################################ + +if __name__ == '__main__': + main() --- binutils-2.22.orig/debian/binutils-static.overrides +++ binutils-2.22/debian/binutils-static.overrides @@ -0,0 +1,5 @@ +# yes, it's embedded +binutils-static binary: embedded-zlib + +# not needed +binutils-static binary: binary-without-manpage --- binutils-2.22.orig/debian/binutils-hppa64.shlibs.in +++ binutils-2.22/debian/binutils-hppa64.shlibs.in @@ -0,0 +1,2 @@ +libbfd @VER@-hppa64@DATE_EXT@ binutils-hppa64 +libopcodes @VER@-hppa64@DATE_EXT@ binutils-hppa64 --- binutils-2.22.orig/debian/binutils-spu.overrides +++ binutils-2.22/debian/binutils-spu.overrides @@ -0,0 +1,8 @@ +# don't warn about missing man pages for diverted binaries +binutils-spu binary: binary-without-manpage + +# the API of the shared libs is not public, don't care about the name +binutils-spu binary: package-name-doesnt-match-sonames + +# it's a cross toolchain +binutils-spu binary: binary-or-shlib-defines-rpath --- binutils-2.22.orig/debian/ld.gold.1 +++ binutils-2.22/debian/ld.gold.1 @@ -0,0 +1,678 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.5. +.TH GOLD "1" "January 2012" "gold (GNU Binutils for Debian 2.22) 1.11" "User Commands" +.SH NAME +gold \- The GNU ELF linker +.SH SYNOPSIS +.B ld.gold +[\fIoptions\fR] \fIfile\fR... +.SH OPTIONS +.TP +\fB\-\-help\fR +Report usage information +.TP +\fB\-v\fR, \fB\-\-version\fR +Report version information +.TP +\fB\-V\fR +Report version and target information +.TP +\fB\-\-add\-needed\fR +Not supported +.TP +\fB\-\-no\-add\-needed\fR +Do not copy DT_NEEDED tags from shared libraries +.HP +\fB\-\-allow\-multiple\-definition\fR Allow multiple definitions of symbols +.TP +\fB\-\-no\-allow\-multiple\-definition\fR +Do not allow multiple definitions +.TP +\fB\-\-allow\-shlib\-undefined\fR +Allow unresolved references in shared libraries +.TP +\fB\-\-no\-allow\-shlib\-undefined\fR +Do not allow unresolved references in shared libraries +.TP +\fB\-\-as\-needed\fR +Only set DT_NEEDED for shared libraries if used +.TP +\fB\-\-no\-as\-needed\fR +Always DT_NEEDED for shared libraries +.TP +\fB\-assert\fR [ignored] +Ignored +.TP +\fB\-b\fR [elf,binary], \fB\-\-format\fR [elf,binary] +Set input format +.HP +\fB\-Bdynamic\fR \fB\-l\fR searches for shared libraries +.HP +\fB\-Bstatic\fR \fB\-l\fR does not search for shared libraries +.TP +\fB\-dy\fR +alias for \fB\-Bdynamic\fR +.TP +\fB\-dn\fR +alias for \fB\-Bstatic\fR +.TP +\fB\-Bgroup\fR +Use group name lookup rules for shared library +.TP +\fB\-Bsymbolic\fR +Bind defined symbols locally +.TP +\fB\-Bsymbolic\-functions\fR +Bind defined function symbols locally +.TP +\fB\-\-build\-id\fR [=STYLE] +Generate build ID note +.TP +\fB\-\-check\-sections\fR +Check segment addresses for overlaps (default) +.TP +\fB\-\-no\-check\-sections\fR +Do not check segment addresses for overlaps +.TP +\fB\-\-compress\-debug\-sections\fR [none,zlib] +Compress .debug_* sections in the output file +.TP +\fB\-\-copy\-dt\-needed\-entries\fR +Not supported +.HP +\fB\-\-no\-copy\-dt\-needed\-entries\fR Do not copy DT_NEEDED tags from shared libraries +.TP +\fB\-\-cref\fR +Output cross reference table +.TP +\fB\-\-no\-cref\fR +Do not output cross reference table +.TP +\fB\-\-ctors\-in\-init\-array\fR +Use DT_INIT_ARRAY for all constructors (default) +.TP +\fB\-\-no\-ctors\-in\-init\-array\fR +Handle constructors as directed by compiler +.TP +\fB\-d\fR, \fB\-\-define\-common\fR +Define common symbols +.TP +\fB\-\-no\-define\-common\fR +Do not define common symbols +.TP +\fB\-dc\fR +Alias for \fB\-d\fR +.TP +\fB\-dp\fR +Alias for \fB\-d\fR +.TP +\fB\-\-debug\fR [all,files,script,task][,...] +Turn on debugging +.TP +\fB\-\-defsym\fR SYMBOL=EXPRESSION +Define a symbol +.TP +\fB\-\-demangle\fR [=STYLE] +Demangle C++ symbols in log messages +.TP +\fB\-\-no\-demangle\fR +Do not demangle C++ symbols in log messages +.TP +\fB\-\-detect\-odr\-violations\fR +Look for violations of the C++ One Definition Rule +.TP +\fB\-\-no\-detect\-odr\-violations\fR +Do not look for violations of the C++ One Definition Rule +.TP +\fB\-x\fR, \fB\-\-discard\-all\fR +Delete all local symbols +.TP +\fB\-X\fR, \fB\-\-discard\-locals\fR +Delete all temporary local symbols +.TP +\fB\-\-dynamic\-list\-data\fR +Add data symbols to dynamic symbols +.TP +\fB\-\-dynamic\-list\-cpp\-new\fR +Add C++ operator new/delete to dynamic symbols +.HP +\fB\-\-dynamic\-list\-cpp\-typeinfo\fR Add C++ typeinfo to dynamic symbols +.TP +\fB\-\-dynamic\-list\fR FILE +Read a list of dynamic symbols +.HP +\fB\-e\fR ADDRESS, \fB\-\-entry\fR ADDRESS Set program start address +.TP +\fB\-\-exclude\-libs\fR lib,lib ... +Exclude libraries from automatic export +.TP +\fB\-E\fR, \fB\-\-export\-dynamic\fR +Export all dynamic symbols +.TP +\fB\-\-no\-export\-dynamic\fR +Do not export all dynamic symbols (default) +.TP +\fB\-EB\fR +Link big\-endian objects. +.TP +\fB\-EL\fR +Link little\-endian objects. +.TP +\fB\-\-eh\-frame\-hdr\fR +Create exception frame header +.TP +\fB\-\-no\-enum\-size\-warning\fR +(ARM only) Do not warn about objects with incompatible enum sizes +.HP +\fB\-f\fR SHLIB, \fB\-\-auxiliary\fR SHLIB Auxiliary filter for shared object symbol table +.TP +\fB\-F\fR SHLIB, \fB\-\-filter\fR SHLIB +Filter for shared object symbol table +.TP +\fB\-\-fatal\-warnings\fR +Treat warnings as errors +.TP +\fB\-\-no\-fatal\-warnings\fR +Do not treat warnings as errors +.TP +\fB\-fini\fR SYMBOL +Call SYMBOL at unload\-time +.TP +\fB\-\-fix\-cortex\-a8\fR +(ARM only) Fix binaries for Cortex\-A8 erratum. +.TP +\fB\-\-no\-fix\-cortex\-a8\fR +(ARM only) Do not fix binaries for Cortex\-A8 erratum. +.TP +\fB\-\-fix\-arm1176\fR +(ARM only) Fix binaries for ARM1176 erratum. +.TP +\fB\-\-no\-fix\-arm1176\fR +(ARM only) Do not fix binaries for ARM1176 erratum. +.TP +\fB\-\-merge\-exidx\-entries\fR +(ARM only) Merge exidx entries in debuginfo. +.TP +\fB\-\-no\-merge\-exidx\-entries\fR +(ARM only) Do not merge exidx entries in debuginfo. +.TP +\fB\-\-fix\-v4bx\fR +(ARM only) Rewrite BX rn as MOV pc, rn for ARMv4 +.TP +\fB\-\-fix\-v4bx\-interworking\fR +(ARM only) Rewrite BX rn branch to ARMv4 interworking veneer +.TP +\fB\-g\fR +Ignored +.TP +\fB\-\-gnu\-unique\fR +Enable STB_GNU_UNIQUE symbol binding (default) +.TP +\fB\-\-no\-gnu\-unique\fR +Disable STB_GNU_UNIQUE symbol binding +.TP +\fB\-h\fR FILENAME, \fB\-soname\fR FILENAME +Set shared library name +.TP +\fB\-\-hash\-bucket\-empty\-fraction\fR FRACTION +Min fraction of empty buckets in dynamic hash +.TP +\fB\-\-hash\-style\fR [sysv,gnu,both] +Dynamic hash style +.TP +\fB\-I\fR PROGRAM, \fB\-\-dynamic\-linker\fR PROGRAM +Set dynamic linker path +.TP +\fB\-\-incremental\fR +Do an incremental link if possible; otherwise, do a full link and prepare output for incremental linking +.TP +\fB\-\-no\-incremental\fR +Do a full link (default) +.TP +\fB\-\-incremental\-full\fR +Do a full link and prepare output for incremental linking +.TP +\fB\-\-incremental\-update\fR +Do an incremental link; exit if not possible +.TP +\fB\-\-incremental\-base\fR FILE +Set base file for incremental linking (default is output file) +.TP +\fB\-\-incremental\-changed\fR +Assume files changed +.TP +\fB\-\-incremental\-unchanged\fR +Assume files didn't change +.TP +\fB\-\-incremental\-unknown\fR +Use timestamps to check files (default) +.TP +\fB\-\-incremental\-startup\-unchanged\fR +Assume startup files unchanged (files preceding this option) +.HP +\fB\-\-incremental\-patch\fR PERCENT Amount of extra space to allocate for patches +.TP +\fB\-init\fR SYMBOL +Call SYMBOL at load\-time +.TP +\fB\-\-just\-symbols\fR FILE +Read only symbol values from FILE +.TP +\fB\-\-map\-whole\-files\fR +Map whole files to memory (default on 64\-bit hosts) +.TP +\fB\-\-no\-map\-whole\-files\fR +Map relevant file parts to memory (default on 32\-bit hosts) +.TP +\fB\-\-keep\-files\-mapped\fR +Keep files mapped across passes (default) +.TP +\fB\-\-no\-keep\-files\-mapped\fR +Release mapped files after each pass +.TP +\fB\-\-ld\-generated\-unwind\-info\fR +Generate unwind information for PLT (default) +.TP +\fB\-\-no\-ld\-generated\-unwind\-info\fR +Do not generate unwind information for PLT +.TP +\fB\-l\fR LIBNAME, \fB\-\-library\fR LIBNAME +Search for library LIBNAME +.TP +\fB\-L\fR DIR, \fB\-\-library\-path\fR DIR +Add directory to search path +.TP +\fB\-nostdlib\fR +Only search directories specified on the command line. +.TP +\fB\-\-rosegment\fR +Put read\-only non\-executable sections in their own segment +.TP +\fB\-m\fR EMULATION +Set GNU linker emulation; obsolete +.TP +\fB\-M\fR, \fB\-\-print\-map\fR +Write map file on standard output +.TP +\fB\-Map\fR MAPFILENAME +Write map file +.TP +\fB\-n\fR, \fB\-\-nmagic\fR +Do not page align data +.TP +\fB\-N\fR, \fB\-\-omagic\fR +Do not page align data, do not make text readonly +.TP +\fB\-\-no\-omagic\fR +Page align data, make text readonly +.TP +\fB\-\-enable\-new\-dtags\fR +Enable use of DT_RUNPATH and DT_FLAGS +.TP +\fB\-\-disable\-new\-dtags\fR +Disable use of DT_RUNPATH and DT_FLAGS +.TP +\fB\-\-noinhibit\-exec\fR +Create an output file even if errors occur +.TP +\fB\-\-no\-undefined\fR +Report undefined symbols (even with \fB\-\-shared\fR) +.TP +\fB\-o\fR FILE, \fB\-\-output\fR FILE +Set output file name +.TP +\fB\-O\fR LEVEL, \fB\-optimize\fR LEVEL +Optimize output file size +.TP +\fB\-\-oformat\fR [binary] +Set output format +.TP +\fB\-p\fR +(ARM only) Ignore for backward compatibility +.TP +\fB\-pie\fR +Create a position independent executable +.TP +\fB\-\-pic\-executable\fR +Create a position independent executable +.TP +\fB\-no\-pipeline\-knowledge\fR +(ARM only) Ignore for backward compatibility +.TP +\fB\-\-plugin\fR PLUGIN +Load a plugin library +.TP +\fB\-\-plugin\-opt\fR OPTION +Pass an option to the plugin +.TP +\fB\-\-preread\-archive\-symbols\fR +Preread archive symbols when multi\-threaded +.TP +\fB\-\-print\-output\-format\fR +Print default output format +.TP +\fB\-\-print\-symbol\-counts\fR FILENAME +Print symbols defined and used for each input +.TP +\fB\-Qy\fR +Ignored for SVR4 compatibility +.TP +\fB\-q\fR, \fB\-\-emit\-relocs\fR +Generate relocations in output +.TP +\fB\-r\fR, \fB\-relocatable\fR +Generate relocatable output +.TP +\fB\-i\fR +Synonym for \fB\-r\fR +.TP +\fB\-\-relax\fR +Relax branches on certain targets +.TP +\fB\-\-retain\-symbols\-file\fR FILE +keep only symbols listed in this file +.TP +\fB\-R\fR DIR +Add DIR to runtime search path +.TP +\fB\-rpath\fR DIR +Add DIR to runtime search path +.TP +\fB\-\-rpath\-link\fR DIR +Add DIR to link time shared library search path +.TP +\fB\-\-section\-ordering\-file\fR FILENAME +Layout sections in the order specified. +.TP +\fB\-\-section\-start\fR SECTION=ADDRESS +Set address of section +.TP +\fB\-\-sort\-common\fR [={ascending,descending}] +Sort common symbols by alignment +.TP +\fB\-\-spare\-dynamic\-tags\fR COUNT +Dynamic tag slots to reserve (default 5) +.TP +\fB\-s\fR, \fB\-\-strip\-all\fR +Strip all symbols +.TP +\fB\-S\fR, \fB\-\-strip\-debug\fR +Strip debugging information +.TP +\fB\-\-strip\-debug\-non\-line\fR +Emit only debug line number information +.TP +\fB\-\-strip\-debug\-gdb\fR +Strip debug symbols that are unused by gdb (at least versions <= 6.7) +.TP +\fB\-\-strip\-lto\-sections\fR +Strip LTO intermediate code sections +.TP +\fB\-\-stub\-group\-size\fR SIZE +(ARM only) The maximum distance from instructions in a group of sections to their stubs. Negative values mean stubs are always after the group. 1 means using default size. +.TP +\fB\-\-no\-keep\-memory\fR +Use less memory and more disk I/O (included only for compatibility with GNU ld) +.TP +\fB\-G\fR, \fB\-shared\fR +Generate shared library +.TP +\fB\-Bshareable\fR +Generate shared library +.TP +\fB\-\-split\-stack\-adjust\-size\fR SIZE +Stack size when \fB\-fsplit\-stack\fR function calls non\-split +.TP +\fB\-static\fR +Do not link against shared libraries +.TP +\fB\-\-icf\fR [none,all,safe] +Identical Code Folding. '\-\-icf=safe' Folds ctors, dtors and functions whose pointers are definitely not taken. +.TP +\fB\-\-icf\-iterations\fR COUNT +Number of iterations of ICF (default 2) +.TP +\fB\-\-print\-icf\-sections\fR +List folded identical sections on stderr +.TP +\fB\-\-no\-print\-icf\-sections\fR +Do not list folded identical sections +.TP +\fB\-\-keep\-unique\fR SYMBOL +Do not fold this symbol during ICF +.TP +\fB\-\-gc\-sections\fR +Remove unused sections +.TP +\fB\-\-no\-gc\-sections\fR +Don't remove unused sections (default) +.TP +\fB\-\-print\-gc\-sections\fR +List removed unused sections on stderr +.TP +\fB\-\-no\-print\-gc\-sections\fR +Do not list removed unused sections +.TP +\fB\-\-stats\fR +Print resource usage statistics +.TP +\fB\-\-sysroot\fR DIR +Set target system root directory +.TP +\fB\-t\fR, \fB\-\-trace\fR +Print the name of each input file +.TP +\fB\-T\fR FILE, \fB\-\-script\fR FILE +Read linker script +.TP +\fB\-\-threads\fR +Run the linker multi\-threaded +.TP +\fB\-\-no\-threads\fR +Do not run the linker multi\-threaded +.TP +\fB\-\-thread\-count\fR COUNT +Number of threads to use +.TP +\fB\-\-thread\-count\-initial\fR COUNT +Number of threads to use in initial pass +.HP +\fB\-\-thread\-count\-middle\fR COUNT Number of threads to use in middle pass +.TP +\fB\-\-thread\-count\-final\fR COUNT +Number of threads to use in final pass +.TP +\fB\-Tbss\fR ADDRESS +Set the address of the bss segment +.TP +\fB\-Tdata\fR ADDRESS +Set the address of the data segment +.TP +\fB\-Ttext\fR ADDRESS +Set the address of the text segment +.TP +\fB\-u\fR SYMBOL, \fB\-\-undefined\fR SYMBOL +Create undefined reference to SYMBOL +.TP +\fB\-\-unresolved\-symbols\fR ignore\-all,report\-all,ignore\-in\-object\-files,ignore\-in\-shared\-libs +How to handle unresolved symbols +.TP +\fB\-\-verbose\fR +Synonym for \fB\-\-debug\fR=\fIfiles\fR +.TP +\fB\-\-version\-script\fR FILE +Read version script +.TP +\fB\-\-warn\-common\fR +Warn about duplicate common symbols +.TP +\fB\-\-no\-warn\-common\fR +Do not warn about duplicate common symbols (default) +.TP +\fB\-\-warn\-constructors\fR +Ignored +.TP +\fB\-\-no\-warn\-constructors\fR +Ignored +.TP +\fB\-\-warn\-execstack\fR +Warn if the stack is executable +.TP +\fB\-\-no\-warn\-execstack\fR +Do not warn if the stack is executable (default) +.TP +\fB\-\-no\-warn\-mismatch\fR +Don't warn about mismatched input files +.TP +\fB\-\-warn\-multiple\-gp\fR +Ignored +.TP +\fB\-\-warn\-search\-mismatch\fR +Warn when skipping an incompatible library +.TP +\fB\-\-no\-warn\-search\-mismatch\fR +Don't warn when skipping an incompatible library +.TP +\fB\-\-warn\-shared\-textrel\fR +Warn if text segment is not shareable +.TP +\fB\-\-no\-warn\-shared\-textrel\fR +Do not warn if text segment is not shareable (default) +.TP +\fB\-\-warn\-unresolved\-symbols\fR +Report unresolved symbols as warnings +.TP +\fB\-\-error\-unresolved\-symbols\fR +Report unresolved symbols as errors +.TP +\fB\-\-no\-wchar\-size\-warning\fR +(ARM only) Do not warn about objects with incompatible wchar_t sizes +.TP +\fB\-\-whole\-archive\fR +Include all archive contents +.TP +\fB\-\-no\-whole\-archive\fR +Include only needed archive contents +.TP +\fB\-\-wrap\fR SYMBOL +Use wrapper functions for SYMBOL +.TP +\fB\-y\fR SYMBOL, \fB\-\-trace\-symbol\fR SYMBOL +Trace references to symbol +.TP +\fB\-\-undefined\-version\fR +Allow unused version in script (default) +.TP +\fB\-\-no\-undefined\-version\fR +Do not allow unused version in script +.TP +\fB\-Y\fR PATH +Default search path for Solaris compatibility +.TP +\-(, \fB\-\-start\-group\fR +Start a library search group +.TP +\-), \fB\-\-end\-group\fR +End a library search group +.TP +\fB\-\-start\-lib\fR +Start a library +.TP +\fB\-\-end\-lib\fR +End a library +.TP +\fB\-z\fR combreloc +Sort dynamic relocs +.TP +\fB\-z\fR nocombreloc +Do not sort dynamic relocs +.TP +\fB\-z\fR common\-page\-size=SIZE +Set common page size to SIZE +.TP +\fB\-z\fR defs +Report undefined symbols (even with \fB\-\-shared\fR) +.TP +\fB\-z\fR execstack +Mark output as requiring executable stack +.TP +\fB\-z\fR initfirst +Mark DSO to be initialized first at runtime +.TP +\fB\-z\fR interpose +Mark object to interpose all DSOs but executable +.TP +\fB\-z\fR lazy +Mark object for lazy runtime binding (default) +.TP +\fB\-z\fR loadfltr +Mark object requiring immediate process +.TP +\fB\-z\fR max\-page\-size=SIZE +Set maximum page size to SIZE +.TP +\fB\-z\fR muldefs +Allow multiple definitions of symbols +.TP +\fB\-z\fR nocopyreloc +Do not create copy relocs +.TP +\fB\-z\fR nodefaultlib +Mark object not to use default search paths +.TP +\fB\-z\fR nodelete +Mark DSO non\-deletable at runtime +.TP +\fB\-z\fR nodlopen +Mark DSO not available to dlopen +.TP +\fB\-z\fR nodump +Mark DSO not available to dldump +.TP +\fB\-z\fR noexecstack +Mark output as not requiring executable stack +.TP +\fB\-z\fR now +Mark object for immediate function binding +.TP +\fB\-z\fR origin +Mark DSO to indicate that needs immediate $ORIGIN processing at runtime +.TP +\fB\-z\fR relro +Where possible mark variables read\-only after relocation +.TP +\fB\-z\fR norelro +Don't mark variables read\-only after relocation +.TP +\fB\-z\fR text +Do not permit relocations in read\-only segments +.TP +\fB\-z\fR notext +Permit relocations in read\-only segments (default) +.TP +\fB\-z\fR textoff +Permit relocations in read\-only segments (default) +.TP +\fB\-z\fR buildd +Dummy z option +.PP +ld.gold: supported targets: elf32\-bigarm elf32\-littlearm elf64\-powerpcle elf64\-powerpc elf32\-powerpcle elf32\-powerpc elf64\-sparc elf32\-sparc elf64\-x86\-64 elf64\-x86\-64\-freebsd elf32\-i386 elf32\-i386\-freebsd +ld.gold: supported emulations: armelfb armelf elf64lppc elf64ppc elf32lppc elf32ppc elf64_sparc elf32_sparc elf_x86_64 elf_i386 +.SH "REPORTING BUGS" +Report bugs to +.SH COPYRIGHT +Copyright 2011 Free Software Foundation, Inc. +This program is free software; you may redistribute it under the terms of +the GNU General Public License version 3 or (at your option) a later version. +This program has absolutely no warranty. +.SH "SEE ALSO" +The full documentation for +.B gold +is maintained as a Texinfo manual. If the +.B info +and +.B gold +programs are properly installed at your site, the command +.IP +.B info gold +.PP +should give you access to the complete manual. --- binutils-2.22.orig/debian/binutils-spu.postrm +++ binutils-2.22/debian/binutils-spu.postrm @@ -0,0 +1,7 @@ +#! /bin/sh + +set -e + +if [ "$1" = "remove" ]; then + ldconfig +fi --- binutils-2.22.orig/debian/control.cross.in +++ binutils-2.22/debian/control.cross.in @@ -0,0 +1,11 @@ +Package: binutils-__TARGET__ +Architecture: any +Depends: binutils, ${shlibs:Depends} +Suggests: binutils-doc (= ${Source-Version}) +Priority: extra +Description: GNU binary utilities, for __TARGET__ target + This package provides GNU assembler, linker and binary utilities + for __TARGET__ target, for use in a cross-compilation environment. + . + You don't need this package unless you plan to cross-compile programs + for __TARGET__. --- binutils-2.22.orig/debian/binutils-hppa64.overrides +++ binutils-2.22/debian/binutils-hppa64.overrides @@ -0,0 +1,8 @@ +# don't warn about missing man pages for diverted binaries +binutils-hppa64 binary: binary-without-manpage + +# the API of the shared libs is not public, don't care about the name +binutils-hppa64 binary: package-name-doesnt-match-sonames + +# it's a cross toolchain +binutils-hppa64 binary: binary-or-shlib-defines-rpath --- binutils-2.22.orig/debian/changelog +++ binutils-2.22/debian/changelog @@ -0,0 +1,4604 @@ +binutils (2.22-6ubuntu1.4) precise-security; urgency=medium + + * debian/patches/binutils-bz17512-misc.patch: fix segfault + in objcopy on i386 to compensate for missing commit + e7ebb214834628b2b0d9d3233febc9fef2912515 to address + sbsigntool FTBFS (LP: #1477350) + + -- Steve Beattie Wed, 01 Jun 2016 00:48:14 -0700 + +binutils (2.22-6ubuntu1.3) precise-proposed; urgency=medium + + * gold: Add -fuse-ld= for GCC linker option compatibility. LP: #1438244. + + -- Matthias Klose Mon, 30 Mar 2015 16:52:07 +0200 + +binutils (2.22-6ubuntu1.2) precise-security; urgency=medium + + * SECURITY UPDATE: integer overflow in objalloc_alloc + - debian/patches/binutils-CVE-2012-3509.patch: Add overflow check + covering alignment and CHUNK_HEADER_SIZE addition. + - CVE-2012-3509 + * SECURITY UPDATE: out-of-bounds read in srec_scan of bfd/srec.c + - debian/patches/binutils-CVE-2014-8484.patch: report an error + for S-records with less than the miniumum size + - CVE-2014-8484 + * SECURITY UPDATE: incorrect memory handling around corrupt group + section headers + - debian/patches/binutils-CVE-2014-8485.patch: Improve handling + of corrupt group sections + - CVE-2014-8485 + * SECURITY UPDATE: out-of-bounds write in _bfd_XXi_swap_aouthdr_in + - debian/patches/binutils-CVE-2014-8501.patch: Handle corrupt + binaries with an invalid value for NumberOfRvaAndSizes. + - CVE-2014-8501 + * SECURITY UPDATE: pe_print_edata buffer overflow + - debian/patches/binutils-CVE-2014-8502.patch: Detect out of + range and truncated rvas or entry counts + - CVE-2014-8502 + * SECURITY UPDATE: ihex_scan buffer overflow + - debian/patches/binutils-CVE-2014-8503.patch: Fix typo in + invocation of ihex_bad_byte. + - CVE-2014-8503 + * SECURITY UPDATE: srec_scan buffer overflow + - debian/patches/binutils-CVE-2014-8504.patch: Increase size of buf + - CVE-2014-8504 + * SECURITY UPDATE: directory traversal vulnerabilities + - debian/patches/binutils-CVE-2014-8737.patch: disallow paths that + include ../ + - CVE-2014-8737 + * SECURITY UPDATE: _bfd_slurp_extended_name_table out-of-bounds write + - debian/patches/binutils-CVE-2014-8738.patch: Handle archives + with corrupt extended name tables. + - CVE-2014-8738 + * SECURITY UPDATE: multiple miscellaneous overflows and out-of-bounds + reads and writes + - debian/patches/binutils-bz17512_prereqs.patch: cherrypicked + prerequisite commits needed to apply following patch + - debian/patches/binutils-bz17512-misc.patch: fix invalid memory + accesses. + * Security hardening: don't use libbfd by default in strings(1) + - debian/patches/binutils-harden_strings.patch: Add new command + line option --data to only scan the initialized, loadable data + sections of binaries, using libbfd; make --all the default. + + -- Steve Beattie Mon, 09 Feb 2015 02:11:51 -0800 + +binutils (2.22-6ubuntu1.1) precise-security; urgency=low + + * Backport gold patch to use PIC stubs in all position independent objects, + so that we can have a functioning build of Chromium on armhf + - add debian/patches/213-gold-arm-pie-fix.patch + - update debian/patches/series + + -- Chris Coulson Thu, 21 Feb 2013 17:06:02 +0000 + +binutils (2.22-6ubuntu1) precise; urgency=low + + * Merge with Debian. + + -- Matthias Klose Thu, 08 Mar 2012 19:21:22 +0100 + +binutils (2.22-6) unstable; urgency=low + + * Update from the binutils-2_22-branch 20120307. + - Fix PR ld/12161 (avr), PR binutils/13622 (readelf crash), + PR binutils/13476 (hppa), PR ld/13387 (hppa), + * Fix typo in elf64-x86-64.c, follow-up patch to PR ld/13302. + + -- Matthias Klose Thu, 08 Mar 2012 18:52:20 +0100 + +binutils (2.22-5ubuntu1) precise; urgency=low + + * Merge with Debian. + + -- Matthias Klose Wed, 25 Jan 2012 11:47:53 +0100 + +binutils (2.22-5) unstable; urgency=low + + * Update from the binutils-2_22-branch 20120124. + - Fix PR ld/13581 (x32). + * Fix PR gas/13449 (ARM), taken from the trunk. + + -- Matthias Klose Tue, 24 Jan 2012 21:26:43 +0100 + +binutils (2.22-4ubuntu1) precise; urgency=low + + * Merge with Debian. + + -- Matthias Klose Sat, 07 Jan 2012 10:27:24 +0100 + +binutils (2.22-4) unstable; urgency=low + + * Don't bump the soversion (revert the change in 2.22-3). + * Apply proposed patch for PR binutils/13534, allowing ar to handle + files bigger than 2GB (Francois Gouget). Closes: #652887). + * Recognize DW_LANG_Go in readelf (backport from trunk). + + -- Matthias Klose Sat, 07 Jan 2012 09:07:25 +0100 + +binutils (2.22-3ubuntu1) precise; urgency=low + + * Merge with Debian. + + -- Matthias Klose Tue, 03 Jan 2012 07:28:18 +0100 + +binutils (2.22-3) unstable; urgency=low + + * Update from the binutils-2_22-branch 20120102. + - gold updates. + - mips updates. + + -- Matthias Klose Tue, 03 Jan 2012 06:06:20 +0100 + +binutils (2.22-2ubuntu1) precise; urgency=low + + * Merge with Debian. + + -- Matthias Klose Sun, 11 Dec 2011 17:37:30 +0100 + +binutils (2.22-2) unstable; urgency=low + + * Update from the binutils-2_22-branch 20111211. + * Fix build failure with make 3.82 (Daniel Schepler). Closes: #650064. + + -- Matthias Klose Sun, 11 Dec 2011 16:30:14 +0000 + +binutils (2.22-1ubuntu1) precise; urgency=low + + * Merge with Debian. + + -- Matthias Klose Mon, 21 Nov 2011 17:47:56 +0100 + +binutils (2.22-1) unstable; urgency=low + + * Binutils 2.22 release. + + -- Matthias Klose Mon, 21 Nov 2011 16:50:53 +0100 + +binutils (2.21.90.20111025-1ubuntu1) precise; urgency=low + + * Merge with Debian. + + -- Matthias Klose Tue, 25 Oct 2011 15:46:41 +0200 + +binutils (2.21.90.20111025-1) unstable; urgency=low + + * Snapshot, taken from the binutils-2_22-branch 20111025. + * Fix lintian warnings. + + -- Matthias Klose Tue, 25 Oct 2011 15:06:46 +0200 + +binutils (2.21.90.20111019-3ubuntu1) precise; urgency=low + + * Merge with Debian. + + -- Matthias Klose Sun, 23 Oct 2011 13:41:58 +0200 + +binutils (2.21.90.20111019-3) unstable; urgency=low + + * Fix PR ld/13302, taken from the trunk. + + -- Matthias Klose Sun, 23 Oct 2011 13:15:07 +0200 + +binutils (2.21.90.20111019-2ubuntu1) precise; urgency=low + + * Merge with Debian. + + -- Matthias Klose Thu, 20 Oct 2011 13:12:50 +0200 + +binutils (2.21.90.20111019-2) unstable; urgency=low + + * Fix PR ld/13287, taken from the trunk. LP: #872687. + + -- Matthias Klose Thu, 20 Oct 2011 12:29:18 +0200 + +binutils (2.21.90.20111019-1) unstable; urgency=low + + * Snapshot, taken from the binutils-2_22-branch 20111019. + + -- Matthias Klose Wed, 19 Oct 2011 22:25:05 +0200 + +binutils (2.21.90.20111004-2ubuntu1) oneiric; urgency=low + + * Merge with Debian. + + -- Matthias Klose Tue, 11 Oct 2011 12:36:33 +0200 + +binutils (2.21.90.20111004-2) unstable; urgency=low + + * Fix PR ld/13250, preserve the maximum alignment and size for common + symbols (H.J. Lu). Closes: #608901. LP: #697229. + + -- Matthias Klose Thu, 06 Oct 2011 08:06:04 +0200 + +binutils (2.21.90.20111004-1) unstable; urgency=medium + + * Snapshot, taken from the binutils-2_22-branch 20111004. + * Fix PR ld/13195, taken from the trunk. Closes: #643858, #644183. + + -- Matthias Klose Tue, 04 Oct 2011 12:12:16 +0200 + +binutils (2.21.53.20110922-1) unstable; urgency=low + + * Snapshot, taken from the binutils-2_22-branch 20110924. + + -- Matthias Klose Sat, 24 Sep 2011 09:55:38 +0200 + +binutils (2.21.53.20110910-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110910. + - Fix PR gas/13024. Closes: #635592. + * Build with proposed patch for PR ld/12965. + * Don't ship .la files in the cross binutils packages. + * For native builds, add the multiarch directories to the default + search path. + + -- Matthias Klose Sat, 10 Sep 2011 13:06:01 +0200 + +binutils (2.21.53.20110823-3) unstable; urgency=low + + * Revert the last change: + - Default to --hash-style=both in ld.bfd and ld.gold. + + -- Matthias Klose Thu, 25 Aug 2011 10:48:28 +0200 + +binutils (2.21.53.20110823-2) unstable; urgency=low + + * Default to --hash-style=both in ld.bfd and ld.gold. + * Fix s390x build (Aurelian Jarno). Closes: #635167. + + -- Matthias Klose Wed, 24 Aug 2011 13:06:48 +0200 + +binutils (2.21.53.20110823-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110823. + - ld --no-copy-dt-needed-entries/--no-add-needed is now the default. + + -- Matthias Klose Tue, 23 Aug 2011 21:23:38 +0200 + +binutils (2.21.53.20110810-0ubuntu4) oneiric-proposed; urgency=low + + * Fix PR ld/13250, preserve the maximum alignment and size for common + symbols (H.J. Lu). Closes: #608901. LP: #697229. + + -- Matthias Klose Thu, 06 Oct 2011 09:22:34 +0200 + +binutils (2.21.53.20110810-0ubuntu3) oneiric; urgency=low + + * Fix PR ld/13201, link error with --as-needed and -flto. LP: #778292. + LP: #690194. + + -- Matthias Klose Tue, 20 Sep 2011 11:34:33 +0200 + +binutils (2.21.53.20110810-0ubuntu2) oneiric; urgency=low + + * Build with proposed patch for PR ld/12965. LP: #641126. + * Don't ship .la files in the cross binutils packages. LP: #760420. + * For native builds, add the multiarch directories to the default + search path. LP: #780455. + + -- Matthias Klose Wed, 07 Sep 2011 15:36:22 +0200 + +binutils (2.21.53.20110810-0ubuntu1) oneiric; urgency=low + + * Snapshot, taken from the trunk 20110810. + + -- Matthias Klose Thu, 11 Aug 2011 22:51:48 +0200 + +binutils (2.21.53.20110805-1ubuntu1) oneiric; urgency=low + + * Merge with Debian. + + -- Matthias Klose Fri, 05 Aug 2011 12:34:26 +0200 + +binutils (2.21.53.20110805-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110805. + + -- Matthias Klose Fri, 05 Aug 2011 12:25:49 +0200 + +binutils (2.21.53.20110729-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110729. + * Fix s390x build (Aurelian Jarno). Closes: #635167. + + -- Matthias Klose Fri, 29 Jul 2011 19:04:46 +0200 + +binutils (2.21.53.20110720-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110720. + - Fix PR ld/12978. Closes: #632681. + + -- Matthias Klose Wed, 20 Jul 2011 20:54:51 +0200 + +binutils (2.21.52.20110707-1ubuntu1) oneiric; urgency=low + + * Merge with Debian. + + -- Matthias Klose Thu, 07 Jul 2011 07:28:51 +0200 + +binutils (2.21.52.20110707-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110707. + - Fix build failure on mips/mipsel. Closes: #632690. + - Fix issues on kfreebsd-amd64. Closes: #632671. + + -- Matthias Klose Thu, 07 Jul 2011 06:48:33 +0200 + +binutils (2.21.52.20110703-1ubuntu1) oneiric; urgency=low + + * Merge with Debian. + + -- Matthias Klose Mon, 04 Jul 2011 10:31:01 +0200 + +binutils (2.21.52.20110703-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110703. + + -- Matthias Klose Sun, 03 Jul 2011 21:56:44 +0200 + +binutils (2.21.52.20110606-2) unstable; urgency=low + + * Fix PR ld/12845, taken from the trunk. Closes: #628685. + + -- Matthias Klose Thu, 09 Jun 2011 12:45:15 +0200 + +binutils (2.21.52.20110606-1ubuntu1) oneiric; urgency=low + + * Merge with Debian. + + -- Matthias Klose Tue, 07 Jun 2011 11:56:41 +0200 + +binutils (2.21.52.20110606-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110606. + - Fix PR ld/12833. Closes: #628770. + - Fix spelling errors. Closes: #604696. + * Let gold accept a dummy -z buildd- option. + * Add a /usr/share/bug/binutils/presubj file for reportbug (and symlinks + from the other /usr/share/bug/binutils-foo directories) explaining how + to make a self-contained testcase (Jonathan Nieder). Closes: #629147. + * Fix ld crash cause of invalid pointer in munmap_chunk. Closes: #628916. + + -- Matthias Klose Tue, 07 Jun 2011 00:03:47 +0200 + +binutils (2.21.51.20110523-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110523. + + -- Matthias Klose Mon, 23 May 2011 23:38:52 +0200 + +binutils (2.21.51.20110421-6ubuntu1) oneiric; urgency=low + + * Merge with Debian. + + -- Matthias Klose Thu, 19 May 2011 16:02:39 +0200 + +binutils (2.21.51.20110421-6) unstable; urgency=low + + [ Marcin Juszkiewicz ] + * Use pregenerated ld.gold.1 for cross builds. + + [ Matthias Klose ] + * Redefine STRIP and install_binary for cross builds (Ken Werner). + * Apply fix for PR ld/12726, taken from the trunk. + + -- Matthias Klose Thu, 19 May 2011 15:51:22 +0200 + +binutils (2.21.51.20110421-5) unstable; urgency=medium + + * Use a symlink for /usr/bin/ld, even if gold is not built. Closes: #615262. + + -- Matthias Klose Tue, 17 May 2011 17:58:17 +0200 + +binutils (2.21.51.20110421-4) unstable; urgency=low + + * Fix PR ld/12730, taken from the trunk. Closes: #625616. + * Cortex A8 workarounds for PLT tail calls (Richard Sandiford). + + -- Matthias Klose Sun, 08 May 2011 02:06:22 +0200 + +binutils (2.21.51.20110421-3) unstable; urgency=low + + * Fix segfault in ar, delete_members. + + -- Matthias Klose Sun, 01 May 2011 17:30:42 +0200 + +binutils (2.21.51.20110421-2) unstable; urgency=low + + * Fix typo in the patch for PR gas/12698. + + -- Matthias Klose Wed, 27 Apr 2011 21:33:47 +0200 + +binutils (2.21.51.20110421-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110421. + * Install a man page for ld.gold, generated by help2man. Closes: #619823. + * Apply proposed patch for PR gas/12698. Closes: #623964. + + -- Matthias Klose Wed, 27 Apr 2011 18:14:39 +0200 + +binutils (2.21.51.20110421-0ubuntu6) oneiric; urgency=low + + * Fix PR ld/12730, taken from the trunk. Closes: #625616. + + -- Matthias Klose Sun, 08 May 2011 02:17:37 +0200 + +binutils (2.21.51.20110421-0ubuntu5) oneiric; urgency=low + + * Cortex A8 workarounds for PLT tail calls (Richard Sandiford). + + -- Matthias Klose Fri, 06 May 2011 11:55:11 +0200 + +binutils (2.21.51.20110421-0ubuntu4) oneiric; urgency=low + + * Fix segfault in ar, delete_members. + + -- Matthias Klose Sun, 01 May 2011 17:30:42 +0200 + +binutils (2.21.51.20110421-0ubuntu3) oneiric; urgency=low + + * Install a man page for ld.gold, generated by help2man. Closes: #619823. + * Apply proposed patch for PR gas/12698. Closes: #623964. + + -- Matthias Klose Wed, 27 Apr 2011 20:26:20 +0200 + +binutils (2.21.51.20110421-0ubuntu1) oneiric; urgency=low + + * Snapshot, taken from the trunk 20110421. + + -- Matthias Klose Thu, 21 Apr 2011 14:24:45 +0200 + +binutils (2.21.51.20110419-2) unstable; urgency=low + + * Fix powerpcspe and sparc builds. + + -- Matthias Klose Tue, 19 Apr 2011 13:47:56 +0200 + +binutils (2.21.51.20110419-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20110419. + + -- Matthias Klose Tue, 19 Apr 2011 10:18:14 +0200 + +binutils (2.21.0.20110327-2ubuntu2) natty; urgency=low + + * Fix architecture field for binutils-gold (powerpcspe). + * Add support for arm-*-gnueabihf targets. Closes: #621029. + * Fix PR ld/12654: Pproperly handle R_386_TLS_LDO_32 for PIE. LP: #663294. + + -- Matthias Klose Sat, 09 Apr 2011 13:35:11 +0200 + +binutils (2.21.0.20110327-2ubuntu1) natty; urgency=low + + [ Marcin Juszkiewicz ] + * Build -dbgsym package for cross builds. LP: #711523. + + -- Matthias Klose Thu, 31 Mar 2011 16:24:10 +0200 + +binutils (2.21.0.20110327-2) unstable; urgency=low + + * Fix architecture field for binutils-gold. + * Configure with --disable-werror on armhf. + + -- Matthias Klose Tue, 29 Mar 2011 19:38:55 +0200 + +binutils (2.21.0.20110327-1) unstable; urgency=low + + * Update from the 2.21 branch 20110327. + * Add multiarch directories to linker search path. Closes: #369064. + LP: #738098. + + -- Matthias Klose Sun, 27 Mar 2011 22:32:57 +0100 + +binutils (2.21.0.20110322-1ubuntu2) natty; urgency=low + + * Add multiarch directories to linker search path. Closes: #369064. + LP: #738098. + + -- Matthias Klose Sat, 26 Mar 2011 11:27:54 +0100 + +binutils (2.21.0.20110322-1ubuntu1) natty; urgency=low + + * Merge with Debian. + + -- Matthias Klose Tue, 22 Mar 2011 23:36:26 +0100 + +binutils (2.21.0.20110322-1) unstable; urgency=low + + * Update from the 2.21 branch 20110322. + * S/390: Make as to accept all instructions if no -march option given. + taken from the trunk (Aurelian Jarno). Closes: #618751. + * Extend support for armhf (Loic Minier). + - debian/control.in, debian/control, debian/rules: Enable gold for armhf. + - debian/rules: Introduce $(CROSS) (set to $(DEB_HOST_GNU_TYPE)- when + cross-building) and call $(CROSS)cpp to check whether -marm is needed or + not instead of testing for armel; an alternative would be to + unconditionally set -marm if DEB_HOST_ARCH_CPU is arm. + - debian/rules: commented out -fno-section-anchors CFLAGS handling would + also be enabled for armhf. + - debian/rules: ignore regressions on armhf as well; note that + ignore_regressions is set three times. + + -- Matthias Klose Tue, 22 Mar 2011 23:12:39 +0100 + +binutils (2.21.0.20110302-2ubuntu1) natty; urgency=low + + * Merge with Debian. + + -- Matthias Klose Fri, 11 Mar 2011 00:14:22 +0100 + +binutils (2.21.0.20110302-2) unstable; urgency=low + + [ Carlos O'Donell ] + * Fix binutils-hppa64 build. + + [ Matthias Klose ] + * Fix PR ld/12376 (John David Anglin), taken from the trunk. + * Update to the 2.21 branch, 20110310. + + -- Matthias Klose Thu, 10 Mar 2011 21:35:07 +0100 + +binutils (2.21.0.20110302-1ubuntu1) natty; urgency=low + + * Merge with Debian. + + -- Matthias Klose Fri, 04 Mar 2011 01:37:26 +0100 + +binutils (2.21.0.20110302-1) unstable; urgency=low + + * Update from the 2.21 branch. + + [ Thorsten Glaser ] + * patches/640_m68k_fix-TLS_GD-relocation: new, temp. Closes: #611768. + + [ Matthias Klose ] + * On ppc64, look for 32 bit target libraries in /lib32, /usr/lib32 etc., + first. + + -- Matthias Klose Wed, 02 Mar 2011 02:41:17 +0100 + +binutils (2.21.0.20110216-2) unstable; urgency=low + + * Upload to unstable. + + -- Matthias Klose Tue, 22 Feb 2011 20:35:16 +0100 + +binutils (2.21.0.20110216-1ubuntu3) natty; urgency=low + + * Read multiarch targets from the first column of /usr/share/dpkg/archtable; + it's not the ideal list, but it's better than a hardcoded list and + enabling all targets was breaking too many tools; LP: #726428. + + -- Loïc Minier Wed, 02 Mar 2011 18:57:13 +0100 + +binutils (2.21.0.20110216-1ubuntu2) natty; urgency=low + + * Remove leftover bfd/elflink.c.rej. + * Pass --enable-targets=all to configure in the multiarch pass; + Debian #610745. + + -- Loïc Minier Thu, 24 Feb 2011 11:46:06 +0100 + +binutils (2.21.0.20110216-1ubuntu1) natty; urgency=low + + * Upload to natty. + + -- Matthias Klose Wed, 16 Feb 2011 19:43:02 +0100 + +binutils (2.21.0.20110216-1) experimental; urgency=low + + * Update from the 2.21 branch. + + -- Matthias Klose Wed, 16 Feb 2011 15:54:15 +0100 + +binutils (2.21-5ubuntu1) natty; urgency=low + + * Upload to natty. + + -- Matthias Klose Tue, 25 Jan 2011 05:46:53 +0100 + +binutils (2.21-5) experimental; urgency=low + + * Update gold to 1.11, taken from the 2.21 branch. + * Add the arm-linux-gnueabi target to binutils-multiarch (Loic Minier). + + -- Matthias Klose Tue, 25 Jan 2011 00:51:38 +0100 + +binutils (2.21-4ubuntu1) natty; urgency=low + + * Revert the soname change. + + -- Matthias Klose Wed, 12 Jan 2011 22:09:24 +0100 + +binutils (2.21-4ubuntu0) natty; urgency=low + + * Intermediate upload to natty to change the soversion on amd64. + + -- Matthias Klose Wed, 12 Jan 2011 21:51:03 +0100 + +binutils (2.21-4) experimental; urgency=low + + * Fix handling of writable .eh_frame section in gold, taken from the + 2.21 branch. + + -- Matthias Klose Wed, 12 Jan 2011 00:42:15 +0100 + +binutils (2.21-3ubuntu1) natty; urgency=low + + * Upload to natty. + + -- Matthias Klose Fri, 31 Dec 2010 16:31:48 +0100 + +binutils (2.21-3) experimental; urgency=low + + [ Matthias Klose ] + * Don't include `-system' in the bfd version identifier. + + [ Sedat Dilek ] + * 160_pr12327.patch: Fix PR ld/12327, taken from the trunk. + + -- Matthias Klose Thu, 29 Dec 2010 23:51:35 +0100 + +binutils (2.21-2) experimental; urgency=low + + * Don't install ld.bfd in binutils-multiarch. + * Fix assembler bug blocking Thumb-2 kernel builds (CS issue #8775). + + -- Matthias Klose Fri, 10 Dec 2010 13:45:00 +0100 + +binutils (2.21-1ubuntu4) natty; urgency=low + + * Don't install ld.bfd in binutils-multiarch. LP: #688497. + * Fix assembler bug blocking Thumb-2 kernel builds (CS issue #8775). + + -- Matthias Klose Fri, 10 Dec 2010 15:35:54 +0100 + +binutils (2.21-1ubuntu2) natty; urgency=low + + * Fix build dependencies. + + -- Matthias Klose Fri, 10 Dec 2010 00:57:01 +0100 + +binutils (2.21-1ubuntu1) natty; urgency=low + + * Upload to natty. + + -- Matthias Klose Fri, 10 Dec 2010 00:17:07 +0100 + +binutils (2.21-1) experimental; urgency=low + + * binutils 2.21 release. + + [ Marcin Juszkiewicz ] + + * Enable building gold in cross builds. LP: #686530. + * Allow to build only the -source package, and include the version + in the package name. LP: #682646. + + -- Matthias Klose Thu, 09 Dec 2010 23:24:49 +0100 + +binutils (2.20.90.20101121-0ubuntu1) natty; urgency=low + + * Update from the binutils 2.21 release branch. + + -- Matthias Klose Sun, 21 Nov 2010 13:53:59 +0100 + +binutils (2.20.90.20101105-0ubuntu1) natty; urgency=low + + * binutils 2.21 prerelease 1. + + -- Matthias Klose Wed, 10 Nov 2010 01:47:38 +0200 + +binutils (2.20.51.20101028-0ubuntu1) natty; urgency=low + + * Snapshot, taken from the trunk 20100928. + + -- Matthias Klose Thu, 28 Oct 2010 17:55:49 +0200 + +binutils (2.20.51.20101014-0ubuntu1) natty; urgency=low + + * Snapshot, taken from the trunk 20100914. + * ld: Accept --sysroot again. LP: #660257. + + -- Matthias Klose Thu, 14 Oct 2010 11:10:06 +0200 + +binutils (2.20.51.20101009-0ubuntu1) natty; urgency=low + + * Snapshot, taken from the trunk 20100909. + * For cross builds, build without sysroot support. Closes LP: #598389. + + -- Matthias Klose Sat, 09 Oct 2010 15:08:04 +0200 + +binutils (2.20.51.20100908-0ubuntu2) maverick; urgency=low + + * debian/patches/216-tilde-in-ar-filenames: Allow ar scripts to contain ~ + in the filename, fixes u-boot-linaro rc build failures that ended up + using pathnames with ~ in them. LP: #641488 + + -- Zygmunt Krynicki Fri, 17 Sep 2010 19:20:28 +0200 + +binutils (2.20.51.20100908-0ubuntu1) maverick; urgency=low + + * Snapshot, taken from the trunk 20100908. + * Build binutils-hppa64 in cross builds (Al Viro). Closes: #595319. + * Don't build the binutils-hppa64 package for Ubuntu. + * Fix some lintian warnings. + + -- Matthias Klose Wed, 08 Sep 2010 15:26:18 +0200 + +binutils (2.20.51.20100813-1ubuntu3) maverick; urgency=low + + * Add missing patch file. + + -- Matthias Klose Fri, 03 Sep 2010 10:32:25 +0200 + +binutils (2.20.51.20100813-1ubuntu2) maverick; urgency=low + + * Link executables statically when `static' is passed in DEB_BUILD_OPTIONS + (Jim Heck). Closes: #590101. + * Apply proposed patch for PR ld/10340 (ld doesn't honor sysroot prefix + for ldscripts). LP: #625320. + + -- Matthias Klose Fri, 27 Aug 2010 16:52:19 +0200 + +binutils (2.20.51.20100813-1ubuntu1) maverick; urgency=low + + * Merge with Debian. + + -- Matthias Klose Fri, 13 Aug 2010 13:26:32 +0200 + +binutils (2.20.51.20100813-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100813. + + [ Jonathan Nieder ] + * Remove ld.bfd from binutils-multiarch (not that useful without an + multiarch assembler). + + [ Marcin Juszkiewicz ] + * Revert sysroot to / for cross builds. LP: #598389. + * Generate debian/control for native and cross builds. LP: #612629. + * Provide packaging rules in -source package. LP: #608745. + + [ Matthias Klose ] + * Don't apply patches, when PATCHED_SOURCES is set to `yes'. + * Proposed patch for PR11889, readelf crashes for malformed binaries + (Dan Rosenberg). LP: #614206. + + -- Matthias Klose Fri, 13 Aug 2010 11:10:14 +0200 + +binutils (2.20.51.20100710-1ubuntu2) maverick; urgency=low + + * Don't use configury for cross builds for native builds. LP: #604134. + + -- Matthias Klose Sun, 11 Jul 2010 10:15:01 +0200 + +binutils (2.20.51.20100710-1ubuntu1) maverick; urgency=low + + * Update HJ patches from binutils 2.20.51.0.10. + + -- Matthias Klose Sat, 10 Jul 2010 11:42:27 +0200 + +binutils (2.20.51.20100710-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100710. + - Fix PR gas/10531. LP: #599485. + * debian/rules: Introduce PF macros (Jim Heck). Closes: #588357. + + [ Marcin Juszkiewicz ] + * Don't install documentation files in -cross packages. Closes: #586636. + * Set sysroot to /usr/$(TARGET) for cross builds. LP: #598389. + + -- Matthias Klose Sat, 10 Jul 2010 10:42:55 +0200 + +binutils (2.20.51.20100617-0ubuntu1) maverick; urgency=low + + * Snapshot, taken from the trunk 20100617. + + -- Matthias Klose Thu, 17 Jun 2010 15:30:31 +0200 + +binutils (2.20.51.20100608-0ubuntu1) maverick; urgency=low + + * Snapshot, taken from the trunk 20100608. + * Merge 'binary-cross' target into 'binary' one (Marcin Juszkiewicz). + LP: #587851. + * debian/copyright: Update to GFDL 1.3. + + -- Matthias Klose Tue, 08 Jun 2010 13:26:49 +0200 + +binutils (2.20.51.20100527-1ubuntu1) maverick; urgency=low + + * Merge with Debian; remaining changes: + - Build binutils-static. + + -- Matthias Klose Thu, 27 May 2010 12:32:39 +0200 + +binutils (2.20.51.20100527-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100527. + + [ Jonathan Nieder ] + * debian/binutils-multiarch.preinst.in: Re-add diversions on reinstall. + Closes: #581156. + * Remove c++filt from binutils-multiarch. + * Rename /usr/bin/ld from multiarch build to ld.bfd. Closes: #582490. + LP: #586227. + + -- Matthias Klose Thu, 27 May 2010 10:40:48 +0200 + +binutils (2.20.51.20100518-1ubuntu1) maverick; urgency=low + + * Snapshot, taken from the trunk 20100518. + * Merge with Debian; remaining changes: + - Build binutils-static. + * Update hjl patches from 2.20.51.0.8. + + -- Matthias Klose Tue, 18 May 2010 14:04:04 +0200 + +binutils (2.20.51.20100518-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100518. + + -- Matthias Klose Tue, 18 May 2010 13:29:45 +0200 + +binutils (2.20.51.20100428-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100428. + + -- Matthias Klose Wed, 28 Apr 2010 10:07:28 +0200 + +binutils (2.20.51.20100418-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100418. + * debian/*.shlibs.in: Automate upstream version changes. + * Configure native build --with-sysroot=/. Closes: #556126. + * Move the ld.gold binary into the binutils package, just keep the + diversion (ld) in the binutils-gold package. + * Linker selection: ld is used by default, to use the gold linker, + pass -fuse-linker-plugin (no other side effects if -flto/-fwhopr + is not passed). To force ld.bfd or ld.gold, pass -B/usr/lib/compat-ld + for ld.bfd or /usr/lib/gold-ld for ld.gold. + * Apply proposed patch for ARM: Add option to disable merging of adjacent + exidx unwinder entries. + + [ Jonathan Nieder ] + * Clean up diversion handling in binutils-multiarch: + - remove diversion of libbfd.a and libopcodes.a. Closes: #545067. + - wait for the new version to be unpacked before removing old diversions + - avoid messages from re-adding diversions when upgrading from a version + that already has them + - remove diversions when downgrading to a version that does not have + them (for example, when recovering from an upgrade failure) + * Add diversion for ld.bfd in binutils-multiarch. + * Update comment in debian/rules to acknowledge that binutils-multiarch + includes a linker now. + * Add c++filt to binutils-multiarch. + * Remove elfedit from binutils-multiarch. + Its functionality does not depend on the list of supported targets. + * Fixup to version changes handling. + + -- Matthias Klose Sun, 18 Apr 2010 14:18:59 +0200 + +binutils (2.20.51.20100407-0ubuntu1) lucid; urgency=low + + * Snapshot, taken from the trunk 20100407. + * debian/*.shlibs: Update to the version from the trunk. + * Configure native build --with-sysroot=/. Closes: #556126. + + -- Matthias Klose Thu, 08 Apr 2010 01:31:49 +0200 + +binutils (2.20.51.20100405-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100405. + * debian/*.shlibs: Update to the version from the trunk. + * Mangle the soname of the binutils libraries to be different than + the default name. Closes: #557620. + Packaged cross builds should do the same. + * Add diversion for elfedit in binutils-multiarch (Jonathan Nieder). + Closes: #576126. + * Convert to quilt (Sedat Dilek). + * Update to proposed patch to enable both gold and ld in a single toolchain. + The gold binary is now installed as `gold'. Keep the name `ld.gold'. + + -- Matthias Klose Mon, 05 Apr 2010 14:49:46 +0200 + +binutils (2.20.51.20100227-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100227. + * debian/*.shlibs: Update to the version from the trunk. + + -- Matthias Klose Sat, 27 Feb 2010 08:55:05 +0100 + +binutils (2.20.51.20100222-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100222. + * debian/*.shlibs: Update to the version from the trunk. + * binutils-dev: Install plugin-api.h. + * Ignore testsuite regressions on armel. + + -- Matthias Klose Tue, 23 Feb 2010 02:27:28 +0100 + +binutils (2.20.51.20100216-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100216. + * debian/*.shlibs: Update to the version from the trunk. + + -- Matthias Klose Tue, 16 Feb 2010 17:49:47 +0100 + +binutils (2.20.51.20100112-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100112. + * debian/*.shlibs: Update to the version from the trunk. + + -- Matthias Klose Tue, 12 Jan 2010 09:06:51 +0100 + +binutils (2.20.51.20100109-2) experimental; urgency=low + + * Regenerate ld/configure (includes ld in the binutils package). + + -- Matthias Klose Mon, 11 Jan 2010 01:48:09 +0100 + +binutils (2.20.51.20100109-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100109. + - PR gold/10980: Support more options available by current GNU ld. + Closes: #555886. + - Fix PR gold/11072: Discard .gnu_debuglink sections, taken from the trunk. + Closes: #563366. + * debian/*.shlibs: Update to the version from the trunk. + + -- Matthias Klose Sat, 09 Jan 2010 14:32:33 +0100 + +binutils (2.20.51.20100101-1) experimental; urgency=low + + * Snapshot, taken from the trunk 20100101. + * debian/*.shlibs: Update to the version from the trunk. + * Remove patches available on the trunk. + + -- Matthias Klose Fri, 01 Jan 2010 18:49:42 +0100 + +binutils (2.20.1-9ubuntu1) maverick; urgency=low + + * Merge with Debian; remaining changes: + - Build binutils-static. + + -- Matthias Klose Thu, 06 May 2010 16:56:40 +0200 + +binutils (2.20.1-9) unstable; urgency=high + + * [arm] branches to weak symbols, update patch from the trunk. + + -- Matthias Klose Thu, 06 May 2010 15:42:22 +0200 + +binutils (2.20.1-8ubuntu2) maverick; urgency=low + + * Build gold for powerpc as well. + + -- Matthias Klose Sat, 01 May 2010 14:22:35 +0200 + +binutils (2.20.1-8ubuntu1) maverick; urgency=low + + * Merge with Debian; remaining changes: + - Build binutils-static. + + -- Matthias Klose Thu, 29 Apr 2010 21:40:16 +0200 + +binutils (2.20.1-8) unstable; urgency=low + + * [arm] branches to weak symbols, patch taken from the trunk. + + -- Matthias Klose Thu, 29 Apr 2010 20:36:07 +0200 + +binutils (2.20.1-7) unstable; urgency=low + + * Apply proposed patch for ARM: Add option to disable merging of adjacent + exidx unwinder entries. Addresses PR libgcj/40860. + + -- Matthias Klose Tue, 20 Apr 2010 22:51:35 +0000 + +binutils (2.20.1-6) unstable; urgency=low + + * Move the ld.gold binary into the binutils package, just keep the + diversion (ld) in the binutils-gold package. + * Linker selection: ld is used by default, to use the gold linker, + pass -fuse-linker-plugin (no other side effects if -flto/-fwhopr + is not passed). To force ld.bfd or ld.gold, pass -B/usr/lib/compat-ld + for ld.bfd or /usr/lib/gold-ld for ld.gold. + * Disable building gold on arm. Use gold from the trunk, if needed. + * Backport fixups of Loongson2F from the trunk. + + -- Matthias Klose Sat, 17 Apr 2010 18:27:45 +0200 + +binutils (2.20.1-5) unstable; urgency=medium + + * Apply patch for PR gas/11456: Use memcpy to copy overlap memory. + + -- Matthias Klose Fri, 02 Apr 2010 01:36:07 +0200 + +binutils (2.20.1-4) unstable; urgency=low + + * Mangle the soname of the binutils libraries to be different than + the default name. Closes: #557620. + Packaged cross builds should do the same. + * Reduce ARM linking time (backport from the trunk). + * Apply fix for PR ld/11426, taken from the trunk. + + -- Matthias Klose Tue, 30 Mar 2010 22:32:12 +0200 + +binutils (2.20.1-3ubuntu5) lucid; urgency=low + + * Rebuild statically linked ld.static binary against recent libc. + + -- Matthias Klose Sun, 18 Apr 2010 23:50:53 +0200 + +binutils (2.20.1-3ubuntu4) lucid; urgency=low + + * Apply patch for PR gas/11456: Use memcpy to copy overlap memory. + + -- Matthias Klose Wed, 31 Mar 2010 19:10:39 +0200 + +binutils (2.20.1-3ubuntu3) lucid; urgency=low + + * Fix versioned dependency in binutils shlibs file. + + -- Matthias Klose Wed, 31 Mar 2010 04:02:51 +0200 + +binutils (2.20.1-3ubuntu2) lucid; urgency=low + + * Mangle the soname of the binutils libraries to be different than + the default name. Closes: #557620. LP: #548451. + Packaged cross builds should do the same. + * Apply fix for PR ld/11426, taken from the trunk. + + -- Matthias Klose Tue, 30 Mar 2010 23:46:50 +0200 + +binutils (2.20.1-3ubuntu1) lucid; urgency=low + + * Merge with Debian; remaining changes: + - Build binutils-static. + + -- Matthias Klose Sun, 21 Mar 2010 13:42:52 +0100 + +binutils (2.20.1-3) unstable; urgency=low + + * binutils-gold: Install the gold binary as `gold' as well, as proposed + by a patch to enable both gold and ld in a single toolchain. + + -- Matthias Klose Sun, 21 Mar 2010 06:43:48 +0100 + +binutils (2.20.1-2ubuntu1) lucid; urgency=low + + * Merge with Debian; remaining changes: + - Build binutils-static. + + -- Matthias Klose Mon, 08 Mar 2010 18:25:25 +0100 + +binutils (2.20.1-2) unstable; urgency=low + + * Fix version in debian/*shlibs to match the release version; + the 2.20.1 upstream release identifies as 2.20.1.20100303. + + -- Matthias Klose Mon, 08 Mar 2010 18:01:22 +0100 + +binutils (2.20.1-1ubuntu1) lucid; urgency=low + + * Merge with Debian; remaining changes: + - Build binutils-static. + + -- Matthias Klose Mon, 08 Mar 2010 13:11:53 +0100 + +binutils (2.20.1-1) unstable; urgency=low + + * New upstream release. + * Don't set has_ifunc_symbols if the symbol comes from a shared library + (backport from the trunk). + * Don't include documentation files in the -cross packages. + Closes: #571522. LP: #514509. + * Fix typo in ld documentation. LP: #497923. + * Add readelf --unwind support for ARM. + + -- Matthias Klose Mon, 08 Mar 2010 04:47:46 +0100 + +binutils (2.20-6ubuntu3) lucid; urgency=low + + * Apply updates from the 2.20 branch up to 20100216 + - Apply patch to fix R_ARM_THM_JUMP24 relocation truncated bug. + * Don't set has_ifunc_symbols if the symbol comes from a shared library + (backport from the trunk). + + -- Matthias Klose Fri, 19 Feb 2010 17:19:09 +0100 + +binutils (2.20-6ubuntu2) lucid; urgency=low + + * Apply updates from the 2.20 branch up to 20100216 + - Fix broken global Thumb to ARM branches. + + -- Matthias Klose Tue, 16 Feb 2010 18:32:35 +0100 + +binutils (2.20-6ubuntu1) lucid; urgency=low + + * Merge with Debian; remaining changes: + - Build binutils-static. + + -- Matthias Klose Fri, 05 Feb 2010 20:30:59 +0100 + +binutils (2.20-6) unstable; urgency=low + + * Apply updates from the 2.20 branch up to 20100205 + - 135_arm_dis_thumb2.dpatch: Remove, applied upstream. + - 136_gold_gnu_debuglink.dpatch: Remove, applied upstream. + * armel: Fix ld-shared/shared.exp and ld-elfvsb/elfvsb.exp failures + (proposed patch, Matthew Gretton-Dann). Closes: #564685. LP: #446478. + * Fix PR other/42602: demangling a global constructors symbol. + Closes: #561150. + + -- Matthias Klose Fri, 05 Feb 2010 20:01:20 +0100 + +binutils (2.20-5ubuntu1) lucid; urgency=low + + * Merge with Debian; remaining changes: + - Build binutils-static. + + -- Matthias Klose Sat, 09 Jan 2010 12:13:43 +0100 + +binutils (2.20-5) unstable; urgency=low + + * Apply updates from the 2.20 branch up to 20100109 + * Apply patches from the trunk: + - [arm] Prevent disassembler from aborting on an invalid Thumb2 instruction. + - Fix PR gold/11072: Discard .gnu_debuglink sections. Closes: #563366. + - Fix PR ld/11138: internal error when DSO is before object files. + Closes: #562822. + - Fix PR gold/11042: COPY relocs need for the dynamic object. + Closes: #559183. + - Fix PR gold/10916: Fix --exclude-libs with undefined symbol. + Closes: #555012. + - Fix PR gold/10979: gold linker crashes. Closes: #553916. + - Fix PR gas/10740: Intel syntax far jumps broken. Closes: #541535. + + -- Matthias Klose Sat, 09 Jan 2010 10:43:04 +0100 + +binutils (2.20-4ubuntu4) lucid; urgency=low + + * ARM - Fix b / bl ranges for Thumb2 (Ramana Radhakrishnan). + + -- Matthias Klose Mon, 21 Dec 2009 13:38:09 +0100 + +binutils (2.20-4ubuntu3) lucid; urgency=low + + * [arm] Prevent disassembler from aborting on an invalid Thumb2 instruction, + taken from the trunk. + + -- Matthias Klose Thu, 19 Nov 2009 18:48:28 +0100 + +binutils (2.20-4ubuntu1) lucid; urgency=low + + * On armel build with -marm; the testsuite is not ready to be run with + -mthumb. + + -- Matthias Klose Thu, 12 Nov 2009 01:10:33 +0100 + +binutils (2.20-4) unstable; urgency=low + + * Fix binutils-gold update. Closes: #555734. + * Don't configure gold for spu on powerpc. + + -- Matthias Klose Wed, 11 Nov 2009 23:33:20 +0100 + +binutils (2.20-3ubuntu1) lucid; urgency=low + + * Merge with Debian; remaining changes: + - Build binutils-static. + + -- Matthias Klose Tue, 10 Nov 2009 11:14:38 +0100 + +binutils (2.20-3) unstable; urgency=low + + * Apply updates from the 2.20 branch up to 20091108: + - Fix PR gold/10876 (closes: #553435), PR gold/10910, PR gold/10860, + PR gold/10880 (closes: #553512, #553436), PR gold/10887, + PR gold/10893, PR gold/10895 (thanks to Peter Fritzsche for tracking + the gold reports). + * Fix libiberty build failure on sh4 (Nobuhiro Iwamatsu). Closes: #550810. + * PR ld/10858: Fix pie on mips/mipsel. Closes: #526961. + * Ignore regressions on sparc; the proper fix is to fix the testcases + for v9. + * Remove the conflict between binutils-multiarch and binutils-gold. + Closes: #521106. + + -- Matthias Klose Tue, 10 Nov 2009 02:15:41 +0100 + +binutils (2.20-2) unstable; urgency=high + + * Apply updates from the 2.20 branch up to 20091028: + - Fix PR binutils/10802, PR binutils/10793, PR binutils/10792, + PR gas/10856. + - Remove local patches now in the branch. + * Ignore regressions on armel when building with gcc-4.4; the proper fix + is to build the testcases using -fno-section-anchors. + + -- Matthias Klose Thu, 29 Oct 2009 22:17:42 +0100 + +binutils (2.20-1ubuntu3) lucid; urgency=low + + * Work around build failure on powerpc, disable the gold build; re-enable + it later with a proper fix. + * Ignore regressions on sparc; the proper fix is to fix the testcases + for v9. + + -- Matthias Klose Sat, 31 Oct 2009 12:21:59 +0100 + +binutils (2.20-1ubuntu2) lucid; urgency=low + + * Don't build just on armel and i386. + + -- Matthias Klose Fri, 30 Oct 2009 14:51:13 +0100 + +binutils (2.20-1ubuntu1) lucid; urgency=low + + * Apply updates from the 2.20 branch up to 20091028: + - Fix PR binutils/10802, PR binutils/10793, PR binutils/10792, + PR gas/10856. + - Remove local patches now in the branch. + * Ignore regressions on armel; the proper fix is to build the + testcases using -fno-section-anchors. + + -- Matthias Klose Fri, 30 Oct 2009 01:27:43 +0100 + +binutils (2.20-1) unstable; urgency=low + + * binutils 2.20 final release. + - Fix PR binutils/10785, memory corruptions. + - PR ld/10749, ia64 linker failure. + - PR gas/2117, ia64 assembler fix. + - gold updates. + * Configure with --enable-plugins. Closes: #550088. + * debian/test-suite-compare.py: Don't count untested test cases as + regressions. + * binutils-gold: Install /usr/lib/compat-ld/ld to point to the + old linker. To use the old linker when gold is installed, use + gcc -B/usr/lib/compat-ld/ (including the trailing slash). + + -- Matthias Klose Sat, 17 Oct 2009 12:22:30 +0200 + +binutils (2.20-0ubuntu2) karmic-proposed; urgency=low + + * Fix PR gas/10856, wrong code with assembler files in intel syntax. + Patch taken from the 2.20 branch. LP: #461303. + + -- Matthias Klose Wed, 28 Oct 2009 09:46:50 +0100 + +binutils (2.20-0ubuntu1) karmic; urgency=low + + * binutils 2.20 final release. + - Fix PR binutils/10785, memory corruptions. + - gold updates. LP: #453278. + * debian/*.shlibs: Update to the release version. LP: #452526. + * Fix build failure on arm, building from the release tarball. + + -- Matthias Klose Sat, 17 Oct 2009 11:14:00 +0200 + +binutils (2.19.91.20091014-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the 2.20 release branch 20091014. + - PR ld/10749, ia64 linker failure. + - PR gas/2117, ia64 assembler fix. + * debian/*.shlibs: Update to the version from the branch. + * Fix build failures for cross build. + + -- Matthias Klose Wed, 14 Oct 2009 14:55:40 +0200 + +binutils (2.19.91.20091006-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the 2.20 release branch 20091006. + - cfi_sections changes applied, remove 129_cfi_sections.dpatch. + * debian/*.shlibs: Update to the version from the branch. + * binutils-gold: Build the testsuite as part of the check target + instead of the build target to avoid build failures when the + installed binutils soname is the same as the one which is built + (gas is segfaulting). Just a workaround, not a solution. + + -- Matthias Klose Tue, 06 Oct 2009 18:14:37 +0200 + +binutils (2.19.91.20091005-0ubuntu2) karmic; urgency=low + + * Really re-enable the binutils-gold build on powerpc. + + -- Matthias Klose Tue, 06 Oct 2009 13:53:22 +0200 + +binutils (2.19.91.20091005-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the 2.20 release branch 20091005. + - no changes, bump the soname only. + * debian/*.shlibs: Update to the version from the branch. + * Re-enable the binutils-gold build on powerpc. + * Add 129_cfi_sections.dpatch, support for .cfi_sections, taken + from the trunk. LP: #440172. + * Add 150_gold_copyrelocs.dpatch, add -z copyrelocs option for gold. + + -- Matthias Klose Tue, 06 Oct 2009 10:31:58 +0200 + +binutils (2.19.91.20091003-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the 2.20 release branch 20091003. + - powerpc fixes. + * debian/*.shlibs: Update to the version from the branch. + * Reenable binutils-gold build on armel (build failures on just + one buildd). + * Disable binutils-gold build on powerpc, fails to build with the + version in the archive. + * binutils-source: Depend on texinfo, zlib1g-dev. + + -- Matthias Klose Tue, 06 Oct 2009 10:16:47 +0200 + +binutils (2.19.91.20091001-0ubuntu2) karmic; urgency=low + + * Don't build binutils-gold for armel, currently ftbfs. + + -- Matthias Klose Thu, 01 Oct 2009 23:54:41 +0200 + +binutils (2.19.91.20091001-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the 2.20 release branch 20091001. + - Fix PR ld/9863, regression in testsuite on armel. + - Fix regressions seen in the GCC/libjava testsuite. + * debian/*.shlibs: Update to the version from the branch. + * No need to build libiberty_pic.a twice. + + -- Matthias Klose Thu, 01 Oct 2009 16:53:04 +0200 + +binutils (2.19.91.20090923-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the 2.20 release branch 20090923 (last upload + was taken from the trunk).. + * debian/*.shlibs: Update to the version from the branch. + + -- Matthias Klose Wed, 23 Sep 2009 09:44:40 +0200 + +binutils (2.19.91.20090922-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the 2.20 release branch 20090922. + * debian/*.shlibs: Update to the version from the branch. + + -- Matthias Klose Tue, 22 Sep 2009 22:01:19 +0200 + +binutils (2.19.91.20090910-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the 2.20 release branch 20090910, corresponding + to the 2.19.90 upstream snapshot. + * Fix Thumb-2 shared libraries (Daniel Jacobowitz), patch taken + from the trunk. + * Update binutils-sec64k patch (H.J. Lu). + + -- Matthias Klose Thu, 10 Sep 2009 17:21:56 +0200 + +binutils (2.19.90.20090909-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the 2.20 release branch 20090909. + * debian/*.shlibs: Update to the version from the branch. + + -- Matthias Klose Wed, 09 Sep 2009 10:01:29 +0200 + +binutils (2.19.51.20090827-1ubuntu1) karmic; urgency=low + + * Merge with Debian unstable; remaining changes: + - Build binutils-static and binutils-static-udeb packages. + - Apply patches derived from the binutils HJL release. + + -- Matthias Klose Fri, 28 Aug 2009 13:49:57 +0200 + +binutils (2.19.51.20090827-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20090827. + - Fix PR ld/10518: In linker scripts override a "*" match by any other + wildcard match. Closes: #540751. + * debian/*.shlibs: Update to the version from the trunk. Closes: #540800. + * Add sysroot support for cross builds (Hector Oron). Closes: #522480. + * Update long description of binutils-doc. Closes: #428764. + * Update build-dependency on autoconf. + * Fix some lintian warnings. + + -- Matthias Klose Thu, 27 Aug 2009 17:09:28 +0200 + +binutils (2.19.51.20090805-1ubuntu1) karmic; urgency=low + + * Snapshot, taken from the trunk 20090805. + * debian/*.shlibs: Update to the version from the trunk. + - Fix PR binutils/10364, strip not failing on unwritable files. + Closes: #276428. + - Fix PR binutils/10363, objdump -T crashing on corrupted file. + Closes: #487963. + * 129_cortex_a8.dpatch: Fix a couple of cortex-a8 erratum bugs. + + -- Matthias Klose Wed, 05 Aug 2009 10:29:44 +0200 + +binutils (2.19.51.20090723-1ubuntu1) karmic; urgency=low + + * Snapshot, taken from the trunk 20090723. + * debian/*.shlibs: Update to the version from the trunk. + * Apply build-id patch to avoid memory corruption (taken from Fedora). + + -- Matthias Klose Thu, 23 Jul 2009 13:47:19 +0200 + +binutils (2.19.51.20090714-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the trunk 20090714. + - Fix PR gas/10387 (branch instruction with no operand causes gas + to segfault on armel). LP: #396049. + - 128_arm_eabi_align64.dpatch: Remove, integrated upstream. + * debian/*.shlibs: Update to the version from the trunk. + + -- Matthias Klose Tue, 14 Jul 2009 12:48:09 -0400 + +binutils (2.19.51.20090713-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the trunk 20090713. + * debian/*.shlibs: Update to the version from the trunk. + * 128_arm_eabi_align64.dpatch: Adjust expected output to changed objdump + output. LP: #398732. + + -- Matthias Klose Mon, 13 Jul 2009 13:21:56 -0400 + +binutils (2.19.51.20090704-1ubuntu1) karmic; urgency=low + + * Snapshot, taken from the trunk 20090704. + * debian/*.shlibs: Update to the version from the trunk. + + -- Matthias Klose Sat, 04 Jul 2009 11:46:03 +0200 + +binutils (2.19.51.20090704-1) unstable; urgency=low + + * Snapshot, taken from the trunk 20090704. + - debian/patches/128_arm_eabi_auto_it.dpatch: Remove, applied upstream. + * debian/*.shlibs: Update to the version from the trunk. + * Bump standards version. + + -- Matthias Klose Sat, 04 Jul 2009 10:37:18 +0200 + +binutils (2.19.51.20090622-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the trunk 20090622. + - debian/patches/128_arm_eabi_auto_it.dpatch: Remove, applied upstream. + * debian/*.shlibs: Update to the version from the trunk. + + -- Matthias Klose Tue, 23 Jun 2009 01:36:34 +0200 + +binutils (2.19.51.20090620-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the trunk 20090620. + * debian/*.shlibs: Update to the version from the trunk. + * Build the binutils-gold package on armel. + * Update hjl patches from the binutils-2.19.51.0.10 release. + + -- Matthias Klose Sat, 20 Jun 2009 22:56:32 +0200 + +binutils (2.19.51.20090616reallz0515-0ubuntu1) karmic; urgency=low + + * Reupload snapshot from trunk 20090515. + * Apply proposed patch to augment maximum alignment size to 64 (ARM gas). + * Apply proposed patch for new option for automatically generating IT blocks. + + -- Matthias Klose Wed, 17 Jun 2009 23:02:25 +0000 + +binutils (2.19.51.20090515-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the trunk 20090515. + - Fix PR ld/10152. LP: #375991. + * Revert work-around from last upload. + * debian/*.shlibs: Update to the version from the trunk. + * Build the binutils-gold package again. + + -- Matthias Klose Fri, 15 May 2009 16:34:56 +0200 + +binutils (2.19.51.20090508-0ubuntu2) karmic; urgency=low + + * Revert change for ARM unwind table linker processing. Addresses #375991. + + -- Matthias Klose Wed, 13 May 2009 17:46:20 +0200 + +binutils (2.19.51.20090508-0ubuntu1) karmic; urgency=low + + * Snapshot, taken from the trunk 20090508. + * debian/*.shlibs: Update to the version from the trunk. + + -- Matthias Klose Fri, 08 May 2009 11:22:40 +0200 + +binutils (2.19.51.20090423-0ubuntu2) karmic; urgency=low + + * Snapshot, taken from the trunk 20090423. + * debian/*.shlibs: Update to the version from the trunk. + * Fix build failure when building with -Os. + * debian/patches/013_bash_in_ld_testsuite.dpatch: Update. + + -- Matthias Klose Fri, 24 Apr 2009 12:29:23 +0200 + +binutils (2.19.1-0ubuntu3) jaunty; urgency=low + + * Re-add -a to dpkg-architecture call; the addition of -f is all what's + needed to ignore the dpkg-architecture env set by dpkg-buildpackage (since + we don't care about the DEB_BUILD_* or DEB_HOST_* arches but only about + the TARGET arch). + + -- Loic Minier Tue, 10 Feb 2009 16:42:28 +0100 + +binutils (2.19.1-0ubuntu2) jaunty; urgency=low + + * binutils-source: Make .dpatch files executable. + * Use dpkg-architecture -f instead of -a for cross builds. + * Call pkg_create_dbgsym explicitly to build debug symbols packages. + LP: #322243. + + -- Matthias Klose Tue, 10 Feb 2009 12:05:51 +0100 + +binutils (2.19.1-0ubuntu1) jaunty; urgency=low + + * Binutils 2.19.1 release. + - 128_arm_relocs_against_weak.dpatch 129_scale-DW_CFA_advance_loc.dpatch: + Remove, applied upstream. + * debian/*.shlibs: Update to the release version. + + -- Matthias Klose Wed, 04 Feb 2009 10:14:33 +0100 + +binutils (2.19.0.20090110-0ubuntu1) jaunty; urgency=low + + * Update to the binutils-2_19-branch 20090110. + - Fix PR binutils/7011. LP: #254790. + * debian/*.shlibs: Update to the version from the branch. + + -- Matthias Klose Sat, 10 Jan 2009 13:47:35 +0100 + +binutils (2.19-0ubuntu3) jaunty; urgency=low + + * debian/patches/129_scale-DW_CFA_advance_loc.dpatch: Scale + DW_CFA_advance_loc[124] output values. + * debian/patches/128_arm_relocs_against_weak.dpatch: Fix R_ARM_THM_CALL + relocations against undefined weak symbols in shared libraries. + + -- Matthias Klose Sat, 29 Nov 2008 11:25:22 +0100 + +binutils (2.19-0ubuntu2) jaunty; urgency=low + + * No-change rebuild to remove translations from the binary package, + accidentally included due to a misbuild. + + -- Steve Langasek Fri, 21 Nov 2008 04:35:45 +0000 + +binutils (2.19-0ubuntu1) jaunty; urgency=low + + * Binutils 2.19 release. + * debian/*.shlibs: Update to the release version. + * debian/control: Update to GPL3, reference the GFDL. + * Make lintian more happy. + + -- Matthias Klose Thu, 30 Oct 2008 15:37:05 +0100 + +binutils (2.18.93.20081009-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the 2.19 branch 20081009 (corresponding to the + 2.18.93 upstream snapshot. + * debian/*.shlibs: Update to the version from the branch. + * In gprof(1), remove references to monitor(3) and profil(2). + + -- Matthias Klose Wed, 08 Oct 2008 15:27:50 +0200 + +binutils (2.18.92.20081003-0ubuntu2) intrepid; urgency=low + + * Add build dependency on zlib1g-dev. + + -- Matthias Klose Tue, 07 Oct 2008 12:52:33 +0200 + +binutils (2.18.92.20081003-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the 2.19 branch 20081003 (corresponding to the + 2.18.92 upstream snapshot. + * Stop building binutils-gold for the intrepid release (still + experimental). + * debian/*.shlibs: Update to the version from the branch. + + -- Matthias Klose Fri, 03 Oct 2008 11:16:43 +0000 + +binutils (2.18.91.20080923-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the 2.19 branch 20080923 (corresponding to the + 2.18.91 upstream snapshot. + * debian/*.shlibs: Update to the version from the branch. + * debian/patches/201-hjl-bfd-ref_addr.dpatch: Remove, integrated upstream. + * Fail the build if the testsuite shows regressions compared to the + last (installed) build. + + -- Matthias Klose Tue, 23 Sep 2008 13:22:34 +0200 + +binutils (2.18.90.20080910-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the 2.19 branch 20080910. + - No testsuite regressions on amd64, i386, lpia, sparc. + * debian/*.shlibs: Update to the version from the branch. + * debian/patches/201-hjl-bfd-ref_addr.dpatch: Update. + + -- Matthias Klose Sat, 13 Sep 2008 19:40:31 +0200 + +binutils (2.18.50.20080814-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the trunk 20080814. + * debian/*.shlibs: Update to the version from the trunk. + * debian/patches/201-hjl-bfd-ref_addr.dpatch: Update. + * debian/patches/209-hjl-binutils-error.dpatch: Likewise. + + -- Matthias Klose Thu, 14 Aug 2008 16:37:01 +0000 + +binutils (2.18.50.20080806-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the trunk 20080806. + - Fix PR ld/6656, disable gas generated debug info if compiler generated + debug info is seen. LP: #240884. Closes: #481592. + * debian/*.shlibs: Update to the version from the trunk. + * Build binutils-gold for powerpc. + + -- Matthias Klose Wed, 06 Aug 2008 08:39:52 +0200 + +binutils (2.18.50.20080707-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the trunk 20080707. + * debian/*.shlibs: Update to the version from the trunk. + * include/safe-ctype.h: Add #include of ctype.h before redefining + the ctype.h macros (proposed for the trunk). + + -- Matthias Klose Mon, 07 Jul 2008 10:21:30 +0000 + +binutils (2.18.50.20080610-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the trunk 20080610. + * debian/*.shlibs: Update to the version from the trunk. LP: #237461. + + -- Matthias Klose Tue, 10 Jun 2008 17:18:50 +0200 + +binutils (2.18.50.20080530-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the trunk 20080530. + - gold recognizes -z relro and -z norelro. + * debian/rules: Explicitely set SHELL to /bin/bash, build-depend on bash. + * debian/rules: Fix setting of TARGET for cross builds. + * binutils-static: Remove dependency on libc6. LP: #184582. + + -- Matthias Klose Fri, 30 May 2008 23:55:07 +0200 + +binutils (2.18.50.20080509-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the trunk 20080509. + * Add -Wno-format-security to CFLAGS, CXXFLAGS, due to picky default + hardening options. + * Let gold ignore -z relro and -z norelro for now. + * Build gold with -Wno-error. + + -- Matthias Klose Fri, 09 May 2008 11:09:24 +0200 + +binutils (2.18.50.20080507-0ubuntu1) intrepid; urgency=low + + * Snapshot, taken from the trunk 20080507. + * Remove patches applied upstream: 304_pr4476.dpatch, 305_arm-dis.dpatch, + 306_pr4453.dpatch, 307_ld-pic.dpatch, 308_mips-pic.dpatch, + 311_pr5006.dpatch, 312_pr5011.dpatch, 313_pr5025.dpatch. + * Update patches from the hjl releases: 200-hjl-ld-env (not applied), + 206-hjl-binutils-shr.dpatch (not applied), + * Remove patches from the hjl release: 204-hjl-binutils-tls-relro.dpatch, + 208-hjl-libtool-relink.dpatch, 209-hjl-binutils-error.dpatch, + 210-hjl-binutils-signed.dpatch, + * New patches from the hjl release: 212-hjl-bfd-64k.dpatch. + * debian/*.shlibs: Update to the version from the trunk. + * On amd64, i386, lpia and sparc, build a binutils-gold package, + diverting /usr/bin/ld. + + -- Matthias Klose Wed, 07 May 2008 17:41:05 +0200 + +binutils (2.18.1~cvs20080103-4ubuntu1) hardy; urgency=low + + * Merge with Debian unstable; remaining changes: + - Build binutils-static and binutils-static-udeb packages. + + -- Matthias Klose Tue, 22 Apr 2008 12:02:51 +0200 + +binutils (2.18.1~cvs20080103-4) unstable; urgency=medium + + * debian-rules: Remove libiberty in /usr/lib64; workaround for + `gcc -print-multi-os-directory' printing the symlink. + Closes: #473665, #473591. + * Don't include development fiiles in binutils-spu. + * Fix binutils-spu build on ppc64 (Andreas Jochens). Closes: #474116. + * Build libiberty with -fPIC on mips/mipsel (Aurelian Jarno). + + -- Matthias Klose Sat, 05 Apr 2008 11:21:08 +0200 + +binutils (2.18.1~cvs20080103-3) unstable; urgency=low + + [ Arthur Loiret ] + * Build a binutils for spu-elf target on powerpc and ppc64. + - debian/control: Add a binutils-spu package. + - debian/binutils-spu.{postinst,postrm,shlibs}: Add. + * Add sh64-linux-gnu to multiarch targets. + * Fix cross-compilation support. + * Make lintian happier: + - Use ${source:Version}, ${binary:Version} variables. + - Remove -1 from Build-Depends revisions. + - Bump Standards-Version to 3.7.3. + + [ Matthias Klose ] + * Keep the spu elfscripts in bintutils, remove them from binutils-spu. + * debian/patches/307_ld-pic.dpatch: Fix failing ld-shared tests when built + with gcc-4.3. + + -- Matthias Klose Sat, 29 Mar 2008 20:32:35 +0100 + +binutils (2.18.1~cvs20080103-2) unstable; urgency=low + + * debian/patches/306_pr4453.dpatch: Fix PR binutils/4453, taken from + the trunk (Aurelian Jarno). Closes: #363423. + + -- Matthias Klose Fri, 21 Mar 2008 20:49:17 +0100 + +binutils (2.18.1~cvs20080103-0ubuntu1) hardy; urgency=low + + * Update to 20080103 from the binutils-2_18-branch. + - Set version number to 2.18.0 (smaller than the one from the trunk). + * debian/*.shlibs: Update to version from the branch. + * debian/patches/305_arm-dis.dpatch: Fix segfault when disassembling ARM + code. Closes: #438956. + + -- Matthias Klose Thu, 03 Jan 2008 21:26:56 +0000 + +binutils (2.18.1~cvs20071027-1ubuntu2) hardy; urgency=low + + * Do not include static libraries in the multiarch package. + * Install a libiberty compiled with -fPIC as libiberty_pic.a. + LP: #50512. + * Don't include /usr/lib64 for cross packages. Closes: #450429. + + -- Matthias Klose Fri, 23 Nov 2007 12:14:31 +0000 + +binutils (2.18.1~cvs20071027-1ubuntu1) hardy; urgency=low + + * Update to 20071027 from the binutils-2_18-branch. + - Fix PR ld/4988, assertion failures in ld. Closes: #440015. + * debian/*.shlibs: Update to version from the branch. + * Drop the build dependency on expect-tcl8.3, don't run the + testsuite on hppa. + + -- Matthias Klose Sat, 27 Oct 2007 17:33:13 +0000 + +binutils (2.18-1ubuntu1) hardy; urgency=low + + * Rebuild using gcc-4.2. + + -- Matthias Klose Sun, 21 Oct 2007 08:31:26 +0000 + +binutils (2.18-1) unstable; urgency=low + + [ Matthias Klose ] + * New upstream release. + - Remove patches applied upstream: 100_warning_arm, 400_gcc42_fix, + 401_builddoc. + * debian/*.shlibs: Update to release version. + + -- Matthias Klose Wed, 29 Aug 2007 01:07:31 +0200 + +binutils (2.18-0ubuntu3) gutsy; urgency=low + + * Apply patches for: + - PR binutils/5011, readelf reads past end of buffer. + - PR ld/5025, downgrade error to a warning if .note.gnu.build-id + has been discarded. + + -- Matthias Klose Wed, 19 Sep 2007 00:31:23 +0200 + +binutils (2.18-0ubuntu2) gutsy; urgency=low + + * Apply fix for PR ld/5008, taken from the trunk. + + -- Matthias Klose Sun, 09 Sep 2007 22:08:19 +0200 + +binutils (2.18-0ubuntu1) gutsy; urgency=low + + * Final 2.18 release. + * debian/*.shlibs: Update to release version. + + -- Matthias Klose Wed, 29 Aug 2007 13:22:09 +0200 + +binutils (2.18~cvs20070827-0ubuntu1) gutsy; urgency=low + + * New upstream CVS snapshot, taken from the binutils-2_18-branch. + - Remove patches applied upstream: 311_sse4_intel_mode, 400_gcc42_fix, + 401_builddoc. + * debian/*.shlibs: Update to snapshot version. + + -- Matthias Klose Mon, 27 Aug 2007 19:30:21 +0200 + +binutils (2.18~cvs20070812-0ubuntu1) gutsy; urgency=low + + * New upstream CVS snapshot, taken from the binutils-2_18-branch. + * debian/rules: Support parallel= with comma separated keywords + in DEB_BUILD_OPTIONS. + * debian/rules (clean): Remove stamp files. + * debian/*.shlibs: Update to snapshot version. + * debian/patches/401_builddoc.dpatch: Fix doc build failure on the branch. + * debian/patches/311_sse4_intel_mode.dpatch: Fix SSE4 for Intel mode. + * Update patches: 200-hjl-ld-env (not applied), 203-hjl-binutils-indirect, + 204-hjl-binutils-tls-relro, 209-hjl-binutils-error, + * Remove patches: 201-hjl-bfd-dwarf-dup.dpatch, 201-hjl-bfd-dwarf-dup, + 205-hjl-bfd-kept, 208-hjl-libtool-relink. + * New patches: 210-hjl-binutils-signed, 211-hjl-binutils-weakdef. + + -- Matthias Klose Sun, 12 Aug 2007 12:42:57 +0200 + +binutils (2.17.20070804cvs-0ubuntu1) gutsy; urgency=low + + * New upstream CVS snapshot. + - PR binutils/4888, fixes objcopy --only-keep-debug. Closes: #435444. + * debian/rules: Support parallel= in DEB_BUILD_OPTIONS (see #209008). + * debian/*.shlibs: Update to snapshot version. + * Build using the default compiler on all architectures. + + -- Matthias Klose Sat, 04 Aug 2007 11:29:10 +0000 + +binutils (2.17.20070801cvs-0ubuntu2) gutsy; urgency=low + + * Build-depend on gcc-4.1 on lpia, since we're calling it explicitly. + + -- Adam Conrad Fri, 3 Aug 2007 13:24:26 +1000 + +binutils (2.17.20070801cvs-0ubuntu1) gutsy; urgency=low + + * CVS snapshot 20070801, taken from the trunk. + - Fixes objcopy --only-keep-debug on amd64. + + -- Matthias Klose Wed, 01 Aug 2007 18:46:10 +0200 + +binutils (2.17.20070718cvs-0ubuntu2) gutsy; urgency=low + + * debian/patches/305_ungetc.dpatch: Allow UNGETC to work with empty buffer, + taken from CVS HEAD. + + -- Matthias Klose Fri, 20 Jul 2007 12:47:44 +0200 + +binutils (2.17.20070718cvs-0ubuntu1) gutsy; urgency=low + + * CVS snapshot 20070718, taken from the trunk. + * Fix cross build failure while stripping binaries. Closes: #432907. + + -- Matthias Klose Wed, 18 Jul 2007 15:19:15 +0000 + +binutils (2.17.20070713cvs-0ubuntu2) gutsy; urgency=low + + * Fix build failure with gcc-4.2. + + -- Matthias Klose Tue, 17 Jul 2007 11:09:25 +0000 + +binutils (2.17.20070713cvs-0ubuntu1) gutsy; urgency=low + + * CVS snapshot 20070713, taken from the trunk. + - Remove patches applied upstream: 301_pr4436.dpatch, 302_pr4448.dpatch, + 303_pr4454.dpatch, 305_pr4497.dpatch, 306_ld_demangler_segfault.dpatch, + 307_pr4558.dpatch. + * Update hjl patches: + - Remove 207-hjl-libtool-archive.dpatch. + - Add 201-hjl-bfd-dwarf-dup.dpatch, 209-hjl-binutils-error.dpatch. + - Update 200-hjl-ld-env.dpatch, 201-hjl-bfd-ref_addr.dpatch, + 204-hjl-binutils-tls-relro.dpatch, hjl-binutils-shr.dpatch. + * debian/copyright: Include GPL-3. + * debian/rules: Fix version extraction. + * debian/rules: Honor `noopt' in DEB_BUILD_OPTIONS. Closes LP: #65607. + * debian/patches/013_bash_in_ld_testsuite.dpatch: Use bash in the ld + testsuite. Closes LP: #124435. + + -- Matthias Klose Fri, 13 Jul 2007 15:43:07 +0200 + +binutils (2.17.20070426cvs-7ubuntu2) gutsy; urgency=low + + * Fix PR gas/4558. + + -- Matthias Klose Mon, 28 May 2007 08:48:33 +0000 + +binutils (2.17.20070426cvs-7ubuntu1) gutsy; urgency=low + + * Merge with Debian. + + -- Matthias Klose Fri, 25 May 2007 08:24:08 +0200 + +binutils (2.17cvs20070426-7) unstable; urgency=low + + * 306_ld_demangler_segfault.dpatch: new CVS patch from Alan Modra to fix + segfaults in ld seen when building, e.g. openipmi. + + * debian/copyright: update source location and copyright years. + * debian/rules: idem. + + -- James Troup Wed, 23 May 2007 02:19:09 +0100 + +binutils (2.17cvs20070426-6) unstable; urgency=low + + * Fix PR ld/4497, regression introduced with the fix for PR ld/4454. + Closes: #423496. + * Fix binutils/4476, readelf support for --hash-style=gnu. Closes: #421790. + + -- Matthias Klose Mon, 14 May 2007 10:51:40 +0200 + +binutils (2.17cvs20070426-5) unstable; urgency=low + + * Fix PR ld/4454. + + -- Matthias Klose Sun, 06 May 2007 09:50:29 +0200 + +binutils (2.17cvs20070426-4) unstable; urgency=low + + * Fix PR gas/4448, overstrict check for powerpc lswi. Closes: #421799. + + -- Matthias Klose Wed, 2 May 2007 18:26:03 +0200 + +binutils (2.17cvs20070426-3) unstable; urgency=low + + * Update debian/*.shlibs files. Closes: #421454. + * Fix PR gas/4436, wrong reject in powerpc opcode table checks. + Closes: #421455. + * Fix build failure on arm (Aurelian Jarno). Closes: #421365. + * Compare testsuite results of the installed binutils with the built one. + + -- Matthias Klose Mon, 30 Apr 2007 07:47:09 +0200 + +binutils (2.17.20070426cvs-2ubuntu7) gutsy; urgency=low + + * Fix PR ld/4497, regression introduced with the fix for PR ld/4454. + + -- Matthias Klose Mon, 14 May 2007 08:13:50 +0000 + +binutils (2.17.20070426cvs-2ubuntu6) gutsy; urgency=low + + * Fix binutils/4476, readelf support for --hash-style=gnu. + + -- Matthias Klose Thu, 10 May 2007 07:32:28 +0000 + +binutils (2.17.20070426cvs-2ubuntu5) gutsy; urgency=low + + * Fix PR ld/4454. + + -- Matthias Klose Sun, 06 May 2007 13:02:11 +0000 + +binutils (2.17.20070426cvs-2ubuntu4) gutsy; urgency=low + + * Fix PR gas/4448, overstrict check for powerpc lswi. + + -- Matthias Klose Wed, 2 May 2007 13:42:10 +0200 + +binutils (2.17.20070426cvs-2ubuntu3) gutsy; urgency=low + + * Update debian/*.shlibs files. + * Fix PR gas/4436, wrong reject in powerpc opcode table checks. + + -- Matthias Klose Mon, 30 Apr 2007 08:02:30 +0200 + +binutils (2.17.20070426cvs-2ubuntu2) gutsy; urgency=low + + * Add binutils-udeb as a dist file with priority optional. + + -- Matthias Klose Fri, 27 Apr 2007 17:27:23 +0200 + +binutils (2.17.20070426cvs-2ubuntu1) gutsy; urgency=low + + * Merge with Debian. + + -- Matthias Klose Fri, 27 Apr 2007 10:16:54 +0200 + +binutils (2.17cvs20070426-2) unstable; urgency=low + + * Fix typo preparing the binutils-hppa64 package. Closes: #421199. + * Compare testsuite results of the installed binutils with the built one. + + -- Matthias Klose Fri, 27 Apr 2007 08:06:49 +0200 + +binutils (2.17cvs20070426-1) unstable; urgency=low + + [ James Troup ] + * New upstream CVS snapshot. + * debian/test-suite-compare.py: simplistic comparator for binutils test + suite runs. + + [ Matthias Klose ] + * Merge changes from the experimental uploads: + * debian/patches/121_i386_x86_64_biarch.dpatch: Remove, applied upstream. + * Build a binutils-source package (containing the patched sources). + * Check for a working expect before building the package. + * Configure the multiarch build for x86_64-linux-gnu instead of + x86_64-linux. + * debian/rules: Don't strip binaries if nostrip is in DEB_BUILD_OPTIONS. + * debian/rules: Don't try to strip shell scripts. + * Configure --with-pkgversion to include the distribution name. + * debian/patches/000_print_debian_version.dpatch: Remove. + * debian/control: Build-depend on lsb-release. + * Enable spu target in powerpc and binutils-multiarch build. + * Don't include embedspu in binutils-multiarch on powerpc. + * debian/control: Set priority for source package to optional. + + -- James Troup Fri, 27 Apr 2007 01:29:57 +0100 + +binutils (2.17.20070420cvs-0ubuntu1) gutsy; urgency=low + + * CVS snapshot 20070420, taken from the trunk. + - debian/patches/007_binutils_soversion.dpatch: Remove, applied upstream. + + -- Matthias Klose Fri, 20 Apr 2007 13:46:05 +0200 + +binutils (2.17.20070406cvs-0ubuntu1) toolchain-test; urgency=low + + * CVS snapshot 20070406, taken from the trunk. + * Do not apply: 200-hjl-ld-env. + * Enable spu target in powerpc, ppc64 builds and in the + binutils-multiarch build. + * Don't include embedspu in binutils-multiarch on powerpc, ppc64. + Closes: #411486. + + -- Matthias Klose Fri, 6 Apr 2007 06:57:41 +0200 + +binutils (2.17.20070329cvs-0ubuntu1) toolchain-test; urgency=low + + * CVS snapshot 20070329, taken from the trunk. + * Patches from the hjl 2.17.50.0.13 release: + - 202-hjl-binutils-check-phdr: Remove, applied upstream. + - 205-hjl-bfd-kept.dpatch: Address the link speed issue by caching + the result of _bfd_elf_check_kept_section. + - 206-hjl-binutils-shr.dpatch: Implementation of ELF sharable section + proposal (not applied by default). + - 208-hjl-libtool-relink.dpatch: Avoid unnecessary linker messages + when running "make check". + + -- Matthias Klose Thu, 29 Mar 2007 07:16:28 +0200 + +binutils (2.17.20070321cvs-0ubuntu2) toolchain-test; urgency=low + + * Configure --with-pkgversion, not including the package version, + which may break ld version detection in configure scripts. + * debian/patches/000_cvs_version_string.dpatch: Remove. + * debian/patches/007_binutils_soversion.dpatch: Use date for non-release + builds in soversion. + + -- Matthias Klose Thu, 22 Mar 2007 07:01:14 +0100 + +binutils (2.17.20070321cvs-0ubuntu1) toolchain-test; urgency=low + + * CVS snapshot 20070321, taken from the trunk. + * debian/patches/000_print_{debian,ubuntu}_version.dpatch: Remove. + * debian/control: Build-depend on lsb-release. + * Configure --with-pkgversion to include the distribution name. + * Apply patches from the hjl 2.17.50.0.13 release: + - 200-hjl-ld-env.dpatch: Handle LD_SYMBOLIC and LD_SYMBOLIC_FUNCTIONS + env vars. + - 201-hjl-bfd-ref_addr.dpatch: Support DW_FORM_ref_addr in Dwarf 2 reader + in linker. + - 202-hjl-binutils-check-phdr.dpatch: Fix PR ld/4007: Linker failed + to issue an error on bad section in segment. + - 203-hjl-binutils-indirect.dpatch: PR ld/3351; avoid linker crash on ia64. + - 204-hjl-binutils-tls-relro.dpatch: PR binutils/3281; objcopy changes + PT_GNU_RELRO when there is PT_TLS. + - 207-hjl-libtool-archive.dpatch: Allow linking against an archive when + building a shared library. + * Set Ubuntu maintainer address. + + -- Matthias Klose Wed, 21 Mar 2007 09:17:21 +0100 + +binutils (2.17.20070210cvs-1ubuntu1) toolchain-test; urgency=low + + * Merge with Debian experimental; remaining changes: + - Build binutils-static and binutils-static-udeb packages. + + -- Matthias Klose Mon, 12 Feb 2007 16:03:23 +0100 + +binutils (2.17.20070210cvs-1) experimental; urgency=low + + * CVS snapshot 20070210, taken from the trunk. + * debian/rules: Don't try to strip shell scripts. + + -- Matthias Klose Sat, 10 Feb 2007 15:59:45 +0100 + +binutils (2.17.20070103cvs-2) experimental; urgency=low + + * Overwrite the VERSION string (date) from the snapshot with + a parsable version string (2.17.50), as found on the trunk. + + -- Matthias Klose Fri, 5 Jan 2007 10:06:09 +0100 + +binutils (2.17.20070103cvs-1) experimental; urgency=low + + * binutils snapshot 20070103, taken from + ftp://sourceware.org/pub/binutils/snapshots/ + * Build a binutils-source package (containing the patched sources). + * Check for a working expect before building the package. + * Configure binutils-multiarch for i486-gnu as well. + * Configure the multiarch build for x86_64-linux-gnu instead of + x86_64-linux. + * debian/rules: Don't strip binaries if nostrip is in DEB_BUILD_OPTIONS. + + -- Matthias Klose Thu, 4 Jan 2007 22:13:54 +0100 + +binutils (2.17.20070103cvs-0ubuntu1) feisty; urgency=low + + * binutils snapshot 20070103, taken from + ftp://sourceware.org/pub/binutils/snapshots/ + * Merge with Debian experimental; remaining changes: + - Build binutils-static and binutils-static-udeb packages. + - Build a binutils-source package (containing the patched + sources). + - Check for a working expect before building the package. + - Configure binutils-multiarch for i486-gnu as well. + * Configure the multiarch build for x86_64-linux-gnu instead of + x86_64-linux. + * debian/rules: Don't strip binaries if nostrip is in DEB_BUILD_OPTIONS. + * Strip binaries in binutils-static and in the binutils udeb. + + -- Matthias Klose Thu, 4 Jan 2007 15:17:45 +0100 + +binutils (2.17.20061210cvs-1) experimental; urgency=low + + * CVS snapshot 20061210, taken from the trunk. + * debian/patches/121_i386_x86_64_biarch.dpatch: Remove, applied upstream. + + -- Matthias Klose Sun, 10 Dec 2006 20:43:41 +0100 + +binutils (2.17.20070103cvs-0ubuntu2) feisty; urgency=low + + * Overwrite the VERSION string (date) from the snapshot with + a parsable version string (2.17.50), as found on the trunk. + + -- Matthias Klose Fri, 5 Jan 2007 09:02:06 +0000 + +binutils (2.17.50.0.6-0ubuntu1) feisty; urgency=low + + [Fabio M. Di Nitto] + + * we are supposed to upload to feisty, aren't we? ;) + + [Jeff Bailey] + + * New upstream snapshot from HJ Lu. + * debian/patches/121_i386_x86_64_biarch: Drop, merged upstream. + + -- Fabio M. Di Nitto Tue, 31 Oct 2006 15:43:58 +0100 + +binutils (2.17-3) unstable; urgency=low + + * debian/rules (configure-multi-stamp): drop i486-kfreebsd-gnu again as + it breaks objdump for i386 on amd64. Closes: #380539 + + -- James Troup Tue, 3 Oct 2006 00:53:17 +0100 + +binutils (2.17-2) unstable; urgency=low + + * The "Laisse le Wookie gagner" release. + + * 127_x86_64_i386_biarch.dpatch: new patch from Aurelien Jarno + to add (/usr)/lib32 to the search paths on + amd64. Closes: #369052 + + * debian/rules (configure-multi-stamp): add i486-kfreebsd-gnu at request + of Aurelien Jarno. Closes: #315306 + + -- James Troup Wed, 26 Jul 2006 20:33:13 +0100 + +binutils (2.17-1ubuntu1) edgy; urgency=low + + * New upstream release. + - ld checks for libs in the same order as ld.so does. Ubuntu #40214. + * Synchronise with Debian unstable. + * Remove patch 122_sparc64_UA2005_instruction_set.dpatch, integrated + upstream. + * Remove patch 130_tekhex_buffer_overflow.dpatch, integrated upstream. + * 122_x86_64_i386_biarch.dpatch: New, search libraries in (/usr)/lib32 on + amd64. Closes: #369052. + * Build a binutils-source package; obsoletes toolchain-source package. + + -- Matthias Klose Wed, 28 Jun 2006 10:29:16 +0200 + +binutils (2.17-1) unstable; urgency=low + + * New upstream release. + * 120_mips_xgot_multigot_workaround.dpatch: removed - superseded by a + proper fix upstream. Closes: #274738 + * debian/binutils.shlibs, debian/binutils-multiarch.shlibs, + debian/binutils-hppa64.shlibs: updated SONAME to 2.17. + + -- James Troup Mon, 26 Jun 2006 13:17:36 +0100 + +binutils (2.16.1cvs20060507-1) unstable; urgency=low + + * New upstream CVS snapshot of 'binutils-2_17-branch'. + + * debian/control (Standards-Version): bump to 3.7.2.0. + + -- James Troup Sun, 7 May 2006 19:57:08 +0100 + +binutils (2.16.1cvs20060413-1) unstable; urgency=low + + * New upstream CVS snapshot. + * 120_mips_xgot_multigot_workaround.dpatch: updated to work with CVS + r1.163 of bfd/elfxx-mips.c, pass 'info' instead of 'output_bfd' to + MIPS_ELF_GOT_MAX_SIZE(). + + * Patch from NIIBE Yutaka in #280884: + * debian/rules (configure-multi-stamp): Support m32r-linux. Closes: + #340264 + * debian/rules: Run 'make check' only if build == host. + + * debian/rules: Also don't run 'make check' if nocheck is in + DEB_BUILD_OPTIONS. Based on a patch from Michael Banck + . Closes: #315290 + + * Integrate most of a patch to build arbitrary binutils-$TARGET + cross-packages from #231707. Thanks to Nikita V. Youshchenko + and Josh Triplett . + + * debian/copyright: update to include GFDL. Closes: #81950 + * debian/copyright: update FSF address. + + * debian/rules: move non-architecture specific conflicts (gas, + elf-binutils, modutils (<< 2.4.19-1)) out of a substitued variable and + into the control file. Rename variable to extraConflicts. + * debian/control: likewise. + + -- James Troup Sat, 15 Apr 2006 03:05:41 +0100 + +binutils (2.16.1cvs20060117-1ubuntu2.1) dapper-security; urgency=low + + * SECURITY UPDATE: Crash and possible arbitrary code execution in apps using + libbfd (such as 'strings'). + * Add debian/patches/130_tekhex_buffer_overflow.dpatch: + - Fix buffer overflow on hexadecimal number parsing in the Tektronix Hex + Format BFD library backend. + - Patch ported from CVS HEAD. + * CVE-2006-2362 + + -- Martin Pitt Tue, 6 Jun 2006 11:35:55 +0200 + +binutils (2.16.1cvs20060117-1ubuntu2) dapper; urgency=low + + * [SPARC64] Add support for new UA2005 instruction set: + - Add patch 122_sparc64_UA2005_instruction_set.dpatch. + (Thanks David S. Miller for providing the patch) + + NOTE: the patch is sparc specific and does NOT touch any other code. + It is a plain rebuild on all other arches. + + -- Fabio M. Di Nitto Sat, 25 Feb 2006 07:11:28 +0100 + +binutils (2.16.1cvs20060117-1ubuntu1) dapper; urgency=low + + * Synchronise with Debian untstable. + + -- Matthias Klose Thu, 19 Jan 2006 09:21:47 +0100 + +binutils (2.16.1cvs20060117-1) unstable; urgency=low + + * New upstream CVS snapshot. + + * 118_arm_pass_all.dpatch, 125_fix_tc_arm_cast.dpatch: merged upstream - + removed. + + -- James Troup Wed, 18 Jan 2006 02:25:25 +0000 + +binutils (2.16.1cvs20051214-1ubuntu1) dapper; urgency=low + + * Synchronise with Debian unstable. + + -- Matthias Klose Thu, 15 Dec 2005 00:11:16 +0000 + +binutils (2.16.1cvs20051214-1) unstable; urgency=low + + * New upstream CVS snapshot. + * Fix ld segfaults on ia64. Closes: #342777 + + * 126_fix_PROVIDE_HIDDEN.dpatch: merged upstream - removed. + + -- James Troup Wed, 14 Dec 2005 08:06:37 +0000 + +binutils (2.16.1cvs20051206-1) unstable; urgency=low + + * New upstream CVS snapshot. + * Fixes linking of qemu. Closes: #340328 + + * 126_fix_PROVIDE_HIDDEN.dpatch: new patch from Thiemo Seufer to fix + handling of hidden symbols which were provided by a linker + script. Closes: #342307 + + * debian/control (Standards-Version): updated to 3.6.2.1. + + -- James Troup Sat, 10 Dec 2005 05:23:34 +0000 + +binutils (2.16.1cvs20051117-1ubuntu1) dapper; urgency=low + + * Synchronise with Debian unstable. + + -- Matthias Klose Fri, 18 Nov 2005 14:09:29 +0100 + +binutils (2.16.1cvs20051117-1) unstable; urgency=low + + * New upstream CVS snapshot. + * Fixes c++filt's flushing of stdout which broke gcj. Closes: #339287 + + * debian/control (Build-Depends): switch from expect to expect-tcl8.3 + since tcl8.4's broken threading causes the testsuite to fail entirely + on hppa. Closes: #339509 + + -- James Troup Thu, 17 Nov 2005 13:15:15 +0000 + +binutils (2.16.1cvs20051109-1ubuntu1) dapper; urgency=low + + * Synchronise with Debian unstable. + * Reenable the testsuite on hppa and sparc. + * debian/control: + - Set standards version to 3.6.2 (no changes). + - Add alternative build dependency on expect-tcl8.3. + + -- Matthias Klose Mon, 14 Nov 2005 10:52:27 +0100 + +binutils (2.16.1cvs20051109-1) unstable; urgency=low + + * New upstream CVS snapshot. + * Fixes broken PLT handling on m68k. Closes: #327780 + * Don't compile flex files with -Werror, fixing mips builds. + Closes: #333980 + * Don't check undefined symbols introduced by "ld -u" for TLS. Closes: + #326103 + + * 117_mips_symbolic_link.dpatch: merged upstream - removed. + + * debian/rules: pass --disable-werror on ia64 as current gcc generates + too many false positives. Closes: #336939 + + * 125_fix_tc_arm_cast.dpatch: new patch from Lennert Buytenhek to fix + cast warning and arm builds. Closes: #336175 + + * 121_i386_x86_64_biarch.dpatch: imported from Ubuntu at request of + Daniel Jacobwitz to fix biarch linking on i386/amd64. Closes: + #334626, #334673 + + * debian/rules: remove any reference to pkgstriptranslations - an + Ubuntu-ism that shouldn't have been in the Debian package in the first + place but that isn't needed in Ubuntu any more in any event. + + * debian/rules: MAKEOVERRIDES is now clobbered by the top level + Makefile, so switch to overriding MAKE itself (sic) to pass the + customized VERSION variable/string down to sub-directories for + -multiarch and -hppa64 builds. Thanks to Daniel Silverstone for the + suggestion. + + -- James Troup Fri, 11 Nov 2005 20:38:22 +0000 + +binutils (2.16.1cvs20050902-1) unstable; urgency=low + + * New upstream CVS snapshot. + * Fixes --as-needed on sparc and hppa. Closes: #320697 + * Fixes buffer overflows and other crashes. Closes: #311975 + + * 124_readelf_robustify.dpatch: merged upstream - removed. + * 001_ld_makefile_patch: regenerated with help of wiggle. + + * debian/*.shlibs: update to version 2.16.91. + + * debian/copyright: use canonical GNU URL. Update copyright years. + * debian/rules: update version and copyright. + + * debian/rules (pre-build): not relevant with a CVS snapshot which + doesn't have pre-generated info files - removed. + * debian/rules (clean): don't save info files for the same reason, in + fact explicitly remove them. + * debian/rules (build_stamps): drop pre-build. + + -- James Troup Sat, 3 Sep 2005 00:30:56 +0100 + +binutils (2.16.1-3) unstable; urgency=low + + * debian/rules: remove powerpc libc header hack. + * debian/include/sys/procfs.h: remove. + + * 124_readelf_robustify.dpatch: new patch from Jakub Jelinek to + robustify readelf. Thanks to Thiemo Seufer . + Closes: #318344 + + -- James Troup Wed, 31 Aug 2005 05:03:11 +0100 + +binutils (2.16.1-2ubuntu7) dapper; urgency=low + + * debian/rules: Stop calling pkgstriptranslations, we now get it + for free with the new and improved dpkg-deb diversion hack. + + -- Adam Conrad Wed, 26 Oct 2005 10:39:15 +1000 + +binutils (2.16.1-2ubuntu6) breezy; urgency=low + + * debian/control: Create a new binutils-static-udeb udeb for d-i. + * debian/rules: Copy stuff from -static to -static-udeb for above. + * debian/rules: compress changelog in /usr/share/doc/binutils-static + + -- Adam Conrad Tue, 4 Oct 2005 16:51:06 +1000 + +binutils (2.16.1-2ubuntu5) breezy; urgency=low + + [ Jeff Bailey ] + * debian/control: binutils-static no longer depends on binutils. + * debian/rules: Install the copyright and changelog into + /usr/share/doc/binutils-static. + + [ Adam Conrad ] + * debian/binutils-static.preinst: Make sure that we lose our doc + symlink before we upgrade, or some Very Bad Things could happen. + * debian/rules: Make the above get installed to the right location. + + -- Adam Conrad Tue, 4 Oct 2005 15:45:12 +1000 + +binutils (2.16.1-2ubuntu4) breezy; urgency=low + + The " jbailey: how soon should I expect an upload?" release. + + * debian/patches/122_sparc_hppa_got.dpatch: New patch to allow + --as-needed on sparc, and to avoid issues with duplicate + GLOBAL_OFFSET_TABLES on hppa. + + * debian/patches/00list.sparc: New file, add this patch there. + + * debian/patches/00list.hppa: New file, add this patch there. + + -- Jeff Bailey Wed, 31 Aug 2005 16:46:13 -0400 + +binutils (2.16.1-2ubuntu3) breezy; urgency=low + + * debian/patches/121_i386_x86_64_biarch: New patch to allow + ld to work in an i386/x86_64 biarch configuration. + + -- Jeff Bailey Fri, 5 Aug 2005 16:24:23 +0000 + +binutils (2.16.1-2ubuntu2) breezy; urgency=low + + * debian/rules: Call it /bin/ld_static, not /bin/ld to avoid + confusion. + + -- Jeff Bailey Tue, 26 Jul 2005 01:34:43 +0000 + +binutils (2.16.1-2ubuntu1) breezy; urgency=low + + * debian/rules: Add binutils-static pass. This provides /bin/ld + for use in linking objects that might be needed at boot time + for mounting /usr or /. + Also remove stamps when cleaning. + + -- Jeff Bailey Tue, 26 Jul 2005 00:12:07 +0000 + +binutils (2.16.1-2) unstable; urgency=low + + * debian/include/sys/procfs.h: Include fixed powerpc libc header, to fix + FTBFS on powerpc. Temporary fix, to be removed with glibc-2.3.5. + + -- Matthias Klose Sun, 10 Jul 2005 16:35:17 +0200 + +binutils (2.16.1-1) unstable; urgency=medium + + * New upstream version. + * debian/patches/117_mips_symbolic_link.dpatch: Updated, apply it again. + (Thiemo Seufer). + * debian/patches/130_bfd_doc_makefile.dpatch: Remove, applied upstream. + * debian/control: Build depend on dpkg-dev (>= 1.13.9), needed to determine + the GNU architecture type. + * The symlinks for the tools change to the the new output of + dpkg-architecture -qDEB_HOST_GNU_TYPE (i.e. i386-linux-ld becomes + i486-linux-gnu-ld). + * Change the values for --enable-targets according to the dpkg-architecture + update. + * Configure the hppa64 cross compiler for hppa64-linux-gnu. Adjust + the hppa64 install target. + * debian/*shlibs: Update to version 2.16.1. + * Make restoring of saved pregenerated info files more robust. + + -- Matthias Klose Sat, 9 Jul 2005 14:58:49 +0200 + +binutils (2.16-1) unstable; urgency=low + + * Update to CVS 2.16 branch 20050612. + * debian/patches/130_bfd_doc_makefile.dpatch: New patch to fix + build failure in bfd/doc. + * debian/watch: New file. + + -- Matthias Klose Sun, 12 Jun 2005 12:29:12 +0200 + +binutils (2.16-0) experimental; urgency=low + + * New upstream release. + - Fixes build failure using gcc-4.0 (closes: #299671). + * debian/patches: + - 000_print_debian_version.dpatch: Updated. + - 001_ld_makefile_patch.dpatch, 002_gprof_profile_arcs.dpatch, + 002_gprof_profile_arcs.dpatch: Regenerated. + - 012_check_ldrunpath_length.dpatch: Updated. + - 112_fix_reloc_sizing.dpatch, 113_elf_backend_hide_symbol.dpatch, + 114_mips_delay_slots_in_branch.dpatch, 115_fix_sparc_fmov.dpatch, + 116_ar_nonexistent_files.dpatch: Removed, applied upstream. + - 117_mips_symbolic_link.dpatch: Disabled. Needs an update. + - 118_arm_pass_all.dpatch: Regenerated. + - 119_fix_gas_double_negative.dpatch: Removed, applied upstream. + - 120_mips_xgot_multigot_workaround.dpatch: Updated. + - 121_ia64_unwind_fixes.dpatch, 122_m68k_undefweak_symbols.dpatch: + Removed, applied upstream. + * Merge Ubuntu changes: + - debian/patches: + - 123_dont_add_to_undefs_twice.dpatch: Removed, applied upstream. + - debian/rules: Call pkgstriptranslations if present. + * debian/rules: + - Fix VERSION extraction. + - Save info files before build and restore them in clean target. + * debian/control: + - Add me as an uploader. + + -- Matthias Klose Fri, 6 May 2005 18:43:09 +0200 + +binutils (2.15-6) unstable; urgency=low + + * 123_bfd_overflow_fix.dpatch: new patch from Alan Modra to fix BFD + overflows. Closes: #308625 + + -- James Troup Sat, 21 May 2005 20:20:01 +0100 + +binutils (2.15-5ubuntu2) hoary; urgency=low + + * debian/rules: Call pkgstriptranslations if present (the package does not + use debhelper, thus it does not happen automatically). + + -- Martin Pitt Fri, 18 Mar 2005 13:07:52 +0000 + +binutils (2.15-5ubuntu1) hoary; urgency=low + + * 123_dont_add_to_undefs_twice.dpatch: new patch from Alan Modra (PR338) to + not add symbols to the undefined list twice, causing an assertion failure + in ld when building the kernel on amd64. + + -- Daniel Stone Tue, 7 Dec 2004 09:29:31 +0100 + +binutils (2.15-5) unstable; urgency=low + + * 121_ia64_unwind_fixes.dpatch: new patch from David Mosberger to fix + unwind related bugs. Closes: #278836 + * 122_m68k_undefweak_symbols: new patch from Andreas Schwab to fix undef + weak symbols with non-default visibilty on m68k. Closes: #278388 + + -- James Troup Thu, 25 Nov 2004 00:13:28 +0000 + +binutils (2.15-4) unstable; urgency=low + + * 120_mips_xgot_multigot_workaround.dpatch: new patch from Thiemo Seufer + to make multigot/xgot handling exclusive and fix mozilla builds on + mipsen. Closes: #272149 + + -- James Troup Thu, 23 Sep 2004 22:44:03 +0100 + +binutils (2.15-3) unstable; urgency=low + + * 112_fix_reloc_sizing.dpatch: update patch based on revised change from + Alan Modra. + + * 116_ar_nonexistent_files.dpatch: new patch from Nick Clifton to fix + ar's handling of non-existent files. Closes: #267139 + + * 117_mips_symbolic_link.dpatch: new patch from Thiemo Seufer to fix the + "final link failed: Bad value" error on mips. Closes: #270619 + + * 118_arm_pass_all.dpatch: new kludge patch to fix broken libtool pass_all + handling on arm and other arches. + + * 119_fix_gas_double_negative.dpatch: new patch from Alan Modra via + Daniel Jacobowitz to fix gas' handling of -- and ++. Closes: #266772 + + -- James Troup Thu, 9 Sep 2004 22:24:08 +0100 + +binutils (2.15-2) unstable; urgency=low + + * 112_fix_reloc_sizing.dpatch: new patch from Daniel Jacobowitz to fix + objcopy relocation sections. Closes: #252719 + + * 113_elf_backend_hide_symbol.dpatch: new patch from Alan Modra to fix + ld internal error on hppa. Closes: #254549 + + * 114_mips_delay_slots_in_branch.dpatch: new patch from Thiemo Seufer to + handle delay slots in branch correctly on mips. Closes: #266660 + + * 115_fix_sparc_fmov.dpatch: new patch from Jakub Jelinek via Dave + Miller to fix bogus fmov* SPARC opcodes. Closes: #267824 + + -- James Troup Tue, 31 Aug 2004 22:45:13 +0100 + +binutils (2.15-1) unstable; urgency=low + + * New upstream release. Closes: #248990, #259458 + * Fixes -Wl,-z,defs to correctly abort builds with unresolved + symbols. Closes: #256481 + * Better error message for truncation of bignums in as. + Closes: #219933 + * strip(1) no longer corrupts binaries for architectures it doesn't + recognise. Closes: #211052 + * nm -C /usr/lib/libcrypto++.a no longer segfaults. Closes: #247917 + + * 105_alpha_rpcc_opcode_fix.dpatch, 106_arm_pic.dpatch, + 107_powerpc_ld_segfault.dpatch, 108_m68k_fmoveml_fix.dpatch, + 109_objcopy_keep_debug.dpatch, 110_hppa64_local_symbols.dpatch, + 111_objcopy_vs_unstripped.dpatch, 906_hjl_libtool_dso.dpatch: merged + upstream - removed. + * 012_check_ldrunpath_length.dpatch: resynced with wiggle(1). + + * debian/binutils.shlibs, debian/binutils-hppa64.shlibs, + debian/binutils-multiarch.shlibs: update for 2.15. + + * debian/rules (install): remove gas.info hack as no longer needed + (fixed properly upstream). + * debian/rules (clean): remove gas/doc/as.info which doesn't seem to be + in the upstream tar ball. + + * debian/rules (binary-arch): install $pkg/ChangeLog.linux only if they + exist (because they don't in GNU releases). + + -- James Troup Thu, 29 Jul 2004 22:44:04 +0100 + +binutils (2.14.90.0.7-8) unstable; urgency=low + + * debian/rules: don't use gcc-2.95 on m68k. Thanks to Adam Conrad for + pointing this out. + + -- James Troup Wed, 19 May 2004 10:35:44 +0100 + +binutils (2.14.90.0.7-7) unstable; urgency=low + + * 111_objcopy_vs_unstripped.dpatch: new patch from Alan Modra via Daniel + Jacobowitz to fix objcopy on unstripped libraries on alpha and arm. + Closes: #234021 + + * debian/control (Build-Depends): remove m68k specific build-depends on + gcc-2.95 and libc6-dev (<< 2.3). Many thanks to Michael Schmitz for + testing this. + + -- James Troup Tue, 30 Mar 2004 18:00:54 +0100 + +binutils (2.14.90.0.7-6) unstable; urgency=low + + * 110_hppa64_local_symbols.dpatch: new patch from Randolph Chung to fix + dynamic name generation of local symbols on hppa64 - needed to build + 64-bit hppa kernels. Closes: #238176 + + -- James Troup Fri, 26 Mar 2004 15:52:27 +0000 + +binutils (2.14.90.0.7-5) unstable; urgency=low + + * 109_objcopy_keep_debug.dpatch: new patch from Daniel Jacobowitz + , objcopy --only-keep-debug and readelf SHT_NOBITS + fixes. + + -- James Troup Mon, 26 Jan 2004 16:25:25 +0000 + +binutils (2.14.90.0.7-4) unstable; urgency=low + + * debian/control: add binutils-hppa64 package. + * debian/rules: add support for binutils-hppa64 package and don't enable + hppa64-linux for binutils or binutils-multiarch. + * debian/binutils-hppa64.postinst: new file. + * debian/binutils-hppa64.postrm: likewise. + * debian/binutils-hppa64.shlibs: likewise. + * Above changes largely based on a patch from Matthias Klose + . Closes: #225892 + + * debian/control (Build-Depends): drop bzip2. + + * debian/rules (install-stamp): remove empty /usr/include directory in + binutils. + * debian/rules (install-stamp): remove /usr/share/info/dir* to + workaround install-info brain damage (cf #213524). + + -- James Troup Thu, 22 Jan 2004 21:32:44 +0000 + +binutils (2.14.90.0.7-3) unstable; urgency=low + + * 108_m68k_fmoveml_fix.dpatch: new patch from H.J. Lu + to fix fmoveml disassembly and associated + testsuite regression on m68k. + + -- James Troup Tue, 18 Nov 2003 14:35:23 +0000 + +binutils (2.14.90.0.7-2) unstable; urgency=low + + * 107_powerpc_ld_segfault.dpatch: new patch from Alan Modra + to fix ld segfault on powerpc. Thanks to + Josselin Mouette for the report. Closes: #219187 + + -- James Troup Wed, 5 Nov 2003 13:32:17 +0000 + +binutils (2.14.90.0.7-1) unstable; urgency=low + + * New upstream release. + * 100_null_owner_ld_fix.dpatch, 101_ppc_as_shf_and_rel_fix.dpatch, + 102_alpha_null_got_ld_fix.dpatch, + 103_static_linking_elf_eh_frame.dpatch, + 104_elf_eh_frame_alpha_fix.dpatch: removed; merged upstream. + * debian/rules: update version number. + * debian/binutils.shlibs: likewise. + * debian/binutils-multiarch.shlibs: likewise. + + * 009_signed_char_fix.dpatch: removed; this was fixed upstream correctly + (http://sources.redhat.com/ml/binutils/2003-05/msg00304.html) and this + patch is breaking that fix. Thanks to Daniel Jacobowitz + . + + * 003_gmon_manpage_fix.dpatch -> 002_gprof_profile_arcs.dpatch. + * 014_gprof_manpage_fix.dpatch -> 003_gprof_see_also_monitor.dpatch. + + * 300_alpha_rpcc_opcode_fix.dpatch -> 105_alpha_rpcc_opcode_fix.dpatch + (committed to trunk). + + * debian/rules (configure-multi-stamp): also enable mips64{el,}-linux + for binutils-multiarch. Alphabetize target list. + + * 106_arm_pic: new patch from Phil Blundell and Daniel + Jacobowitz which implements GC for GOT and PLT relocs + in the elf32-arm backend. + + * debian/rules (install-stamp): work around upstream bug which causes + as.info and as.1 to disappear by explicitly calling "make + install-info-am install-am" in builddir-single/gas/doc. + + -- James Troup Sat, 1 Nov 2003 18:14:04 +0000 + +binutils (2.14.90.0.6-5) unstable; urgency=low + + * 104_elf_eh_frame_alpha_fix.dpatch: new patch from H.J. Lu + to fix regressions on alpha caused by + 103_static_linking_elf_eh_frame. Thanks to Thimo Neubauer + for the original report. Closes: #215636 + + -- James Troup Fri, 17 Oct 2003 00:02:09 +0100 + +binutils (2.14.90.0.6-4) unstable; urgency=low + + * 103_static_linking_elf_eh_frame.dpatch: new patch from H.J. Lu + to fix static linking of C++ binaries. + + * 200_alpha_null_got_ld_fix.dpatch: renamed... + * 102_alpha_null_got_ld_fix.dpatch: to this. + + * debian/rules: patch from Guido Guenther to enable + mips64 support. Closes: #213448 + + -- James Troup Sun, 12 Oct 2003 14:26:26 +0100 + +binutils (2.14.90.0.6-3) unstable; urgency=low + + * 100_null_owner_ld_fix.dpatch: new patch from Alan Modra + to fix an ld crash with null owner sections. + Closes: #212029 + + * debian/rules: don't compile with gcc-2.95 on arm; the only failures + are a) testsuite-only (i.e. don't appear to affect real world + applications) and b) fixed by upcoming gcc patches by Phil Blundell + in any event. + * debian/control (Build-Depends): likewise don't build-depend on + gcc-2.95 for arm. + + * 101_ppc_as_shf_and_rel_fix.dpatch: new patch from Alan Modra + to fix an as regression where it refused to + compile utils.S from Linux/PPC 2.6. Closes: #211668 + + -- James Troup Tue, 23 Sep 2003 01:32:08 +0100 + +binutils (2.14.90.0.6-2) unstable; urgency=low + + * debian/rules (CONFLICTS): remove spurious "--", left over from + debhelper based-rules. Fixes build failure on sparc. + + * 200_alpha_null_got_ld_fix.dpatch: new patch from Daniel Jacobowitz + to fix an ld crash on alpha with null .got sections. + Closes: #204615 + + * scripts/dpkg-arch.mk: remove. + * debian/rules: define DEB_BUILD_GNU_TYPE, DEB_HOST_ARCH and + DEB_HOST_GNU_TYPE here instead. + + * debian/rules (binary-indep): use ':' as a separator to chown, rather + than '.' which is a legal character for a username. + * debian/rules (binary-arch): likewise. + + * debian/rules: further trivial cleanups. + + -- James Troup Thu, 18 Sep 2003 22:13:36 +0100 + +binutils (2.14.90.0.6-1) unstable; urgency=low + + * New "upstream" release. + * Fixes core dump of nm -C on certain object files. Closes: #205616 + + * New maintainer. + * debian/control (Maintainer): adjust accordingly. + * debian/copyright: likewise. Update copyright years, URL. + * debian/control (Standards-Version): bump to 3.6.1.0. + + * 011_disable_combreloc_ARM_ONLY.diff: dropped on request of Phil + Blundell - this is obsolete, it was working around a + bug in ld since fixed by Daniel Jacobowitz upstream. + + * 890-elf64_alpha_segfault.diff: dropped as bogus + (http://sources.redhat.com/ml/binutils/2003-04/msg00399.html); rth's + correct fix is already in the upstream source. + + * debian/README.Debian: migrate nearly-obsolete debconf notes to here. + * debian/control (Depends): drop debconf. + * binutils.config, binutils.templates, binutils.templates.ca, + binutils.templates.fr, binutils.templates.ja, + binutils.templates.pt_BR, postrm.debhelper: obsolete, removed. + Closes: #189641, #198222 + + * Migrated from dbs... + * debian/README.build: obsolete; removed. + * debian/rules: remove $(BUILD_TREE)/, $(STAMP_DIR)/, $(unpacked), $(patched) and other references + to DBS. + * debian/rules (clean): remove build tree directories. + * debian/scripts/dbs-build.mk: unused, remove. + * debian/scripts/file2cat: likewise. + + * ... to dpatch. + * debian/rules: include /usr/share/dpatch/dpatch.make. + * debian/rules (configure-single-stamp): depend on patch-stamp. + * debian/rules (configure-multi-stamp): likewise. + * debian/rules (clean): depend on unpatch. Remove debian/patched. + * debian/control (Build-Depends): add dpatch. + + * binutils-doc.postinst, binutils-doc.prerm, + binutils-multiarch.postinst, binutils-multiarch.postrm, + binutils-multiarch.preinst, binutils-multiarch.shlibs, + binutils.postinst, binutils.postrm, binutils.shlibs: new files based + on .deb and packages.d/. + * scripts/dh_split: obsolete, removed. + * debian/packages.d/binutils-dev.in, debian/packages.d/binutils-doc.in, + debian/packages.d/binutils-multiarch.in, + debian/packages.d/binutils.in: likewise. + + * debian/rules: rewritten, de-debhelper-ized. + * debian/control (Build-Depends): drop debhelper and add file. + + -- James Troup Thu, 11 Sep 2003 22:08:18 +0100 + +binutils (2.14.90.0.5-0.2) unstable; urgency=low + + * NMU. + * Rebuild using fixed gcc on sparc (closes: #202924). + + -- Matthias Klose Mon, 28 Jul 2003 20:12:00 +0200 + +binutils (2.14.90.0.5-0.1) unstable; urgency=low + + * NMU. + * New upstream version. + * Remove patches applied upstream: + - debian/patches/500_s390_gas.diff + - debian/patches/905-hppa_visibility.diff + - debian/patches/906-mips_ld_fix.diff + * Updated patch: + - debian/patches/906-hjl_libtool_dso.diff + + -- Matthias Klose Wed, 23 Jul 2003 20:09:51 +0200 + +binutils (2.14.90.0.4-0.1) unstable; urgency=low + + * NMU + * New upstream version. + 1. Work around the brain dead libtool. + * New patches: + - debian/patches/500_s390_gas.diff (closes: #194929). + - debian/patches/905-hppa_visibility.diff (closes: #195203). + - debian/patches/906-mips_ld_fix.diff (closes: #195207). + - debian/patches/906-hjl_libtool_dso.diff + + -- Matthias Klose Sat, 31 May 2003 12:12:10 +0200 + +binutils (2.14.90.0.3-0.1) unstable; urgency=low + + * NMU + * New upstream version. + 1. Update from binutils 2003 0523. + 2. Fix 2 ELF visibility bugs. + 3. Fix ELF/ppc linker bugs. + * Remove patches applied upstream: + - debian/patches/903-hjl_ld-dso-test.diff + - debian/patches/904_hjl_hppa_whitespace.diff + + -- Matthias Klose Sat, 24 May 2003 09:02:54 +0200 + +binutils (2.14.90.0.2-0.1) unstable; urgency=low + + * NMU + * New upstream version. + 1. Update from binutils 2003 0515. + 2. Fix various ELF visibility bugs. + 3. Fix some ia64 linker bugs. + 4. Add more IAS compatibilities to ia64 assembler. + * New patches: + - debian/patches/903-hjl_ld-dso-test.diff (closes: #193505). + - debian/patches/904_hjl_hppa_whitespace.diff. + * Remove patches applied upstream: + - debian/patches/900_binutils-2.14.90.0.1-empty-test.diff + - debian/patches/901-hjl_weaksymfix.diff + + -- Matthias Klose Sun, 18 May 2003 10:50:00 +0200 + +binutils (2.14.90.0.1-0.1) unstable; urgency=low + + * NMU + * New upstream version. + - Fix: MIPS branch-to-global bug (closes: #189031). + - Fix: Crash on alpha with --gdwarf2 and bad file number (closes: #187211). + - Fix: objdump -R BFD ICE on prelinked binaries (closes: #180088). + * New patches: + - debian/patches/900_binutils-2.14.90.0.1-empty-test.diff + - debian/patches/901-hjl_weaksymfix.diff + * Remove patches applied upstream: + - debian/patches/002_ldlex_inflexible_transition.diff + - debian/patches/013_objdump_doc_fix.diff + - debian/patches/850_hppa_stub_fix.diff + - debian/patches/860_m68k_elf.diff + - debian/patches/861_m68k_elf.diff + - debian/patches/870-sparc64-update.diff + - debian/patches/880-alpha-update.diff + * Remove obsolete patch: + - debian/patches/patches/800_hjl_mips_fixes.diff + * Add x86_64 for the i386 binutils package and the binutils-multiarch + package (closes: #189350). + * Set CFLAGS to -g -O2 for build (closes: #181268). + + -- Matthias Klose Tue, 6 May 2003 09:58:14 +0200 + +binutils (2.13.90.0.18-1.7) unstable; urgency=high + + * NMU + * Fixed ld segv (replaced yy_current_buffer by YY_CURRENT_BUFFER) + (Closes: #188876, 188900, 188912) + + -- Julien LEMOINE Mon, 14 Apr 2003 04:45:03 +0200 + +binutils (2.13.90.0.18-1.6) unstable; urgency=high + + * NMU + * [002_ldlex_inflexible_transition.diff] New. Make ld buildable again with + sid's current flex. + + -- J.H.M. Dassen (Ray) Sun, 13 Apr 2003 16:54:46 +0200 + +binutils (2.13.90.0.18-1.5) unstable; urgency=medium + + * NMU + * [890-elf64_alpha_segfault.diff] Patch from Julien LEMOINE + to fix the segfault encountered while building + gal on alpha. (Closes: #185556) + * sid's current flex breaks the building of several packages, including this + one; see #188665. The i386 upload is built using a pbuilder sid chroot + with flex downgraded to the sarge version. + + -- J.H.M. Dassen (Ray) Sun, 13 Apr 2003 13:44:17 +0200 + +binutils (2.13.90.0.18-1.4) unstable; urgency=low + + * NMU + * ld/emulparams/elf64_sparc.sh: Set LIBPATH_SUFFIX instead of suffix + for emulation. Patch from current CVS suggested by Clint Adams, + needed for sparc64 glibc build. + * bfd/elf64-alpha.c: Patch from current CVS suggested by Falk Hueffner, + needed to build xstow, kdegames (#181623), sfs. + * Explicitely fail, when trying to build with glibc-2.3 on arm and + m68k. See #184048 for m68k ld failures. + + -- Matthias Klose Tue, 8 Apr 2003 23:27:46 +0200 + +binutils (2.13.90.0.18-1.3) unstable; urgency=low + + * NMU + * Another fix for ELF/m68k (__bb_exit_func initialization). + + -- Matthias Klose Tue, 18 Mar 2003 00:05:47 +0100 + +binutils (2.13.90.0.18-1.2) unstable; urgency=high + + * NMU + * Apply upstream fix for ELF/m68k. Closes: #182313. + * Use gcc-2.95 on m68k-linux. Built on testing (glibc-2.2). + + -- Matthias Klose Sun, 9 Mar 2003 01:02:39 +0100 + +binutils (2.13.90.0.18-1.1) unstable; urgency=low + + * NMU + * Apply upstream fix for hppa stubs. Closes: #181397 + + -- LaMont Jones Wed, 19 Feb 2003 12:34:58 -0700 + +binutils (2.13.90.0.18-1) unstable; urgency=low + + * New upstream version (synced with CVS 2002-01-21) + * Upstream: Fix an ia64 gas bug + * Upstream: Fix some TLS bugs + * Upstream: Fix ELF/ppc bugs + * Upstream: Fix an ELF/m68k bug + * Corrected ARM combreloc disabling patch + (closes: Bug#175204) + * Upstream fixes take care of TEXTREL bug + on powerpc (closes: Bug#176084) + * Fixed shellutils dependency problem + (closes: Bug#175673) + * Removed mention of the monitor manpage + from the gprof manpage (closes: Bug#160654) + + -- Christopher C. Chimelis Sun, 2 Feb 2003 23:17:29 -0500 + +binutils (2.13.90.0.16-1) unstable; urgency=low + + * New upstream version (synced with CVS 2002-11-26) + * Upstream: Include /usr/bin/c++filt + * Upstream: Fix "ld -r" with exception handling + + -- Christopher C. Chimelis Mon, 9 Dec 2002 19:14:02 -0500 + +binutils (2.13.90.0.14-1) unstable; urgency=low + + * New upstream version (synced with CVS 2002-11-14) + * Upstream: Fix ELF/alpha bugs + * Upstream: Fix an ELF/i386 assembler bug + * Updated package MIPS patch from HJ Lu + * Added s390 patches from Gerhard Tonn. + Actually, the patches to support s390x were + already included upstream, so I just enabled + it in the rules script (closes: Bug#168074, Bug#168974) + * Since powerpc64-linux support was already + added in a prior upload, I'm closing the + wishlist bug for it (closes: Bug#156955) + + -- Christopher C. Chimelis Tue, 20 Nov 2002 05:36:21 -0500 + +binutils (2.13.90.0.10-2) unstable; urgency=low + + * Added two patches from upstream to fix alpha BFD. + (closes: Bug#165633) + + -- Christopher C. Chimelis Sun, 27 Oct 2002 14:21:51 -0400 + +binutils (2.13.90.0.10-1) unstable; urgency=low + + * New upstream version (synced with CVS 2002-10-10) + * Upstream: More ELF/PPC linker bug fixes. + * Upstream: Fix an ELF/alpha linker bug. + * Upstream: Fix an ELF/sparc linker bug to support + Solaris. + * Upstream: More TLS updates. + * Updated m68k gcc 3.1 patch since it wasn't applying + cleanly. Is this still needed? + * Added patches to allow building with new bison + (closes: Bug#164436, Bug#164042) + * Should be better for prelink support, which is coming + soon (closes: Bug#161427) + * Removed windres manpage from all packages + (closes: Bug#157415) + * Fixed download location in copyright file + (closes: Bug#158028) + * Added i386-gnu to multiarch build targets + (closes: Bug#157057) + * Add alpha opcode patch from Falk Hueffner + (closes: Bug#164201) + * Remove .la files from packages + (closes: Bug#160455) + + -- Christopher C. Chimelis Mon, 15 Oct 2002 20:22:29 -0400 + +binutils (2.13.90.0.4-1) unstable; urgency=low + + * New upstream version (synced with CVS 2002-08-) + * Upstream: Update from binutils 2002 0814 + * Upstream: Fix symbol versioning bugs for gcc 3.2 + * Upstream: Fix mips gas + * Upstream: Fix an x86 TLS bfd bug + * Upstream: Fix an x86 PIC gas bug + + -- Christopher C. Chimelis Thu, 15 Aug 2002 20:13:44 -0400 + +binutils (2.12.90.0.15-2) unstable; urgency=low + + * Fix combreloc disabling patch for ARM + (closes: Bug#156315) + * Remove S390 patch since it is no longer + needed (thanks to Gerhard Tonn for checking + this out) + * Fix BFD version string escaping + (closes: Bug#154989) + * Add SH patch from Yaegashi Takeshi + (closes: Bug#156230) + * Added conflicts for older modutils + (closes: Bug#155324) + * Forgot to apply MIPS patch from HJ Lu + (apologies to MIPS folks) + + -- Christopher C. Chimelis Wed, 14 Aug 2002 13:09:12 -0400 + +binutils (2.12.90.0.15-1) unstable; urgency=low + + * New upstream version (synced with CVS 2002-07-17) + * Upstream: Fix an ia64 assembler bug + * Upstream: Fix a symbol versioning bug + * Upstream: You have to apply the modutils patch + enclosed here in order to support System.map + generated by the new nm (bug filed) + * The symbol visibility patch is included + upstream, as is the alpha PLT/GOT patch, so + both removed from my packaging. + * Included patch from upstream to fix RELA targets + (closes: Bug#153729) + + -- Christopher C. Chimelis Thu, 2 Aug 2002 02:24:29 -0400 + +binutils (2.12.90.0.14-2) unstable; urgency=low + + * The "Let's Get This Party Started Right" upload + (since I'm closing as many old bugs as possible) + * Removed sparc patch altogether + * Added a small alpha patch from upstream to fix + some obscure PLT/GOT issues. + * Manpages are now fixed finally -- no more + I (closes: Bug#108369) + * Have not gotten another report of the + debconf message being cut off, so I'm closing + the debconf-related bug. I suspect this may + have been a problem in the debconf front-end + being used, but I have not been able to reproduce + it (closes: Bug#149045) + * Closing a bug report that I had tagged moreinfo + a LONG time ago (over one year), but never got + more info on. I have not heard of this kind + of problem since, nor have I been able to + reproduce it at any time since (closes: Bug#105986). + For interested parties, it revolved around + allowing gcc to show a linker error, but the + reporter didn't know about the -v option for + gcc. There was a linker problem, but it appeared + to be either hardware failure or user error. + * Closing a demangler 'bug' that revolved around + stripping @PLT from symbol names. Since the + PLT suffix is documented, I'm going to close + this bug. Also, it doesn't help that the symbol + in the bug report uses an obsolete mangling style, + so I can't test this even if I wanted to + (closes: Bug#45889) + + -- Christopher C. Chimelis Mon, 22 Jul 2002 12:54:01 -0400 + +binutils (2.12.90.0.14-1) unstable; urgency=low + + * New upstream version (synced with CVS 2002-06-27) + * Upstream: Fix a mips assembler bug + * Upstream: Fix an ELF/mips SHF_MERGE bug + * Upstream: Fix a linker bug which leads to the + incorrect Linux 2.2 kernel. + * PE patch removed since it is included + in upstream source now + * Includes some patches which allow for + more true testsuite results from gcc-3.1 + * Fix sparc ld emulation script patches to get + rid of the lib/64 silliness (now uses lib64) + * Removed the L word from the package description + since Debian is no longer linux-only + (closes: Bug#150575) + * The strings dereferencing problem with + some Windows binaries seems to also be fixed now + (closes: Bug#121366) + * Added a patch to only generate an RPATH entry + if LD_RUN_PATH is not empty, for cases where + -rpath isn't specified (closes: Bug#151024) + * Fixed arch detection problem in the build + scripts. + * Fixed bad capitalisation of -g in the objdump + manpage (closes: Bug#152697) + * Added patch from HJ Lu to fix a symbol + visibility issue. + + -- Christopher C. Chimelis Wed, 17 Jul 2002 14:23:42 -0400 + +binutils (2.12.90.0.9-1) unstable; urgency=low + + * New upstream version (synced with CVS 2002-05-26). + * Upstream: Supports "-z muldefs" + * Updated PE bfd from CVS to fix auto-import + segfaults (closes: Bug#131407) + * Remove the PE-removing patch for i386 targets + due to the above + + -- Christopher C. Chimelis Thu, 6 Jun 2002 15:52:29 -0400 + +binutils (2.12.90.0.7-1) unstable; urgency=low + + * New upstream version (synced with CVS 2002-04-23). + * Upstream: ELF EH frame bug fix + * Upstream: MIPS ELF visibility bug fix + * Upstream: Bug fixes for ELF/sparc + * Upstream: Bug fixes for ELF/cris + * Upstream: Fix linking a.out relocatable files + with ELF + * Upstream: Fix a PPC altivec assembler bug + * Numerous upstream changes since I have + deliberately not updated in awhile so that + I could stabilise the package for woody + release + * Fixed a glaring typo in the Debian additions + to the version string. + * Upstream incorporated --oformat + documentation patch; removed. + * Added a patch from upstream involving + relative relocs on Alpha + * Removed configure.info-[1-3] from -doc + (closes: Bug#146205) + + -- Christopher C. Chimelis Sun, 5 Apr 2002 04:52:33 -0400 + +binutils (2.12.90.0.1-5) unstable; urgency=high + + * Added a patch to m68k bits for gas to allow + gcc 3.1 to build + * Added Brazilian Portuguese translation for + debconf (closes: Bug#144677) + * Removed unneeded gasp manpage since gasp + was eliminated as a distinct binary + (closes: Bug#144583) + + -- Christopher C. Chimelis Mon, 29 Apr 2002 14:40:21 -0400 + +binutils (2.12.90.0.1-4) unstable; urgency=low + + * Added patch from Gerhardt Tonn + to fix s390 merge problem (closes: Bug#143187) + * Corrected DOW of my last changelog entry :-P + + -- Christopher C. Chimelis Thu, 18 Apr 2002 13:03:49 -0400 + +binutils (2.12.90.0.1-3) unstable; urgency=low + + * Oops...I used dpkg-architecture from dpkg-dev + in the postinst and didn't add a dependency + for it. It was a bad choice anyway and I'm + going to use uname -s instead + (closes: Bug#142744, Bug#142915) + + -- Christopher C. Chimelis Mon, 15 Apr 2002 12:41:10 -0400 + +binutils (2.12.90.0.1-2) unstable; urgency=low + + * Added Catalan debconf translation + (closes: Bug#139740) + * Ensure that info entries are removed from the + texinfo dirfile when binutils-doc is removed + (closes: Bug#126557) + * Ensure that the kernel link debconf warning + only shows up on linux systems + (closes: Bug#142360) + + -- Christopher C. Chimelis Thu, 13 Mar 2002 01:30:22 -0400 + +binutils (2.12.90.0.1-1) unstable; urgency=high + + * New upstream version (synced with CVS 2002-03-07). + * Upstream: Add the .preinit_array/.init_array/.fini_array + support. + * Upstream: Fix eh_frame. + * Upstream: Turn on combreloc by default. + * Upstream: Enable gprof for Linux/mips. + * Turn combreloc off for ARM explicitely until + I can confirm that PIC is not still broken + by using it. + * Remove IA-64 unwind patch and objcopy fix + since they are included in the upstream sources + now. + * Re-enable testsuite run since Randolph did the NMU + on dejagnu (thank you!). + * Appears to fix sparc64 linking problems. I'm + still looking into exactly what was going on with + that (closes: Bug#137850) + * Enabled hppa64-linux support in main binutils + package (closes: Bug#137955) + * Added Japanese debconf template. Thanks to + Tomohiro KUBOTA for supplying that + (closes: Bug#138112) + * Added patch for ld to fix dosemu problems + (closes: Bug#126863) + + -- Christopher C. Chimelis Mon, 11 Mar 2002 14:02:45 -0500 + +binutils (2.11.93.0.2-3) unstable; urgency=high + + * Split translated debconf templates out. + I apparently misunderstood the instructions + on integrating the French translation since + this is my first real attempt at using + debconf (closes: Bug#136295) + * Disable combreloc default on ARM since it + breaks PIC, apparently (closes: Bug#134241) + Please test other ARM bugs against this + version and inform me of the results! + + -- Christopher C. Chimelis Fri, 8 Mar 2002 19:10:10 -0500 + +binutils (2.11.93.0.2-2) unstable; urgency=high + + * Include a patch from upstream to fix stripping + archives containing multiple files with the + same name (like libgcj, unfortunately). + (closes: Bug#107812) + * Include IA64 unwind fix from CVS to fix kernel + linking on IA64. (closes: Bug#135143) + * Added French translation of the debconf + bits. Thanks to Denis Barbier for the + work on that. (closes: Bug#134626) + * Disabled testsuite run until dejagnu is + fixed. I'm leaving the build-dep for dejagnu + in, though, since I know I'll forget to + reinsert it when I do re-enable the testsuite + run. + + -- Christopher C. Chimelis Fri, 22 Feb 2002 14:05:22 -0500 + +binutils (2.11.93.0.2-1) unstable; urgency=high + + * New upstream version (synced with CVS 2002-02-07). + * Upstream: Fix a weak symbol alpha linker bug for glibc. + * Upstream: More support for gcc 3.1. + * Keep on disabling efi-app-ia32 type targets + since the segfault is still unfixed in CVS and + I haven't had the time to go back and really + debug and fix this. + * Updated standards version. + * Corrected some of the lintian problems (all except + the ones involving Changelog.linux, the .comment + section, and the missing manpages for + binutils-multiarch's binaries since that package + depends on binutils, which provides those). + + -- Christopher C. Chimelis Wed, 13 Feb 2002 13:41:47 -0500 + +binutils (2.11.92.0.12.3-7) unstable; urgency=high + + * The "Remind Me To Think Next Time" upload. + * Fix the postinst to only compare versions on + upgrade rather than during configure. + (closes: Bug#133349, Bug#133514) + * Still working on the other bugs...if only + I could get a day off of work... + + -- Christopher C. Chimelis Tue, 12 Feb 2002 06:15:02 -0500 + +binutils (2.11.92.0.12.3-6) unstable; urgency=high + + * The "Make The Bad Man Stop" upload. + * Revert patch to bfd/elf32-sparc.c (already + reverted upstream) that broke UA32 relocs on sparc + and caused bus errors with C++/Java binaries + (closes: Bug#126162) + * Remove i486-mingw32 target from the enabled + in multiarch and removed efi-app-ia32 from the + BFD config for Intel linux targets until I can find + and fixthe segfaults that seem to keep coming up when + reading Windows files and viruses with objdump or + strings. This is only temporary, so I'm not closing + the bugs until the problem gets fixed, but + I am going to bump them down to wishlist, merge + them, and note the above in them. + (debian/patches/010_disable_efi_app_ia32_TEMPORARY.diff + disables the efi-app-ia32 BFD in case someone + wants to revert this change easily) + * Added debconf warning about the kernel linking + situation since it keeps coming up and people + keep initially disagreeing with me about this + being a kernel bug. Also, merged prior warning + about -oformat change into the same debconf warning + (it's two, two, two warnings in one). This makes + the DEBIAN_FRONTEND case bug moot (closes: Bug#131801) + * Added powerpc64-linux target to multiarch since + work is progressing on that target and the machines + are due to hit the shelves Very Soon(TM). + + -- Christopher C. Chimelis Fri, 1 Feb 2002 17:06:29 -0500 + +binutils (2.11.92.0.12.3-5) unstable; urgency=high + + * Fix signed char assumption in i386 disassembly bits + (closes: Bug#126993) + + -- Christopher C. Chimelis Mon, 8 Jan 2002 17:27:17 -0500 + +binutils (2.11.92.0.12.3-4) unstable; urgency=high + + * Go back to enabling archs by enumeration for + multiarch. Apparently, a few aren't enabled + with --enable-targets=all (sparc64-linux, namely). + Besides, multiarch was incredibly large, which + was probably unneeded. + + -- Christopher C. Chimelis Wed, 26 Dec 2001 13:53:49 -0500 + +binutils (2.11.92.0.12.3-3) unstable; urgency=high + + * Include patch from Alan Modra to fix more + refcount problems on hppa. + + -- Christopher C. Chimelis Fri, 7 Dec 2001 05:42:04 -0500 + +binutils (2.11.92.0.12.3-2) unstable; urgency=high + + * Include patch from Alan Modra to fix hppa linking + woes wrt undefined symbols (closes: Bug#121993) + + -- Christopher C. Chimelis Wed, 5 Dec 2001 04:14:51 -0500 + +binutils (2.11.92.0.12.3-1) unstable; urgency=high + + * New upstream version (synced with CVS 2001-11-21) + * Upstream: Fix a linker symbol version bug + for common symbols. + * Upstream: Update handling relocations against + the discarded sections. You may need to apply + the kernel patch enclosed here to your kernel + source. + * Upstream: Support "-march=xxx -mipsN" for mips + gas if they are compatible. + * Upstream: Fix a regression when linking with + non-ELF object files. + * Includes Alan Modra's patch to reduce stub sizes + on HPPA. Should help C++ on HPPA. + * Once again includes a mips patch from HJ Lu. + * My documentation changes were cleaned up and + accepted upstream, so the gas manpage fixes go + away (hurray!). + * Stopped iterating targets for binutils-multiarch + and started enabling all of them. This saves + maintenance time since new targets will be + automatically supported in future uploads + and existing targets that I didn't include + before will be supported from now on. This may + grow build time and the libbfd in the multiarch + package, but it's worth it. + * Also, started using the --enable-64-bit-bfd + flag for configuring multiarch. I don't know + why I didn't realise this wasn't there before + since I test with it all of the time. + + -- Christopher C. Chimelis Fri, 30 Nov 2001 20:11:42 -0500 + +binutils (2.11.92.0.10-4) unstable; urgency=high + + * The "Fingers crossed" upload. + * Enable combreloc by default for s390 again. + Rumour has it that it worked before, but there + was a misunderstanding in the s390 developer + community, hence the disabling in the past. + * Fix the ld texinfo file to not mention the old + oformat invocation (closes: Bug#116182) + * Next upload should include the mips updates and + some powerpc updates. I just need time to test + those out first. + + -- Christopher C. Chimelis Fri, 23 Nov 2001 23:23:22 -0500 + +binutils (2.11.92.0.10-3) unstable; urgency=high + + * Replace HPPA reloc patch with patches from Alan + Modra upstream. + * Add upstream patch to fix quoted -rpath bug + (closes: Bug#107214) + + -- Christopher C. Chimelis Sat, 10 Nov 2001 18:19:05 -0400 + +binutils (2.11.92.0.10-2) unstable; urgency=high + + * Disable -z combreloc enable patch on S/390 + since it's not supported there yet + (closes: Bug#117087) + + -- Christopher C. Chimelis Fri, 26 Oct 2001 00:07:01 -0400 + +binutils (2.11.92.0.10-1) unstable; urgency=high + + * New upstream version (synced with CVS 2001-10-21) + * Upstream: Fix the ELF/PPC linker. + * Upstream: Fix the ELF/cris linker. + * Upstream: Fix ELF strip. + * Includes beginnings of Altivec support + (closes: Bug#98617) + * Fixes use of BookE instruction format on 4xx + PowerPC (closes: Bug#116627) + * Includes patches from Alan Modra to fix hppa + relocations. + * Forgot to close the previous PPC bug with last + upload (closes: Bug#116454) + * Moved to enclosing a bzipped tarball rather than + a gzipped one to save download time for everyone + involved. Build-deps adjusted accordingly. + + -- Christopher C. Chimelis Tue, 23 Oct 2001 03:29:49 -0400 + +binutils (2.11.92.0.7-2) unstable; urgency=high + + * Include a patch from H.J Lu to fix a powerpc + issue not shown in the testsuite results. + + -- Christopher C. Chimelis Fri, 19 Oct 2001 00:49:04 -0400 + +binutils (2.11.92.0.7-1) unstable; urgency=high + + * New upstream release (synced with CVS 2001-10-16) + * Upstream: Fix all breakages introduced in 2.11.92.0.5 + * No mips/ dir patches need to be applied with this one. + Woohoo! + * Removed patches from debian/patches that are already + applied upstream. + * Patched version strings to reflect that this is a + Debian release at the request of upstream (to prevent + confusion, apparently). + * Applied patch from H.J. Lu to fix mips section + misalignment. + * Applied patch from Jakub Jelinek to fix kernel linking + on i386 and possibly other archs (closes: Bug#116041) + * Fixed postinst and prerm for binutils-doc to test that + the files exist before calling install-info. This should + fix the odd circumstance when binutils-doc is packaged on + an arch that doesn't support gprof (or any other dir for + that matter) and, therefore, the docs that are usually + made in that dir aren't made. This is particularly true + with gprof on mips. + + -- Christopher C. Chimelis Wed, 17 Oct 2001 18:56:51 -0400 + +binutils (2.11.92.0.5-3) unstable; urgency=high + + * Enable -z combreloc on all targets. This will make + prelinking possible with the prelink package. Please + test this on all archs prior to upload. If it fails, file + a bug immediately and I'll disable the patch for that + platform. + * Added patches from Alan Modra (from CVS) to fix other + archs after the refcount patch broke them. This supercedes + the powerpc patch, so I replaced that with this. + (closes: Bug#115218) + * Added patch from H.J. Lu (from CVS) to fix IA64 linker + problems as well. + * Added patch from David Kimdon to specify which filename is + causing an error if that filename is a dir (closes: Bug#45832). + * Removed workaround patch for stabs problem on Alpha since + it appears to be causing problems on mips and is no longer + needed on Alpha anyway. + * Now runs the testsuite and includes the results in the + binutils package for reference. + + -- Christopher C. Chimelis Sat, 13 Oct 2001 15:10:20 -0400 + +binutils (2.11.92.0.5-2) unstable; urgency=high + + * Applied fix from H.J. Lu to fix PowerPC target + (closes: Bug#115285). Thanks to Jack Howarth + for forcing the issue upstream. + + -- Christopher C. Chimelis Fri, 12 Oct 2001 23:14:51 -0400 + +binutils (2.11.92.0.5-1) unstable; urgency=high + + * New upstream release (synced with CVS 2001-10-05) + * Upstream: Support gcc 3.1 for IA64. + * Upstream: Support prelink for ELF/PPC. + * Upstream: Fix an ELF/x86 linker bug for Oracle + (closes: Bug#113614) + * Upstream: Fix a weak symbol bug. + * Upstream: Support locale. + + -- Christopher C. Chimelis Tue, 9 Oct 2001 19:53:49 -0400 + +binutils (2.11.90.0.31-2) unstable; urgency=high + + * Applied IA64 patch from CVS to fix gcc issues + on IA64. + + -- Christopher C. Chimelis Mon, 24 Sep 2001 12:45:29 -0400 + +binutils (2.11.90.0.31-1) unstable; urgency=high + + * New upstream source (synced with CVS 2001-08-30) + * Upstream: Fix a MIPS linker bug. + * Now applying mips diffs from H.J. Lu (upstream) + for better MIPS and MIPS64 support. + * Applied patch from Christopher Cramer to fix + gasp .REG issue (closes: Bug#110560) + + -- Christopher C. Chimelis Sat, 1 Sep 2001 23:42:22 -0400 + +binutils (2.11.90.0.29-1) unstable; urgency=high + + * New upstream source (synced with CVS 2001-08-27) + * Upstream: Fix an Alpha assembler bug. + * Upstream: Fix an IA64 linker bug. + * Upstream: Fix a MIPS linker bug. + * Upstream: Support '-z combreloc|nocombreloc' in linker. + + -- Christopher C. Chimelis Thu, 30 Aug 2001 04:48:04 -0400 + +binutils (2.11.90.0.27-4) unstable; urgency=high + + * Argh. Really remove the manpages from multiarch + this time (closes: Bug#110410) + + -- Christopher C. Chimelis Tue, 28 Aug 2001 14:32:34 -0400 + +binutils (2.11.90.0.27-3) unstable; urgency=high + + * Include hppa patch to force error + (closes: Bug#109173) + * Fix manpages - seems that I accidentally included + the multiarch manpages rather than the target + manpages (sorry). + * Partial update to as manpage to denote arch options + and added options for the rest of the targets + Still need to elaborate on them, though. More + changes are forthcoming (closes: Bug#110127) + + -- Christopher C. Chimelis Mon, 27 Aug 2001 10:13:27 -0400 + +binutils (2.11.90.0.27-2) unstable; urgency=high + + * Remove bash dependency...ash's behaviour has + already been modified, so it should be able + to build binutils now (closes: Bug#106992) + * Includes new S/390 patch (closes: Bug#109300) + * Could never reproduce objdump segfault and + never got a reply on the bug report + (closes: Bug#93884) + * Can't reproduce m68k segfault either + (closes: Bug#87714) + + -- Christopher C. Chimelis Mon, 20 Aug 2001 23:07:30 -0400 + +binutils (2.11.90.0.27-1) unstable; urgency=high + + * New upstream source (synced with 20010810 CVS) + * Upstream: Fixed x86 linker bug. + * Reverted a patch to gas to dodge a bug in STABS output + on Alpha using gcc 2.95.4, so alpha can be in sync + with the rest of the archs now. + * Fixes strip problems with busybox (closes: Bug#106593) + * Kernels should compile ok again on i386 + (closes: Bug#107190) + + -- Christopher C. Chimelis Thu, 16 Aug 2001 08:24:49 -0400 + +binutils (2.11.90.0.25-1) unstable; urgency=high + + * New upstream source (synced with 20010726 CVS) + * Upstream: fix i386 assembler bug. + * Upstream: "make check" has 2 failures in the + ld-selective test in ld on Linux/alpha. They + should be marked xfail. Fixed in the next release. + * Removed m68k patch (closes: Bug#106431) + * Man pages appear to be correctly generated now + (closes: Bug#98569, Bug# 98938) + * Added bash build dependency (closes: Bug#106992) + * Should compile ok on powerpc (the last one did + also...don't know why voltaire's build daemon failed). + I won't close this bug until I build it myself + on voltaire or hear back from the autobuilder folks + on PPC. + * Looking into the whole LD_LIBRARY_PATH issue that + keeps being brought up. I think the docs are wrong + because the templates say that it shouldn't obey that + at all. Can we please stop filing duplicate bugs for + this? I would greatly appreciate it... + + -- Christopher C. Chimelis Wed, 1 Aug 2001 07:06:52 -0400 + +binutils (2.11.90.0.24-1) unstable; urgency=high + + * New upstream source (synced with 20010714 CVS) + * DO NOT COMPILE FOR ALPHA. I need to fix gcc 2.95.4 + prior to this release working on Alpha correctly + (long story). + * Upstream: Avoid COPY relocs on i386 + * Upstream: Fix IA64 assembler (please try this and let me know) + * Upstream: Fix a static linking the PIC object files on ia32 + * Upstream: Add the version script support for --export-dynamic + * Upstream: Fix sparc/elf for linux/sparc + * Upstream: Fix alpha/elf for gcc 3.0 + * Supposedly required for gcc-3.0 usage on many platforms + * Add s390 to multiarch list (closes: Bug#98095) + * Supposedly good on mips, but please check. I emailed Ryan + to see if bug 98095 still happens, but never got a reply. + If I get around it, I'll check it myself since my mips + lives once again. + * Retake my package from Matt (next time we agree to an NMU, + please don't change the maintainer name...no wonder I didn't + get any bug reports!) + * Cross-compilation support will be added in the next upload + (I'll be uploading alpha debs with the next release as well, + the alpha problem outweighs cross-compilation support in + priority right now). + + -- Christopher C. Chimelis Thu, 19 Jul 2001 05:12:05 -0400 + +binutils (2.11.90.0.7-2) unstable; urgency=high + + * Applied patch from Alan Modra to fix m68k + assertion problems (closes: Bug#96352) + * Applied srec patch from Richard Henderson for + alpha. + + -- Christopher C. Chimelis Wed, 9 May 2001 03:11:19 -0400 + +binutils (2.11.90.0.7-1) unstable; urgency=high + + * New upstream source (synced with 20010425 CVS) + * Upstream: Fix the -Bsymbolic bug introduced in + binutils 2.11.90.0.5 (closes: Bug#95168) + + -- Christopher C. Chimelis Sun, 29 Apr 2001 20:03:22 -0400 + +binutils (2.11.90.0.5-1) unstable; urgency=high + + * New upstream source (synced with 20010414 CVS) + * Upstream: Fix in IA64 assembler + * Upstream: Change Linux/MIPS to use SVR4 MIPS ABI + rather than IRIX ABI. + * The above change may cause problems for MIPS. + If so, please file a bug and I'll revert those + changes if need be. I suspect that glibc, gcc, + and the kernel may eventually follow suit, though + to fit in with this change (it makes sense... + see the symbol ordering problems threads on the + binutils list for more info). + * Upstream: IA32 gas bug fixed...no further details + provided, unfortunately. + * Reportedly fixes core dumping when trying to link + object files from other platforms (now warns) + (closes: Bug#60502) + * Includes Philip Blundell's ARM PLT patch finally... + sorry for the delay (closes: Bug#94181) + * m68k problems should be fixed by now. Wish I had + gotten more feedback, but I didn't so I'm assuming it + works at this point (closes: Bug#74396) + * Stopped compiling cross-compiler packages until we + work out a better system for the entire toolchain. + Sorry, but it was taking far too long on even fast + machines and I've gotten more complaints about the + current arrangement than I have positive feedback. + (closes: Bug#91120, Bug#91119, Bug#91118, Bug#91117, + Bug#91116, Bug#88311, Bug#78028, Bug#90177) + * Fixed readelf manpage so that it no longer says that + it is a preprocessor for assembly programs + (closes: Bug#90798) + + -- Christopher C. Chimelis Tue, 17 Apr 2001 20:07:14 -0400 + +binutils (2.11.90.0.1-1) unstable; urgency=high + + * New upstream source (synced with 20010309 + CVS). + * Fixed misapplied m68k ld patch. + I am hoping that this almost totally fixes + m68k ELF for now. + * Fixed typo in mips patch and applied another + mips patch from Daniel Jacobowitz. + * Should no longer build same-arch cross + packages. Please let me know if this fix + worked so that I can close the bugs (I have + no access to such an arch at the moment) + * Made urgency high since m68k really needs + this if the bugs are truly fixed. Even if + not, this version is infinitely better on + at least two platforms than prior ones were. + + -- Christopher C. Chimelis Thu, 15 Mar 2001 16:29:32 -0500 + +binutils (2.10.91.0.2-4) unstable; urgency=low + + * Applied m68k ld and bfd patches from + Michael Fedrowitz to hopefully make things + better on m68k. + + -- Christopher C. Chimelis Sun, 11 Mar 2001 20:16:44 -0500 + +binutils (2.10.91.0.2-3) unstable; urgency=low + + * Adjusted the priority of binutils-doc to + optional. + * Added debhelper build-depends (closes: Bug#87690) + * Fixed postinst problem for new binutils + installations (closes: Bug#87911) + + -- Christopher C. Chimelis Thu, 1 Mar 2001 15:06:50 -0500 + +binutils (2.10.91.0.2-2) unstable; urgency=low + + * Add support for SH and IA64 to binutils-multiarch. + * Applied m68k gas patch from Michael Fedrowitz + in hopes that this will fix the grave bug that + has been such a pain to m68k folks. I'll leave + the bug open until it's verified that it works + ok. + * Applied IA-64 printf patch (closes: Bug#82702) + * Kernels appear to be building fine with this + release on all archs available to me + (closes: Bug#77610) + * Added text during postinst that informs users + to modify their i386 kernel Makefiles for the + --oformat change (closes: Bug#86995) + * Incorporated remaining mips diffs that weren't + already applied upstream (closes: Bug#81280) + * Sparc/sparc64 patch seems to be doing fine, so + closing the bug (closes: Bug#86781) + * Added non-linux cross- package support to rules + (closes: Bug#79948) + * Close misc bugs: + Missing info file in binutils-doc (closes: Bug#78754) + + -- Christopher C. Chimelis Thu, 22 Feb 2001 19:36:12 -0500 + +binutils (2.10.91.0.2-1) unstable; urgency=low + + * New upstream version. + * Added weak symbol relocation patch for sparc/sparc64. + * Included m68k ELF fix from Michael Fedrowitz. + * BIG NOTE: any i386 kernels compiled with this will need + to be patched to change the ld option '-oformat' to + '--oformat' (extra hyphen). + + -- Christopher C. Chimelis Tue, 20 Feb 2001 21:32:44 -0500 + +binutils (2.10.1.0.2-1) unstable; urgency=low + + * New upstream release (really prerel, but better than + using a CVS version). + * Should re-add Compaq demangling style to all + tools (alpha-only). + * Again, hopefully fixes m68k ELF support...still have + no idea why or how this was broken before. + + -- Christopher C. Chimelis Mon, 20 Nov 2000 16:25:44 -0500 + +binutils (2.10.0.27-0.cvs20001011.2) unstable; urgency=low + + * Applied another PowerPC patch to correct the + implementation of .protected and .hidden in the + linker. This should also aid in the glibc + transition on PowerPC. + + -- Christopher C. Chimelis Tue, 17 Oct 2000 13:23:40 -0400 + +binutils (2.10.0.27-0.cvs20001011.1) unstable; urgency=low + + * Applied PowerPC weak symbol patch from CVS to aid + in glibc transition on that platform. + + -- Christopher C. Chimelis Sun, 15 Oct 2000 19:12:22 -0400 + +binutils (2.10.0.27-0.cvs20001011) unstable; urgency=low + + * Grabbed a new CVS version since it backs out a + change that prevented current gcc snapshots from + linking properly to libstdc++v3. This may also + solve some other problems related to global + section symbols (feedback appreciated). + * Finally changed my email address in the control + file (how I overlooked this after all of this + time I'll never know). + + -- Christopher C. Chimelis Wed, 11 Oct 2000 08:59:36 -0400 + +binutils (2.10.0.27-0.cvs20001008) unstable; urgency=low + + * Removed configure.info.gz from binutils-doc since + it didn't really belong there. (closes: Bug#72746) + * Update for hppa/hppa64 targets (included testsuite + changes committed on 07-Oct-2000). (closes: Bug#71524) + * Upstream change to elflink.h to hopefully stop + segfaults on some archs when linking binaries to + shared libs. + + -- Christopher C. Chimelis Sun, 8 Oct 2000 16:14:08 -0400 + +binutils (2.10.0.27-0.cvs20000923.1) unstable; urgency=low + + * Fixed rules file so that builds don't fail when compiling the + binary-arch target (added binary-cross to binary-arch). + * Fixed harmless attempt at removing builddir-avr twice. + + -- Christopher C. Chimelis Thu, 28 Sep 2000 10:39:12 -0400 + +binutils (2.10.0.27-0.cvs20000923) unstable; urgency=low + + * CVS snapshot from 2000-09-23. + * Should fix some (most) HPPA issues. + * Adds binutils-m68k cross-assembler. + + -- Christopher C. Chimelis Sun, 24 Sep 2000 10:19:20 -0400 + +binutils (2.10.0.26-2) unstable; urgency=low + + * Added the avr target for Amtel's AVR MCU's + * Applied Frank I. Smith to generate packages for + multiple cross targets: + + Bump rev number, NOP. + + Testing out bumping up the rev number. + + Added powerpc, arm, mipsel cross binutils packages. + + -- Christopher C. Chimelis Fri, 22 Sep 2000 17:31:44 -0400 + +binutils (2.10.0.26-1) unstable; urgency=low + + * New upstream source. + * Added mips-linux, hppa-linux, and hppa64-linux to multiarch targets + + -- Christopher C. Chimelis Sun, 17 Sep 2000 01:05:49 -0400 + +binutils (2.10.0.24-1) unstable; urgency=low + + * New upstream source. + * Fixes ia32 assembler buglet. + * (Hopefully) fixes PPC visibility problems with + glibc 2.2 + + -- Christopher C. Chimelis Thu, 24 Aug 2000 16:52:44 -0400 + +binutils (2.10.0.18-3) unstable; urgency=low + + * Added build depends stuff. + + -- Christopher C. Chimelis Sat, 5 Aug 2000 21:09:04 -0400 + +binutils (2.10.0.18-2) unstable; urgency=low + + * Added proviso to control file saying that -multiarch + should not be installed by the average user. + + -- Christopher C. Chimelis Sat, 29 Jul 2000 20:07:15 -0400 + +binutils (2.10.0.18-1) unstable; urgency=low + + * New upstream source. + * Should address some needed things for glibc 2.2 + (added new DT_XXXX dynamic tags and fixes DT_NEEDED + link bug) + * Reapplied the now-infamous "ObjC patch" until + we can figure out why we still have this problem + (hint hint hint...we really need to do this). + + -- Christopher C. Chimelis Sat, 22 Jul 2000 13:18:27 -0400 + +binutils (2.10.0.9-4) unstable; urgency=low + + * Applied a patch from Ben Collins to fix sparc64 + linker scripts + + -- Christopher C. Chimelis Sat, 8 Jul 2000 07:24:10 -0400 + +binutils (2.10.0.9-3) unstable; urgency=low + + * Applied a patch from the libstdc++ mailing list to + make sure that the linker doesn't eat the eh_frame + section. + + -- Christopher C. Chimelis Fri, 7 Jul 2000 10:26:59 -0400 + +binutils (2.10.0.9-2) unstable; urgency=low + + * Wow, already a bug fix. + * binutils-dev now provides libiberty.h + + -- Christopher C. Chimelis Fri, 23 Jun 2000 19:54:39 -0400 + +binutils (2.10.0.9-1) unstable; urgency=low + + * New upstream version (more linux-specific). + + -- Christopher C. Chimelis Fri, 23 Jun 2000 14:31:04 -0400 + +binutils (2.10-1) unstable; urgency=low + + * New upstream version (finally, a real release!) + + -- Christopher C. Chimelis Wed, 21 Jun 2000 19:08:14 -0400 + +binutils (2.9.5.0.46-1) unstable; urgency=low + + * New upstream source. + * ELF visibility attribute should work correctly now. + * ia32 "jmp" instructions are now assembled differently + to use relocation for global jumps (affects PIC asm + code). + + -- Christopher C. Chimelis Thu, 8 Jun 2000 21:34:42 -0400 + +binutils (2.9.5.0.42-1) unstable; urgency=low + + * New upstream source. + * Includes a testcase for hidden symbol support. + + -- Christopher C. Chimelis Fri, 19 May 2000 20:48:52 -0400 + +binutils (2.9.5.0.41-1) unstable; urgency=high + + * New upstream source. + * Now includes patch to enable hidden symbol support + needed for gcc 3.0 testing. + + -- Christopher C. Chimelis Fri, 5 May 2000 20:38:41 -0400 + +binutils (2.9.5.0.37-1) frozen unstable; urgency=high + + * Was forced to bring the current frozen version up to + upstream 2.9.5.0.37 in order to fix a rather nasty + i386 gas bug and also since the existing ARM patch + applied in 2.9.5.0.31-3 has been superceded upstream + (closes:Bug#62119) + * Includes proper demangler support for Compaq compiler + usage on Alpha (may be superceded upstream shortly, + but is good enough for potato and for Compaq's usage) + (closes:Bug#62079) + * Added cross-compilation support for individual use. + Please note that the binary packages do not support + this. If you require this feature, you need to compile + the source package changing debian/rules. Also, if + you do this, YMMV since things on this front are changing + rapidly upstream and also because cross-compiling from + certain platforms to others may not work (i386->alpha, + for example). (closes:Bug#59246) + * Fixed replaces statement in binutils-multiarch + (closes:Bug#62496) + * Release Manager: I once again beg that this be included + in potato. I've freed up some time to deal with bug + reports quickly if needed. + + -- Christopher C. Chimelis Sat, 29 Apr 2000 04:03:39 -0400 + +binutils (2.9.5.0.31-3) frozen unstable; urgency=high + + * Applied patch to fix broken ARM code generation (closes:Bug#61977) + + -- Christopher C. Chimelis Fri, 7 Apr 2000 15:50:42 -0400 + +binutils (2.9.5.0.31-2) frozen unstable; urgency=high + + * Remove ld from binutils-multiarch since it doesn't want to + link kernels on several archs properly (fixes severity:important bug) + (closes: Bug#61719, Bug#61615, Bug#51625) + + -- Christopher C. Chimelis Mon, 3 Apr 2000 22:48:55 -0400 + +binutils (2.9.5.0.31-1) frozen unstable; urgency=high + + * Yet another patch (this time from H.J. Lu upstream) to fix + the unlink race condition bug. This is VERY important and + needs to be in potato. It also fixes the temp file creation + problem with objcopy on PPC (closes: Bug#60934) + * New upstream release. Fixes a serious Alpha bug along + with a demangler bug and several others (closes: Bug#61121) + * Should fix apt-get upgrade problem...please test + (closes: Bug#56175) + * Release manager: can we squeeze this in? I know it's a + new version, but the ELF bug on Alpha really needs to + be fixed along with the rest of the above and some others + not mentioned here. + + -- Christopher C. Chimelis Wed, 22 Mar 2000 05:05:12 -0500 + +binutils (2.9.5.0.22-5) frozen unstable; urgency=high + + * Applied fixed patch from Colin Phipps to seal the unlink + race condition in bfd/cache.c (closes: Bug#58865, Bug#57831) + * Installed a proper changelog in binutils-doc + (closes: Bug#58522) + * Closes other older bug (closes: Bug#55801) + * Included bbconv.pl in binutils main package in the doc dir + under the gprof subdir (closes: Bug#57521) + + -- Christopher C. Chimelis Tue, 14 Mar 2000 10:32:52 -0500 + +binutils (2.9.5.0.22-4) frozen unstable; urgency=high + + * Patched gprof/hertz.h to allow binutils to actually + build and work on Hurd (closes: Bug#57564) + * Patched bfd/cache.c to avoid a rare, but possible + security problem when as is creating/opening temp + files (closes: Bug#57831) + + -- Christopher C. Chimelis Thu, 17 Feb 2000 10:31:05 -0500 + +binutils (2.9.5.0.22-3) frozen unstable; urgency=high + + * Removed standards.info...do we really need seven + bugs filed for the same problem + (closes: Bug#54521, Bug#54546, Bug#54614, Bug#54682, Bug#55402, Bug#55582, Bug#55602) + * Changed binutils-multiarch extended description + to mention that a cross-assembling gas is not + included (closes: Bug#49308) + * Closing a bug because it related to lack of disk space + (closes: Bug#52714) + + -- Christopher C. Chimelis Wed, 19 Jan 2000 19:28:09 -0500 + +binutils (2.9.5.0.22-2) unstable; urgency=high + + * Added getopt.h include that was omitted in the -taso patch + (closes: Bug#52380) + * Fixed table misalignment when calling objdump --info + (closes: Bug#51517) + * Added Debian changelog to binutils-doc (closes: Bug#52574) + + -- Christopher C. Chimelis Wed, 15 Dec 1999 19:14:05 -0500 + +binutils (2.9.5.0.22-1) unstable; urgency=high + + * New upstream version. + * More MIPS fixes. + * Added support for -taso linker flag for Alpha. + * Reapplied all previous patches. + + -- Christopher C. Chimelis Wed, 7 Dec 1999 01:08:51 -0600 + +binutils (2.9.5.0.19-1) unstable; urgency=high + + * New upstream version + * Fixes some MIPS problems + * Reapplied the ObjC patch (is this ever going to be fixed upstream) + since it's badly needed right now + + -- Christopher C. Chimelis Thu, 4 Nov 1999 15:00:35 -0400 + +binutils (2.9.5.0.16-3) unstable; urgency=low + + * Added support for mipsel-linux in binutils-multiarch + + -- Christopher C. Chimelis Thu, 4 Nov 1999 15:00:35 -0400 + +binutils (2.9.5.0.16-2) unstable; urgency=low + + * Added a replaces field in the control file to fix + previous file overwrite problems (closes: Bug#47518, Bug#47938) + * Verified manpages are up to date (closes: Bug#18483) + * Added m68k-rtems to targets in -multiarch in hopes + that it will actually work as advertised (closes: Bug#47468) + + -- Christopher C. Chimelis Mon, 25 Oct 1999 15:58:55 -0400 + +binutils (2.9.5.0.16-1) unstable; urgency=low + + * New upstream version. + * Massive bugfix upload on the Debian side: + * Fixes changelog problems between all of the binutils + debs (closes: Bug#47133, Bug#47208, Bug#47211) + * Fixes other overwrite problems (closes: Bug#46991, Bug#47024, Bug#46074) + * Multiarch should now make good diversions when + upgrading (closes: Bug#47359) + * Applied patch from Kevin Buhr to fix ld segfaults with + empty archives (closes: Bug#47019) + * Should have fixed info install problems by now + (closes: Bug#35935) + + -- Christopher C. Chimelis Fri, 15 Oct 1999 03:18:55 -0400 + +binutils (2.9.5.0.14-1) unstable; urgency=low + + * New upstream version. + * Thanks to Matthias Klose for the following: + * Separate documentation to binutils-doc package. + * debian/rules: + - Remove extra /usr/share/doc/binutils/changelog.gz file. + - Move bfd docs to binutils-dev package. + - Move upstream changelogs to binutils-doc package. + - Remove standard GNU info files left in /usr/share/info. + - Call dh_installdocs for all packages. + * debian/*{dirs,files}: Remove. Mention explicitely in debian/rules. + + -- Christopher C. Chimelis Wed, 6 Oct 1999 03:18:55 -0400 + +binutils (2.9.5.0.12-2) unstable; urgency=low + + * Applied patch from Matthias Klose to fix many issues including architecture detection. + * Rules file is now much prettier and easier to manage. + * Binutils is now built for i386 rather than i486 in the rules file (oops). + * Added diversion for readelf in binutils-multiarch. + + -- Christopher C. Chimelis Tue, 21 Sep 1999 03:39:08 -0400 + +binutils (2.9.5.0.12-1) unstable; urgency=low + + * Massive bugfix release. + * New upstream source (finally) (closes: Bug#44934) + * Fixes upstream bugs on many platforms. + * Gives powerpc a working binutils again. (closes: Bug#45052) + * Now provides .code16 support on i386 (please test) + * Manpage for objdump should now be complete (closes: Bug#27039) + * Put together manpages for gasp and the new binary readelf (closes: Bug#21918) + * Fixes nm core dump problem (closes: Bug#41999) + * Applied patches from Ben Collins to add sparc64 support (closes: Bug#44426) + * Update Standards version + * FHS compliance + + -- Christopher C. Chimelis Sat, 18 Sept 1999 01:21:05 -0400 + +binutils (2.9.5.0.12-0.2) experimental; urgency=low + + * Added Sparc/Sparc64 changes from Ben Collins (I really need a Sparc one of these days). + * Again, this should be the last experimental before a new release. + + -- Christopher C. Chimelis Fri, 17 Aug 1999 16:32:05 -0400 + +binutils (2.9.5.0.12-0.1) experimental; urgency=low + + * New upstream version. + * Should be the last experimental before a new release. + + -- Christopher C. Chimelis Thu, 9 Aug 1999 23:12:52 -0400 + +binutils (2.9.5.0.10-0.1) experimental; urgency=low + + * New upstream version. + * Didn't apply PPC patches...let me know if still needed + + -- Christopher C. Chimelis Thu, 9 Aug 1999 23:12:52 -0400 + +binutils (2.9.5.0.6-0.1) experimental; urgency=low + + * New upstream version. + * Didn't apply PPC patches...let me know if still needed + + -- Christopher C. Chimelis Thu, 9 Aug 1999 23:12:52 -0400 + +binutils (2.9.4.0.8-0.1) unstable; urgency=low + + * New upstream version. + * Applied as much of the PPC patches as I could. + + -- Christopher C. Chimelis Thu, 15 Jul 1999 12:46:45 -0400 + +binutils (2.9.4.0.3-0.1) unstable; urgency=low + + * New upstream version. + * Apply patch from Richard Henderson to fix PPC's libpath. + * Apply patch from Franz Sirl to fix Richard Henderson. + + -- Daniel Jacobowitz Sun, 6 Jun 1999 01:27:10 -0400 + +binutils (2.9.4.0.2-0.1) unstable; urgency=low + + * New upstream version. 2.9.4.0.1 was hurriedly recalled. + + -- Daniel Jacobowitz Sun, 6 Jun 1999 01:27:10 -0400 + +binutils (2.9.4.0.1-0.1) unstable; urgency=low + + * New upstream version. + + -- Daniel Jacobowitz Sun, 6 Jun 1999 01:27:10 -0400 + +binutils (2.9.1.0.25-2) unstable; urgency=low + + * Added ObjC patch AGAIN...sorry about that + + -- Christopher C. Chimelis Sun, 23 May 1999 15:14:35 -0400 + +binutils (2.9.1.0.25-1) unstable; urgency=low + + * New upstream version - Fixes a PIII asm optimisation bug + + -- Christopher C. Chimelis Sun, 23 May 1999 00:36:55 -0400 + +binutils (2.9.1.0.24-2) unstable; urgency=low + + * Reapplied ObjC patch...apparently it's still needed. + + -- Christopher C. Chimelis Mon, 10 May 1999 19:53:15 -0400 + +binutils (2.9.1.0.24-1) unstable; urgency=low + + * New upstream release - fixes too many little things to mention. + + -- Christopher C. Chimelis Tue, 3 May 1999 16:35:08 -0400 + +binutils (2.9.1.0.23-1) unstable; urgency=low + + * New upstream release - incorporates sparc64 and arm patches. + * Added RPATH patch from Joel Klecker since my last upload failed. + * Removed ObjC patch. Let me know if it is still needed (doubtful, but + still might be). + + -- Christopher C. Chimelis Mon, 5 Apr 1999 13:26:55 -0500 + +binutils (2.9.1.0.22b-2) unstable; urgency=low + + * Added patch from Joel Klecker to finally (properly) fix the rpath issue + (Thanks, Joel!). + + -- Christopher C. Chimelis Fri, 2 Apr 1999 18:14:05 -0600 + +binutils (2.9.1.0.22b-1) unstable; urgency=low + + * Converted package to CVS (so bear with any delays in handling + bug fixes; I'm new to CVS ironically) + * New upstream version (sparc64 and ARM patches again added). + * Added support for mingw32 target in binutils-multiarch + + -- Christopher C. Chimelis Fri, 12 Mar 1999 03:51:44 -0600 + +binutils (2.9.1.0.19a-4) frozen unstable; urgency=high + * Added sparc64 patches from Steve Dunham to fix sparc64 targets + * Modified rules to add support for gcc/egcs by arch. + + -- Christopher C. Chimelis Mon, 1 Feb 1999 15:51:19 -0600 + +binutils (2.9.1.0.19a-3) frozen unstable; urgency=high + + * Reverted a patch to elflink.h that caused problems for + Obj-C code (symbols weren't exported with a size or + type). + + -- Christopher C. Chimelis Thu, 21 Jan 1999 19:25:17 -0600 + +binutils (2.9.1.0.19a-2) frozen unstable; urgency=low + + * Added arm-linux as multiarch target (sorry Jim). + * Uploaded to frozen to fix strange intermittant kernel + compilation problems (Fixes #31434). + * Fixed multiarch's postinst script to check for + c++filt.single before trying to remove it to prevent + warning messages if using g++ from egcs. + * Fixed typo in multiarch's postrm (addr2line) (Fixes: #31533) + * Added links to .so's for clean removal in the future (Fixes: #31536) + + -- Christopher C. Chimelis Fri, 8 Jan 1999 15:28:32 -0600 + +binutils (2.9.1.0.19a-1) unstable; urgency=low + + * New upstream version; fixes some Alpha problems and other archs + should benefit also. + * Added ARM target patch from Corel again (still not in upstream). + + -- Christopher C. Chimelis Mon, 4 Jan 1999 20:24:36 -0600 + +binutils (2.9.1.0.16-1) unstable; urgency=low + + * New upstream version; merges some ARM patches for Netwinders + * Added patch for ARM target from Corel (thanks Jim Pick) + + -- Christopher C. Chimelis Mon, 30 Nov 1998 16:59:25 -0600 + +binutils (2.9.1.0.15-5) frozen unstable; urgency=low + + * Reuploaded to frozen (why it wasn't there earlier....) + + -- Christopher C. Chimelis Mon, 30 Nov 1998 16:37:08 -0600 + +binutils (2.9.1.0.15-4) unstable frozen; urgency=low + + * Removed c++filt diversion in -multiarch to prevent conflicting + diversions when using egcs' g++ (which also wants to divert c++filt) + + -- Christopher C. Chimelis Wed, 25 Nov 1998 18:06:17 -0600 + +binutils (2.9.1.0.15-3) unstable frozen; urgency=low + + * Made Roman's changes "official" (thanks Roman). + + -- Christopher C. Chimelis Mon, 2 Nov 1998 05:46:56 -0600 + +binutils (2.9.1.0.15-2.1) unstable; urgency=low + + * Non-maintainer upload with agreement from Chris. + * Use a different soname for multi-arch libbfd and libopcodes; this + fixes the problem that the single-arch binaries (as and the diverted + ones) will all dump core because they're runtime-linked against the + multi-arch libs. (Fixes: #28656) + * Due to the above, binutils-multiarch also needs ldconfig in postinst + now. + * Fixup diversions once again: Do not even package the ldscripts for the + native architecture, so diversions for files in /usr/lib/ldscripts + aren't necessary. + * Also remove diversions on abort-install. + * Remove now obsolete diversions in preinst. + * Also symlink /usr/doc/binutils-multiarch to binutils, and do not + put /usr/doc/binutils in the package again. + * Put the symlinks libbfd.so and libopcode.so into binutils-dev, so one + can link to them. + + -- Roman Hodek Sat, 31 Oct 1998 11:31:14 +0100 + +binutils (2.9.1.0.15-2) unstable; urgency=low + + * Fixed binutils-multiarch diversions + * Reverted elf.c to .13 version to fix bug in strip + + -- Christopher C. Chimelis Tue, 27 Oct 1998 05:26:28 -0600 + +binutils (2.9.1.0.15-1) unstable; urgency=low + + * New upstream version. + * Moved over to debhelper and updated standards version to 2.4.1.4. + * Adds 3DNow instruction support for AMD processors. + * Fixes MANY Alpha bugs and a few for Sparc, PPC, and m68k reportedly. + * Added binutils-multiarch package to allow for multiple-arch support + (fixes bug #19471). + + -- Christopher C. Chimelis Thu, 14 Oct 1998 19:30:10 -0500 + +binutils (2.9.1.0.13-1) unstable; urgency=low + + * New upstream version, fixes bug #25354. + * Hopefully, all requested docs are included, fixes bug #21325. + * Fixes MANY Alpha problems. + * Reportedly may fix MIPS and Sparc problems also...see changelogs. + * Has been tested on x86's with great success. + + -- Christopher C. Chimelis Mon, 5 Oct 1998 23:02:08 -0500 + +binutils (2.9.1-0.2) frozen unstable; urgency=low + + * Fixed binutils-dev dependencies. + + -- Joel Klecker Tue, 05 May 1998 09:24:04 -0700 + +binutils (2.9.1-0.1) frozen unstable; urgency=medium + + * Non-maintainer release. + * New upstream release. + * Moved docs into subdirs where appropriate. + * Integrated the following changes from J.H.M. Dassen: + * Updated FSF address in copyright file. (lintian). + * Reported lack of "gasp" manpage (# ....), and link it to + undocumented(7). (lintian). + * Added a TODO list. + + -- Joel Klecker Thu, 30 Apr 1998 10:43:42 -0700 + +binutils (2.9-0.3) frozen unstable; urgency=medium + + * Added upstream patch which fixes a problem with strip + and netscape (#17971). + + -- Joel Klecker Tue, 28 Apr 1998 08:58:27 -0700 + +binutils (2.9-0.2) frozen unstable; urgency=low + + * Added more of the upstream docs (#21325). + * Put a changelog.gz symlink in /usr/doc/binutils + to satisfy policy. + + -- Joel Klecker Tue, 21 Apr 1998 09:02:22 -0700 + +binutils (2.9-0.1) frozen unstable; urgency=low + + * Non-maintainer release. + * New upstream release (bugfixes only). + + -- Joel Klecker Sun, 12 Apr 1998 04:11:07 -0700 + +binutils (2.8.1.0.23-1) unstable; urgency=low + + * New upstream version + * -dev replaces libc5-dev (#17840) + * No longer possible to link against shared libbbfd/opcodes (#18121) + + -- Galen Hazelwood Sat, 14 Mar 1998 18:19:10 -0700 + +binutils (2.8.1.0.19-1) unstable; urgency=low + + * New upstream version (#17296) + * Fixed typo in description (#16481) + * Fully replaces libbfd-dev (#16619) + + -- Galen Hazelwood Sun, 25 Jan 1998 15:37:03 -0700 + +binutils (2.8.1.0.17-1) unstable; urgency=low + + * New upstream version + * Rejoined libbfd and binutils packages (#15486) + * Added "SHELL=bash" to rules file (#14528) + * bfd info docs seem to be broken, don't install for now + + -- Galen Hazelwood Sat, 6 Dec 1997 14:55:26 -0700 + +binutils (2.8.1.0.15-1) unstable; urgency=low + + * New upstream version (#14250) + * Updated to Standard 2.3.0.0 + * Restored ansidecl.h to libbfd-dev (#14116) + + -- Galen Hazelwood Thu, 30 Oct 1997 20:04:24 -0700 + +binutils (2.8.1-2) unstable; urgency=low + + * Added 2.8.1.0.4 patch + + -- Galen Hazelwood Thu, 12 Jun 1997 20:49:57 -0600 + +binutils (2.8.1-1) unstable; urgency=low + + * New upstream version + * Added 2.8.1.0.1 patch + + -- Galen Hazelwood Fri, 30 May 1997 14:48:42 -0600 + +binutils (2.8-1) unstable; urgency=low + + * New upstream version + * Smarter debian build environment (automatic version handling) + * Added 2.8.0.3 patch + * Built with libc6 + + -- Galen Hazelwood Sun, 4 May 1997 11:16:12 -0600 + +binutils (2.7.0.9-3) frozen unstable; urgency=low + + * Patched for alpha support + * Distribute libiberty.a with -dev package (#8376) + * libbfd[x]-dev now has standard Provides/Conflicts behavior (#8377) + + -- Galen Hazelwood Fri, 28 Mar 1997 11:45:58 -0700 + +binutils (2.7.0.9-2) unstable; urgency=low + + * Moved 2.7.0.9 out of experimental (no longer unreleased beta) + + -- Galen Hazelwood Sun, 9 Mar 1997 23:43:19 -0700 + +binutils (2.7.0.9-1) experimental; urgency=low + + * New upstream beta version (fixes bug #7336) + * Split shared libraries (bfd) out of binutils (fixes bug #7244) + * No longer builds aout-binutils + + -- Galen Hazelwood Thu, 13 Feb 1997 00:27:18 -0700 + +binutils (2.7-6) unstable; urgency=low + + * Uses dpkg --print-gnu-build-architecture for build + * Demoted aout-binutils to priority "extra" + + -- Galen Hazelwood Mon, 27 Jan 1997 13:34:08 -0700 + +binutils (2.7-5) unstable; urgency=low (HIGH for m68k) + + * Added patch for m68k, will now compile X68 and kernel 2.1.15 + + -- Galen Hazelwood Tue, 31 Dec 1996 22:15:03 -0700 + +binutils (2.7-4) unstable; urgency=low + + * New maintainer + * Updated to new source format + * Fixed typo in script.1 (Fixes bug #4558) + * Fixed typo in as.1 (Fixes bug #5567) + * Postinst now calls ldconfig without explicit pathname (Fixes bug #6151) + + -- Galen Hazelwood Mon, 30 Dec 1996 12:10:25 -0700 + +binutils (2.7-3): + +Remove lib*.so links so the libs are not used for develpment. +gzip manpages + +Changes made by Michael Meskes in consent with David Engel. + +binutils (2.7-2): + +Include shared libraries +Strip shared libraries +Also update AOUT version +Minor changes to debian.rules + +binutils (2.7-1): + +Updated to new upstream version. + +Added a simple extended description (Bug#3574). + +Don't call ldconfig from postrm script (Bug#4246). + + LocalWords: Aurelien Jarno + --- binutils-2.22.orig/debian/binutils-multiarch.prerm.in +++ binutils-2.22/debian/binutils-multiarch.prerm.in @@ -0,0 +1,66 @@ +#! /bin/sh +# Remove obsolete diversions. +# +# They are already removed in postinst, but if configuration fails, +# they will still be around. Removing the package without +# configuring would then allow the diversions to leak. +# +# So we catch them here. This cannot wait for postrm because that +# would break error recovery during upgrades: after the old, working +# version re-adds the diversion in preinst, the diversion would be removed +# again in postrm. More generally, removing a diversion requires +# a guarantee that the conflicting file is not present any more, +# and we cannot guarantee that if some other version of +# binutils-multiarch is installed. +set -e +this_ver=@DEB_VER@; # this version +context=$1; # action: upgrade, remove, deconfigure, or failed-upgrade. +if + test "$context" = failed-upgrade && + dpkg --compare-versions "$this_ver" lt "$2" +then + # prerm of the future failed. + # Who knows what it was supposed to do? Abort. + exit 1 +fi + +old_diversion() { + local divertto file + file=$1 + divertto=${2-$file.single} + if + dpkg-divert --package binutils-multiarch --list | + grep -q -F "$divertto" + then + dpkg-divert --package binutils-multiarch \ + --remove --rename \ + --divert "$divertto" "$file" + fi +} + +# remove obsolete diversions +old_diversion /usr/bin/ld.bfd +old_diversion /usr/bin/c++filt +old_diversion /usr/lib/libbfd.a /usr/lib/libbfd-single.a +old_diversion /usr/lib/libopcodes.a /usr/lib/libopcodes-single.a +old_diversion /usr/bin/ld +old_diversion /usr/bin/elfedit +for f in elf32_sparc elf32ppc elf64alpha elf_i386 m68kelf \ + alpha i386linux m68klinux sparclinux sun4 +do + for ext in x xbn xn xr xs xu + do + old_diversion /usr/lib/ldscripts/$f.$ext + done +done +old_diversion /usr/lib/libbfd-2.9.1.0.15.so.0.0.0 \ + /usr/lib/libbfd-single-2.9.1.0.15.so.0.0.0 +old_diversion /usr/lib/libopcodes-2.9.1.0.15.so.0.0.0 \ + /usr/lib/libopcodes-single-2.9.1.0.15.so.0.0.0 +old_diversion /usr/lib/libbfd.la /usr/lib/libbfd-single.la +old_diversion /usr/lib/libopcodes.la /usr/lib/libopcodes-single.la +old_diversion /usr/include/bfd.h /usr/include/bfd.single.h +old_diversion /usr/lib/ldscripts + +rm -f /usr/lib/libbfd-*-multiarch.so.0 +rm -f /usr/lib/libopcodes-*-multiarch.so.0 --- binutils-2.22.orig/debian/binutils-static-udeb.overrides +++ binutils-2.22/debian/binutils-static-udeb.overrides @@ -0,0 +1,2 @@ +# yes, it's embedded +binutils-static-udeb udeb: embedded-zlib --- binutils-2.22.orig/debian/rules +++ binutils-2.22/debian/rules @@ -0,0 +1,1320 @@ +#!/usr/bin/make -f +# debian/rules file - for binutils (2.20) +# Based on sample debian/rules file - for GNU Hello (1.3). +# Copyright 1994,1995 by Ian Jackson. +# Copyright 1998-2007 James Troup. +# Portions Copyright 2008-2009 Canonical Ltd. +# Portions Copyright 2008-2009 Matthias Klose. +# I hereby give you perpetual unlimited permission to copy, +# modify and relicense this file, provided that you do not remove +# my name from the file itself. (I assert my moral right of +# paternity under the Copyright, Designs and Patents Act 1988.) +# This file may have to be extensively modified + +################################################################################ + +p_bin = binutils +p_dev = $(p_bin)-dev +p_mul = $(p_bin)-multiarch +p_gold = $(p_bin)-gold +p_doc = $(p_bin)-doc +p_hppa64 = $(p_bin)-hppa64 +p_spu = $(p_bin)-spu +p_src = $(p_bin)-source +p_static = $(p_bin)-static +p_udeb = $(p_static)-udeb + +# BACKPORT is used for cross builds for a -source package not conflicting +# with the source package of the native package. +ifeq ($(BACKPORT),true) + p_src = $(p_bin)-$(VERSION)-source +else + p_src = $(p_bin)-source +endif + +pwd := $(shell pwd) +d = debian/tmp +d_bin = $(d) +d_dev = debian/$(p_dev) +d_mul = debian/$(p_mul) +d_gold = debian/$(p_gold) +d_doc = debian/$(p_doc) +d_hppa64 = debian/$(p_hppa64) +d_spu = debian/$(p_spu) +d_src = debian/$(p_src) +d_static = debian/$(p_static) +d_udeb = debian/$(p_udeb) + +install_dir = install -d -m 755 +install_file = install -m 644 +install_script = install -m 755 +install_binary = install -m 755 -s + +vafilt = $(subst $(2)=,,$(filter $(2)=%,$(1))) +DPKG_VARS := $(shell dpkg-architecture) +DEB_BUILD_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_GNU_TYPE) +DEB_HOST_ARCH ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH) +DEB_HOST_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_GNU_TYPE) +DEB_HOST_MULTIARCH ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_MULTIARCH) + +ifeq (,$(DEB_HOST_MULTIARCH)) + ifeq ($(DEB_HOST_ARCH),i386) + DEB_HOST_MULTIARCH = i386-linux-gnu + else + DEB_HOST_MULTIARCH = $(DEB_HOST_GNU_TYPE) + endif +endif + +SHELL = /bin/bash + +ifneq (,$(filter $(DEB_HOST_ARCH), amd64 armel armhf i386 powerpc powerpcspe ppc64 sparc sparc64)) + with_gold = yes +endif + +with_multiarch := yes +with_static := yes + +CC = gcc +CXX = g++ +CFLAGS = -g -O2 -Wno-format-security +STRIP = strip --remove-section=.comment --remove-section=.note +CROSS := +ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) + CROSS := $(DEB_HOST_GNU_TYPE)- + CC = $(CROSS)gcc + CXX = $(CROSS)g++ + STRIP= $(CROSS)strip --remove-section=.comment --remove-section=.note + install_binary = install -m 755 -s --strip-program="$(STRIP)" +endif + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS = -g -O0 +endif + +# this outputs 0 or 1 depending on whether a macro appears in the *default* cpp +# -dM -P output; this is used to test the toolchain *default* configuration +check_cpp = $(shell $(CROSS)cpp -dM -P /dev/null | grep -q '^\#define $(1)' && echo 1 || echo 0) + +# testsuite doesn't expect to be built with -mthumb +# TODO if the testsuite is only broken with Thumb-2 (and not with "Thumb-1"), +# we should test for __thumb2__ instead +ifneq (,$(filter $(DEB_HOST_ARCH), armel armhf)) + ifeq ($(call check_cpp,__thumb__),1) + CFLAGS += -marm + endif +endif + +# see LP: #446478, would only fix the testcases +#ifneq (,$(filter $(DEB_HOST_ARCH), armel armhf)) +# CFLAGS += -fno-section-anchors +#endif + +SPACE = $(EMPTY) $(EMPTY) +COMMA = , +CHANGELOG_VARS := $(shell dpkg-parsechangelog | \ + sed -n 's/ /_/g;/^[^_]/s/^\([^:]*\):_\(.*\)/\1=\2/p') + +DEB_VERSION := $(call vafilt,$(CHANGELOG_VARS),Version) +DEB_SVERSION := $(shell echo $(DEB_VERSION) | sed 's/+b[0-9][0-9]*$$//') +DEB_UPSTREAM := $(firstword $(subst -,$(SPACE),$(DEB_VERSION))) + +VERSION := $(shell sed -n 's/^ *VERSION=\(.*\)/\1/p' bfd/configure | head -1) +#DATE := $(shell sed -n 's/.* \([0-9]*\)$$/\1/p' bfd/version.h) +ifneq (,$(DATE)) + DATE_EXT := .$(DATE) +endif + +ifneq ($(DEB_UPSTREAM),$(VERSION)$(DATE_EXT)) + $(error upstream ($(DEB_UPSTREAM)) and debian ($(VERSION)$(DATE_EXT)) version mismatch) +endif + +STATIC_UDEB = $(p_udeb)_$(DEB_VERSION)_$(DEB_HOST_ARCH).udeb + +SINGLE_VERSION= $(VERSION)-system +MULTI_VERSION = $(VERSION)-multiarch +HPPA64_VERSION= $(VERSION)-hppa64 +SPU_VERSION = $(VERSION)-spu + +DISTRIBUTION := $(shell lsb_release -is) +NJOBS = +# Support parallel= in DEB_BUILD_OPTIONS (see #209008) +ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) + NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) +endif +ifneq (,$(findstring nogold,$(DEB_BUILD_OPTIONS))) + with_gold = disabled in DEB_BUILD_OPTIONS +endif +ifneq (,$(findstring nostat,$(DEB_BUILD_OPTIONS))) + with_static = disabled in DEB_BUILD_OPTIONS +endif +ifneq (,$(findstring nomult,$(DEB_BUILD_OPTIONS))) + with_multiarch = disabled in DEB_BUILD_OPTIONS +endif + +# If $(TARGET) is not set, try reading debian/target +ifeq (,$(TARGET)) + ifneq (,$(wildcard debian/target)) + TARGET := $(shell cat debian/target 2>/dev/null) + endif +endif + +# PF is the installation prefix for the package without the leading slash. +# It's "usr" for gcc releases, so use this if not explicitly set +ifeq ($(PF),) + PF = usr +endif + +######################################## + +CONFARGS = \ + --enable-shared \ + --enable-plugins \ + --prefix=/$(PF) \ + --build=$(DEB_BUILD_GNU_TYPE) \ + --host=$(DEB_HOST_GNU_TYPE) \ + --with-pkgversion="GNU Binutils for $(DISTRIBUTION)" + +ifeq ($(DEB_HOST_MULTIARCH),x86_64-linux-gnu) + DEB_HOST_MULTIARCH32 = i386-linux-gnu +else ifeq ($(DEB_HOST_MULTIARCH),powerpc64-linux-gnu) + DEB_HOST_MULTIARCH32 = powerpc-linux-gnu +else ifeq ($(DEB_HOST_MULTIARCH),s390x-linux-gnu) + DEB_HOST_MULTIARCH32 = s390-linux-gnu +else ifeq ($(DEB_HOST_MULTIARCH),sparc64-linux-gnu) + DEB_HOST_MULTIARCH32 = sparc-linux-gnu +else ifeq ($(DEB_HOST_MULTIARCH),x86_64-kfreebsd-gnu) + DEB_HOST_MULTIARCH32 = i386-kfreebsd-gnu +else ifeq ($(DEB_HOST_MULTIARCH),i386-linux-gnu) + DEB_HOST_MULTIARCH64 = x86_64-linux-gnu +else ifeq ($(DEB_HOST_MULTIARCH),powerpc-linux-gnu) + DEB_HOST_MULTIARCH64 = powerpc64-linux-gnu +else ifeq ($(DEB_HOST_MULTIARCH),sparc-linux-gnu) + DEB_HOST_MULTIARCH64 = sparc64-linux-gnu +else ifeq ($(DEB_HOST_MULTIARCH),s390-linux-gnu) + DEB_HOST_MULTIARCH64 = s390x-linux-gnu +else ifeq ($(DEB_HOST_MULTIARCH),i386-kfreebsd-gnu) + DEB_HOST_MULTIARCH64 = x86_64-linux-gnu +else ifeq ($(DEB_HOST_MULTIARCH),mips-linux-gnu) + DEB_HOST_MULTIARCH64 = mips64-linux-gnu +else ifeq ($(DEB_HOST_MULTIARCH),mipsel-linux-gnu) + DEB_HOST_MULTIARCH64 = mips64el-linux-gnu +endif +export DEB_HOST_MULTIARCH DEB_HOST_MULTIARCH32 DEB_HOST_MULTIARCH64 + +ifeq ($(DEB_HOST_ARCH),sparc) + CONFARGS += --enable-targets=sparc64-linux-gnu + CONFLICTS = -VextraConflicts="libc6-dev-sparc64 (<< 2.2.5-7)" +endif +ifeq ($(DEB_HOST_ARCH),sparc64) + CONFARGS += --enable-targets=sparc-linux-gnu + CONFLICTS = -VextraConflicts="libc6-dev-sparc64 (<< 2.2.5-7)" +endif +ifeq ($(DEB_HOST_ARCH),powerpc) + CONFARGS += --enable-targets=powerpc64-linux-gnu,spu +endif +ifeq ($(DEB_HOST_ARCH),ppc64) + CONFARGS += --enable-targets=powerpc-linux-gnu,spu +endif +ifeq ($(DEB_HOST_ARCH),s390) + CONFARGS += --enable-targets=s390x-linux-gnu +endif +ifeq ($(DEB_HOST_ARCH),s390x) + CONFARGS += --enable-targets=s390-linux-gnu +endif +ifeq ($(DEB_HOST_ARCH),i386) + CONFARGS += --enable-targets=x86_64-linux-gnu +endif +ifeq ($(DEB_HOST_ARCH),kfreebsd-i386) + CONFARGS += --enable-targets=x86_64-kfreebsd-gnu +endif +ifeq ($(DEB_HOST_ARCH),mips) + CONFARGS += --enable-targets=mips64-linux-gnu +endif +ifeq ($(DEB_HOST_ARCH),mipsel) + CONFARGS += --enable-targets=mips64el-linux-gnu +endif +ifneq (,$(filter $(DEB_HOST_ARCH),armhf i386 ia64 sparc sparc64)) + CONFARGS += --disable-werror +endif +CONFARGS += --disable-werror + +with_check := yes +ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) + with_check := disabled through DEB_BUILD_OPTIONS +endif +ifneq (,$(filter $(DEB_HOST_ARCH), armel armhf mips mipsel sparc)) + ignore_regressions := regressions ignored on architecture $(DEB_HOST_ARCH) +endif +ignore_regressions := regressions ignored on architecture $(DEB_HOST_ARCH) + +with_strip := yes +ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + with_strip := disabled through DEB_BUILD_OPTIONS +endif + +source_files = $(addprefix $(shell basename $(pwd))/, \ + $(filter-out %-stamp .pc CVS debian builddir-% test-summary, $(wildcard *))) + +################################################################################ + +################# +# patch targets # +################# + +patch: patch-stamp +patch-stamp: +ifneq ($(PATCHED_SOURCES),yes) + QUILT_PATCHES=$(CURDIR)/debian/patches \ + quilt --quiltrc /dev/null push -a || test $$? = 2 +endif + touch $@ + +unpatch: + QUILT_PATCHES=$(CURDIR)/debian/patches \ + quilt --quiltrc /dev/null pop -a -R || test $$? = 2 + rm -rf .pc + +update-patches: + export QUILT_PATCHES=$(CURDIR)/debian/patches; \ + export QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab"; \ + export QUILT_DIFF_ARGS="--no-timestamps --no-index -pab"; \ + while quilt push; do quilt refresh; done + +################################################################################ + +################ +# clean target # +################ + +clean: unpatch + $(checkdir) + -rm -fr builddir-multi builddir-single builddir-hppa64 builddir-spu builddir-gold + -find . -name \*.gmo -o -name \*~ -o -name \*.info ! -name sysroff.info | xargs rm -f + -rm -f $(pwd)/test-summary* + -rm -fr $(d_bin) $(d_dev) $(d_mul) $(d_doc) $(d_hppa64) $(d_src) $(d_spu) $(d_gold) + -rm -fr builddir-static + -rm -fr $(d_static) $(d_udeb) + -rm -rf debian/patched debian/tmp debian/files* debian/substvars + -rm -f debian/*.orig debian/*.rej + -rm -rf $(d_cross) debian/files debian/substvars + -rm -rf builddir-$(TARGET) {configure,build,install}-cross-stamp + for i in debian/*.in; do \ + case "$$i" in debian/control*.in) continue; esac; \ + rm -f $${i%*.in}; \ + done + + -rm -f *-stamp + +################################################################################ + +####################### +# single-arch targets # +####################### + +SINGLE_CONFARGS = $(CONFARGS) +ifeq ($(with_gold),yes) + SINGLE_CONFARGS += --enable-ld=default --enable-gold +endif + +configure-single-stamp: patch-stamp + $(checkdir) + +ifeq ($(with_check),yes) + @if echo "spawn true" | /usr/bin/expect -f - >/dev/null; then \ + : ; \ + else \ + echo "expect is failing on your system with the above error, which means the"; \ + echo "testsuite will fail. Please resolve the above issues and retry the build."; \ + echo "-----------------------------------------------------------------------------"; \ + exit 1; \ + fi +endif + + rm -rf configure-single-stamp \ + builddir-single + mkdir builddir-single + cd builddir-single && env CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" \ + ../configure --with-sysroot=/ $(SINGLE_CONFARGS) + $(MAKE) -C builddir-single configure-host + touch configure-single-stamp + +build-single-stamp: configure-single-stamp + $(checkdir) + env MAKE="$(MAKE) VERSION=$(SINGLE_VERSION)" \ + $(MAKE) -C builddir-single/bfd headers + env MAKE="$(MAKE) VERSION=$(SINGLE_VERSION)" \ + $(MAKE) $(NJOBS) -C builddir-single +ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) +ifeq ($(with_check),yes) + -env MAKE="$(MAKE) VERSION=$(SINGLE_VERSION)" \ + $(MAKE) -C builddir-single -k check + cat builddir-single/binutils/binutils.sum \ + builddir-single/gas/testsuite/gas.sum \ + builddir-single/ld/ld.sum >> $(pwd)/test-summary + set -e; \ + if [ ! -f /usr/share/doc/binutils/test-summary.gz ]; then \ + echo "No test results available for the installed binutils version"; \ + elif [ -x /usr/bin/python ]; then \ + echo "Test results, compared with installed binutils:"; \ + zcat /usr/share/doc/binutils/test-summary.gz > test-summary-installed; \ + if python debian/test-suite-compare.py test-summary-installed test-summary; then \ + : ; \ + elif [ -n "$(ignore_regressions)" ]; then \ + echo "$(ignore_regressions)"; \ + else \ + case "$(DEB_HOST_ARCH)" in \ + powerpc) \ + echo "WARNING: ignoring test results";; \ + *) \ + false;; \ + esac; \ + fi; \ + else \ + echo "python not installed, not comparing test results."; \ + fi +endif +endif + touch build-single-stamp + + +################################################################################ + +##################### +# multiarch targets # +##################### + +# strictly speaking this is incorrect as the first column of this file should +# be ignored, but it's not obvious how to compute a proper list of triplets +# which Debian cares about since this table only lists official ports and the +# other tables combined give too many ports and generate triplets which break +# the binutils build; also, it's not possible to use --enable-targets=all +# either; see: +# http://lists.debian.org/debian-dpkg/2011/02/msg00085.html +multiarch_targets := $(shell sed -n 's/^\([^[:space:]\#]\+\).*/\1/p' /usr/share/dpkg/archtable) + +# some extra targets which were present in earlier versions of the +# multiarch_targets list; would be good to find out who needs them for what +multiarch_targets += \ + i686-linux-gnu \ + m32r-linux-gnu \ + m68k-linux-gnu \ + m68k-rtems \ + mips64el-linux-gnu \ + mips64-linux-gnu \ + powerpc64-linux-gnu \ + s390x-linux-gnu \ + sh64-linux-gnu \ + sh-linux-gnu \ + sparc64-linux-gnu \ + spu \ + +configure-multi-stamp: patch-stamp + $(checkdir) + rm -rf configure-multi-stamp \ + builddir-multi + mkdir builddir-multi + cd builddir-multi \ + && env CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" ../configure $(CONFARGS) \ + --with-sysroot=/ \ + --disable-werror \ + --enable-targets=$(subst $(SPACE),$(COMMA),$(multiarch_targets)) + $(MAKE) -C builddir-multi configure-host + touch configure-multi-stamp + +build-multi-stamp: configure-multi-stamp + $(checkdir) + $(MAKE) -C builddir-multi/bfd headers + env MAKE="$(MAKE) VERSION=$(MULTI_VERSION)" \ + $(MAKE) $(NJOBS) -C builddir-multi + touch build-multi-stamp + +################################################################################ + +################# +# static target # +################# + +configure-static-stamp: patch-stamp + $(checkdir) + rm -rf configure-static-stamp \ + builddir-static + mkdir builddir-static + cd builddir-static \ + && env CC="$(CC)" CXX="$(CXX)" CFLAGS="-g0 -Os" ../configure \ + --prefix=/$(PF) \ + --build=$(DEB_BUILD_GNU_TYPE) \ + --host=$(DEB_HOST_GNU_TYPE) \ + --with-pkgversion="GNU Binutils for $(DISTRIBUTION)" + $(MAKE) -C builddir-static configure-bfd + $(MAKE) -C builddir-static configure-ld + touch configure-static-stamp + +build-static-stamp: configure-static-stamp + $(checkdir) + $(MAKE) $(NJOBS) -C builddir-static/libiberty CCLD='$(CC) -all-static' + $(MAKE) $(NJOBS) -C builddir-static/bfd CCLD='$(CC) -all-static' + $(MAKE) $(NJOBS) -C builddir-static/ld CCLD='$(CC) -all-static' + touch build-static-stamp + +################################################################################ + +################# +# hppa64 target # +################# + +configure-hppa64-stamp: patch-stamp + $(checkdir) + rm -rf configure-hppa64-stamp \ + builddir-hppa64 + mkdir builddir-hppa64 + cd builddir-hppa64 \ + && env CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" ../configure \ + --enable-shared \ + --prefix=/$(PF) \ + --build=$(DEB_BUILD_GNU_TYPE) \ + --host=$(DEB_HOST_GNU_TYPE) \ + --target=hppa64-linux-gnu + $(MAKE) -C builddir-hppa64 configure-host + touch configure-hppa64-stamp + +build-hppa64-stamp: configure-hppa64-stamp + $(checkdir) + $(MAKE) -C builddir-hppa64/bfd headers + env MAKE="$(MAKE) VERSION=$(HPPA64_VERSION)" \ + $(MAKE) $(NJOBS) -C builddir-hppa64 + touch build-hppa64-stamp + +################################################################################ + +############## +# spu target # +############## + +configure-spu-stamp: patch-stamp + $(checkdir) + rm -rf configure-spu-stamp \ + builddir-spu + mkdir builddir-spu + cd builddir-spu \ + && env CC="$(CC)" CFLAGS="$(CFLAGS)" ../configure \ + --enable-shared \ + --prefix=/$(PF) \ + --program-prefix=spu- \ + --build=$(DEB_BUILD_GNU_TYPE) \ + --host=$(DEB_BUILD_GNU_TYPE) \ + --target=spu-elf + $(MAKE) -C builddir-spu configure-host + touch configure-spu-stamp + +build-spu-stamp: configure-spu-stamp + $(checkdir) + $(MAKE) -C builddir-spu/bfd headers + env MAKE="$(MAKE) VERSION=$(SPU_VERSION)" \ + $(MAKE) $(NJOBS) -C builddir-spu + touch build-spu-stamp + +################################################################################ + +pre-build: +#ifneq (,$(filter $(DEB_HOST_ARCH), amd64)) +# @echo Build it ... +#else +# @echo Explicitely fail the build for architecture $(DEB_HOST_ARCH) +# false +#endif + +build_stamps = build-single-stamp +ifeq ($(with_multiarch),yes) + build_stamps += build-multi-stamp +endif +ifeq ($(DEB_HOST_ARCH),hppa) + build_stamps += build-hppa64-stamp +endif +ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64)) + build_stamps += build-spu-stamp +endif +ifneq (,$(TARGET)) + ifneq (,$(findstring static-cross,$(DEB_BUILD_OPTIONS))) + build_stamps = build-static-cross-stamp + else + build_stamps = build-cross-stamp + endif +endif + +ifeq ($(BACKPORT),true) + build_stamps := + with_check := no +endif + +build: pre-build build-stamp +build-arch: pre-build build-stamp +build-indep: pre-build build-stamp +build-stamp: $(build_stamps) + touch build-stamp + +################################################################################ + +################## +# install target # +################## + +install_stamps = install-stamp +ifeq ($(DEB_HOST_ARCH),hppa) + install_stamps += install-hppa64-stamp +endif +ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64)) + install_stamps += install-spu-stamp +endif +ifeq ($(with_static),yes) + install_stamps += install-static-stamp +endif +ifneq (,$(TARGET)) + ifneq (,$(findstring static-cross,$(DEB_BUILD_OPTIONS))) + install_stamps = install-static-cross-stamp + else + install_stamps = install-cross-stamp + endif +endif +ifeq ($(BACKPORT),true) + install_stamps := +endif +install: $(install_stamps) +install-stamp: checkroot build-stamp + $(checkdir) + + rm -fr $(d_bin) $(d_dev) $(d_mul) $(d_doc) $(d_src) + $(install_dir) $(d_bin) $(d_dev) $(d_mul) $(d_doc) $(d_src) + + : # install binutils and -dev stuff + env MAKE="$(MAKE) VERSION=$(SINGLE_VERSION)" \ + $(MAKE) -C builddir-single \ + CFLAGS="$(CFLAGS)" prefix=$(pwd)/$(d_bin)/$(PF) \ + mandir=$(pwd)/$(d_bin)/$(PF)/share/man \ + infodir=$(pwd)/$(d_doc)/$(PF)/share/info install + +ifeq ($(with_multiarch),yes) + : # now install binutils-multiarch stuff + env MAKE="$(MAKE) VERSION=$(MULTI_VERSION)" \ + $(MAKE) -C builddir-multi \ + CFLAGS="$(CFLAGS)" \ + prefix=$(pwd)/$(d_mul)/$(PF) \ + mandir=$(pwd)/$(d_mul)/$(PF)/share/man \ + infodir=$(pwd)/$(d_doc)/$(PF)/share/info install +endif + + : # copy libiberty.h ... not too keen on this, but it was requested + cp -f include/libiberty.h $(d_bin)/$(PF)/include + + : # copy demangle.h ... not too keen on this, but it was requested + cp -f include/demangle.h $(d_bin)/$(PF)/include + + : # copy plugin-api.h ... + cp -f include/plugin-api.h $(d_bin)/$(PF)/include + + : # We don't need to distribute everything in binutils and -dev + rm -rf $(d_bin)/$(PF)/include/obstack.h + rm -f $(d_bin)/$(PF)/man/man1/configure.1 + rm -f $(d_doc)/$(PF)/share/info/configure.* $(d_doc)/$(PF)/share/info/standards.* + : # *sigh*, bugs.debian.org/213524 + rm -f $(d_doc)/$(PF)/share/info/dir* + +ifeq ($(with_multiarch),yes) + : # Now get rid of just about everything in binutils-multiarch + rm -rf $(d_mul)/$(PF)/man $(d_mul)/$(PF)/info $(d_mul)/$(PF)/include + rm -rf $(d_mul)/$(PF)/share/man $(d_mul)/$(PF)/share/info $(d_mul)/$(PF)/share/locale + + : # elfedit (even with its --input-mach option) + : # is the same for all targets. + rm -f $(d_mul)/$(PF)/bin/elfedit + + : # c++filt does not link to libbfd for anything more than + : # the help message, and its behavior does not vary + : # between arches aside from the --version message. + rm -f $(d_mul)/$(PF)/bin/c++filt + + : # As gas/README points out (search for --enable-targets), + : # multi-arch gas is not ready yet. + rm -f $(d_mul)/$(PF)/bin/as + rm -f $(d_mul)/$(PF)/bin/ld + rm -f $(d_mul)/$(PF)/bin/ld.bfd + rm -f $(d_mul)/$(PF)/bin/ld.gold + rm -fr $(d_mul)/$(PF)/lib/ldscripts + + ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64)) + rm -f $(d_mul)/$(PF)/bin/embedspu + endif +endif + + $(install_dir) $(d_dev)/$(PF)/include/ $(d_dev)/$(PF)/lib/ + mv $(d_bin)/$(PF)/include/* $(d_dev)/$(PF)/include/ + mv $(d_bin)/$(PF)/lib/*.a $(d_bin)/$(PF)/lib/libbfd.so $(d_bin)/$(PF)/lib/libopcodes.so \ + $(d_dev)/$(PF)/lib/ + +ifeq ($(with_multiarch),yes) + rm -f $(d_mul)/$(PF)/lib/libbfd.so $(d_mul)/$(PF)/lib/libopcodes.so + rm -f $(d_mul)/$(PF)/lib/*.la $(d_mul)/$(PF)/lib/*.a + rm -f $(d_mul)/$(PF)/lib*/libiberty* +endif + + : # Get rid of .la files since libtool obviously has no idea about transient paths + rm -f $(d_bin)/$(PF)/lib/*.la + +ifeq ($(with_strip),yes) + : # Strip shared libraries + pkg_create_dbgsym $(p_bin) $(d_bin) || true + $(STRIP) --strip-unneeded $(d_bin)/$(PF)/lib/libbfd-*so + $(STRIP) --strip-unneeded $(d_bin)/$(PF)/lib/libopcodes-*so + + chmod ugo-x $(d_bin)/$(PF)/lib/*.so + + $(STRIP) $$(file $(d_bin)/$(PF)/bin/* |awk -F: '$$0 !~ /script/ {print $$1}') + + ifeq ($(with_multiarch),yes) + pkg_create_dbgsym $(p_mul) $(d_mul) || true + $(STRIP) --strip-unneeded $(d_mul)/$(PF)/lib/libbfd-*so + $(STRIP) --strip-unneeded $(d_mul)/$(PF)/lib/libopcodes-*so + + chmod ugo-x $(d_mul)/$(PF)/lib/*.so + + $(STRIP) $$(file $(d_mul)/$(PF)/bin/* |awk -F: '$$0 !~ /script/ {print $$1}') + endif +endif + + : # Don't want /usr/-linux to exist in any package + rm -rf $(d_bin)/$(PF)/$(DEB_HOST_GNU_TYPE) + + : # Remove windres manpages + rm -f $(d_bin)/$(PF)/share/man/man1/windres.1 + +ifeq ($(with_multiarch),yes) + rm -rf $(d_mul)/$(PF)/$(DEB_HOST_GNU_TYPE) + rm -f $(d_mul)/$(PF)/share/man/man1/windres.1 +endif + + rm -f $(d_bin)/$(PF)/bin/ld + ln -s ld.bfd $(d_bin)/$(PF)/bin/ld +ifeq ($(with_gold),yes) + ln -s ld.gold $(d_bin)/$(PF)/bin/gold + mv $(d_bin)/$(PF)/share/man/man1/ld.1 \ + $(d_bin)/$(PF)/share/man/man1/ld.bfd.1 + ln -s ld.bfd.1.gz $(d_bin)/$(PF)/share/man/man1/ld.1.gz + ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) + if which help2man >/dev/null 2>&1; then \ + help2man -n 'The GNU ELF linker' $(d_bin)/$(PF)/bin/ld.gold \ + | sed 's,$(d_bin)/$(PF)/bin/,,g' > debian/ld.gold.1; \ + fi + endif + cp debian/ld.gold.1 $(d_bin)/$(PF)/share/man/man1/ + ln -s ld.gold.1.gz $(d_bin)/$(PF)/share/man/man1/gold.1.gz + + : # install a symlink for the gold linker + $(install_dir) $(d_bin)/$(PF)/lib/gold-ld + ln -s ../../bin/ld.gold $(d_bin)/$(PF)/lib/gold-ld/ld + + : # only keep the gold linker diversion to it's own package. + rm -fr $(d_gold) + $(install_dir) $(d_gold) + $(install_dir) $(d_gold)/$(PF)/bin + $(install_dir) $(d_gold)/$(PF)/share/man/man1 + ln -s ld.gold $(d_gold)/$(PF)/bin/ld + ln -s ld.gold.1.gz $(d_gold)/$(PF)/share/man/man1/ld.1.gz +endif + : # install a symlink for the old linker + $(install_dir) $(d_bin)/$(PF)/lib/compat-ld + ln -s ../../bin/ld.bfd $(d_bin)/$(PF)/lib/compat-ld/ld + + : # Remove empty directory + rmdir $(d_bin)/$(PF)/include/ + + : # install libiberty PIC library + $(install_file) builddir-single/libiberty/pic/libiberty.a \ + $(d_dev)/$(PF)/lib/libiberty_pic.a + + touch install-stamp + +install-hppa64-stamp: checkroot build-hppa64-stamp + $(checkdir) + + rm -fr $(d_hppa64) + $(install_dir) $(d_hppa64) + $(install_dir) $(d_hppa64)/$(PF)/lib + + : # install binutils-hppa64 stuff + env MAKE="$(MAKE) VERSION=$(HPPA64_VERSION)" \ + $(MAKE) -C builddir-hppa64 \ + CFLAGS="$(CFLAGS)" \ + prefix=$(pwd)/$(d_hppa64)/$(PF)/ \ + mandir=$(pwd)/$(d_hppa64)/$(PF)/share/man \ + infodir=$(pwd)/$(d_hppa64)/$(PF)/share/info install + + : # move shared libs to the standard path + mv $(d_hppa64)/$(PF)/$(DEB_HOST_GNU_TYPE)/hppa64-linux-gnu/lib/lib*-*.so \ + $(d_hppa64)/$(PF)/lib/. + + : # Now get rid of just about everything in binutils-hppa64 + rm -rf $(d_hppa64)/$(PF)/man + rm -rf $(d_hppa64)/$(PF)/info + rm -rf $(d_hppa64)/$(PF)/include + rm -rf $(d_hppa64)/$(PF)/share + rm -rf $(d_hppa64)/$(PF)/hppa-linux-gnu + rm -rf $(d_hppa64)/$(PF)/lib/libiberty.a + +ifeq ($(with_strip),yes) + : # Strip shared libraries + pkg_create_dbgsym $(p_hppa64) $(d_hppa64) || true + $(STRIP) --strip-unneeded $(d_hppa64)/$(PF)/lib/libbfd-*so + $(STRIP) --strip-unneeded $(d_hppa64)/$(PF)/lib/libopcodes-*so + $(STRIP) $$(file $(d_hppa64)/$(PF)/bin/* | awk -F: '$$0 !~ /script/ {print $$1}') +endif + + chmod ugo-x $(d_hppa64)/$(PF)/lib/*.so + + : # Don't want /usr/-linux to exist in any package + rm -rf $(d_hppa64)/$(PF)/hppa64-linux-gnu + + touch install-hppa64-stamp + +install-static-stamp: checkroot build-static-stamp + $(checkdir) + + rm -fr $(d_static) $(d_udeb) + $(install_dir) $(d_static) $(d_udeb) + + : # Copy static ld-new into /bin for both -static and -static-udeb + $(install_dir) $(d_static)/bin + $(install_binary) builddir-static/ld/ld-new $(d_static)/bin/ld_static + $(install_dir) $(d_udeb)/bin + $(install_binary) builddir-static/ld/ld-new $(d_udeb)/bin/ld_static +ifeq ($(with_strip),yes) + pkg_create_dbgsym $(p_static) $(d_static) || true + $(STRIP) --strip-unneeded $(d_static)/bin/ld_static $(d_udeb)/bin/ld_static +endif + + touch install-static-stamp + +install-spu-stamp: checkroot build-spu-stamp + $(checkdir) + + rm -fr $(d_spu) + $(install_dir) $(d_spu) + $(install_dir) $(d_spu)/$(PF)/lib + + : # install binutils-spu stuff + env MAKE="$(MAKE) VERSION=$(SPU_VERSION)" \ + $(MAKE) -C builddir-spu \ + CFLAGS="$(CFLAGS)" \ + prefix=$(pwd)/$(d_spu)/$(PF)/ \ + mandir=$(pwd)/$(d_spu)/$(PF)/share/man \ + infodir=$(pwd)/$(d_spu)/$(PF)/share/info install + + : # move shared libs to the standard path + mv $(d_spu)/$(PF)/$(DEB_HOST_GNU_TYPE)/spu-elf/lib/lib*-*.so \ + $(d_spu)/$(PF)/lib/. + + : # Now get rid of just about everything in binutils-spu + rm -rf $(d_spu)/$(PF)/man + rm -rf $(d_spu)/$(PF)/info + rm -rf $(d_spu)/$(PF)/include + rm -rf $(d_spu)/$(PF)/share + rm -rf $(d_spu)/$(PF)/$(DEB_HOST_GNU_TYPE) + rm -rf $(d_spu)/$(PF)/lib/libiberty.a + rm -rf $(d_spu)/$(PF)/lib/ldscripts + +ifeq ($(with_strip),yes) + : # Strip shared libraries + pkg_create_dbgsym $(p_spu) $(d_spu) || true + $(STRIP) --strip-unneeded $(d_spu)/$(PF)/lib/libbfd-*so + $(STRIP) --strip-unneeded $(d_spu)/$(PF)/lib/libopcodes-*so + $(STRIP) $$(file $(d_spu)/$(PF)/bin/* | awk -F: '$$0 !~ /script/ {print $$1}') +endif + + chmod ugo-x $(d_spu)/$(PF)/lib/*.so + + : # Don't want /usr/-linux to exist in any package + rm -rf $(d_spu)/$(PF)/spu-elf + + touch install-spu-stamp + +################################################################################ + +####################### +# binary-indep target # +####################### + +binary-indep: checkroot build install + $(checkdir) + + rm -f debian/files debian/substvars + +# Cross builds do not have documentation packages +ifeq (,$(TARGET)) + + $(install_dir) $(d_doc)/DEBIAN + +ifneq ($(BACKPORT),true) + $(install_dir) $(d_doc)/$(PF)/share/doc/$(p_doc)/ + $(install_file) debian/changelog $(d_doc)/$(PF)/share/doc/$(p_doc)/changelog.Debian + $(install_file) debian/copyright $(d_doc)/$(PF)/share/doc/$(p_doc)/ + for i in bfd gas gprof ld; do \ + ln -sf ../$(p_bin)/$$i $(d_doc)/$(PF)/share/doc/$(p_doc)/$$i; \ + done + find $(d_doc)/$(PF)/share/doc/$(p_doc) -maxdepth 1 -type f ! -name copyright | xargs gzip -9 + gzip -9 $(d_doc)/$(PF)/share/info/* + + dpkg-gencontrol -isp -P$(d_doc) -p$(p_doc) + chown -R root:root $(d_doc) + chmod -R go=rX $(d_doc) + dpkg --build $(d_doc) .. + + $(install_dir) $(d_src)/$(PF)/share/doc/$(p_src)/ + $(install_file) debian/changelog $(d_src)/$(PF)/share/doc/$(p_src)/changelog.Debian + $(install_file) debian/copyright $(d_src)/$(PF)/share/doc/$(p_src)/ + find $(d_src)/$(PF)/share/doc/$(p_src) -maxdepth 1 -type f ! -name copyright | xargs gzip -9 +endif # ifndef BACKPORT + + $(install_dir) $(d_src)/DEBIAN + $(install_dir) $(d_src)/$(PF)/src/binutils/patches + $(install_file) debian/patches/* $(d_src)/$(PF)/src/binutils/patches/ + tar -c --xz -C .. --exclude=CVS \ + -f $(pwd)/$(d_src)/$(PF)/src/binutils/binutils-$(VERSION).tar.xz \ + $(source_files) + + tar cf - $$(find './debian' -mindepth 1 \( \ + -path './debian/binutils*' -type d -prune -o \ + -path './debian/patches' -prune -o \ + -path './debian/tmp*' -prune -o \ + -path './debian/.bzr*' -prune -o \ + -path './debian/files' -prune -o \ + -print \) ) \ + | tar -x -C $(d_src)/$(PF)/src/binutils -f - + -chmod 755 $(d_src)/$(PF)/src/binutils/debian/*.{pre,post}{inst,rm} + chmod 755 $(d_src)/$(PF)/src/binutils/debian/test-suite-compare.py + + dpkg-gencontrol -isp -P$(d_src) -p$(p_src) + chown -R root:root $(d_src) + chmod -R go=rX $(d_src) + dpkg --build $(d_src) .. + +endif + +################################################################################ + +####################### +# binary-arch target # +####################### + +binary-arch: checkroot build install + $(checkdir) + +ifneq ($(BACKPORT),true) +# Process the following only if $(TARGET) is set +ifneq (,$(TARGET)) + test "" != "$(TARGET)" + + rm -rf $(d_cross)/$(PF)/share/info $(d_cross)/$(PF)/share/man + + sed "/^$$/ q" < debian/control.in > debian/control + sed -e "s/__TARGET__/$$(echo -n $(TARGET) | sed s/_/-/g)/" \ + < debian/control.cross.in >> debian/control + + $(install_dir) $(d_cross)/DEBIAN + + $(install_dir) $(d_cross)/$(PF)/share/doc/$(p_cross)/ + $(install_file) debian/changelog $(d_cross)/$(PF)/share/doc/$(p_cross)/changelog.Debian + $(install_file) debian/copyright debian/README.cross $(d_cross)/$(PF)/share/doc/$(p_cross)/ + gzip -9f $(d_cross)/$(PF)/share/doc/$(p_cross)/changelog.Debian + + for pkg in bfd gas gprof ld; do \ + ln -sf ../binutils/$$pkg $(d_cross)/$(PF)/share/doc/$(p_cross)/$$pkg; \ + done + + rm -f debian/substvars + dpkg-shlibdeps $(d_cross)/$(PF)/bin/* + dpkg-gencontrol -isp -P$(d_cross) -p$(p_cross) + dpkg --build $(d_cross) .. + +else + cp debian/control.in debian/control + : # generate some control & helper files + nver=$$(echo $(DEB_UPSTREAM) | awk -F. '{ OFS="."; $$NF=$$NF+1; print }'); \ + for i in debian/*.in; do \ + case "$$i" in debian/control.cross.in) continue; esac; \ + sed -e 's/@VER@/$(VERSION)/g' \ + -e 's/@DEB_VER@/$(DEB_VERSION)/g' \ + -e 's/@DEB_SVER@/$(DEB_SVERSION)/g' \ + -e 's/@DEB_UVER@/$(DEB_UPSTREAM)/g' \ + -e "s/@DEB_NVER@/$$nver/g" \ + -e 's/@DATE_EXT@/$(DATE_EXT)/g' \ + $$i > $${i%*.in}; \ + case "$$i" in *.post*|*.pre*) chmod 755 $${i%*.in}; esac; \ + done + + : # install bug reporting information + $(install_file) -D debian/$(p_bin).presubj \ + $(d_bin)/$(PF)/share/bug/$(p_bin)/presubj +ifeq ($(with_multiarch),yes) + $(install_dir) $(d_mul)/$(PF)/share/bug + ln -sf $(p_bin) $(d_mul)/$(PF)/share/bug/$(p_mul) +endif +ifeq ($(with_gold),yes) + $(install_dir) $(d_gold)/$(PF)/share/bug + ln -sf $(p_bin) $(d_gold)/$(PF)/share/bug/$(p_gold) +endif +ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64)) + $(install_dir) $(d_spu)/$(PF)/share/bug + ln -sf $(p_bin) $(d_spu)/$(PF)/share/bug/$(p_spu) +endif +ifeq ($(DEB_HOST_ARCH),hppa) + $(install_dir) $(d_hppa64)/$(PF)/share/bug + ln -sf $(p_bin) $(d_hppa64)/$(PF)/share/bug/$(p_hppa64) +endif + + : # make lintian happy + $(install_file) -D debian/$(p_bin).overrides \ + $(d_bin)/$(PF)/share/lintian/overrides/$(p_bin) +ifeq ($(with_multiarch),yes) + $(install_file) -D debian/$(p_mul).overrides \ + $(d_mul)/$(PF)/share/lintian/overrides/$(p_mul) +endif +ifeq ($(with_static),yes) + $(install_file) -D debian/$(p_static).overrides \ + $(d_static)/$(PF)/share/lintian/overrides/$(p_static) + $(install_file) -D debian/$(p_udeb).overrides \ + $(d_udeb)/$(PF)/share/lintian/overrides/$(p_udeb) +endif +ifeq ($(with_gold),yes) + $(install_file) -D debian/$(p_gold).overrides \ + $(d_gold)/$(PF)/share/lintian/overrides/$(p_gold) +endif +ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64)) + $(install_file) -D debian/$(p_spu).overrides \ + $(d_spu)/$(PF)/share/lintian/overrides/$(p_spu) +endif +ifeq ($(DEB_HOST_ARCH),hppa) + $(install_file) -D debian/$(p_hppa64).overrides \ + $(d_hppa64)/$(PF)/share/lintian/overrides/$(p_hppa64) +endif + + : # install maintainer scrtips + $(install_dir) $(d_bin)/DEBIAN + $(install_script) debian/binutils.postinst $(d_bin)/DEBIAN/postinst + $(install_script) debian/binutils.postrm $(d_bin)/DEBIAN/postrm + $(install_file) debian/binutils.shlibs $(d_bin)/DEBIAN/shlibs + + $(install_dir) $(d_dev)/DEBIAN + +ifeq ($(with_multiarch),yes) + $(install_dir) $(d_mul)/DEBIAN + $(install_script) debian/binutils-multiarch.preinst $(d_mul)/DEBIAN/preinst + $(install_script) debian/binutils-multiarch.postinst $(d_mul)/DEBIAN/postinst + $(install_script) debian/binutils-multiarch.prerm $(d_mul)/DEBIAN/prerm + $(install_script) debian/binutils-multiarch.postrm $(d_mul)/DEBIAN/postrm + $(install_file) debian/binutils-multiarch.shlibs $(d_mul)/DEBIAN/shlibs +endif + +ifeq ($(with_static),yes) + $(install_dir) $(d_static)/DEBIAN + $(install_script) debian/binutils-static.preinst $(d_static)/DEBIAN/preinst + $(install_dir) $(d_udeb)/DEBIAN +endif + +ifeq ($(with_gold),yes) + $(install_dir) $(d_gold)/DEBIAN + $(install_script) debian/binutils-gold.postrm $(d_gold)/DEBIAN/postrm + $(install_script) debian/binutils-gold.preinst $(d_gold)/DEBIAN/preinst +endif + +ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64)) + $(install_dir) $(d_spu)/DEBIAN + $(install_script) debian/binutils-spu.postinst $(d_spu)/DEBIAN/postinst + $(install_script) debian/binutils-spu.postrm $(d_spu)/DEBIAN/postrm + $(install_file) debian/binutils-spu.shlibs $(d_spu)/DEBIAN/shlibs +endif + +ifeq ($(DEB_HOST_ARCH),hppa) + $(install_dir) $(d_hppa64)/DEBIAN + $(install_script) debian/binutils-hppa64.postinst $(d_hppa64)/DEBIAN/postinst + $(install_script) debian/binutils-hppa64.postrm $(d_hppa64)/DEBIAN/postrm + $(install_file) debian/binutils-hppa64.shlibs $(d_hppa64)/DEBIAN/shlibs +endif + + : # install docs + $(install_dir) $(d_bin)/$(PF)/share/doc/$(p_bin)/ + $(install_file) debian/changelog $(d_bin)/$(PF)/share/doc/$(p_bin)/changelog.Debian + $(install_file) debian/copyright $(d_bin)/$(PF)/share/doc/$(p_bin)/ + +ifeq ($(with_static),yes) + $(install_dir) $(d_static)/$(PF)/share/doc/$(p_static)/ + $(install_file) debian/changelog $(d_static)/$(PF)/share/doc/$(p_static)/changelog.Debian + $(install_file) debian/copyright $(d_static)/$(PF)/share/doc/$(p_static)/ +endif + + $(install_dir) $(d_dev)/$(PF)/share/doc/ + ln -sf $(p_bin) $(d_dev)/$(PF)/share/doc/$(p_dev) +ifeq ($(with_multiarch),yes) + $(install_dir) $(d_mul)/$(PF)/share/doc/ + ln -sf $(p_bin) $(d_mul)/$(PF)/share/doc/$(p_mul) +endif +ifeq ($(with_gold),yes) + $(install_dir) $(d_gold)/$(PF)/share/doc/ + ln -sf $(p_bin) $(d_gold)/$(PF)/share/doc/$(p_gold) +endif +ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64)) + $(install_dir) $(d_spu)/$(PF)/share/doc/ + ln -sf $(p_bin) $(d_spu)/$(PF)/share/doc/$(p_spu) +endif +ifeq ($(DEB_HOST_ARCH),hppa) + $(install_dir) $(d_hppa64)/$(PF)/share/doc/ + ln -sf $(p_bin) $(d_hppa64)/$(PF)/share/doc/$(p_hppa64) +endif + +ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) +ifeq ($(with_check),yes) + $(install_file) $(pwd)/test-summary $(d_bin)/$(PF)/share/doc/$(p_bin)/ +endif +endif + $(install_file) binutils/NEWS debian/README.cross \ + $(d_bin)/$(PF)/share/doc/$(p_bin)/ + + $(install_file) binutils/ChangeLog $(d_bin)/$(PF)/share/doc/$(p_bin)/changelog + + for pkg in bfd gas gprof ld; do \ + $(install_dir) $(d_bin)/$(PF)/share/doc/$(p_bin)/$$pkg; \ + done + $(install_file) bfd/ChangeLog bfd/PORTING bfd/TODO \ + $(d_bin)/$(PF)/share/doc/$(p_bin)/bfd/ + $(install_file) gas/ChangeLog gas/NEWS $(d_bin)/$(PF)/share/doc/$(p_bin)/gas/ + $(install_file) gprof/ChangeLog gprof/TODO gprof/TEST \ + $(d_bin)/$(PF)/share/doc/$(p_bin)/gprof/ + $(install_file) ld/ChangeLog ld/TODO ld/NEWS \ + $(d_bin)/$(PF)/share/doc/$(p_bin)/ld/ + + : # These only exist in H. J. Lu releases not GNU ones. + for dir in binutils bfd gas gprof ld; do \ + if [ -f $$dir/ChangeLog.linux ]; then \ + $(install_file) $$dir/ChangeLog.linux $(d_bin)/$(PF)/share/doc/$(p_bin)/$$dir/; \ + fi; \ + done + + : # Copy bbconv.pl to the doc dir for use by interested people + $(install_file) gprof/bbconv.pl $(d_bin)/$(PF)/share/doc/$(p_bin)/gprof/. + + : # Compress stuff that needs it + gzip -9 $(d_bin)/$(PF)/share/man/man1/*.1 + find $(d_bin)/$(PF)/share/doc/$(p_bin)/ -type f ! -name copyright -a ! -name bbconv.pl | xargs gzip -9 +ifeq ($(with_static),yes) + find $(d_static)/$(PF)/share/doc/$(p_static)/ -type f ! -name copyright | xargs gzip -9 +endif + + : # Finish it all up + find $(d_bin) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps + dpkg-gencontrol -isp -P$(d_bin) -p$(p_bin) $(CONFLICTS) + + rm -f debian/substvars + dpkg-gencontrol -isp -P$(d_dev) -p$(p_dev) + +ifeq ($(with_multiarch),yes) + rm -f debian/substvars + find $(d_mul) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps + dpkg-gencontrol -isp -P$(d_mul) -p$(p_mul) +endif + +ifeq ($(with_static),yes) + dpkg-gencontrol -isp -P$(d_static) -p$(p_static) + dpkg-gencontrol -isp -P$(d_udeb) -p$(p_udeb) -fdebian/files~ + dpkg-distaddfile $(STATIC_UDEB) debian-installer optional +endif + +ifeq ($(with_gold),yes) + rm -f debian/substvars +# no binary +# find $(d_gold) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps + dpkg-gencontrol -isp -P$(d_gold) -p$(p_gold) +endif +ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64)) + rm -f debian/substvars + find $(d_spu) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps + dpkg-gencontrol -isp -P$(d_spu) -p$(p_spu) +endif +ifeq ($(DEB_HOST_ARCH),hppa) + rm -f debian/substvars + find $(d_hppa64) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps + dpkg-gencontrol -isp -P$(d_hppa64) -p$(p_hppa64) +endif + + chown -R root:root $(d_bin) $(d_dev) + chmod -R go=rX $(d_bin) $(d_dev) + dpkg --build $(d_bin) .. + dpkg --build $(d_dev) .. +ifeq ($(with_multiarch),yes) + chown -R root:root $(d_mul) + chmod -R go=rX $(d_mul) + dpkg --build $(d_mul) .. +endif +ifeq ($(with_gold),yes) + chown -R root:root $(d_gold) + chmod -R go=rX $(d_gold) + dpkg --build $(d_gold) .. +endif +ifeq ($(with_static),yes) + chown -R root:root $(d_static) $(d_udeb) + chmod -R go=rX $(d_static) $(d_udeb) + dpkg --build $(d_static) .. + dpkg --build $(d_udeb) ../$(STATIC_UDEB) +endif +ifneq (,$(filter $(DEB_HOST_ARCH),powerpc ppc64)) + chown -R root:root $(d_spu) + chmod -R go=rX $(d_spu) + dpkg --build $(d_spu) .. +endif +ifeq ($(DEB_HOST_ARCH),hppa) + chown -R root:root $(d_hppa64) + chmod -R go=rX $(d_hppa64) + dpkg --build $(d_hppa64) .. +endif + +endif # Process the following only if $(TARGET) is set +endif # ifndef BACKPORT +################################################################################ + +################# +# cross targets # +################# + + +# Support TARGET both as Debian architecture specification (e.g. arm), +# and as the target name (e.g. arm-linux-gnu). +try_convert := $(shell dpkg-architecture -f -a$(TARGET) -qDEB_HOST_GNU_TYPE 2>/dev/null) +ifneq ($(try_convert),) +override TARGET := $(try_convert) +endif + +# Process the following only if $(TARGET) is set +ifneq (,$(TARGET)) + +p_cross = $(subst _,-,binutils-$(TARGET)) +d_cross = debian/$(p_cross) + +ifneq ($(filter sparc-linux-gnu powerpc-linux-gnu mips-linux-gnu, $(TARGET)),) +ADDITIONAL_TARGETS = --enable-targets=$(TARGET:%-linux-gnu=%64-linux-gnu) +endif +ifneq ($(filter i386-linux-gnu i486-linux-gnu i586-linux-gnu i686-linux-gnu x86-linux-gnu, $(TARGET)),) +ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu +endif +ifneq ($(filter i386-kfreebsd-gnu i486-kfreebsd-gnu i586-kfreebsd-gnu x86-kfreebsd-gnu, $(TARGET)),) +ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu +endif +ifeq ($(TARGET), x86_64-linux-gnu) +ADDITIONAL_TARGETS = --enable-targets=i686-linux-gnu +endif +ifeq ($(TARGET), x86_64-kfreebsd-gnu) +ADDITIONAL_TARGETS = --enable-targets=i486-kfreebsd-gnu +endif +ifeq ($(TARGET), mipsel-linux-gnu) +ADDITIONAL_TARGETS = --enable-targets=mips64el-linux-gnu +endif +ifeq ($(TARGET), sparc64-linux-gnu) +ADDITIONAL_TARGETS = --enable-targets=sparc-linux-gnu +endif +ifeq ($(TARGET), s390-linux-gnu) +ADDITIONAL_TARGETS = --enable-targets=s390x-linux-gnu +endif +ifeq ($(TARGET), s390x-linux-gnu) +ADDITIONAL_TARGETS = --enable-targets=s390-linux-gnu +endif + +#----------------------------------------------------------------- +# sysroot options +ifdef WITH_SYSROOT + with_sysroot = $(WITH_SYSROOT) +endif +ifdef WITH_BUILD_SYSROOT + with_build_sysroot = $(WITH_BUILD_SYSROOT) +endif + +CROSS_CONFARGS := $(ADDITIONAL_TARGETS) $(CONFARGS) +ifneq ($(with_sysroot),) + CROSS_CONFARGS += --with-sysroot=$(with_sysroot) +endif +ifneq ($(with_build_sysroot),) + CROSS_CONFARGS += --with-build-sysroot=$(with_build_sysroot) +endif +ifeq ($(with_gold),yes) + CROSS_CONFARGS += --enable-ld=default --enable-gold +endif + +configure-cross-stamp: patch-stamp + $(checkdir) + test "" != "$(TARGET)" + rm -rf configure-cross-stamp builddir-$(TARGET) + mkdir builddir-$(TARGET) + cd builddir-$(TARGET) \ + && env CC="$(CC)" CXX="$(CXX)" ../configure --host=$(DEB_HOST_GNU_TYPE) \ + --build=$(DEB_BUILD_GNU_TYPE) --target=$(TARGET) --prefix=/$(PF) \ + $(CROSS_CONFARGS) + touch $@ + +build-cross-stamp: configure-cross-stamp + $(checkdir) + test "" != "$(TARGET)" + $(MAKE) -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)" + touch $@ + +install-cross-stamp: build-cross-stamp + $(checkdir) + test "" != "$(TARGET)" + rm -rf $(d_cross) + $(MAKE) -C builddir-$(TARGET) prefix=$(pwd)/$(d_cross)/$(PF) \ + mandir=$(pwd)/$(d_cross)/$(PF)/share/man install + rm -rf $(d_cross)/$(PF)/lib* $(d_cross)/$(PF)/info $(d_cross)/$(PF)/share/locale +ifeq ($(with_strip),yes) + pkg_create_dbgsym $(p_cross) $(d_cross) || true + $(STRIP) --strip-unneeded $(d_cross)/$(PF)/$(DEB_HOST_GNU_TYPE)/$(TARGET)/lib/libbfd-*so + $(STRIP) --strip-unneeded $(d_cross)/$(PF)/$(DEB_HOST_GNU_TYPE)/$(TARGET)/lib/libopcodes-*so + + $(STRIP) $$(file $(d_cross)/$(PF)/bin/* | awk -F: '$$0 !~ /script/ {print $$1}') + + chmod ugo-x $(d_cross)/$(PF)/$(DEB_HOST_GNU_TYPE)/$(TARGET)/lib/*.so +endif + + # Get rid of .la files since libtool obviously has no idea about transient paths + rm -f $(d_cross)/$(PF)/$(DEB_HOST_GNU_TYPE)/$(TARGET)/lib/*.la + + gzip -9 $(d_cross)/$(PF)/share/man/man1/* + touch $@ + +configure-host-cross-stamp: configure-cross-stamp + $(checkdir) + test "" != "$(TARGET)" + $(MAKE) configure-host -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)" + touch $@ + +build-static-cross-stamp: configure-host-cross-stamp + $(checkdir) + test "" != "$(TARGET)" + $(MAKE) -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)" LDFLAGS="-all-static" + touch $@ + +install-static-cross-stamp: build-static-cross-stamp install-cross-stamp + +binary-cross: + @echo "Please use dpkg-buildpackage instead of calling binary-cross directly; see README.cross" + @false + +endif + +################################################################################ + +define checkdir + test -f bfd/elf32.c -a -f debian/rules +endef + +# Below here is fairly generic really + +binary: binary-indep binary-arch + +checkroot: + $(checkdir) + test root = "`whoami`" + +.PHONY: binary binary-arch binary-indep clean checkroot --- binutils-2.22.orig/debian/control.in +++ binutils-2.22/debian/control.in @@ -0,0 +1,121 @@ +Source: binutils +Section: devel +Priority: optional +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Matthias Klose +Uploaders: James Troup , Daniel Jacobowitz +Standards-Version: 3.9.2 +Build-Depends: dpkg-dev (>= 1.13.9), autoconf (>= 2.64), bison, flex, gettext, texinfo, dejagnu (>= 1.4.2-1.1), quilt, file, xz-utils, lsb-release, zlib1g-dev, g++ +Vcs-Browser: https://code.launchpad.net/~ubuntu-core-dev/binutils/pkg-ubuntu +Vcs-Bzr: http://bazaar.launchpad.net/~ubuntu-core-dev/binutils/pkg-ubuntu + +Package: binutils +Architecture: any +Depends: ${shlibs:Depends} +Conflicts: gas, elf-binutils, modutils (<< 2.4.19-1), ${extraConflicts}, binutils-gold (<< 2.20.51.20100415) +Replaces: binutils-gold (<< 2.20.51.20100415) +Provides: elf-binutils +Suggests: binutils-doc (>= ${source:Version}) +Description: GNU assembler, linker and binary utilities + The programs in this package are used to assemble, link and manipulate + binary and object files. They may be used in conjunction with a compiler + and various libraries to build programs. + +Package: binutils-dev +Architecture: any +Priority: extra +Depends: binutils (= ${binary:Version}) +Conflicts: libbfd-dev +Provides: libbfd-dev +Replaces: libbfd-dev, libc5-dev +Description: GNU binary utilities (BFD development files) + This package includes header files and static libraries necessary to build + programs which use the GNU BFD library, which is part of binutils. Note + that building Debian packages which depend on the shared libbfd is Not + Allowed. + +Package: binutils-multiarch +Architecture: any +Priority: extra +Depends: ${shlibs:Depends}, binutils (= ${binary:Version}) +Provides: multiarch-binutils +Description: Binary utilities that support multi-arch targets + The programs in this package are used to manipulate binary and object + files that may have been created on other architectures. This package + is primarily for multi-architecture developers and cross-compilers and + is not needed by normal users or developers. Note that a cross-assembling + version of gas is not included in this package, just the binary utilities. + NORMAL USERS SHOULD NOT INSTALL THIS PACKAGE. It's meant only for those + requiring support for reading info from binaries from other architectures. + +Package: binutils-gold +Architecture: amd64 armel armhf i386 powerpc powerpcspe ppc64 sparc sparc64 +Priority: extra +Depends: ${shlibs:Depends}, binutils (= ${binary:Version}) +Description: GNU gold linker utility + Gold is a new linker, which is faster than the current linker included + in binutils. + . + This package diverts the GNU linker (ld) with the gold linker. + +Package: binutils-static +Architecture: any +Description: statically linked binutils tools + This package contains statically linked binutils tools used + for linking kernel modules needed to mount /usr or /. At the moment, + it only contains ld. + +Package: binutils-static-udeb +Section: debian-installer +Architecture: any +Description: statically linked binutils tools for for the Debian installer + This package contains statically linked binutils tools used + for linking kernel modules needed to mount /usr or /. At the moment, + it only contains ld. + +Package: binutils-hppa64 +Architecture: any +Depends: ${shlibs:Depends}, binutils (= ${binary:Version}) +Recommends: libc6-dev +Suggests: binutils-doc (>= ${source:Version}) +Description: GNU assembler, linker and binary utilities targeted for hppa64-linux + The programs in this package are used to assemble, link and manipulate + binary and object files. They may be used in conjunction with a compiler + and various libraries to build programs. + . + This package is needed to build an 64-bit kernel for 64-bit hppa machines. + +Package: binutils-spu +Architecture: powerpc ppc64 +Depends: ${shlibs:Depends}, binutils (= ${binary:Version}) +Recommends: libc6-dev +Conflicts: spu-binutils +Replaces: spu-binutils +Provides: spu-binutils +Suggests: binutils-doc (>= ${source:Version}) +Description: GNU assembler, linker and binary utilities targeted for spu-elf + The programs in this package are used to assemble, link and manipulate + binary and object files. They may be used in conjunction with a compiler + and various libraries to build programs. + . + This package is needed to build programs for Cell Broadband Engine SPU + processors. + +Package: binutils-doc +Section: doc +Architecture: all +Priority: optional +Depends: dpkg (>= 1.15.4) | install-info +Conflicts: binutils (<< 2.9.1.0.25-3) +Suggests: binutils (= ${binary:Version}) +Description: Documentation for the GNU assembler, linker and binary utilities + This package consists of the documentation for the GNU assembler, + linker and binary utilities in info format. + +Package: binutils-source +Architecture: all +Priority: optional +Depends: texinfo, zlib1g-dev, make, python +Description: GNU assembler, linker and binary utilities (source) + This package contains the sources and patches which are needed to + build binutils. --- binutils-2.22.orig/debian/binutils-spu.shlibs.in +++ binutils-2.22/debian/binutils-spu.shlibs.in @@ -0,0 +1,2 @@ +libbfd @VER@-spu@DATE_EXT@ binutils-spu +libopcodes @VER@-spu@DATE_EXT@ binutils-spu --- binutils-2.22.orig/debian/source/format +++ binutils-2.22/debian/source/format @@ -0,0 +1 @@ +1.0 --- binutils-2.22.orig/debian/patches/131_ld_bootstrap_testsuite.patch +++ binutils-2.22/debian/patches/131_ld_bootstrap_testsuite.patch @@ -0,0 +1,45 @@ +Author: +Description: Description: Fix ld-bootstrap testsuite when configured with --enable-plugins +Author: Rafael Espindola +Upstream status: proposed patch +--- a/ld/testsuite/ld-bootstrap/bootstrap.exp ++++ b/ld/testsuite/ld-bootstrap/bootstrap.exp +@@ -40,6 +40,15 @@ + set plugins "no" + } + ++remote_exec host "$nm --help" "" "/dev/null" "plugin-support" ++set tmp [file_contents "plugin-support"] ++regexp ".*\(--plugin\).*\n" $tmp foo plugins ++if [info exists plugins] then { ++ set plugins "yes" ++} else { ++ set plugins "no" ++} ++ + # Bootstrap ld. First link the object files together using -r, in + # order to test -r. Then link the result into an executable, ld1, to + # really test -r. Use ld1 to link a fresh ld, ld2. Use ld2 to link a +@@ -78,6 +87,11 @@ + continue + } + ++ if { $flags == "--static" && $plugins == "yes" } then { ++ untested $testname ++ continue ++ } ++ + # If we only have a shared libbfd, we probably can't run the + # --static test.will fail. + if { $flags == "--static" && ! [string match "*libbfd.a*" $BFDLIB] } then { +@@ -112,6 +126,10 @@ + if { $plugins == "yes" } { + set extralibs "$extralibs -ldl" + } ++ ++ if { $plugins == "yes" } { ++ set extralibs "$extralibs -ldl" ++ } + + # On Irix 5, linking with --static only works if all the files are + # compiled using -non_shared. --- binutils-2.22.orig/debian/patches/163_multiarch_search_path.patch +++ binutils-2.22/debian/patches/163_multiarch_search_path.patch @@ -0,0 +1,79 @@ +# DP: multiarch search paths + +--- binutils-2.21.53.20110810.orig/gold/Makefile.am ++++ binutils-2.21.53.20110810/gold/Makefile.am +@@ -15,7 +15,7 @@ + -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../elfcpp \ + -DLOCALEDIR="\"$(datadir)/locale\"" \ + -DBINDIR="\"$(bindir)\"" -DTOOLBINDIR="\"$(tooldir)/bin\"" \ +- @INCINTL@ ++ @INCINTL@ @MULTIARCH_DIRNAME@ + + LIBIBERTY = ../libiberty/libiberty.a + +--- binutils-2.21.53.20110810.orig/gold/configure ++++ binutils-2.21.53.20110810/gold/configure +@@ -594,6 +594,7 @@ + MAINT + MAINTAINER_MODE_FALSE + MAINTAINER_MODE_TRUE ++MULTIARCH_DIRNAME + CXXCPP + HAVE_ZLIB_FALSE + HAVE_ZLIB_TRUE +@@ -7133,6 +7134,14 @@ + ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ++if test x$target = x$host; then ++ multiarch=`$CC -print-multiarch 2>/dev/null` ++ if test -n "$multiarch"; then ++ MULTIARCH_DIRNAME='-DMULTIARCH_DIRNAME=\"'$multiarch'\"' ++ fi ++fi ++ ++ + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 + $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } +--- binutils-2.21.53.20110810.orig/gold/configure.ac ++++ binutils-2.21.53.20110810/gold/configure.ac +@@ -475,6 +475,14 @@ + + AC_LANG_POP(C++) + ++if test x$target = x$host; then ++ multiarch=`$CC -print-multiarch 2>/dev/null` ++ if test -n "$multiarch"; then ++ MULTIARCH_DIRNAME='-DMULTIARCH_DIRNAME=\"'$multiarch'\"' ++ fi ++fi ++AC_SUBST(MULTIARCH_DIRNAME) ++ + AM_MAINTAINER_MODE + + AC_OUTPUT(Makefile testsuite/Makefile po/Makefile.in:po/Make-in) +--- binutils-2.21.53.20110810.orig/gold/options.cc ++++ binutils-2.21.53.20110810/gold/options.cc +@@ -1145,6 +1147,10 @@ + { + // Even if they don't specify it, we add -L /lib and -L /usr/lib. + // FIXME: We should only do this when configured in native mode. ++#ifdef MULTIARCH_DIRNAME ++ this->add_to_library_path_with_sysroot("/lib/" MULTIARCH_DIRNAME); ++ this->add_to_library_path_with_sysroot("/usr/lib/" MULTIARCH_DIRNAME); ++#endif + this->add_to_library_path_with_sysroot("/lib"); + this->add_to_library_path_with_sysroot("/usr/lib"); + } +--- binutils-2.21.53.20110810.orig/gold/Makefile.in ++++ binutils-2.21.53.20110810/gold/Makefile.in +@@ -364,7 +364,7 @@ + -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../elfcpp \ + -DLOCALEDIR="\"$(datadir)/locale\"" \ + -DBINDIR="\"$(bindir)\"" -DTOOLBINDIR="\"$(tooldir)/bin\"" \ +- @INCINTL@ ++ @INCINTL@ @MULTIARCH_DIRNAME@ + + LIBIBERTY = ../libiberty/libiberty.a + @PLUGINS_TRUE@LIBDL = -ldl --- binutils-2.22.orig/debian/patches/001_ld_makefile_patch.patch +++ binutils-2.22/debian/patches/001_ld_makefile_patch.patch @@ -0,0 +1,27 @@ +Author: +Description: Description: correct where ld scripts are installed +Author: Chris Chimelis +Upstream status: N/A +Date: ?? +--- a/ld/Makefile.am ++++ b/ld/Makefile.am +@@ -24,7 +24,7 @@ + # We put the scripts in the directory $(scriptdir)/ldscripts. + # We can't put the scripts in $(datadir) because the SEARCH_DIR + # directives need to be different for native and cross linkers. +-scriptdir = $(tooldir)/lib ++scriptdir = $(libdir) + + EMUL = @EMUL@ + EMULATION_OFILES = @EMULATION_OFILES@ +--- a/ld/Makefile.in ++++ b/ld/Makefile.in +@@ -337,7 +337,7 @@ + # We put the scripts in the directory $(scriptdir)/ldscripts. + # We can't put the scripts in $(datadir) because the SEARCH_DIR + # directives need to be different for native and cross linkers. +-scriptdir = $(tooldir)/lib ++scriptdir = $(libdir) + BASEDIR = $(srcdir)/.. + BFDDIR = $(BASEDIR)/bfd + INCDIR = $(BASEDIR)/include --- binutils-2.22.orig/debian/patches/binutils-CVE-2012-3509.patch +++ binutils-2.22/debian/patches/binutils-CVE-2012-3509.patch @@ -0,0 +1,84 @@ +From 63d6cef520317622e38fb04be409db9ee43f9807 Mon Sep 17 00:00:00 2001 +From: fw +Date: Tue, 18 Sep 2012 08:34:05 +0000 +Subject: [PATCH] PR other/54411: integer overflow in objalloc_alloc + +2012-09-18 Florian Weimer + + PR other/54411 + * objalloc.h (objalloc_alloc): Do not use fast path on wraparound. + +2012-09-18 Florian Weimer + + PR other/54411 + * objalloc.c (_objalloc_alloc): Add overflow check covering + alignment and CHUNK_HEADER_SIZE addition. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191413 138bc75d-0d04-0410-961f-82ee72b054a4 + +[Ubuntu note: patch differs from upstream commit in that the Changelog +entries have dropped to avoid patch conflicts. --sbeattie] + +CVE-2012-3509 + +--- + include/objalloc.h | 4 ++-- + libiberty/objalloc.c | 11 +++++++++-- + 2 files changed, 11 insertions(+), 4 deletions(-) + +Index: b/include/objalloc.h +=================================================================== +--- a/include/objalloc.h ++++ b/include/objalloc.h +@@ -1,5 +1,5 @@ + /* objalloc.h -- routines to allocate memory for objects +- Copyright 1997, 2001 Free Software Foundation, Inc. ++ Copyright 1997-2012 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Solutions. + + This program is free software; you can redistribute it and/or modify it +@@ -91,7 +91,7 @@ extern void *_objalloc_alloc (struct obj + if (__len == 0) \ + __len = 1; \ + __len = (__len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); \ +- (__len <= __o->current_space \ ++ (__len != 0 && __len <= __o->current_space \ + ? (__o->current_ptr += __len, \ + __o->current_space -= __len, \ + (void *) (__o->current_ptr - __len)) \ +Index: b/libiberty/objalloc.c +=================================================================== +--- a/libiberty/objalloc.c ++++ b/libiberty/objalloc.c +@@ -1,5 +1,5 @@ + /* objalloc.c -- routines to allocate memory for objects +- Copyright 1997 Free Software Foundation, Inc. ++ Copyright 1997-2012 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Solutions. + + This program is free software; you can redistribute it and/or modify it +@@ -112,8 +112,10 @@ objalloc_create (void) + /* Allocate space from an objalloc structure. */ + + PTR +-_objalloc_alloc (struct objalloc *o, unsigned long len) ++_objalloc_alloc (struct objalloc *o, unsigned long original_len) + { ++ unsigned long len = original_len; ++ + /* We avoid confusion from zero sized objects by always allocating + at least 1 byte. */ + if (len == 0) +@@ -121,6 +123,11 @@ _objalloc_alloc (struct objalloc *o, uns + + len = (len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); + ++ /* Check for overflow in the alignment operation above and the ++ malloc argument below. */ ++ if (len + CHUNK_HEADER_SIZE < original_len) ++ return NULL; ++ + if (len <= o->current_space) + { + o->current_ptr += len; --- binutils-2.22.orig/debian/patches/127_x86_64_i386_biarch.patch +++ binutils-2.22/debian/patches/127_x86_64_i386_biarch.patch @@ -0,0 +1,20 @@ +Author: +Description: Description: Add (/usr)/lib32 to the search paths on x86_64. +Author: Aurelien Jarno +Upstream status: Debian specific +--- a/ld/emulparams/elf_i386.sh ++++ b/ld/emulparams/elf_i386.sh +@@ -13,3 +13,13 @@ + NO_SMALL_DATA=yes + SEPARATE_GOTPLT=12 + IREL_IN_PLT= ++ ++# Linux modify the default library search path to first include ++# a 32-bit specific directory. ++case "$target" in ++ x86_64*-linux* | i[3-7]86*-linux* | x86_64*-kfreebsd*-gnu | i[3-7]86*-kfreebsd*-gnu) ++ case "$EMULATION_NAME" in ++ *i386*) LIBPATH_SUFFIX=32 ;; ++ esac ++ ;; ++esac --- binutils-2.22.orig/debian/patches/128_build_id.patch +++ binutils-2.22/debian/patches/128_build_id.patch @@ -0,0 +1,42 @@ +Author: +Description: Description: Fix ld corrupt build ID generation +Author: Nick Clifton +Upstream status: Taken from Fedora (BZ 501582) +--- a/bfd/compress.c ++++ b/bfd/compress.c +@@ -174,7 +174,7 @@ + case COMPRESS_SECTION_NONE: + if (p == NULL) + { +- p = (bfd_byte *) bfd_malloc (sz); ++ p = (bfd_byte *) bfd_zmalloc (sz); + if (p == NULL) + return FALSE; + need_free = TRUE; +--- a/bfd/elfcode.h ++++ b/bfd/elfcode.h +@@ -1158,6 +1158,24 @@ + + if (i_shdr.contents) + (*process) (i_shdr.contents, i_shdr.sh_size, arg); ++ else ++ { ++ asection *sec; ++ ++ sec = bfd_section_from_elf_index (abfd, count); ++ if (sec != NULL) ++ { ++ if (sec->contents == NULL) ++ { ++ /* Force rereading from file. */ ++ sec->flags &= ~SEC_IN_MEMORY; ++ if (! bfd_malloc_and_get_section (abfd, sec, & sec->contents)) ++ continue; ++ } ++ if (sec->contents != NULL) ++ (*process) (sec->contents, i_shdr.sh_size, arg); ++ } ++ } + } + + return TRUE; --- binutils-2.22.orig/debian/patches/162_fpic_s390x.diff +++ binutils-2.22/debian/patches/162_fpic_s390x.diff @@ -0,0 +1,31 @@ +# DP: Fix s390x build. + +2011-08-24 Aurelien Jarno + + * config/picflag.m4: use -FPIC on s390x. + * libiberty/configure: regenerate. + +--- binutils-2.21.53.20110823.orig/config/picflag.m4 ++++ binutils-2.21.53.20110823/config/picflag.m4 +@@ -51,6 +51,9 @@ + m68k-*-*) + $1=-fpic + ;; ++ s390x*-*-*) ++ $1=-fPIC ++ ;; + s390*-*-*) + $1=-fpic + ;; +--- binutils-2.21.53.20110823.orig/libiberty/configure ++++ binutils-2.21.53.20110823/libiberty/configure +@@ -4891,6 +4891,9 @@ + m68k-*-*) + PICFLAG=-fpic + ;; ++ s390x*-*-*) ++ PICFLAG=-fPIC ++ ;; + s390*-*-*) + PICFLAG=-fpic + ;; --- binutils-2.22.orig/debian/patches/branch-version.diff +++ binutils-2.22/debian/patches/branch-version.diff @@ -0,0 +1,52 @@ +diff --git a/bfd/Makefile.am b/bfd/Makefile.am +index ea4fd28..8610d5e 100644 +--- a/bfd/Makefile.am ++++ b/bfd/Makefile.am +@@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = 1.11 no-dist foreign + ACLOCAL_AMFLAGS = -I . -I .. -I ../config + + # Uncomment the following line when doing a release. +-RELEASE=y ++# RELEASE=y + + INCDIR = $(srcdir)/../include + CSEARCH = -I. -I$(srcdir) -I$(INCDIR) +diff --git a/bfd/Makefile.in b/bfd/Makefile.in +index 741809c..34196aa 100644 +--- a/bfd/Makefile.in ++++ b/bfd/Makefile.in +@@ -320,7 +320,7 @@ AUTOMAKE_OPTIONS = 1.11 no-dist foreign + ACLOCAL_AMFLAGS = -I . -I .. -I ../config + + # Uncomment the following line when doing a release. +-RELEASE = y ++# RELEASE=y + INCDIR = $(srcdir)/../include + CSEARCH = -I. -I$(srcdir) -I$(INCDIR) + SUBDIRS = doc po +diff --git a/bfd/configure b/bfd/configure +index bc242b9..d31f0d9 100755 +--- a/bfd/configure ++++ b/bfd/configure +@@ -3988,7 +3988,7 @@ fi + + # Define the identity of the package. + PACKAGE=bfd +- VERSION=2.22 ++ VERSION=2.22.0 + + + cat >>confdefs.h <<_ACEOF +diff --git a/bfd/configure.in b/bfd/configure.in +index 435aaaa..9ba3000 100644 +--- a/bfd/configure.in ++++ b/bfd/configure.in +@@ -8,7 +8,7 @@ AC_CONFIG_SRCDIR([libbfd.c]) + AC_CANONICAL_TARGET + AC_ISC_POSIX + +-AM_INIT_AUTOMAKE(bfd, 2.22) ++AM_INIT_AUTOMAKE(bfd, 2.22.0) + + dnl These must be called before LT_INIT, because it may want + dnl to call AC_CHECK_PROG. --- binutils-2.22.orig/debian/patches/206-hjl-binutils-shr.patch +++ binutils-2.22/debian/patches/206-hjl-binutils-shr.patch @@ -0,0 +1,1251 @@ +Description: implementation of ELF sharable section proposal +Author: H.J. Lu +Upstream status: hjl 2.21.51.0.8 +Original patch: binutils-shr-97.patch + +http://groups.google.com/group/generic-abi/browse_thread/thread/f7b3e06417ead85a +http://groups.google.com/group/generic-abi/browse_thread/thread/bca08f6560f61b0d + +bfd/ + +2009-12-12 H.J. Lu + + * elf.c: Fix shadowed variable warnings. + * elf64-x86-64.c: Likewise. + * elflink.c: Likewise. + +2007-01-23 H.J. Lu + + * elf-bfd.h (_bfd_elf_sharable_com_section): New. + (_bfd_elf_add_sharable_symbol): Likewise. + (_bfd_elf_sharable_section_from_bfd_section): Likewise. + (_bfd_elf_sharable_symbol_processing): Likewise. + (_bfd_elf_sharable_common_definition): Likewise. + (_bfd_elf_sharable_common_section_index): Likewise. + (_bfd_elf_sharable_common_section): Likewise. + (_bfd_elf_sharable_merge_symbol): Likewise. + + * elf.c (special_sections_g): Add ".gnu.linkonce.shrb" and + ".gnu.linkonce.shrd". + (special_sections_s): Add ".sharable_bss" and ".sharable_data". + (get_program_header_size): Handle PT_GNU_SHR segment. + (_bfd_elf_map_sections_to_segments): Likewise. + (assign_file_positions_for_load_sections): Likewise. + + * elf32-i386.c (elf_i386_link_hash_table): Add sdynsharablebss + and srelsharablebss fields. + (elf_i386_link_hash_table_create): Initialize sdynsharablebss + and srelsharablebss. + (elf_i386_create_dynamic_sections): Handle sdynsharablebss and + srelsharablebss. + (elf_i386_adjust_dynamic_symbol): Likewise. + (elf_i386_size_dynamic_sections): Likewise. + (elf_i386_finish_dynamic_symbol): Likewise. + (elf_backend_add_symbol_hook): Defined. + (elf_backend_section_from_bfd_section): Likewise. + (elf_backend_symbol_processing): Likewise. + (elf_backend_common_section_index): Likewise. + (elf_backend_common_section): Likewise. + (elf_backend_common_definition): Likewise. + (elf_backend_merge_symbol): Likewise. + + * elf64-x86-64.c (elf64_x86_64_link_hash_table): Add + sdynsharablebss and srelsharablebss fields. + (elf64_x86_64_link_hash_table_create): Initialize sdynsharablebss + and srelsharablebss. + (elf64_x86_64_create_dynamic_sections): Handle sdynsharablebss + and srelsharablebss. + (elf64_x86_64_adjust_dynamic_symbol): Likewise. + (elf64_x86_64_size_dynamic_sections): Likewise. + (elf64_x86_64_finish_dynamic_symbol): Likewise. + (elf64_x86_64_add_symbol_hook): Handle sharable symbols. + (elf64_x86_64_elf_section_from_bfd_section): Likewise. + (elf64_x86_64_symbol_processing): Likewise. + (elf64_x86_64_merge_symbol): Likewise. + (elf64_x86_64_common_definition): Handle sharable sections. + (elf64_x86_64_common_section_index): Likewise. + (elf64_x86_64_common_section): Likewise. + + * elflink.c (_bfd_elf_create_dynamic_sections): Handle + .dynsharablebss section. + (_bfd_elf_sharable_com_section): New. + (get_sharable_common_section): Likewise. + (_bfd_elf_add_sharable_symbol): Likewise. + (_bfd_elf_sharable_section_from_bfd_section): Likewise. + (_bfd_elf_sharable_symbol_processing): Likewise. + (_bfd_elf_sharable_common_definition): Likewise. + (_bfd_elf_sharable_common_section_index): Likewise. + (_bfd_elf_sharable_common_section): Likewise. + (_bfd_elf_sharable_merge_symbol): Likewise. + + * elfxx-ia64.c (elfNN_ia64_add_symbol_hook): Handle sharable + symbols. + (elf_backend_add_symbol_hook): Defined. + (elf_backend_section_from_bfd_section): Likewise. + (elf_backend_symbol_processing): Likewise. + (elf_backend_common_section_index): Likewise. + (elf_backend_common_section): Likewise. + (elf_backend_common_definition): Likewise. + (elf_backend_merge_symbol): Likewise. + +binutils/ + +2007-01-04 H.J. Lu + + * readelf.c (dump_relocations): Handle sharable sections. + (get_segment_type): Handle sharable segment. + (get_symbol_index_type): Handle sharable sections. + +gas/ + +2007-01-04 H.J. Lu + + * config/obj-elf.c (obj_elf_sharable_common): New. + (elf_pseudo_table): Add "sharable_common". + (obj_elf_change_section): Handle sharable sections. + +include/ + +2007-01-23 H.J. Lu + + * bfdlink.h (bfd_link_info): Add sharable_sections. + +include/elf/ + +2007-01-04 H.J. Lu + + * common.h (PT_GNU_SHR): New. + (SHF_GNU_SHARABLE): Likewise. + (SHN_GNU_SHARABLE_COMMON): Likewise. + +ld/ + +2011-01-08 H.J. Lu + + * emulparams/elf32_x86_64.sh (SHARABLE_SECTIONS): Set to yes. + +2007-01-04 H.J. Lu + + * emulparams/elf64_ia64.sh (SHARABLE_SECTIONS): Set to yes. + * emulparams/elf_i386.sh (SHARABLE_SECTIONS): Likewise. + * emulparams/elf_x86_64.sh (SHARABLE_SECTIONS): Likewise. + + * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Set + link_info.sharable_sections based on $SHARABLE_SECTIONS. + (gld${EMULATION_NAME}_place_orphan): Don't allow orphaned + sharable sections. + + * ldmain.c (main): Initialize link_info.sharable_sections. + * scripttempl/elf.sc: Support sharable sections. + +diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h +index 21ec38f..6478a78 100644 +--- a/bfd/elf-bfd.h ++++ b/bfd/elf-bfd.h +@@ -2092,6 +2092,28 @@ extern bfd_boolean bfd_elf_link_add_symbols + (bfd *, struct bfd_link_info *); + extern bfd_boolean _bfd_elf_add_dynamic_entry + (struct bfd_link_info *, bfd_vma, bfd_vma); ++extern asection _bfd_elf_sharable_com_section; ++extern bfd_boolean _bfd_elf_add_sharable_symbol ++ (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, ++ flagword *, asection **, bfd_vma *); ++extern bfd_boolean _bfd_elf_sharable_section_from_bfd_section ++ (bfd *, asection *, int *); ++extern void _bfd_elf_sharable_symbol_processing ++ (bfd *, asymbol *); ++extern bfd_boolean _bfd_elf_sharable_common_definition ++ (Elf_Internal_Sym *); ++extern unsigned int _bfd_elf_sharable_common_section_index ++ (asection *); ++extern asection *_bfd_elf_sharable_common_section ++ (asection *); ++extern bfd_boolean _bfd_elf_sharable_merge_symbol ++ (struct bfd_link_info *, struct elf_link_hash_entry **, ++ struct elf_link_hash_entry *, Elf_Internal_Sym *, asection **, ++ bfd_vma *, unsigned int *, bfd_boolean *, bfd_boolean *, ++ bfd_boolean *, bfd_boolean *, bfd_boolean *, bfd_boolean *, ++ bfd_boolean *, bfd_boolean *, bfd *, asection **, ++ bfd_boolean *, bfd_boolean *, bfd_boolean *, bfd_boolean *, ++ bfd *, asection **); + + extern bfd_boolean bfd_elf_link_record_dynamic_symbol + (struct bfd_link_info *, struct elf_link_hash_entry *); +diff --git a/bfd/elf.c b/bfd/elf.c +index f69abf2..c1c76fe 100644 +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -2090,6 +2090,8 @@ static const struct bfd_elf_special_section special_sections_g[] = + { STRING_COMMA_LEN (".gnu.liblist"), 0, SHT_GNU_LIBLIST, SHF_ALLOC }, + { STRING_COMMA_LEN (".gnu.conflict"), 0, SHT_RELA, SHF_ALLOC }, + { STRING_COMMA_LEN (".gnu.hash"), 0, SHT_GNU_HASH, SHF_ALLOC }, ++ { STRING_COMMA_LEN (".gnu.linkonce.shrb"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_GNU_SHARABLE}, ++ { STRING_COMMA_LEN (".gnu.linkonce.shrd"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_GNU_SHARABLE}, + { NULL, 0, 0, 0, 0 } + }; + +@@ -2144,6 +2146,8 @@ static const struct bfd_elf_special_section special_sections_s[] = + /* See struct bfd_elf_special_section declaration for the semantics of + this special case where .prefix_length != strlen (.prefix). */ + { ".stabstr", 5, 3, SHT_STRTAB, 0 }, ++ { STRING_COMMA_LEN (".sharable_bss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_GNU_SHARABLE}, ++ { STRING_COMMA_LEN (".sharable_data"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_GNU_SHARABLE}, + { NULL, 0, 0, 0, 0 } + }; + +@@ -3589,6 +3593,32 @@ get_program_header_size (bfd *abfd, struct bfd_link_info *info) + } + } + ++ /* Check to see if we need a PT_GNU_SHR segment for sharable data ++ sections. */ ++ for (s = abfd->sections; s != NULL; s = s->next) ++ { ++ if ((elf_section_flags (s) & SHF_GNU_SHARABLE) != 0 ++ && elf_section_type (s) == SHT_PROGBITS) ++ { ++ /* We need a PT_GNU_SHR segment. */ ++ ++segs; ++ break; ++ } ++ } ++ ++ /* Check to see if we need a PT_GNU_SHR segment for sharable bss ++ sections. */ ++ for (s = abfd->sections; s != NULL; s = s->next) ++ { ++ if ((elf_section_flags (s) & SHF_GNU_SHARABLE) != 0 ++ && elf_section_type (s) == SHT_NOBITS) ++ { ++ /* We need a PT_GNU_SHR segment. */ ++ ++segs; ++ break; ++ } ++ } ++ + /* Let the backend count up any program headers it might need. */ + bed = get_elf_backend_data (abfd); + if (bed->elf_backend_additional_program_headers) +@@ -3756,6 +3786,8 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) + bfd_boolean phdr_in_segment = TRUE; + bfd_boolean writable; + int tls_count = 0; ++ int sharable_data_count = 0, sharable_bss_count = 0; ++ asection *first_sharable_data = NULL, *first_sharable_bss = NULL; + asection *first_tls = NULL; + asection *dynsec, *eh_frame_hdr; + bfd_size_type amt; +@@ -4059,6 +4091,22 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) + first_tls = s; + tls_count++; + } ++ if (elf_section_flags (s) & SHF_GNU_SHARABLE) ++ { ++ if (elf_section_type (s) == SHT_PROGBITS) ++ { ++ if (! sharable_data_count) ++ first_sharable_data = s; ++ sharable_data_count++; ++ } ++ else ++ { ++ BFD_ASSERT (elf_section_type (s) == SHT_NOBITS); ++ if (! sharable_bss_count) ++ first_sharable_bss = s; ++ sharable_bss_count++; ++ } ++ } + } + + /* If there are any SHF_TLS output sections, add PT_TLS segment. */ +@@ -4086,6 +4134,60 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) + pm = &m->next; + } + ++ /* If there are any output SHF_GNU_SHARABLE data sections, add a ++ PT_GNU_SHR segment. */ ++ if (sharable_data_count > 0) ++ { ++ int j; ++ ++ amt = sizeof (struct elf_segment_map); ++ amt += (sharable_data_count - 1) * sizeof (asection *); ++ m = bfd_zalloc (abfd, amt); ++ if (m == NULL) ++ goto error_return; ++ m->next = NULL; ++ m->p_type = PT_GNU_SHR; ++ m->count = sharable_data_count; ++ /* Mandated PF_R. */ ++ m->p_flags = PF_R; ++ m->p_flags_valid = 1; ++ for (j = 0; j < sharable_data_count; ++j) ++ { ++ m->sections[j] = first_sharable_data; ++ first_sharable_data = first_sharable_data->next; ++ } ++ ++ *pm = m; ++ pm = &m->next; ++ } ++ ++ /* If there are any output SHF_GNU_SHARABLE bss sections, add a ++ PT_GNU_SHR segment. */ ++ if (sharable_bss_count > 0) ++ { ++ int j; ++ ++ amt = sizeof (struct elf_segment_map); ++ amt += (sharable_bss_count - 1) * sizeof (asection *); ++ m = bfd_zalloc (abfd, amt); ++ if (m == NULL) ++ goto error_return; ++ m->next = NULL; ++ m->p_type = PT_GNU_SHR; ++ m->count = sharable_bss_count; ++ /* Mandated PF_R. */ ++ m->p_flags = PF_R; ++ m->p_flags_valid = 1; ++ for (j = 0; j < sharable_bss_count; ++j) ++ { ++ m->sections[j] = first_sharable_bss; ++ first_sharable_bss = first_sharable_bss->next; ++ } ++ ++ *pm = m; ++ pm = &m->next; ++ } ++ + /* If there is a .eh_frame_hdr section, throw in a PT_GNU_EH_FRAME + segment. */ + eh_frame_hdr = elf_tdata (abfd)->eh_frame_hdr; +@@ -4616,6 +4718,7 @@ assign_file_positions_for_load_sections (bfd *abfd, + align = (bfd_size_type) 1 << bfd_get_section_alignment (abfd, sec); + + if ((p->p_type == PT_LOAD ++ || p->p_type == PT_GNU_SHR + || p->p_type == PT_TLS) + && (this_hdr->sh_type != SHT_NOBITS + || ((this_hdr->sh_flags & SHF_ALLOC) != 0 +diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c +index 693c8e8..3a537b8 100644 +--- a/bfd/elf32-i386.c ++++ b/bfd/elf32-i386.c +@@ -686,6 +686,9 @@ struct elf_i386_link_hash_table + + /* Value used to fill the last word of the first plt entry. */ + bfd_byte plt0_pad_byte; ++ ++ asection *sdynsharablebss; ++ asection *srelsharablebss; + }; + + /* Get the i386 ELF linker hash table from a link_info structure. */ +@@ -827,6 +830,8 @@ elf_i386_link_hash_table_create (bfd *abfd) + ret->srelplt2 = NULL; + ret->plt0_pad_byte = 0; + ret->tls_module_base = NULL; ++ ret->sdynsharablebss = NULL; ++ ret->srelsharablebss = NULL; + + ret->loc_hash_table = htab_try_create (1024, + elf_i386_local_htab_hash, +@@ -875,10 +880,19 @@ elf_i386_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) + + htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); + if (!info->shared) +- htab->srelbss = bfd_get_section_by_name (dynobj, ".rel.bss"); ++ { ++ htab->srelbss = bfd_get_section_by_name (dynobj, ".rel.bss"); ++ htab->sdynsharablebss ++ = bfd_get_section_by_name (dynobj, ".dynsharablebss"); ++ htab->srelsharablebss ++ = bfd_get_section_by_name (dynobj, ".rel.sharable_bss"); ++ } + + if (!htab->sdynbss +- || (!info->shared && !htab->srelbss)) ++ || (!info->shared ++ && (!htab->srelbss ++ || !htab->sdynsharablebss ++ || !htab->srelsharablebss))) + abort (); + + if (htab->is_vxworks +@@ -2052,17 +2066,23 @@ elf_i386_adjust_dynamic_symbol (struct bfd_link_info *info, + both the dynamic object and the regular object will refer to the + same memory location for the variable. */ + ++ s = htab->sdynbss; ++ + /* We must generate a R_386_COPY reloc to tell the dynamic linker to + copy the initial value out of the dynamic object and into the + runtime process image. */ + if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) + { +- htab->srelbss->size += sizeof (Elf32_External_Rel); ++ if (elf_section_flags (h->root.u.def.section) & SHF_GNU_SHARABLE) ++ { ++ htab->srelsharablebss->size += sizeof (Elf32_External_Rel); ++ s = htab->sdynsharablebss; ++ } ++ else ++ htab->srelbss->size += sizeof (Elf32_External_Rel); + h->needs_copy = 1; + } + +- s = htab->sdynbss; +- + return _bfd_elf_adjust_dynamic_copy (h, s); + } + +@@ -2600,6 +2620,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, + || s == htab->elf.sgotplt + || s == htab->elf.iplt + || s == htab->elf.igotplt ++ || s == htab->sdynsharablebss + || s == htab->sdynbss) + { + /* Strip this section if we don't need it; see the +@@ -4392,21 +4413,27 @@ do_glob_dat: + { + Elf_Internal_Rela rel; + bfd_byte *loc; ++ asection *s; ++ ++ if (h->root.u.def.section == htab->sdynsharablebss) ++ s = htab->srelsharablebss; ++ else ++ s = htab->srelbss; + + /* This symbol needs a copy reloc. Set it up. */ + + if (h->dynindx == -1 + || (h->root.type != bfd_link_hash_defined + && h->root.type != bfd_link_hash_defweak) +- || htab->srelbss == NULL) ++ || s == NULL) + abort (); + + rel.r_offset = (h->root.u.def.value + + h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset); + rel.r_info = ELF32_R_INFO (h->dynindx, R_386_COPY); +- loc = htab->srelbss->contents; +- loc += htab->srelbss->reloc_count++ * sizeof (Elf32_External_Rel); ++ loc = s->contents; ++ loc += s->reloc_count++ * sizeof (Elf32_External_Rel); + bfd_elf32_swap_reloc_out (output_bfd, &rel, loc); + } + +@@ -4702,7 +4729,8 @@ elf_i386_add_symbol_hook (bfd * abfd, + && ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) + elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; + +- return TRUE; ++ return _bfd_elf_add_sharable_symbol (abfd, info, sym, namep, flagsp, ++ secp, valp); + } + + #define TARGET_LITTLE_SYM bfd_elf32_i386_vec +@@ -4755,6 +4783,19 @@ elf_i386_add_symbol_hook (bfd * abfd, + #undef elf_backend_post_process_headers + #define elf_backend_post_process_headers _bfd_elf_set_osabi + ++#define elf_backend_section_from_bfd_section \ ++ _bfd_elf_sharable_section_from_bfd_section ++#define elf_backend_symbol_processing \ ++ _bfd_elf_sharable_symbol_processing ++#define elf_backend_common_section_index \ ++ _bfd_elf_sharable_common_section_index ++#define elf_backend_common_section \ ++ _bfd_elf_sharable_common_section ++#define elf_backend_common_definition \ ++ _bfd_elf_sharable_common_definition ++#define elf_backend_merge_symbol \ ++ _bfd_elf_sharable_merge_symbol ++ + #include "elf32-target.h" + + /* FreeBSD support. */ +diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c +index 927b3ed..d7c908d 100644 +--- a/bfd/elf64-x86-64.c ++++ b/bfd/elf64-x86-64.c +@@ -514,6 +514,9 @@ struct elf_x86_64_link_hash_table + /* The offset into sgot of the GOT entry used by the PLT entry + above. */ + bfd_vma tlsdesc_got; ++ ++ asection *sdynsharablebss; ++ asection *srelsharablebss; + }; + + /* Get the x86-64 ELF linker hash table from a link_info structure. */ +@@ -654,6 +657,8 @@ elf_x86_64_link_hash_table_create (bfd *abfd) + ret->tls_ld_got.refcount = 0; + ret->sgotplt_jump_table_size = 0; + ret->tls_module_base = NULL; ++ ret->sdynsharablebss = NULL; ++ ret->srelsharablebss = NULL; + + if (ABI_64_P (abfd)) + { +@@ -720,10 +725,19 @@ elf_x86_64_create_dynamic_sections (bfd *dynobj, + + htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); + if (!info->shared) +- htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss"); ++ { ++ htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss"); ++ htab->sdynsharablebss ++ = bfd_get_section_by_name (dynobj, ".dynsharablebss"); ++ htab->srelsharablebss ++ = bfd_get_section_by_name (dynobj, ".rela.sharable_bss"); ++ } + + if (!htab->sdynbss +- || (!info->shared && !htab->srelbss)) ++ || (!info->shared ++ && (!htab->srelbss ++ || !htab->sdynsharablebss ++ || !htab->srelsharablebss))) + abort (); + + return TRUE; +@@ -1998,6 +2012,8 @@ elf_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info, + if (htab == NULL) + return FALSE; + ++ s = htab->sdynbss; ++ + /* We must generate a R_X86_64_COPY reloc to tell the dynamic linker + to copy the initial value out of the dynamic object and into the + runtime process image. */ +@@ -2005,12 +2021,16 @@ elf_x86_64_adjust_dynamic_symbol (struct bfd_link_info *info, + { + const struct elf_backend_data *bed; + bed = get_elf_backend_data (info->output_bfd); +- htab->srelbss->size += bed->s->sizeof_rela; ++ if (elf_section_flags (h->root.u.def.section) & SHF_GNU_SHARABLE) ++ { ++ htab->srelsharablebss->size += bed->s->sizeof_rela; ++ s = htab->sdynsharablebss; ++ } ++ else ++ htab->srelbss->size += bed->s->sizeof_rela; + h->needs_copy = 1; + } + +- s = htab->sdynbss; +- + return _bfd_elf_adjust_dynamic_copy (h, s); + } + +@@ -2531,6 +2551,7 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd, + || s == htab->elf.sgotplt + || s == htab->elf.iplt + || s == htab->elf.igotplt ++ || s == htab->sdynsharablebss + || s == htab->sdynbss) + { + /* Strip this section if we don't need it; see the +@@ -4132,13 +4153,19 @@ do_glob_dat: + if (h->needs_copy) + { + Elf_Internal_Rela rela; ++ asection *s; ++ ++ if (h->root.u.def.section == htab->sdynsharablebss) ++ s = htab->srelsharablebss; ++ else ++ s = htab->srelbss; + + /* This symbol needs a copy reloc. Set it up. */ + + if (h->dynindx == -1 + || (h->root.type != bfd_link_hash_defined + && h->root.type != bfd_link_hash_defweak) +- || htab->srelbss == NULL) ++ || s == NULL) + abort (); + + rela.r_offset = (h->root.u.def.value +@@ -4146,7 +4173,7 @@ do_glob_dat: + + h->root.u.def.section->output_offset); + rela.r_info = htab->r_info (h->dynindx, R_X86_64_COPY); + rela.r_addend = 0; +- elf_append_rela (output_bfd, htab->srelbss, &rela); ++ elf_append_rela (output_bfd, s, &rela); + } + + /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. SYM may +@@ -4454,7 +4481,8 @@ elf_x86_64_add_symbol_hook (bfd *abfd, + && ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) + elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; + +- return TRUE; ++ return _bfd_elf_add_sharable_symbol (abfd, info, sym, namep, flagsp, ++ secp, valp); + } + + +@@ -4470,7 +4498,8 @@ elf_x86_64_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED, + *index_return = SHN_X86_64_LCOMMON; + return TRUE; + } +- return FALSE; ++ return _bfd_elf_sharable_section_from_bfd_section (abfd, sec, ++ index_return); + } + + /* Process a symbol. */ +@@ -4488,22 +4517,26 @@ elf_x86_64_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, + asym->value = elfsym->internal_elf_sym.st_size; + /* Common symbol doesn't set BSF_GLOBAL. */ + asym->flags &= ~BSF_GLOBAL; ++ return; + break; + } ++ ++ _bfd_elf_sharable_symbol_processing (abfd, asym); + } + + static bfd_boolean + elf_x86_64_common_definition (Elf_Internal_Sym *sym) + { + return (sym->st_shndx == SHN_COMMON +- || sym->st_shndx == SHN_X86_64_LCOMMON); ++ || sym->st_shndx == SHN_X86_64_LCOMMON ++ || _bfd_elf_sharable_common_definition (sym)); + } + + static unsigned int + elf_x86_64_common_section_index (asection *sec) + { + if ((elf_section_flags (sec) & SHF_X86_64_LARGE) == 0) +- return SHN_COMMON; ++ return _bfd_elf_sharable_common_section_index (sec); + else + return SHN_X86_64_LCOMMON; + } +@@ -4512,7 +4545,7 @@ static asection * + elf_x86_64_common_section (asection *sec) + { + if ((elf_section_flags (sec) & SHF_X86_64_LARGE) == 0) +- return bfd_com_section_ptr; ++ return _bfd_elf_sharable_common_section (sec); + else + return &_bfd_elf_large_com_section; + } +@@ -4549,7 +4582,8 @@ elf_x86_64_merge_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED, + && h->root.type == bfd_link_hash_common + && !*newdyn + && bfd_is_com_section (*sec) +- && *oldsec != *sec) ++ && *oldsec != *sec ++ && _bfd_elf_sharable_common_section_index (*oldsec) == SHN_COMMON) + { + if (sym->st_shndx == SHN_COMMON + && (elf_section_flags (*oldsec) & SHF_X86_64_LARGE) != 0) +@@ -4557,13 +4591,26 @@ elf_x86_64_merge_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED, + h->root.u.c.p->section + = bfd_make_section_old_way (oldbfd, "COMMON"); + h->root.u.c.p->section->flags = SEC_ALLOC; ++ return TRUE; + } + else if (sym->st_shndx == SHN_X86_64_LCOMMON + && (elf_section_flags (*oldsec) & SHF_X86_64_LARGE) == 0) +- *psec = *sec = bfd_com_section_ptr; ++ { ++ *psec = *sec = bfd_com_section_ptr; ++ return TRUE; ++ } + } + +- return TRUE; ++ return _bfd_elf_sharable_merge_symbol (info, sym_hash, h, sym, ++ psec, pvalue, pold_alignment, ++ skip, override, ++ type_change_ok, size_change_ok, ++ newdyn, newdef, ++ newdyncommon, newweak, ++ abfd, sec, ++ olddyn, olddef, ++ olddyncommon, oldweak, ++ oldbfd, oldsec); + } + + static int +diff --git a/bfd/elflink.c b/bfd/elflink.c +index 9ccc841..f48fbbe 100644 +--- a/bfd/elflink.c ++++ b/bfd/elflink.c +@@ -383,6 +383,27 @@ _bfd_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) + if (s == NULL + || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) + return FALSE; ++ ++ if (info->sharable_sections) ++ { ++ s = bfd_make_section (abfd, ".dynsharablebss"); ++ if (s == NULL ++ || ! bfd_set_section_flags (abfd, s, ++ (SEC_ALLOC ++ | SEC_LINKER_CREATED))) ++ return FALSE; ++ ++ s = bfd_make_section (abfd, ++ (bed->default_use_rela_p ++ ? ".rela.sharable_bss" ++ : ".rel.sharable_bss")); ++ if (s == NULL ++ || ! bfd_set_section_flags (abfd, s, ++ flags | SEC_READONLY) ++ || ! bfd_set_section_alignment (abfd, s, ++ bed->s->log_file_align)) ++ return FALSE; ++ } + } + } + +@@ -12736,3 +12757,219 @@ elf_append_rel (bfd *abfd, asection *s, Elf_Internal_Rela *rel) + BFD_ASSERT (loc + bed->s->sizeof_rel <= s->contents + s->size); + bed->s->swap_reloca_out (abfd, rel, loc); + } ++ ++asection _bfd_elf_sharable_com_section ++ = BFD_FAKE_SECTION (_bfd_elf_sharable_com_section, SEC_IS_COMMON, ++ NULL, "SHARABLE_COMMON", 0); ++ ++static asection * ++get_sharable_common_section (bfd *abfd) ++{ ++ asection *scomm = bfd_get_section_by_name (abfd, "SHARABLE_COMMON"); ++ ++ if (scomm == NULL) ++ { ++ scomm = bfd_make_section_with_flags (abfd, ++ "SHARABLE_COMMON", ++ (SEC_ALLOC ++ | SEC_IS_COMMON ++ | SEC_LINKER_CREATED)); ++ if (scomm == NULL) ++ return scomm; ++ elf_section_flags (scomm) |= SHF_GNU_SHARABLE; ++ } ++ ++ return scomm; ++} ++ ++bfd_boolean ++_bfd_elf_add_sharable_symbol (bfd *abfd ATTRIBUTE_UNUSED, ++ struct bfd_link_info *info ATTRIBUTE_UNUSED, ++ Elf_Internal_Sym *sym, ++ const char **namep ATTRIBUTE_UNUSED, ++ flagword *flagsp ATTRIBUTE_UNUSED, ++ asection **secp, ++ bfd_vma *valp) ++{ ++ asection *scomm; ++ ++ switch (sym->st_shndx) ++ { ++ case SHN_GNU_SHARABLE_COMMON: ++ scomm = get_sharable_common_section (abfd); ++ if (scomm == NULL) ++ return FALSE; ++ *secp = scomm; ++ *valp = sym->st_size; ++ break; ++ } ++ return TRUE; ++} ++ ++bfd_boolean ++_bfd_elf_sharable_section_from_bfd_section ++ (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, int *index_return) ++{ ++ if (sec == &_bfd_elf_sharable_com_section) ++ { ++ *index_return = SHN_GNU_SHARABLE_COMMON; ++ return TRUE; ++ } ++ return FALSE; ++} ++ ++void ++_bfd_elf_sharable_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, ++ asymbol *asym) ++{ ++ elf_symbol_type *elfsym = (elf_symbol_type *) asym; ++ ++ switch (elfsym->internal_elf_sym.st_shndx) ++ { ++ case SHN_GNU_SHARABLE_COMMON: ++ asym->section = &_bfd_elf_sharable_com_section; ++ asym->value = elfsym->internal_elf_sym.st_size; ++ asym->flags &= ~BSF_GLOBAL; ++ break; ++ } ++} ++ ++bfd_boolean ++_bfd_elf_sharable_common_definition (Elf_Internal_Sym *sym) ++{ ++ return (sym->st_shndx == SHN_COMMON ++ || sym->st_shndx == SHN_GNU_SHARABLE_COMMON); ++} ++ ++unsigned int ++_bfd_elf_sharable_common_section_index (asection *sec) ++{ ++ if ((elf_section_flags (sec) & SHF_GNU_SHARABLE) == 0) ++ return SHN_COMMON; ++ else ++ return SHN_GNU_SHARABLE_COMMON; ++} ++ ++asection * ++_bfd_elf_sharable_common_section (asection *sec) ++{ ++ if ((elf_section_flags (sec) & SHF_GNU_SHARABLE) == 0) ++ return bfd_com_section_ptr; ++ else ++ return &_bfd_elf_sharable_com_section; ++} ++ ++bfd_boolean ++_bfd_elf_sharable_merge_symbol ++ (struct bfd_link_info *info ATTRIBUTE_UNUSED, ++ struct elf_link_hash_entry **sym_hash ATTRIBUTE_UNUSED, ++ struct elf_link_hash_entry *h, ++ Elf_Internal_Sym *sym ATTRIBUTE_UNUSED, ++ asection **psec, ++ bfd_vma *pvalue ATTRIBUTE_UNUSED, ++ unsigned int *pold_alignment ATTRIBUTE_UNUSED, ++ bfd_boolean *skip ATTRIBUTE_UNUSED, ++ bfd_boolean *override ATTRIBUTE_UNUSED, ++ bfd_boolean *type_change_ok ATTRIBUTE_UNUSED, ++ bfd_boolean *size_change_ok ATTRIBUTE_UNUSED, ++ bfd_boolean *newdef ATTRIBUTE_UNUSED, ++ bfd_boolean *newdyn, ++ bfd_boolean *newdyncommon ATTRIBUTE_UNUSED, ++ bfd_boolean *newweak ATTRIBUTE_UNUSED, ++ bfd *abfd, ++ asection **sec, ++ bfd_boolean *olddef ATTRIBUTE_UNUSED, ++ bfd_boolean *olddyn, ++ bfd_boolean *olddyncommon ATTRIBUTE_UNUSED, ++ bfd_boolean *oldweak ATTRIBUTE_UNUSED, ++ bfd *oldbfd, ++ asection **oldsec) ++{ ++ /* Check sharable symbol. If one is undefined, it is OK. */ ++ if (*oldsec && !bfd_is_und_section (*sec)) ++ { ++ bfd_boolean sharable, oldsharable; ++ ++ sharable = (elf_section_data (*sec) ++ && (elf_section_flags (*sec) & SHF_GNU_SHARABLE)); ++ oldsharable = (elf_section_data (*oldsec) ++ && (elf_section_flags (*oldsec) ++ & SHF_GNU_SHARABLE)); ++ ++ if (sharable != oldsharable) ++ { ++ bfd *nsbfd, *sbfd; ++ asection *nssec, *ssec; ++ bfd_boolean nsdyn, sdyn, nsdef, sdef; ++ ++ if (oldsharable) ++ { ++ sbfd = oldbfd; ++ nsbfd = abfd; ++ ssec = *oldsec; ++ nssec = *sec; ++ sdyn = *olddyn; ++ nsdyn = *newdyn; ++ sdef = *olddef; ++ nsdef = *newdef; ++ } ++ else ++ { ++ sbfd = abfd; ++ nsbfd = oldbfd; ++ ssec = *sec; ++ nssec = *oldsec; ++ sdyn = *newdyn; ++ nsdyn = *olddyn; ++ sdef = *newdef; ++ nsdef = *olddef; ++ } ++ ++ if (sdef && !sdyn) ++ { ++ /* If the sharable definition comes from a relocatable ++ file, it will override the non-sharable one in DSO. */ ++ return TRUE; ++ } ++ else if (!nsdef ++ && !nsdyn ++ && (h->root.type == bfd_link_hash_common ++ || bfd_is_com_section (nssec))) ++ { ++ asection *scomm; ++ ++ /* When the non-sharable common symbol in a relocatable ++ file, we can turn it into sharable. If the sharable ++ symbol isn't common, the non-sharable common symbol ++ will be overidden. We only need to handle the ++ sharable common symbol and the non-sharable common ++ symbol. We just turn the non-sharable common symbol ++ into the sharable one. */ ++ if (sym->st_shndx == SHN_GNU_SHARABLE_COMMON) ++ { ++ scomm = get_sharable_common_section (oldbfd); ++ if (scomm == NULL) ++ return FALSE; ++ h->root.u.c.p->section = scomm; ++ } ++ else ++ { ++ scomm = get_sharable_common_section (abfd); ++ if (scomm == NULL) ++ return FALSE; ++ *psec = *sec = scomm; ++ } ++ ++ return TRUE; ++ } ++ ++ (*_bfd_error_handler) ++ (_("%s: sharable symbol in %B section %A mismatches non-shrable symbol in %B section %A"), ++ sbfd, ssec, nsbfd, nssec, h->root.root.string); ++ bfd_set_error (bfd_error_bad_value); ++ return FALSE; ++ } ++ } ++ ++ return TRUE; ++} +diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c +index bd73d28..80f6219 100644 +--- a/bfd/elfxx-ia64.c ++++ b/bfd/elfxx-ia64.c +@@ -1577,7 +1577,8 @@ elfNN_ia64_add_symbol_hook (bfd *abfd, + *valp = sym->st_size; + } + +- return TRUE; ++ return _bfd_elf_add_sharable_symbol (abfd, info, sym, namep, flagsp, ++ secp, valp); + } + + /* Return the number of additional phdrs we will need. */ +@@ -6069,6 +6070,19 @@ elfNN_vms_close_and_cleanup (bfd *abfd) + #define elf_backend_special_sections elfNN_ia64_special_sections + #define elf_backend_default_execstack 0 + ++#define elf_backend_section_from_bfd_section \ ++ _bfd_elf_sharable_section_from_bfd_section ++#define elf_backend_symbol_processing \ ++ _bfd_elf_sharable_symbol_processing ++#define elf_backend_common_section_index \ ++ _bfd_elf_sharable_common_section_index ++#define elf_backend_common_section \ ++ _bfd_elf_sharable_common_section ++#define elf_backend_common_definition \ ++ _bfd_elf_sharable_common_definition ++#define elf_backend_merge_symbol \ ++ _bfd_elf_sharable_merge_symbol ++ + /* FIXME: PR 290: The Intel C compiler generates SHT_IA_64_UNWIND with + SHF_LINK_ORDER. But it doesn't set the sh_link or sh_info fields. + We don't want to flood users with so many error messages. We turn +diff --git a/binutils/readelf.c b/binutils/readelf.c +index c975189..f8c6bb3 100644 +--- a/binutils/readelf.c ++++ b/binutils/readelf.c +@@ -1304,6 +1304,8 @@ dump_relocations (FILE * file, + sec_name = "ABS"; + else if (psym->st_shndx == SHN_COMMON) + sec_name = "COMMON"; ++ else if (psym->st_shndx == SHN_GNU_SHARABLE_COMMON) ++ sec_name = "GNU_SHARABLE_COMMON"; + else if ((elf_header.e_machine == EM_MIPS + && psym->st_shndx == SHN_MIPS_SCOMMON) + || (elf_header.e_machine == EM_TI_C6000 +@@ -2756,6 +2758,7 @@ get_segment_type (unsigned long p_type) + case PT_SHLIB: return "SHLIB"; + case PT_PHDR: return "PHDR"; + case PT_TLS: return "TLS"; ++ case PT_GNU_SHR: return "GNU_SHR"; + + case PT_GNU_EH_FRAME: + return "GNU_EH_FRAME"; +@@ -8475,6 +8478,8 @@ get_symbol_index_type (unsigned int type) + case SHN_UNDEF: return "UND"; + case SHN_ABS: return "ABS"; + case SHN_COMMON: return "COM"; ++ case SHN_GNU_SHARABLE_COMMON: ++ return "GNU_SHARABLE_COM"; + default: + if (type == SHN_IA_64_ANSI_COMMON + && elf_header.e_machine == EM_IA_64 +diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c +index 30eb816..ae3339c 100644 +--- a/gas/config/obj-elf.c ++++ b/gas/config/obj-elf.c +@@ -73,6 +73,7 @@ static void obj_elf_symver (int); + static void obj_elf_subsection (int); + static void obj_elf_popsection (int); + static void obj_elf_tls_common (int); ++static void obj_elf_sharable_common (int); + static void obj_elf_lcomm (int); + static void obj_elf_struct (int); + +@@ -130,6 +131,8 @@ static const pseudo_typeS elf_pseudo_table[] = + + {"tls_common", obj_elf_tls_common, 0}, + ++ {"sharable_common", obj_elf_sharable_common, 0}, ++ + /* End sentinel. */ + {NULL, NULL, 0}, + }; +@@ -385,6 +388,39 @@ obj_elf_tls_common (int ignore ATTRIBUTE_UNUSED) + } + + static void ++obj_elf_sharable_common (int ignore ATTRIBUTE_UNUSED) ++{ ++ static segT sharable_bss_section; ++ asection *saved_com_section_ptr = elf_com_section_ptr; ++ asection *saved_bss_section = bss_section; ++ ++ if (sharable_bss_section == NULL) ++ { ++ flagword applicable; ++ segT seg = now_seg; ++ subsegT subseg = now_subseg; ++ ++ /* The .sharable_bss section is for local .sharable_common ++ symbols. */ ++ sharable_bss_section = subseg_new (".sharable_bss", 0); ++ applicable = bfd_applicable_section_flags (stdoutput); ++ bfd_set_section_flags (stdoutput, sharable_bss_section, ++ applicable & SEC_ALLOC); ++ seg_info (sharable_bss_section)->bss = 1; ++ ++ subseg_set (seg, subseg); ++ } ++ ++ elf_com_section_ptr = &_bfd_elf_sharable_com_section; ++ bss_section = sharable_bss_section; ++ ++ s_comm_internal (0, elf_common_parse); ++ ++ elf_com_section_ptr = saved_com_section_ptr; ++ bss_section = saved_bss_section; ++} ++ ++static void + obj_elf_lcomm (int ignore ATTRIBUTE_UNUSED) + { + symbolS *symbolP = s_comm_internal (0, s_lcomm_internal); +@@ -604,11 +640,17 @@ obj_elf_change_section (const char *name, + + .section .lbss,"aw",@progbits + ++ "@progbits" is incorrect. Also for sharable bss ++ sections, gcc, as of 2005-07-06, will emit ++ ++ .section .sharable_bss,"aw",@progbits ++ + "@progbits" is incorrect. */ + #ifdef TC_I386 + && (bed->s->arch_size != 64 + || !(ssect->attr & SHF_X86_64_LARGE)) + #endif ++ && !(ssect->attr & SHF_GNU_SHARABLE) + && ssect->type != SHT_INIT_ARRAY + && ssect->type != SHT_FINI_ARRAY + && ssect->type != SHT_PREINIT_ARRAY) +diff --git a/include/bfdlink.h b/include/bfdlink.h +index 0d6e9f8..d3c13f6 100644 +--- a/include/bfdlink.h ++++ b/include/bfdlink.h +@@ -354,6 +354,9 @@ struct bfd_link_info + /* Non-NULL if .note.gnu.build-id section should be created. */ + char *emit_note_gnu_build_id; + ++ /* TRUE if sharables sections may be created. */ ++ unsigned int sharable_sections: 1; ++ + /* What to do with unresolved symbols in an object file. + When producing executables the default is GENERATE_ERROR. + When producing shared libraries the default is IGNORE. The +diff --git a/include/elf/common.h b/include/elf/common.h +index 52ce9a5..babcd29 100644 +--- a/include/elf/common.h ++++ b/include/elf/common.h +@@ -429,6 +429,7 @@ + #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME /* Solaris uses the same value */ + #define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */ + #define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */ ++#define PT_GNU_SHR (PT_LOOS + 0x474e554) /* Sharable segment */ + + /* Program segment permissions, in program header p_flags field. */ + +@@ -511,6 +512,8 @@ + are not to be further + relocated. */ + ++#define SHF_GNU_SHARABLE 0x01000000 /* sharable section */ ++ + /* Values of note segment descriptor types for core files. */ + + #define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ +@@ -657,6 +660,9 @@ + #define STT_LOPROC 13 /* Processor-specific semantics */ + #define STT_HIPROC 15 /* Processor-specific semantics */ + ++/* Associated symbol is in common sharable */ ++#define SHN_GNU_SHARABLE_COMMON (SHN_LOOS + 10) ++ + /* The following constants control how a symbol may be accessed once it has + become part of an executable or shared library. */ + +diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh +index 8895e29..8bbccd4 100644 +--- a/ld/emulparams/elf32_x86_64.sh ++++ b/ld/emulparams/elf32_x86_64.sh +@@ -15,6 +15,7 @@ NO_SMALL_DATA=yes + LARGE_SECTIONS=yes + SEPARATE_GOTPLT=24 + IREL_IN_PLT= ++SHARABLE_SECTIONS=yes + + if [ "x${host}" = "x${target}" ]; then + case " $EMULATION_LIBPATH " in +diff --git a/ld/emulparams/elf64_ia64.sh b/ld/emulparams/elf64_ia64.sh +index 7e5e54d..d8cf531 100644 +--- a/ld/emulparams/elf64_ia64.sh ++++ b/ld/emulparams/elf64_ia64.sh +@@ -37,3 +37,4 @@ OTHER_READONLY_SECTIONS="${OTHER_READONLY_SECTIONS} + # .dtors. They have to be next to .sbss/.sbss2/.sdata/.sdata2. + SMALL_DATA_CTOR=" " + SMALL_DATA_DTOR=" " ++SHARABLE_SECTIONS=yes +diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh +index d480811..8268106 100644 +--- a/ld/emulparams/elf_i386.sh ++++ b/ld/emulparams/elf_i386.sh +@@ -13,3 +13,4 @@ GENERATE_PIE_SCRIPT=yes + NO_SMALL_DATA=yes + SEPARATE_GOTPLT=12 + IREL_IN_PLT= ++SHARABLE_SECTIONS=yes +diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh +index 0e93ad8..c82d6c9 100644 +--- a/ld/emulparams/elf_x86_64.sh ++++ b/ld/emulparams/elf_x86_64.sh +@@ -15,6 +15,7 @@ NO_SMALL_DATA=yes + LARGE_SECTIONS=yes + SEPARATE_GOTPLT=24 + IREL_IN_PLT= ++SHARABLE_SECTIONS=yes + + if [ "x${host}" = "x${target}" ]; then + case " $EMULATION_LIBPATH " in +diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em +index 17fb8bf..bfef7a3 100644 +--- a/ld/emultempl/elf32.em ++++ b/ld/emultempl/elf32.em +@@ -104,6 +104,7 @@ gld${EMULATION_NAME}_before_parse (void) + ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`); + config.dynamic_link = ${DYNAMIC_LINK-TRUE}; + config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`; ++ link_info.sharable_sections = `if test "$SHARABLE_SECTIONS" = "yes" ; then echo TRUE ; else echo FALSE ; fi`; + } + + EOF +@@ -1813,6 +1814,12 @@ gld${EMULATION_NAME}_place_orphan (asection *s, + int iself = s->owner->xvec->flavour == bfd_target_elf_flavour; + unsigned int sh_type = iself ? elf_section_type (s) : SHT_NULL; + ++ /* Orphaned sharable sections won't have correct page ++ requirements. */ ++ if (elf_section_flags (s) & SHF_GNU_SHARABLE) ++ einfo ("%F%P: unable to place orphaned sharable section %A (%B)\n", ++ s, s->owner); ++ + if (! link_info.relocatable + && link_info.combreloc + && (s->flags & SEC_ALLOC)) +diff --git a/ld/ldmain.c b/ld/ldmain.c +index 005a894..e6ebcfd 100644 +--- a/ld/ldmain.c ++++ b/ld/ldmain.c +@@ -281,6 +281,7 @@ main (int argc, char **argv) + link_info.pei386_auto_import = -1; + link_info.spare_dynamic_tags = 5; + link_info.path_separator = ':'; ++ link_info.sharable_sections = FALSE; + + ldfile_add_arch (""); + emulation = get_emulation (argc, argv); +diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc +index 4f298a1..10f5b70 100644 +--- a/ld/scripttempl/elf.sc ++++ b/ld/scripttempl/elf.sc +@@ -290,6 +290,40 @@ STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : + ${RELOCATING+${USER_LABEL_PREFIX}_stack = .;} + *(.stack) + }" ++test "${SHARABLE_SECTIONS}" = "yes" && OTHER_READWRITE_SECTIONS=" ++ ${OTHER_READWRITE_SECTIONS} ++ /* Sharable data sections. */ ++ .sharable_data ${RELOCATING-0} : ${RELOCATING+ALIGN(${MAXPAGESIZE})} ++ { ++ ${RELOCATING+PROVIDE_HIDDEN (__sharable_data_start = .);} ++ *(.sharable_data${RELOCATING+ .sharable_data.* .gnu.linkonce.shrd.*}) ++ /* Align here to ensure that the sharable data section ends at the ++ page boundary. */ ++ ${RELOCATING+. = ALIGN(. != 0 ? ${MAXPAGESIZE} : 1);} ++ ${RELOCATING+PROVIDE_HIDDEN (__sharable_data_end = .);} ++ } ++" ++test "${SHARABLE_SECTIONS}" = "yes" && OTHER_BSS_SECTIONS=" ++ ${OTHER_BSS_SECTIONS} ++ /* Sharable bss sections */ ++ .sharable_bss ${RELOCATING-0} : ${RELOCATING+ALIGN(${MAXPAGESIZE})} ++ { ++ ${RELOCATING+PROVIDE_HIDDEN (__sharable_bss_start = .);} ++ *(.dynsharablebss) ++ *(.sharable_bss${RELOCATING+ .sharable_bss.* .gnu.linkonce.shrb.*}) ++ *(SHARABLE_COMMON) ++ /* Align here to ensure that the sharable bss section ends at the ++ page boundary. */ ++ ${RELOCATING+. = ALIGN(. != 0 ? ${MAXPAGESIZE} : 1);} ++ ${RELOCATING+PROVIDE_HIDDEN (__sharable_bss_end = .);} ++ } ++" ++test "${SHARABLE_SECTIONS}" = "yes" && REL_SHARABLE=" ++ .rel.sharable_data ${RELOCATING-0} : { *(.rel.sharable_data${RELOCATING+ .rel.sharable_data.* .rel.gnu.linkonce.shrd.*}) } ++ .rela.sharable_data ${RELOCATING-0} : { *(.rela.sharable_data${RELOCATING+ .rela.sharable_data.* .rela.gnu.linkonce.shrd.*}) } ++ .rel.sharable_bss ${RELOCATING-0} : { *(.rel.sharable_bss${RELOCATING+ .rel.sharable_bss.* .rel.gnu.linkonce.shrb.*}) } ++ .rela.sharable_bss ${RELOCATING-0} : { *(.rela.sharable_bss${RELOCATING+ .rela.sharable_bss.* .rela.gnu.linkonce.shrb.*}) } ++" + + TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" + SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" +@@ -370,6 +404,7 @@ eval $COMBRELOCCAT < +Description: Only generate an RPATH entry if LD_RUN_PATH is not empty, for +cases where -rpath isn't specified. (#151024) +--- a/ld/emultempl/elf32.em ++++ b/ld/emultempl/elf32.em +@@ -1266,6 +1266,8 @@ + && command_line.rpath == NULL) + { + lib_path = (const char *) getenv ("LD_RUN_PATH"); ++ if ((lib_path) && (strlen (lib_path) == 0)) ++ lib_path = NULL; + if (gld${EMULATION_NAME}_search_needed (lib_path, &n, + force)) + break; +@@ -1493,6 +1495,8 @@ + rpath = command_line.rpath; + if (rpath == NULL) + rpath = (const char *) getenv ("LD_RUN_PATH"); ++ if ((rpath) && (strlen (rpath) == 0)) ++ rpath = NULL; + + for (abfd = link_info.input_bfds; abfd; abfd = abfd->link_next) + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) --- binutils-2.22.orig/debian/patches/211-hjl-binutils-weakdef.patch +++ binutils-2.22/debian/patches/211-hjl-binutils-weakdef.patch @@ -0,0 +1,105 @@ +Description: elflink.c (elf_link_add_object_symbols): Check symbol type +Description: for symbol alias in a dynamic object. +Author: H.J. Lu +Upstream status: hjl 2.19.51.0.3 +Original patch: binutils-weakdef-2.patch + +bfd/ + +2007-07-19 H.J. Lu + + * elflink.c (elf_link_add_object_symbols): Check symbol type + for symbol alias in a dynamic object. + +ld/testsuite/ + +2007-07-19 H.J. Lu + + * ld-elf/data2.c: New. + * ld-elf/weakdef1.c: Likewise. + + * ld-elf/shared.exp: Add tests for libdata2 and weakdef1. + +--- a/bfd/elflink.c ++++ b/bfd/elflink.c +@@ -4712,6 +4712,7 @@ + asection *slook; + bfd_vma vlook; + long ilook; ++ int tlook; + size_t i, j, idx; + + hlook = weaks; +@@ -4724,6 +4725,7 @@ + || hlook->root.type == bfd_link_hash_indirect); + slook = hlook->root.u.def.section; + vlook = hlook->root.u.def.value; ++ tlook = hlook->type; + + ilook = -1; + i = 0; +@@ -4761,9 +4763,10 @@ + { + h = sorted_sym_hash [i]; + +- /* Stop if value or section doesn't match. */ ++ /* Stop if value, section or type doesn't match. */ + if (h->root.u.def.value != vlook +- || h->root.u.def.section != slook) ++ || h->root.u.def.section != slook ++ || h->type != tlook) + break; + else if (h != hlook) + { +--- /dev/null ++++ b/ld/testsuite/ld-elf/data2.c +@@ -0,0 +1,9 @@ ++int foo = 0; ++extern int foo_alias __attribute__ ((weak, alias ("foo"))); ++ ++void ++bar (void) ++{ ++ foo = -1; ++} ++ +--- a/ld/testsuite/ld-elf/shared.exp ++++ b/ld/testsuite/ld-elf/shared.exp +@@ -123,6 +123,9 @@ + {"Build libdata1.so" + "-shared" "-fPIC" + {data1.c} {} "libdata1.so"} ++ {"Build libdata2.so" ++ "-shared" "-fPIC" ++ {data2.c} {} "libdata2.so"} + {"Build libcomm1.o" + "-r -nostdlib" "" + {comm1.c} {} "libcomm1.o"} +@@ -266,6 +269,9 @@ + {"Run with libdata1.so" + "tmpdir/libdata1.so" "" + {dynbss1.c} "dynbss1" "pass.out"} ++ {"Run with libdata2.so" ++ "tmpdir/libdata2.so" "" ++ {weakdef1.c} "weakdef1" "pass.out"} + {"Run with libfunc1.so comm1.o" + "tmpdir/libfunc1.so tmpdir/comm1.o" "" + {dummy.c} "comm1" "pass.out"} +--- /dev/null ++++ b/ld/testsuite/ld-elf/weakdef1.c +@@ -0,0 +1,15 @@ ++#include ++#include ++ ++extern int foo_alias; ++extern void bar (void); ++ ++int ++main (void) ++{ ++ bar (); ++ if (foo_alias != -1) ++ abort (); ++ printf ("PASS\n"); ++ return 0; ++} --- binutils-2.22.orig/debian/patches/binutils-bz17512_prereqs.patch +++ binutils-2.22/debian/patches/binutils-bz17512_prereqs.patch @@ -0,0 +1,3113 @@ +From 90061c3348116fbc64c9ef19dc28c154450d218e Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Tue, 22 May 2012 12:09:26 +0000 +Subject: [PATCH] * elflink.c (bfd_elf_discard_info): Handle multiple .eh_frame + sections attached to a BFD. + * section.c (bfd_get_section_by_name): Rewrite description. + (bfd_get_next_section_by_name): New function. + * bfd-in2.h: Regenerate. + +From f6f0e17bc3616a0e976b250e361bdd61bbffc6e8 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Mon, 25 Mar 2013 13:16:41 +0000 +Subject: [PATCH] PR binutils/15202 + * dwarf.c (read_leb128): Add END parameter. Do not read at or + beyond end. + (read_sleb128): Add END parameter. + (read_uleb128): New function. + (process_extended_line_op): Pass END to leb128 functions. + (process_abbrev_section): Likewise. + (decode_location_expression): Likewise. + (read_and_display_attr_value): Likewise. + (read_and_display_attr): Likewise. + (process_debug_info): Likewise. + (display_debug_lines_raw): Likewise. + (display_debug_lines_decoded): Likewise. + (display_debug_macinfo): Likewise. + (get_line_filename_and_dirname): Likewise. + (display_debug_macro): Likewise. + (display_loc_list_dwo): Likewise. + (display_debug_ranges): Likewise. + * dwarf.h (read_leb128): Update prototype. + * readelf.c (read_uleb128): Add END parameter. + (decode_arm_unwind_bytecode): Pass END to read_uleb128. + (decode_tic6x_unwind_bytecode): Likewise. + (display_tag_value): New function. + (display_arm_attribute): Add END parameter. Pass END to + read_uleb128. Use display_tag_value. + (display_gnu_attribute): Likewise. + (display_power_gnu_attribute): Likewise. + (display_sparc_gnu_attribute): Likewise. + (display_mips_gnu_attribute): Likewise. + (display_tic6x_attribute): Likewise. + (process_attributes): Likewise. + (display_raw_attribute): New function. + +From 0c5882475c48596b92ed08a7ccfa6347d44f8f65 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Tue, 26 Mar 2013 22:51:12 +0000 +Subject: [PATCH] PR binutils/15206 + * dwarf.c (SAFE_BYTE_GET): New macro - checks remaining buffer + space before calling byte_get. + (SAFE_BYTE_GET_AND_INC): New macro. + (SAFE_SIGNED_BYTE_GET): New macro. + (SAFE_SIGNED_BYTE_GET_AND_INC): New macro. + (SAFE_BYTE_GET64): New macro. + (process_extened_line_op): Use new macros. Use strnlen when + appropriate. + (fetch_indirect_string): Likewise. + (get_FORM_name): Likewise. + (decode_location_expression): Likewise. + (read_and_display_attr_value): Likewise. + (process_debug_info): Likewise. + (display_debug_lines_raw): Likewise. + (display_debug_lines_decoded): Likewise. + (display_debug_pubnames): Likewise. + (display_debug_macinfo): Likewise. + (get_line_filename_and_dirname): Likewise. + (display_debug_macro): Likewise. + (display_loc_list): Likewise. + (display_loc_list_dwo): Likewise. + (display_debug_aranges): Likewise. + (display_debug_ranges): Likewise. + (frame_display_row): Likewise. + (display_debug_frames): Likewise. + +From 49727e46175419c638251b39091f24c575568bee Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Mon, 22 Sep 2014 17:53:15 +0930 +Subject: [PATCH] Readelf: Handle forward references to CIEs + +The linker side of pr16563 was fixed with commit 18cd5bce, but +unfortunately people continue to use older linkers with -flto. This +means we have binaries with working .eh_frame that can't be dumped by +readelf, and I'm seeing internal IBM bug reports about this fact. + + PR 16563 + * dwarf.c (GET): Remove semicolon. + (read_cie): New function, extracted from.. + (display_debug_frames): ..here. Correctly handle signed offset + from FDE to CIE in .eh_frame. Decode forward referenced CIEs too. + +[Ubuntu note: patch is commits that were prequisite commits for the +binutils-bz17512.patch, where it was easier/less error-prone to take a +patch rather than try to backport the bz17512 fixes to the existing +code. + +This patch differs from the upstream commits in that it drops the +changelog updates to reduce patch conflicts. -- sbeattie] + +--- + bfd/bfd-in2.h | 2 + bfd/elflink.c | 5 + bfd/section.c | 45 +- + binutils/dwarf.c | 1065 ++++++++++++++++++++++++++++++----------------------- + binutils/dwarf.h | 5 + binutils/readelf.c | 339 ++++++++-------- + 6 files changed, 830 insertions(+), 631 deletions(-) + +Index: b/binutils/dwarf.c +=================================================================== +--- a/binutils/dwarf.c ++++ b/binutils/dwarf.c +@@ -169,15 +169,23 @@ dwarf_vmatoa (const char *fmtch, dwarf_v + return ret; + } + ++/* Read in a LEB128 encoded value starting at address DATA. ++ If SIGN is true, return a signed LEB128 value. ++ If LENGTH_RETURN is not NULL, return in it the number of bytes read. ++ No bytes will be read at address END or beyond. */ ++ + dwarf_vma +-read_leb128 (unsigned char *data, unsigned int *length_return, int sign) ++read_leb128 (unsigned char *data, ++ unsigned int *length_return, ++ bfd_boolean sign, ++ const unsigned char * const end) + { + dwarf_vma result = 0; + unsigned int num_read = 0; + unsigned int shift = 0; +- unsigned char byte; ++ unsigned char byte = 0; + +- do ++ while (data < end) + { + byte = *data++; + num_read++; +@@ -185,9 +193,9 @@ read_leb128 (unsigned char *data, unsign + result |= ((dwarf_vma) (byte & 0x7f)) << shift; + + shift += 7; +- ++ if ((byte & 0x80) == 0) ++ break; + } +- while (byte & 0x80); + + if (length_return != NULL) + *length_return = num_read; +@@ -199,11 +207,88 @@ read_leb128 (unsigned char *data, unsign + } + + /* Create a signed version to avoid painful typecasts. */ +-static dwarf_signed_vma +-read_sleb128 (unsigned char *data, unsigned int *length_return) +-{ +- return (dwarf_signed_vma) read_leb128 (data, length_return, 1); +-} ++static inline dwarf_signed_vma ++read_sleb128 (unsigned char * data, ++ unsigned int * length_return, ++ const unsigned char * const end) ++{ ++ return (dwarf_signed_vma) read_leb128 (data, length_return, TRUE, end); ++} ++ ++static inline dwarf_vma ++read_uleb128 (unsigned char * data, ++ unsigned int * length_return, ++ const unsigned char * const end) ++{ ++ return read_leb128 (data, length_return, FALSE, end); ++} ++ ++#define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \ ++ do \ ++ { \ ++ unsigned int amount = (AMOUNT); \ ++ if (((PTR) + amount) >= (END)) \ ++ { \ ++ if ((PTR) < (END)) \ ++ amount = (END) - (PTR); \ ++ else \ ++ amount = 0; \ ++ } \ ++ if (amount) \ ++ VAL = byte_get ((PTR), amount); \ ++ else \ ++ VAL = 0; \ ++ } \ ++ while (0) ++ ++#define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \ ++ do \ ++ { \ ++ SAFE_BYTE_GET (VAL, PTR, AMOUNT, END); \ ++ PTR += AMOUNT; \ ++ } \ ++ while (0) ++ ++#define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END) \ ++ do \ ++ { \ ++ unsigned int amount = (AMOUNT); \ ++ if (((PTR) + amount) >= (END)) \ ++ { \ ++ if ((PTR) < (END)) \ ++ amount = (END) - (PTR); \ ++ else \ ++ amount = 0; \ ++ } \ ++ if (amount) \ ++ VAL = byte_get_signed ((PTR), amount); \ ++ else \ ++ VAL = 0; \ ++ } \ ++ while (0) ++ ++#define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END) \ ++ do \ ++ { \ ++ SAFE_SIGNED_BYTE_GET (VAL, PTR, AMOUNT, END); \ ++ PTR += AMOUNT; \ ++ } \ ++ while (0) ++ ++#define SAFE_BYTE_GET64(PTR, HIGH, LOW, END) \ ++ do \ ++ { \ ++ if (((PTR) + 8) < (END)) \ ++ { \ ++ byte_get_64 ((PTR), (HIGH), (LOW)); \ ++ } \ ++ else \ ++ { \ ++ PTR = END; \ ++ * (LOW) = * (HIGH) = 0; \ ++ } \ ++ } \ ++ while (0) + + typedef struct State_Machine_Registers + { +@@ -240,18 +325,21 @@ reset_state_machine (int is_stmt) + Returns the number of bytes read. */ + + static int +-process_extended_line_op (unsigned char *data, int is_stmt) ++process_extended_line_op (unsigned char * data, ++ int is_stmt, ++ unsigned char * end) + { + unsigned char op_code; + unsigned int bytes_read; + unsigned int len; + unsigned char *name; ++ unsigned char *orig_data = data; + dwarf_vma adr; + +- len = read_leb128 (data, & bytes_read, 0); ++ len = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + +- if (len == 0) ++ if (len == 0 || data == end) + { + warn (_("badly formed extended line op encountered!\n")); + return bytes_read; +@@ -270,7 +358,7 @@ process_extended_line_op (unsigned char + break; + + case DW_LNE_set_address: +- adr = byte_get (data, len - bytes_read - 1); ++ SAFE_BYTE_GET (adr, data, len - bytes_read - 1, end); + printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr)); + state_machine_regs.address = adr; + state_machine_regs.op_index = 0; +@@ -279,21 +367,25 @@ process_extended_line_op (unsigned char + case DW_LNE_define_file: + printf (_(" define new File Table entry\n")); + printf (_(" Entry\tDir\tTime\tSize\tName\n")); +- + printf (" %d\t", ++state_machine_regs.last_file_entry); ++ + name = data; +- data += strlen ((char *) data) + 1; +- printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); ++ data += strnlen ((char *) data, end - data) + 1; ++ printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; +- printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); ++ printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); ++ data += bytes_read; ++ printf ("%s\t", dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; +- printf ("%s\t", dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); + printf ("%s\n\n", name); ++ ++ if (((unsigned int) (data - orig_data) != len) || data == end) ++ warn (_("DW_LNE_define_file: Bad opcode length\n")); + break; + + case DW_LNE_set_discriminator: + printf (_("set Discriminator to %s\n"), +- dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); ++ dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + break; + + /* HP extensions. */ +@@ -337,7 +429,7 @@ process_extended_line_op (unsigned char + { + unsigned int opc; + +- opc = read_leb128 (data, & bytes_read, 0); ++ opc = read_uleb128 (data, & bytes_read, edata); + data += bytes_read; + + switch (opc) +@@ -348,22 +440,22 @@ process_extended_line_op (unsigned char + case DW_LNE_HP_SFC_set_listing_line: + printf (" DW_LNE_HP_SFC_set_listing_line (%s)\n", + dwarf_vmatoa ("u", +- read_leb128 (data, & bytes_read, 0))); ++ read_uleb128 (data, & bytes_read, edata))); + data += bytes_read; + break; + case DW_LNE_HP_SFC_associate: + printf (" DW_LNE_HP_SFC_associate "); + printf (_("(%s"), + dwarf_vmatoa ("u", +- read_leb128 (data, & bytes_read, 0))); ++ read_uleb128 (data, & bytes_read, edata))); + data += bytes_read; + printf (_(",%s"), + dwarf_vmatoa ("u", +- read_leb128 (data, & bytes_read, 0))); ++ read_uleb128 (data, & bytes_read, edata))); + data += bytes_read; + printf (_(",%s)\n"), + dwarf_vmatoa ("u", +- read_leb128 (data, & bytes_read, 0))); ++ read_uleb128 (data, & bytes_read, edata))); + data += bytes_read; + break; + default: +@@ -398,13 +490,13 @@ process_extended_line_op (unsigned char + return len; + } + +-static const char * ++static const unsigned char * + fetch_indirect_string (dwarf_vma offset) + { + struct dwarf_section *section = &debug_displays [str].section; + + if (section->start == NULL) +- return _(""); ++ return (const unsigned char *) _(""); + + /* DWARF sections under Mach-O have non-zero addresses. */ + offset -= section->address; +@@ -412,10 +504,10 @@ fetch_indirect_string (dwarf_vma offset) + { + warn (_("DW_FORM_strp offset too big: %s\n"), + dwarf_vmatoa ("x", offset)); +- return _(""); ++ return (const unsigned char *) _(""); + } + +- return (const char *) section->start + offset; ++ return (const unsigned char *) section->start + offset; + } + + /* FIXME: There are better and more efficient ways to handle +@@ -534,17 +626,21 @@ process_abbrev_section (unsigned char *s + unsigned long attribute; + int children; + +- entry = read_leb128 (start, & bytes_read, 0); ++ entry = read_uleb128 (start, & bytes_read, end); + start += bytes_read; + + /* A single zero is supposed to end the section according + to the standard. If there's more, then signal that to + the caller. */ ++ if (start == end) ++ return NULL; + if (entry == 0) +- return start == end ? NULL : start; ++ return start; + +- tag = read_leb128 (start, & bytes_read, 0); ++ tag = read_uleb128 (start, & bytes_read, end); + start += bytes_read; ++ if (start == end) ++ return NULL; + + children = *start++; + +@@ -554,11 +650,15 @@ process_abbrev_section (unsigned char *s + { + unsigned long form; + +- attribute = read_leb128 (start, & bytes_read, 0); ++ attribute = read_uleb128 (start, & bytes_read, end); + start += bytes_read; ++ if (start == end) ++ break; + +- form = read_leb128 (start, & bytes_read, 0); ++ form = read_uleb128 (start, & bytes_read, end); + start += bytes_read; ++ if (start == end) ++ break; + + if (attribute != 0) + add_abbrev_attr (attribute, form); +@@ -700,10 +800,17 @@ get_FORM_name (unsigned long form) + } + + static unsigned char * +-display_block (unsigned char *data, dwarf_vma length) ++display_block (unsigned char *data, ++ dwarf_vma length, ++ const unsigned char * const end) + { ++ dwarf_vma maxlen; ++ + printf (_(" %s byte block: "), dwarf_vmatoa ("u", length)); + ++ maxlen = (dwarf_vma) (end - data); ++ length = length > maxlen ? maxlen : length; ++ + while (length --) + printf ("%lx ", (unsigned long) byte_get (data++, 1)); + +@@ -722,6 +829,7 @@ decode_location_expression (unsigned cha + unsigned op; + unsigned int bytes_read; + dwarf_vma uvalue; ++ dwarf_signed_vma svalue; + unsigned char *end = data + length; + int need_frame_base = 0; + +@@ -732,53 +840,56 @@ decode_location_expression (unsigned cha + switch (op) + { + case DW_OP_addr: +- printf ("DW_OP_addr: %s", +- dwarf_vmatoa ("x", byte_get (data, pointer_size))); +- data += pointer_size; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); ++ printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue)); + break; + case DW_OP_deref: + printf ("DW_OP_deref"); + break; + case DW_OP_const1u: +- printf ("DW_OP_const1u: %lu", (unsigned long) byte_get (data++, 1)); ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); ++ printf ("DW_OP_const1u: %lu", (unsigned long) uvalue); + break; + case DW_OP_const1s: +- printf ("DW_OP_const1s: %ld", (long) byte_get_signed (data++, 1)); ++ SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 1, end); ++ printf ("DW_OP_const1s: %ld", (long) svalue); + break; + case DW_OP_const2u: +- printf ("DW_OP_const2u: %lu", (unsigned long) byte_get (data, 2)); +- data += 2; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); ++ printf ("DW_OP_const2u: %lu", (unsigned long) uvalue); + break; + case DW_OP_const2s: +- printf ("DW_OP_const2s: %ld", (long) byte_get_signed (data, 2)); +- data += 2; ++ SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); ++ printf ("DW_OP_const2s: %ld", (long) svalue); + break; + case DW_OP_const4u: +- printf ("DW_OP_const4u: %lu", (unsigned long) byte_get (data, 4)); +- data += 4; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); ++ printf ("DW_OP_const4u: %lu", (unsigned long) uvalue); + break; + case DW_OP_const4s: +- printf ("DW_OP_const4s: %ld", (long) byte_get_signed (data, 4)); +- data += 4; ++ SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); ++ printf ("DW_OP_const4s: %ld", (long) svalue); + break; + case DW_OP_const8u: +- printf ("DW_OP_const8u: %lu %lu", (unsigned long) byte_get (data, 4), +- (unsigned long) byte_get (data + 4, 4)); +- data += 8; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); ++ printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue); ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); ++ printf ("%lu", (unsigned long) uvalue); + break; + case DW_OP_const8s: +- printf ("DW_OP_const8s: %ld %ld", (long) byte_get (data, 4), +- (long) byte_get (data + 4, 4)); +- data += 8; ++ SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); ++ printf ("DW_OP_const8s: %ld ", (long) svalue); ++ SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); ++ printf ("%ld", (long) svalue); + break; + case DW_OP_constu: + printf ("DW_OP_constu: %s", +- dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); ++ dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_consts: + printf ("DW_OP_consts: %s", +- dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read))); ++ dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_dup: +@@ -791,7 +902,8 @@ decode_location_expression (unsigned cha + printf ("DW_OP_over"); + break; + case DW_OP_pick: +- printf ("DW_OP_pick: %ld", (unsigned long) byte_get (data++, 1)); ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); ++ printf ("DW_OP_pick: %ld", (unsigned long) uvalue); + break; + case DW_OP_swap: + printf ("DW_OP_swap"); +@@ -834,7 +946,7 @@ decode_location_expression (unsigned cha + break; + case DW_OP_plus_uconst: + printf ("DW_OP_plus_uconst: %s", +- dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); ++ dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_shl: +@@ -850,8 +962,8 @@ decode_location_expression (unsigned cha + printf ("DW_OP_xor"); + break; + case DW_OP_bra: +- printf ("DW_OP_bra: %ld", (long) byte_get_signed (data, 2)); +- data += 2; ++ SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); ++ printf ("DW_OP_bra: %ld", (long) svalue); + break; + case DW_OP_eq: + printf ("DW_OP_eq"); +@@ -872,8 +984,8 @@ decode_location_expression (unsigned cha + printf ("DW_OP_ne"); + break; + case DW_OP_skip: +- printf ("DW_OP_skip: %ld", (long) byte_get_signed (data, 2)); +- data += 2; ++ SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); ++ printf ("DW_OP_skip: %ld", (long) svalue); + break; + + case DW_OP_lit0: +@@ -982,13 +1094,12 @@ decode_location_expression (unsigned cha + printf ("DW_OP_breg%d (%s): %s", + op - DW_OP_breg0, + regname (op - DW_OP_breg0, 1), +- dwarf_vmatoa ("d", (dwarf_signed_vma) +- read_leb128 (data, &bytes_read, 1))); ++ dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + + case DW_OP_regx: +- uvalue = read_leb128 (data, &bytes_read, 0); ++ uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_regx: %s (%s)", + dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); +@@ -996,27 +1107,29 @@ decode_location_expression (unsigned cha + case DW_OP_fbreg: + need_frame_base = 1; + printf ("DW_OP_fbreg: %s", +- dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read))); ++ dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_bregx: +- uvalue = read_leb128 (data, &bytes_read, 0); ++ uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_bregx: %s (%s) %s", + dwarf_vmatoa ("u", uvalue), regname (uvalue, 1), +- dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read))); ++ dwarf_vmatoa ("d", read_sleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_piece: + printf ("DW_OP_piece: %s", +- dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); ++ dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + case DW_OP_deref_size: +- printf ("DW_OP_deref_size: %ld", (long) byte_get (data++, 1)); ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); ++ printf ("DW_OP_deref_size: %ld", (long) uvalue); + break; + case DW_OP_xderef_size: +- printf ("DW_OP_xderef_size: %ld", (long) byte_get (data++, 1)); ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); ++ printf ("DW_OP_xderef_size: %ld", (long) uvalue); + break; + case DW_OP_nop: + printf ("DW_OP_nop"); +@@ -1029,18 +1142,16 @@ decode_location_expression (unsigned cha + case DW_OP_call2: + /* XXX: Strictly speaking for 64-bit DWARF3 files + this ought to be an 8-byte wide computation. */ ++ SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end); + printf ("DW_OP_call2: <0x%s>", +- dwarf_vmatoa ("x", (dwarf_signed_vma) byte_get (data, 2) +- + cu_offset)); +- data += 2; ++ dwarf_vmatoa ("x", svalue + cu_offset)); + break; + case DW_OP_call4: + /* XXX: Strictly speaking for 64-bit DWARF3 files + this ought to be an 8-byte wide computation. */ ++ SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end); + printf ("DW_OP_call4: <0x%s>", +- dwarf_vmatoa ("x", (dwarf_signed_vma) byte_get (data, 4) +- + cu_offset)); +- data += 4; ++ dwarf_vmatoa ("x", svalue + cu_offset)); + break; + case DW_OP_call_ref: + /* XXX: Strictly speaking for 64-bit DWARF3 files +@@ -1053,16 +1164,13 @@ decode_location_expression (unsigned cha + } + if (dwarf_version == 2) + { +- printf ("DW_OP_call_ref: <0x%s>", +- dwarf_vmatoa ("x", byte_get (data, pointer_size))); +- data += pointer_size; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); + } + else + { +- printf ("DW_OP_call_ref: <0x%s>", +- dwarf_vmatoa ("x", byte_get (data, offset_size))); +- data += offset_size; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); + } ++ printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue)); + break; + case DW_OP_form_tls_address: + printf ("DW_OP_form_tls_address"); +@@ -1073,10 +1181,10 @@ decode_location_expression (unsigned cha + case DW_OP_bit_piece: + printf ("DW_OP_bit_piece: "); + printf ("size: %s ", +- dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); ++ dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); + data += bytes_read; + printf ("offset: %s ", +- dwarf_vmatoa ("u", read_leb128 (data, &bytes_read, 0))); ++ dwarf_vmatoa ("u", read_uleb128 (data, &bytes_read, end))); + data += bytes_read; + break; + +@@ -1087,9 +1195,9 @@ decode_location_expression (unsigned cha + + case DW_OP_implicit_value: + printf ("DW_OP_implicit_value"); +- uvalue = read_leb128 (data, &bytes_read, 0); ++ uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; +- display_block (data, uvalue); ++ display_block (data, uvalue, end); + data += uvalue; + break; + +@@ -1125,23 +1233,20 @@ decode_location_expression (unsigned cha + } + if (dwarf_version == 2) + { +- printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s", +- dwarf_vmatoa ("x", byte_get (data, pointer_size)), +- dwarf_vmatoa ("d", read_sleb128 (data + pointer_size, +- &bytes_read))); +- data += pointer_size + bytes_read; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); + } + else + { +- printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s", +- dwarf_vmatoa ("x", byte_get (data, offset_size)), +- dwarf_vmatoa ("d", read_sleb128 (data + offset_size, +- &bytes_read))); +- data += offset_size + bytes_read; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); + } ++ printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s", ++ dwarf_vmatoa ("x", uvalue), ++ dwarf_vmatoa ("d", read_sleb128 (data, ++ &bytes_read, end))); ++ data += bytes_read; + break; + case DW_OP_GNU_entry_value: +- uvalue = read_leb128 (data, &bytes_read, 0); ++ uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_GNU_entry_value: ("); + if (decode_location_expression (data, pointer_size, offset_size, +@@ -1152,45 +1257,46 @@ decode_location_expression (unsigned cha + data += uvalue; + break; + case DW_OP_GNU_const_type: +- uvalue = read_leb128 (data, &bytes_read, 0); ++ uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_GNU_const_type: <0x%s> ", + dwarf_vmatoa ("x", cu_offset + uvalue)); +- uvalue = byte_get (data++, 1); +- display_block (data, uvalue); ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); ++ display_block (data, uvalue, end); + data += uvalue; + break; + case DW_OP_GNU_regval_type: +- uvalue = read_leb128 (data, &bytes_read, 0); ++ uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_GNU_regval_type: %s (%s)", + dwarf_vmatoa ("u", uvalue), regname (uvalue, 1)); +- uvalue = read_leb128 (data, &bytes_read, 0); ++ uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); + break; + case DW_OP_GNU_deref_type: +- printf ("DW_OP_GNU_deref_type: %ld", (long) byte_get (data++, 1)); +- uvalue = read_leb128 (data, &bytes_read, 0); ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); ++ printf ("DW_OP_GNU_deref_type: %ld", (long) uvalue); ++ uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue)); + break; + case DW_OP_GNU_convert: +- uvalue = read_leb128 (data, &bytes_read, 0); ++ uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_GNU_convert <0x%s>", + dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); + break; + case DW_OP_GNU_reinterpret: +- uvalue = read_leb128 (data, &bytes_read, 0); ++ uvalue = read_uleb128 (data, &bytes_read, end); + data += bytes_read; + printf ("DW_OP_GNU_reinterpret <0x%s>", + dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0)); + break; + case DW_OP_GNU_parameter_ref: ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); + printf ("DW_OP_GNU_parameter_ref: <0x%s>", +- dwarf_vmatoa ("x", cu_offset + byte_get (data, 4))); +- data += 4; ++ dwarf_vmatoa ("x", cu_offset + uvalue)); + break; + + /* HP extensions. */ +@@ -1250,6 +1356,7 @@ static unsigned char * + read_and_display_attr_value (unsigned long attribute, + unsigned long form, + unsigned char * data, ++ unsigned char * end, + dwarf_vma cu_offset, + dwarf_vma pointer_size, + dwarf_vma offset_size, +@@ -1263,6 +1370,12 @@ read_and_display_attr_value (unsigned lo + unsigned char * orig_data = data; + unsigned int bytes_read; + ++ if (data == end) ++ { ++ warn (_("corrupt attribute\n")); ++ return data; ++ } ++ + switch (form) + { + default: +@@ -1270,29 +1383,21 @@ read_and_display_attr_value (unsigned lo + + case DW_FORM_ref_addr: + if (dwarf_version == 2) +- { +- uvalue = byte_get (data, pointer_size); +- data += pointer_size; +- } ++ SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); + else if (dwarf_version == 3 || dwarf_version == 4) +- { +- uvalue = byte_get (data, offset_size); +- data += offset_size; +- } ++ SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); + else + error (_("Internal error: DWARF version is not 2, 3 or 4.\n")); + + break; + + case DW_FORM_addr: +- uvalue = byte_get (data, pointer_size); +- data += pointer_size; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end); + break; + + case DW_FORM_strp: + case DW_FORM_sec_offset: +- uvalue = byte_get (data, offset_size); +- data += offset_size; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end); + break; + + case DW_FORM_flag_present: +@@ -1302,38 +1407,36 @@ read_and_display_attr_value (unsigned lo + case DW_FORM_ref1: + case DW_FORM_flag: + case DW_FORM_data1: +- uvalue = byte_get (data++, 1); ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end); + break; + + case DW_FORM_ref2: + case DW_FORM_data2: +- uvalue = byte_get (data, 2); +- data += 2; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end); + break; + + case DW_FORM_ref4: + case DW_FORM_data4: +- uvalue = byte_get (data, 4); +- data += 4; ++ SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end); + break; + + case DW_FORM_sdata: +- uvalue = read_leb128 (data, & bytes_read, 1); ++ uvalue = read_sleb128 (data, & bytes_read, end); + data += bytes_read; + break; + + case DW_FORM_ref_udata: + case DW_FORM_udata: +- uvalue = read_leb128 (data, & bytes_read, 0); ++ uvalue = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + break; + + case DW_FORM_indirect: +- form = read_leb128 (data, & bytes_read, 0); ++ form = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + if (!do_loc) + printf (" %s", get_FORM_name (form)); +- return read_and_display_attr_value (attribute, form, data, ++ return read_and_display_attr_value (attribute, form, data, end, + cu_offset, pointer_size, + offset_size, dwarf_version, + debug_info_p, do_loc, +@@ -1376,62 +1479,65 @@ read_and_display_attr_value (unsigned lo + case DW_FORM_data8: + if (!do_loc) + { +- uvalue = byte_get (data, 4); ++ SAFE_BYTE_GET (uvalue, data, 4, end); + printf (" 0x%s", dwarf_vmatoa ("x", uvalue)); +- printf (" 0x%lx", (unsigned long) byte_get (data + 4, 4)); ++ SAFE_BYTE_GET (uvalue, data + 4, 4, end); ++ printf (" 0x%lx", (unsigned long) uvalue); + } ++ + if ((do_loc || do_debug_loc || do_debug_ranges) + && num_debug_info_entries == 0) + { + if (sizeof (uvalue) == 8) +- uvalue = byte_get (data, 8); ++ SAFE_BYTE_GET (uvalue, data, 8, end); + else + error (_("DW_FORM_data8 is unsupported when sizeof (dwarf_vma) != 8\n")); + } ++ + data += 8; + break; + + case DW_FORM_string: + if (!do_loc) +- printf (" %s", data); +- data += strlen ((char *) data) + 1; ++ printf (" %.*s", (int) (end - data), data); ++ data += strnlen ((char *) data, end - data) + 1; + break; + + case DW_FORM_block: + case DW_FORM_exprloc: +- uvalue = read_leb128 (data, & bytes_read, 0); ++ uvalue = read_uleb128 (data, & bytes_read, end); + block_start = data + bytes_read; + if (do_loc) + data = block_start + uvalue; + else +- data = display_block (block_start, uvalue); ++ data = display_block (block_start, uvalue, end); + break; + + case DW_FORM_block1: +- uvalue = byte_get (data, 1); ++ SAFE_BYTE_GET (uvalue, data, 1, end); + block_start = data + 1; + if (do_loc) + data = block_start + uvalue; + else +- data = display_block (block_start, uvalue); ++ data = display_block (block_start, uvalue, end); + break; + + case DW_FORM_block2: +- uvalue = byte_get (data, 2); ++ SAFE_BYTE_GET (uvalue, data, 2, end); + block_start = data + 2; + if (do_loc) + data = block_start + uvalue; + else +- data = display_block (block_start, uvalue); ++ data = display_block (block_start, uvalue, end); + break; + + case DW_FORM_block4: +- uvalue = byte_get (data, 4); ++ SAFE_BYTE_GET (uvalue, data, 4, end); + block_start = data + 4; + if (do_loc) + data = block_start + uvalue; + else +- data = display_block (block_start, uvalue); ++ data = display_block (block_start, uvalue, end); + break; + + case DW_FORM_strp: +@@ -1783,7 +1889,7 @@ read_and_display_attr_value (unsigned lo + unsigned long abbrev_number; + abbrev_entry * entry; + +- abbrev_number = read_leb128 (section->start + uvalue, NULL, 0); ++ abbrev_number = read_uleb128 (section->start + uvalue, NULL, end); + + printf ("[Abbrev Number: %ld", abbrev_number); + for (entry = first_abbrev; entry != NULL; entry = entry->next) +@@ -1987,6 +2093,7 @@ static unsigned char * + read_and_display_attr (unsigned long attribute, + unsigned long form, + unsigned char * data, ++ unsigned char * end, + dwarf_vma cu_offset, + dwarf_vma pointer_size, + dwarf_vma offset_size, +@@ -1997,8 +2104,8 @@ read_and_display_attr (unsigned long att + { + if (!do_loc) + printf (" %-18s:", get_AT_name (attribute)); +- data = read_and_display_attr_value (attribute, form, data, cu_offset, +- pointer_size, offset_size, ++ data = read_and_display_attr_value (attribute, form, data, end, ++ cu_offset, pointer_size, offset_size, + dwarf_version, debug_info_p, + do_loc, section); + if (!do_loc) +@@ -2038,11 +2145,11 @@ process_debug_info (struct dwarf_section + /* Read the first 4 bytes. For a 32-bit DWARF section, this + will be the length. For a 64-bit DWARF section, it'll be + the escape code 0xffffffff followed by an 8 byte length. */ +- length = byte_get (section_begin, 4); ++ SAFE_BYTE_GET (length, section_begin, 4, end); + + if (length == 0xffffffff) + { +- length = byte_get (section_begin + 4, 8); ++ SAFE_BYTE_GET (length, section_begin + 4, 8, end); + section_begin += length + 12; + } + else if (length >= 0xfffffff0 && length < 0xffffffff) +@@ -2112,13 +2219,11 @@ process_debug_info (struct dwarf_section + + hdrptr = start; + +- compunit.cu_length = byte_get (hdrptr, 4); +- hdrptr += 4; ++ SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 4, end); + + if (compunit.cu_length == 0xffffffff) + { +- compunit.cu_length = byte_get (hdrptr, 8); +- hdrptr += 8; ++ SAFE_BYTE_GET_AND_INC (compunit.cu_length, hdrptr, 8, end); + offset_size = 8; + initial_length_size = 12; + } +@@ -2128,16 +2233,13 @@ process_debug_info (struct dwarf_section + initial_length_size = 4; + } + +- compunit.cu_version = byte_get (hdrptr, 2); +- hdrptr += 2; ++ SAFE_BYTE_GET_AND_INC (compunit.cu_version, hdrptr, 2, end); + + cu_offset = start - section_begin; + +- compunit.cu_abbrev_offset = byte_get (hdrptr, offset_size); +- hdrptr += offset_size; ++ SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end); + +- compunit.cu_pointer_size = byte_get (hdrptr, 1); +- hdrptr += 1; ++ SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end); + + if (do_types) + { +@@ -2145,12 +2247,10 @@ process_debug_info (struct dwarf_section + + for (i = 0; i < 8; i++) + { +- signature[i] = byte_get (hdrptr, 1); +- hdrptr += 1; ++ SAFE_BYTE_GET_AND_INC (signature[i], hdrptr, 1, end); + } + +- type_offset = byte_get (hdrptr, offset_size); +- hdrptr += offset_size; ++ SAFE_BYTE_GET_AND_INC (type_offset, hdrptr, offset_size, end); + } + + if ((do_loc || do_debug_loc || do_debug_ranges) +@@ -2246,7 +2346,7 @@ process_debug_info (struct dwarf_section + + die_offset = tags - section_begin; + +- abbrev_number = read_leb128 (tags, & bytes_read, 0); ++ abbrev_number = read_uleb128 (tags, & bytes_read, start); + tags += bytes_read; + + /* A null DIE marks the end of a list of siblings or it may also be +@@ -2356,7 +2456,9 @@ process_debug_info (struct dwarf_section + + tags = read_and_display_attr (attr->attribute, + attr->form, +- tags, cu_offset, ++ tags, ++ end, ++ cu_offset, + compunit.cu_pointer_size, + offset_size, + compunit.cu_version, +@@ -2438,14 +2540,12 @@ display_debug_lines_raw (struct dwarf_se + hdroff = hdrptr - start; + + /* Check the length of the block. */ +- linfo.li_length = byte_get (hdrptr, 4); +- hdrptr += 4; ++ SAFE_BYTE_GET_AND_INC (linfo.li_length, hdrptr, 4, end); + + if (linfo.li_length == 0xffffffff) + { + /* This section is 64-bit DWARF 3. */ +- linfo.li_length = byte_get (hdrptr, 8); +- hdrptr += 8; ++ SAFE_BYTE_GET_AND_INC (linfo.li_length, hdrptr, 8, end); + offset_size = 8; + initial_length_size = 12; + } +@@ -2464,8 +2564,7 @@ display_debug_lines_raw (struct dwarf_se + } + + /* Check its version number. */ +- linfo.li_version = byte_get (hdrptr, 2); +- hdrptr += 2; ++ SAFE_BYTE_GET_AND_INC (linfo.li_version, hdrptr, 2, end); + if (linfo.li_version != 2 + && linfo.li_version != 3 + && linfo.li_version != 4) +@@ -2474,14 +2573,13 @@ display_debug_lines_raw (struct dwarf_se + return 0; + } + +- linfo.li_prologue_length = byte_get (hdrptr, offset_size); +- hdrptr += offset_size; +- linfo.li_min_insn_length = byte_get (hdrptr, 1); +- hdrptr++; ++ SAFE_BYTE_GET_AND_INC (linfo.li_prologue_length, hdrptr, offset_size, end); ++ SAFE_BYTE_GET_AND_INC (linfo.li_min_insn_length, hdrptr, 1, end); ++ + if (linfo.li_version >= 4) + { +- linfo.li_max_ops_per_insn = byte_get (hdrptr, 1); +- hdrptr++; ++ SAFE_BYTE_GET_AND_INC (linfo.li_max_ops_per_insn, hdrptr, 1, end); ++ + if (linfo.li_max_ops_per_insn == 0) + { + warn (_("Invalid maximum operations per insn.\n")); +@@ -2490,14 +2588,11 @@ display_debug_lines_raw (struct dwarf_se + } + else + linfo.li_max_ops_per_insn = 1; +- linfo.li_default_is_stmt = byte_get (hdrptr, 1); +- hdrptr++; +- linfo.li_line_base = byte_get (hdrptr, 1); +- hdrptr++; +- linfo.li_line_range = byte_get (hdrptr, 1); +- hdrptr++; +- linfo.li_opcode_base = byte_get (hdrptr, 1); +- hdrptr++; ++ ++ SAFE_BYTE_GET_AND_INC (linfo.li_default_is_stmt, hdrptr, 1, end); ++ SAFE_BYTE_GET_AND_INC (linfo.li_line_base, hdrptr, 1, end); ++ SAFE_BYTE_GET_AND_INC (linfo.li_line_range, hdrptr, 1, end); ++ SAFE_BYTE_GET_AND_INC (linfo.li_opcode_base, hdrptr, 1, end); + + /* Sign extend the line base field. */ + linfo.li_line_base <<= 24; +@@ -2540,7 +2635,7 @@ display_debug_lines_raw (struct dwarf_se + { + printf (" %s\n", data); + +- data += strlen ((char *) data) + 1; ++ data += strnlen ((char *) data, end - data) + 1; + } + } + +@@ -2562,19 +2657,24 @@ display_debug_lines_raw (struct dwarf_se + + printf (" %d\t", ++state_machine_regs.last_file_entry); + name = data; +- +- data += strlen ((char *) data) + 1; ++ data += strnlen ((char *) data, end - data) + 1; + + printf ("%s\t", +- dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); ++ dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; + printf ("%s\t", +- dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); ++ dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; + printf ("%s\t", +- dwarf_vmatoa ("u", read_leb128 (data, & bytes_read, 0))); ++ dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end))); + data += bytes_read; + printf ("%s\n", name); ++ ++ if (data == end) ++ { ++ warn (_("Corrupt file name table entry\n")); ++ break; ++ } + } + } + +@@ -2629,7 +2729,7 @@ display_debug_lines_raw (struct dwarf_se + else switch (op_code) + { + case DW_LNS_extended_op: +- data += process_extended_line_op (data, linfo.li_default_is_stmt); ++ data += process_extended_line_op (data, linfo.li_default_is_stmt, end); + break; + + case DW_LNS_copy: +@@ -2637,7 +2737,7 @@ display_debug_lines_raw (struct dwarf_se + break; + + case DW_LNS_advance_pc: +- uladv = read_leb128 (data, & bytes_read, 0); ++ uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + if (linfo.li_max_ops_per_insn == 1) + { +@@ -2664,7 +2764,7 @@ display_debug_lines_raw (struct dwarf_se + break; + + case DW_LNS_advance_line: +- adv = read_sleb128 (data, & bytes_read); ++ adv = read_sleb128 (data, & bytes_read, end); + data += bytes_read; + state_machine_regs.line += adv; + printf (_(" Advance Line by %s to %d\n"), +@@ -2673,7 +2773,7 @@ display_debug_lines_raw (struct dwarf_se + break; + + case DW_LNS_set_file: +- adv = read_leb128 (data, & bytes_read, 0); ++ adv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + printf (_(" Set File Name to entry %s in the File Name Table\n"), + dwarf_vmatoa ("d", adv)); +@@ -2681,7 +2781,7 @@ display_debug_lines_raw (struct dwarf_se + break; + + case DW_LNS_set_column: +- uladv = read_leb128 (data, & bytes_read, 0); ++ uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + printf (_(" Set column to %s\n"), + dwarf_vmatoa ("u", uladv)); +@@ -2727,8 +2827,7 @@ display_debug_lines_raw (struct dwarf_se + break; + + case DW_LNS_fixed_advance_pc: +- uladv = byte_get (data, 2); +- data += 2; ++ SAFE_BYTE_GET_AND_INC (uladv, data, 2, end); + state_machine_regs.address += uladv; + state_machine_regs.op_index = 0; + printf (_(" Advance PC by fixed size amount %s to 0x%s\n"), +@@ -2745,7 +2844,7 @@ display_debug_lines_raw (struct dwarf_se + break; + + case DW_LNS_set_isa: +- uladv = read_leb128 (data, & bytes_read, 0); ++ uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + printf (_(" Set ISA to %s\n"), dwarf_vmatoa ("u", uladv)); + break; +@@ -2755,8 +2854,8 @@ display_debug_lines_raw (struct dwarf_se + + for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) + { +- printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data, +- &bytes_read, 0)), ++ printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data, ++ &bytes_read, end)), + i == 1 ? "" : ", "); + data += bytes_read; + } +@@ -2807,14 +2906,12 @@ display_debug_lines_decoded (struct dwar + (section 6.2.4 in the Dwarf3 doc). */ + + /* Get the length of this CU's line number information block. */ +- linfo.li_length = byte_get (hdrptr, 4); +- hdrptr += 4; ++ SAFE_BYTE_GET_AND_INC (linfo.li_length, hdrptr, 4, end); + + if (linfo.li_length == 0xffffffff) + { + /* This section is 64-bit DWARF 3. */ +- linfo.li_length = byte_get (hdrptr, 8); +- hdrptr += 8; ++ SAFE_BYTE_GET_AND_INC (linfo.li_length, hdrptr, 8, end); + offset_size = 8; + initial_length_size = 12; + } +@@ -2832,8 +2929,7 @@ display_debug_lines_decoded (struct dwar + } + + /* Get this CU's Line Number Block version number. */ +- linfo.li_version = byte_get (hdrptr, 2); +- hdrptr += 2; ++ SAFE_BYTE_GET_AND_INC (linfo.li_version, hdrptr, 2, end); + if (linfo.li_version != 2 + && linfo.li_version != 3 + && linfo.li_version != 4) +@@ -2843,14 +2939,12 @@ display_debug_lines_decoded (struct dwar + return 0; + } + +- linfo.li_prologue_length = byte_get (hdrptr, offset_size); +- hdrptr += offset_size; +- linfo.li_min_insn_length = byte_get (hdrptr, 1); +- hdrptr++; ++ SAFE_BYTE_GET_AND_INC (linfo.li_prologue_length, hdrptr, offset_size, end); ++ SAFE_BYTE_GET_AND_INC (linfo.li_min_insn_length, hdrptr, 1, end); ++ + if (linfo.li_version >= 4) + { +- linfo.li_max_ops_per_insn = byte_get (hdrptr, 1); +- hdrptr++; ++ SAFE_BYTE_GET_AND_INC (linfo.li_max_ops_per_insn, hdrptr, 1, end); + if (linfo.li_max_ops_per_insn == 0) + { + warn (_("Invalid maximum operations per insn.\n")); +@@ -2859,14 +2953,11 @@ display_debug_lines_decoded (struct dwar + } + else + linfo.li_max_ops_per_insn = 1; +- linfo.li_default_is_stmt = byte_get (hdrptr, 1); +- hdrptr++; +- linfo.li_line_base = byte_get (hdrptr, 1); +- hdrptr++; +- linfo.li_line_range = byte_get (hdrptr, 1); +- hdrptr++; +- linfo.li_opcode_base = byte_get (hdrptr, 1); +- hdrptr++; ++ ++ SAFE_BYTE_GET_AND_INC (linfo.li_default_is_stmt, hdrptr, 1, end); ++ SAFE_BYTE_GET_AND_INC (linfo.li_line_base, hdrptr, 1, end); ++ SAFE_BYTE_GET_AND_INC (linfo.li_line_range, hdrptr, 1, end); ++ SAFE_BYTE_GET_AND_INC (linfo.li_opcode_base, hdrptr, 1, end); + + /* Sign extend the line base field. */ + linfo.li_line_base <<= 24; +@@ -2889,7 +2980,7 @@ display_debug_lines_decoded (struct dwar + + while (*data != 0) + { +- data += strlen ((char *) data) + 1; ++ data += strnlen ((char *) data, end - data) + 1; + n_directories++; + } + +@@ -2901,7 +2992,8 @@ display_debug_lines_decoded (struct dwar + while (*ptr_directory_table != 0) + { + directory_table[i] = ptr_directory_table; +- ptr_directory_table += strlen ((char *) ptr_directory_table) + 1; ++ ptr_directory_table += strnlen ((char *) ptr_directory_table, ++ ptr_directory_table - end) + 1; + i++; + } + } +@@ -2920,12 +3012,12 @@ display_debug_lines_decoded (struct dwar + + /* Skip Name, directory index, last modification time and length + of file. */ +- data += strlen ((char *) data) + 1; +- read_leb128 (data, & bytes_read, 0); ++ data += strnlen ((char *) data, end - data) + 1; ++ read_uleb128 (data, & bytes_read, end); + data += bytes_read; +- read_leb128 (data, & bytes_read, 0); ++ read_uleb128 (data, & bytes_read, end); + data += bytes_read; +- read_leb128 (data, & bytes_read, 0); ++ read_uleb128 (data, & bytes_read, end); + data += bytes_read; + + n_files++; +@@ -2940,16 +3032,17 @@ display_debug_lines_decoded (struct dwar + unsigned int bytes_read; + + file_table[i].name = ptr_file_name_table; +- ptr_file_name_table += strlen ((char *) ptr_file_name_table) + 1; ++ ptr_file_name_table += strnlen ((char *) ptr_file_name_table, ++ end - ptr_file_name_table) + 1; + + /* We are not interested in directory, time or size. */ +- file_table[i].directory_index = read_leb128 (ptr_file_name_table, +- & bytes_read, 0); ++ file_table[i].directory_index = read_uleb128 (ptr_file_name_table, ++ & bytes_read, end); + ptr_file_name_table += bytes_read; +- file_table[i].modification_date = read_leb128 (ptr_file_name_table, +- & bytes_read, 0); ++ file_table[i].modification_date = read_uleb128 (ptr_file_name_table, ++ & bytes_read, end); + ptr_file_name_table += bytes_read; +- file_table[i].length = read_leb128 (ptr_file_name_table, & bytes_read, 0); ++ file_table[i].length = read_uleb128 (ptr_file_name_table, & bytes_read, end); + ptr_file_name_table += bytes_read; + i++; + } +@@ -3019,7 +3112,8 @@ display_debug_lines_decoded (struct dwar + unsigned char ext_op_code; + unsigned char *op_code_data = data; + +- ext_op_code_len = read_leb128 (op_code_data, &bytes_read, 0); ++ ext_op_code_len = read_uleb128 (op_code_data, &bytes_read, ++ end_of_sequence); + op_code_data += bytes_read; + + if (ext_op_code_len == 0) +@@ -3036,8 +3130,9 @@ display_debug_lines_decoded (struct dwar + reset_state_machine (linfo.li_default_is_stmt); + break; + case DW_LNE_set_address: +- state_machine_regs.address = +- byte_get (op_code_data, ext_op_code_len - bytes_read - 1); ++ SAFE_BYTE_GET_AND_INC (state_machine_regs.address, ++ op_code_data, ext_op_code_len - bytes_read - 1, ++ end); + state_machine_regs.op_index = 0; + break; + case DW_LNE_define_file: +@@ -3046,11 +3141,15 @@ display_debug_lines_decoded (struct dwar + + ++state_machine_regs.last_file_entry; + op_code_data += strlen ((char *) op_code_data) + 1; +- dir_index = read_leb128 (op_code_data, & bytes_read, 0); ++ dir_index = ++ read_uleb128 (op_code_data, & bytes_read, ++ end_of_sequence); + op_code_data += bytes_read; +- read_leb128 (op_code_data, & bytes_read, 0); ++ read_uleb128 (op_code_data, & bytes_read, ++ end_of_sequence); + op_code_data += bytes_read; +- read_leb128 (op_code_data, & bytes_read, 0); ++ read_uleb128 (op_code_data, & bytes_read, ++ end_of_sequence); + + printf ("%s:\n", directory_table[dir_index]); + break; +@@ -3066,7 +3165,7 @@ display_debug_lines_decoded (struct dwar + break; + + case DW_LNS_advance_pc: +- uladv = read_leb128 (data, & bytes_read, 0); ++ uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + if (linfo.li_max_ops_per_insn == 1) + { +@@ -3086,13 +3185,13 @@ display_debug_lines_decoded (struct dwar + break; + + case DW_LNS_advance_line: +- adv = read_sleb128 (data, & bytes_read); ++ adv = read_sleb128 (data, & bytes_read, end); + data += bytes_read; + state_machine_regs.line += adv; + break; + + case DW_LNS_set_file: +- adv = read_leb128 (data, & bytes_read, 0); ++ adv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + state_machine_regs.file = adv; + if (file_table[state_machine_regs.file - 1].directory_index == 0) +@@ -3111,7 +3210,7 @@ display_debug_lines_decoded (struct dwar + break; + + case DW_LNS_set_column: +- uladv = read_leb128 (data, & bytes_read, 0); ++ uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + state_machine_regs.column = uladv; + break; +@@ -3146,8 +3245,7 @@ display_debug_lines_decoded (struct dwar + break; + + case DW_LNS_fixed_advance_pc: +- uladv = byte_get (data, 2); +- data += 2; ++ SAFE_BYTE_GET_AND_INC (uladv, data, 2, end); + state_machine_regs.address += uladv; + state_machine_regs.op_index = 0; + break; +@@ -3159,7 +3257,7 @@ display_debug_lines_decoded (struct dwar + break; + + case DW_LNS_set_isa: +- uladv = read_leb128 (data, & bytes_read, 0); ++ uladv = read_uleb128 (data, & bytes_read, end); + data += bytes_read; + printf (_(" Set ISA to %lu\n"), uladv); + break; +@@ -3169,8 +3267,8 @@ display_debug_lines_decoded (struct dwar + + for (i = standard_opcodes[op_code - 1]; i > 0 ; --i) + { +- printf ("0x%s%s", dwarf_vmatoa ("x", read_leb128 (data, +- &bytes_read, 0)), ++ printf ("0x%s%s", dwarf_vmatoa ("x", read_uleb128 (data, ++ &bytes_read, end)), + i == 1 ? "" : ", "); + data += bytes_read; + } +@@ -3303,12 +3401,10 @@ display_debug_pubnames (struct dwarf_sec + + data = start; + +- names.pn_length = byte_get (data, 4); +- data += 4; ++ SAFE_BYTE_GET_AND_INC (names.pn_length, data, 4, end); + if (names.pn_length == 0xffffffff) + { +- names.pn_length = byte_get (data, 8); +- data += 8; ++ SAFE_BYTE_GET_AND_INC (names.pn_length, data, 8, end); + offset_size = 8; + initial_length_size = 12; + } +@@ -3318,11 +3414,8 @@ display_debug_pubnames (struct dwarf_sec + initial_length_size = 4; + } + +- names.pn_version = byte_get (data, 2); +- data += 2; +- +- names.pn_offset = byte_get (data, offset_size); +- data += offset_size; ++ SAFE_BYTE_GET_AND_INC (names.pn_version, data, 2, end); ++ SAFE_BYTE_GET_AND_INC (names.pn_offset, data, offset_size, end); + + if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE + && num_debug_info_entries > 0 +@@ -3330,8 +3423,7 @@ display_debug_pubnames (struct dwarf_sec + warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), + (unsigned long) names.pn_offset, section->name); + +- names.pn_size = byte_get (data, offset_size); +- data += offset_size; ++ SAFE_BYTE_GET_AND_INC (names.pn_size, data, offset_size, end); + + start += names.pn_length + initial_length_size; + +@@ -3361,13 +3453,13 @@ display_debug_pubnames (struct dwarf_sec + + do + { +- offset = byte_get (data, offset_size); ++ SAFE_BYTE_GET (offset, data, offset_size, end); + + if (offset != 0) + { + data += offset_size; + printf (" %-6lx\t%s\n", offset, data); +- data += strlen ((char *) data) + 1; ++ data += strnlen ((char *) data, end - data) + 1; + } + } + while (offset != 0); +@@ -3392,7 +3484,7 @@ display_debug_macinfo (struct dwarf_sect + while (curr < end) + { + unsigned int lineno; +- const char *string; ++ const unsigned char *string; + + op = (enum dwarf_macinfo_record_type) *curr; + curr++; +@@ -3403,9 +3495,9 @@ display_debug_macinfo (struct dwarf_sect + { + unsigned int filenum; + +- lineno = read_leb128 (curr, & bytes_read, 0); ++ lineno = read_uleb128 (curr, & bytes_read, end); + curr += bytes_read; +- filenum = read_leb128 (curr, & bytes_read, 0); ++ filenum = read_uleb128 (curr, & bytes_read, end); + curr += bytes_read; + + printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), +@@ -3418,19 +3510,19 @@ display_debug_macinfo (struct dwarf_sect + break; + + case DW_MACINFO_define: +- lineno = read_leb128 (curr, & bytes_read, 0); ++ lineno = read_uleb128 (curr, & bytes_read, end); + curr += bytes_read; +- string = (char *) curr; +- curr += strlen (string) + 1; ++ string = curr; ++ curr += strnlen ((char *) string, end - string) + 1; + printf (_(" DW_MACINFO_define - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACINFO_undef: +- lineno = read_leb128 (curr, & bytes_read, 0); ++ lineno = read_uleb128 (curr, & bytes_read, end); + curr += bytes_read; +- string = (char *) curr; +- curr += strlen (string) + 1; ++ string = curr; ++ curr += strnlen ((char *) string, end - string) + 1; + printf (_(" DW_MACINFO_undef - lineno : %d macro : %s\n"), + lineno, string); + break; +@@ -3439,10 +3531,10 @@ display_debug_macinfo (struct dwarf_sect + { + unsigned int constant; + +- constant = read_leb128 (curr, & bytes_read, 0); ++ constant = read_uleb128 (curr, & bytes_read, end); + curr += bytes_read; +- string = (char *) curr; +- curr += strlen (string) + 1; ++ string = curr; ++ curr += strnlen ((char *) string, end - string) + 1; + printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %s\n"), + constant, string); + } +@@ -3458,7 +3550,8 @@ display_debug_macinfo (struct dwarf_sect + FILEIDX. Return NULL on failure. */ + + static unsigned char * +-get_line_filename_and_dirname (dwarf_vma line_offset, dwarf_vma fileidx, ++get_line_filename_and_dirname (dwarf_vma line_offset, ++ dwarf_vma fileidx, + unsigned char **dir_name) + { + struct dwarf_section *section = &debug_displays [line].section; +@@ -3466,6 +3559,7 @@ get_line_filename_and_dirname (dwarf_vma + unsigned int offset_size, initial_length_size; + unsigned int version, opcode_base, bytes_read; + dwarf_vma length, diridx; ++ const unsigned char * end; + + *dir_name = NULL; + if (section->start == NULL +@@ -3474,13 +3568,13 @@ get_line_filename_and_dirname (dwarf_vma + return NULL; + + hdrptr = section->start + line_offset; +- length = byte_get (hdrptr, 4); +- hdrptr += 4; ++ end = section->start + section->size; ++ ++ SAFE_BYTE_GET_AND_INC (length, hdrptr, 4, end); + if (length == 0xffffffff) + { + /* This section is 64-bit DWARF 3. */ +- length = byte_get (hdrptr, 8); +- hdrptr += 8; ++ SAFE_BYTE_GET_AND_INC (length, hdrptr, 8, end); + offset_size = 8; + initial_length_size = 12; + } +@@ -3491,44 +3585,45 @@ get_line_filename_and_dirname (dwarf_vma + } + if (length + initial_length_size > section->size) + return NULL; +- version = byte_get (hdrptr, 2); +- hdrptr += 2; ++ ++ SAFE_BYTE_GET_AND_INC (version, hdrptr, 2, end); + if (version != 2 && version != 3 && version != 4) + return NULL; + hdrptr += offset_size + 1;/* Skip prologue_length and min_insn_length. */ + if (version >= 4) + hdrptr++; /* Skip max_ops_per_insn. */ + hdrptr += 3; /* Skip default_is_stmt, line_base, line_range. */ +- opcode_base = byte_get (hdrptr, 1); ++ ++ SAFE_BYTE_GET_AND_INC (opcode_base, hdrptr, 1, end); + if (opcode_base == 0) + return NULL; +- hdrptr++; ++ + hdrptr += opcode_base - 1; + dirtable = hdrptr; + /* Skip over dirname table. */ + while (*hdrptr != '\0') +- hdrptr += strlen ((char *) hdrptr) + 1; ++ hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; + hdrptr++; /* Skip the NUL at the end of the table. */ + /* Now skip over preceding filename table entries. */ + for (; *hdrptr != '\0' && fileidx > 1; fileidx--) + { +- hdrptr += strlen ((char *) hdrptr) + 1; +- read_leb128 (hdrptr, &bytes_read, 0); ++ hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; ++ read_uleb128 (hdrptr, &bytes_read, end); + hdrptr += bytes_read; +- read_leb128 (hdrptr, &bytes_read, 0); ++ read_uleb128 (hdrptr, &bytes_read, end); + hdrptr += bytes_read; +- read_leb128 (hdrptr, &bytes_read, 0); ++ read_uleb128 (hdrptr, &bytes_read, end); + hdrptr += bytes_read; + } +- if (*hdrptr == '\0') ++ if (hdrptr == end || *hdrptr == '\0') + return NULL; + file_name = hdrptr; +- hdrptr += strlen ((char *) hdrptr) + 1; +- diridx = read_leb128 (hdrptr, &bytes_read, 0); ++ hdrptr += strnlen ((char *) hdrptr, end - hdrptr) + 1; ++ diridx = read_uleb128 (hdrptr, &bytes_read, end); + if (diridx == 0) + return file_name; + for (; *dirtable != '\0' && diridx > 1; diridx--) +- dirtable += strlen ((char *) dirtable) + 1; ++ dirtable += strnlen ((char *) dirtable, end - dirtable) + 1; + if (*dirtable == '\0') + return NULL; + *dir_name = dirtable; +@@ -3554,13 +3649,11 @@ display_debug_macro (struct dwarf_sectio + { + unsigned int lineno, version, flags; + unsigned int offset_size = 4; +- const char *string; ++ const unsigned char *string; + dwarf_vma line_offset = 0, sec_offset = curr - start, offset; + unsigned char **extended_ops = NULL; + +- version = byte_get (curr, 2); +- curr += 2; +- ++ SAFE_BYTE_GET_AND_INC (version, curr, 2, end); + if (version != 4) + { + error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"), +@@ -3568,7 +3661,7 @@ display_debug_macro (struct dwarf_sectio + return 0; + } + +- flags = byte_get (curr++, 1); ++ SAFE_BYTE_GET_AND_INC (flags, curr, 1, end); + if (flags & 1) + offset_size = 8; + printf (_(" Offset: 0x%lx\n"), +@@ -3577,15 +3670,17 @@ display_debug_macro (struct dwarf_sectio + printf (_(" Offset size: %d\n"), offset_size); + if (flags & 2) + { +- line_offset = byte_get (curr, offset_size); +- curr += offset_size; ++ SAFE_BYTE_GET_AND_INC (line_offset, curr, offset_size, end); + printf (_(" Offset into .debug_line: 0x%lx\n"), + (unsigned long) line_offset); + } + if (flags & 4) + { +- unsigned int i, count = byte_get (curr++, 1), op; ++ unsigned int i, count, op; + dwarf_vma nargs, n; ++ ++ SAFE_BYTE_GET_AND_INC (count, curr, 1, end); ++ + memset (extended_op_buf, 0, sizeof (extended_op_buf)); + extended_ops = extended_op_buf; + if (count) +@@ -3593,9 +3688,9 @@ display_debug_macro (struct dwarf_sectio + printf (_(" Extension opcode arguments:\n")); + for (i = 0; i < count; i++) + { +- op = byte_get (curr++, 1); ++ SAFE_BYTE_GET_AND_INC (op, curr, 1, end); + extended_ops[op] = curr; +- nargs = read_leb128 (curr, &bytes_read, 0); ++ nargs = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + if (nargs == 0) + printf (_(" DW_MACRO_GNU_%02x has no arguments\n"), op); +@@ -3604,7 +3699,9 @@ display_debug_macro (struct dwarf_sectio + printf (_(" DW_MACRO_GNU_%02x arguments: "), op); + for (n = 0; n < nargs; n++) + { +- unsigned int form = byte_get (curr++, 1); ++ unsigned int form; ++ ++ SAFE_BYTE_GET_AND_INC (form, curr, 1, end); + printf ("%s%s", get_FORM_name (form), + n == nargs - 1 ? "\n" : ", "); + switch (form) +@@ -3646,7 +3743,7 @@ display_debug_macro (struct dwarf_sectio + return 0; + } + +- op = byte_get (curr++, 1); ++ SAFE_BYTE_GET_AND_INC (op, curr, 1, end); + if (op == 0) + break; + +@@ -3657,9 +3754,9 @@ display_debug_macro (struct dwarf_sectio + unsigned int filenum; + unsigned char *file_name = NULL, *dir_name = NULL; + +- lineno = read_leb128 (curr, &bytes_read, 0); ++ lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; +- filenum = read_leb128 (curr, &bytes_read, 0); ++ filenum = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; + + if ((flags & 2) == 0) +@@ -3684,46 +3781,43 @@ display_debug_macro (struct dwarf_sectio + break; + + case DW_MACRO_GNU_define: +- lineno = read_leb128 (curr, &bytes_read, 0); ++ lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; +- string = (char *) curr; +- curr += strlen (string) + 1; ++ string = curr; ++ curr += strnlen ((char *) string, end - string) + 1; + printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACRO_GNU_undef: +- lineno = read_leb128 (curr, &bytes_read, 0); ++ lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; +- string = (char *) curr; +- curr += strlen (string) + 1; ++ string = curr; ++ curr += strnlen ((char *) string, end - string) + 1; + printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACRO_GNU_define_indirect: +- lineno = read_leb128 (curr, &bytes_read, 0); ++ lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; +- offset = byte_get (curr, offset_size); +- curr += offset_size; ++ SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + string = fetch_indirect_string (offset); + printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACRO_GNU_undef_indirect: +- lineno = read_leb128 (curr, &bytes_read, 0); ++ lineno = read_uleb128 (curr, &bytes_read, end); + curr += bytes_read; +- offset = byte_get (curr, offset_size); +- curr += offset_size; ++ SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + string = fetch_indirect_string (offset); + printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"), + lineno, string); + break; + + case DW_MACRO_GNU_transparent_include: +- offset = byte_get (curr, offset_size); +- curr += offset_size; ++ SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end); + printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"), + (unsigned long) offset); + break; +@@ -3739,7 +3833,7 @@ display_debug_macro (struct dwarf_sectio + /* Skip over unhandled opcodes. */ + dwarf_vma nargs, n; + unsigned char *desc = extended_ops[op]; +- nargs = read_leb128 (desc, &bytes_read, 0); ++ nargs = read_uleb128 (desc, &bytes_read, end); + desc += bytes_read; + if (nargs == 0) + { +@@ -3749,9 +3843,12 @@ display_debug_macro (struct dwarf_sectio + printf (_(" DW_MACRO_GNU_%02x -"), op); + for (n = 0; n < nargs; n++) + { ++ int val; ++ ++ SAFE_BYTE_GET_AND_INC (val, desc, 1, end); + curr +- = read_and_display_attr_value (0, byte_get (desc++, 1), +- curr, 0, 0, offset_size, ++ = read_and_display_attr_value (0, val, ++ curr, end, 0, 0, offset_size, + version, NULL, 0, NULL); + if (n != nargs - 1) + printf (","); +@@ -3989,10 +4086,8 @@ display_debug_loc (struct dwarf_section + top 32 bits of a 32-bit address will not affect the values + that we display since we always show hex values, and always + the bottom 32-bits. */ +- begin = byte_get_signed (start, pointer_size); +- start += pointer_size; +- end = byte_get_signed (start, pointer_size); +- start += pointer_size; ++ SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end); ++ SAFE_BYTE_GET_AND_INC (end, start, pointer_size, section_end); + + printf (" %8.8lx ", offset); + +@@ -4019,8 +4114,7 @@ display_debug_loc (struct dwarf_section + break; + } + +- length = byte_get (start, 2); +- start += 2; ++ SAFE_BYTE_GET_AND_INC (length, start, 2, section_end); + + if (start + length > section_end) + { +@@ -4167,13 +4261,10 @@ display_debug_aranges (struct dwarf_sect + + hdrptr = start; + +- arange.ar_length = byte_get (hdrptr, 4); +- hdrptr += 4; +- ++ SAFE_BYTE_GET_AND_INC (arange.ar_length, hdrptr, 4, end); + if (arange.ar_length == 0xffffffff) + { +- arange.ar_length = byte_get (hdrptr, 8); +- hdrptr += 8; ++ SAFE_BYTE_GET_AND_INC (arange.ar_length, hdrptr, 8, end); + offset_size = 8; + initial_length_size = 12; + } +@@ -4183,11 +4274,8 @@ display_debug_aranges (struct dwarf_sect + initial_length_size = 4; + } + +- arange.ar_version = byte_get (hdrptr, 2); +- hdrptr += 2; +- +- arange.ar_info_offset = byte_get (hdrptr, offset_size); +- hdrptr += offset_size; ++ SAFE_BYTE_GET_AND_INC (arange.ar_version, hdrptr, 2, end); ++ SAFE_BYTE_GET_AND_INC (arange.ar_info_offset, hdrptr, offset_size, end); + + if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE + && num_debug_info_entries > 0 +@@ -4195,11 +4283,8 @@ display_debug_aranges (struct dwarf_sect + warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), + (unsigned long) arange.ar_info_offset, section->name); + +- arange.ar_pointer_size = byte_get (hdrptr, 1); +- hdrptr += 1; +- +- arange.ar_segment_size = byte_get (hdrptr, 1); +- hdrptr += 1; ++ SAFE_BYTE_GET_AND_INC (arange.ar_pointer_size, hdrptr, 1, end); ++ SAFE_BYTE_GET_AND_INC (arange.ar_segment_size, hdrptr, 1, end); + + if (arange.ar_version != 2 && arange.ar_version != 3) + { +@@ -4249,13 +4334,8 @@ display_debug_aranges (struct dwarf_sect + + while (addr_ranges + 2 * address_size <= start) + { +- address = byte_get (addr_ranges, address_size); +- +- addr_ranges += address_size; +- +- length = byte_get (addr_ranges, address_size); +- +- addr_ranges += address_size; ++ SAFE_BYTE_GET_AND_INC (address, addr_ranges, address_size, end); ++ SAFE_BYTE_GET_AND_INC (length, addr_ranges, address_size, end); + + printf (" "); + print_dwarf_vma (address, address_size); +@@ -4299,13 +4379,12 @@ display_debug_ranges (struct dwarf_secti + void *file ATTRIBUTE_UNUSED) + { + unsigned char *start = section->start; +- unsigned long bytes; ++ unsigned long bytes = section->size; + unsigned char *section_begin = start; ++ unsigned char *finish = start + bytes; + unsigned int num_range_list, i; + struct range_entry *range_entries, *range_entry_fill; + +- bytes = section->size; +- + if (bytes == 0) + { + printf (_("\nThe %s section is empty.\n"), section->name); +@@ -4383,7 +4462,7 @@ display_debug_ranges (struct dwarf_secti + } + start = next; + +- while (1) ++ while (start < finish) + { + dwarf_vma begin; + dwarf_vma end; +@@ -4393,10 +4472,10 @@ display_debug_ranges (struct dwarf_secti + top 32 bits of a 32-bit address will not affect the values + that we display since we always show hex values, and always + the bottom 32-bits. */ +- begin = byte_get_signed (start, pointer_size); +- start += pointer_size; +- end = byte_get_signed (start, pointer_size); +- start += pointer_size; ++ SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish); ++ if (start >= finish) ++ break; ++ SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish); + + printf (" %8.8lx ", offset); + +@@ -4658,9 +4737,96 @@ frame_display_row (Frame_Chunk *fc, int + printf ("\n"); + } + +-#define GET(N) byte_get (start, N); start += N +-#define LEB() read_leb128 (start, & length_return, 0); start += length_return +-#define SLEB() read_sleb128 (start, & length_return); start += length_return ++#define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end) ++#define LEB() read_uleb128 (start, & length_return, end); start += length_return ++#define SLEB() read_sleb128 (start, & length_return, end); start += length_return ++ ++static unsigned char * ++read_cie (unsigned char *start, unsigned char *end, ++ Frame_Chunk **p_cie, int *p_version, ++ unsigned long *p_aug_len, unsigned char **p_aug) ++{ ++ int version; ++ Frame_Chunk *fc; ++ unsigned int length_return; ++ unsigned char *augmentation_data = NULL; ++ unsigned long augmentation_data_len = 0; ++ ++ fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); ++ memset (fc, 0, sizeof (Frame_Chunk)); ++ ++ fc->col_type = (short int *) xmalloc (sizeof (short int)); ++ fc->col_offset = (int *) xmalloc (sizeof (int)); ++ ++ version = *start++; ++ ++ fc->augmentation = (char *) start; ++ start = (unsigned char *) strchr ((char *) start, '\0') + 1; ++ ++ if (strcmp (fc->augmentation, "eh") == 0) ++ start += eh_addr_size; ++ ++ if (version >= 4) ++ { ++ GET (fc->ptr_size, 1); ++ GET (fc->segment_size, 1); ++ eh_addr_size = fc->ptr_size; ++ } ++ else ++ { ++ fc->ptr_size = eh_addr_size; ++ fc->segment_size = 0; ++ } ++ fc->code_factor = LEB (); ++ fc->data_factor = SLEB (); ++ if (version == 1) ++ { ++ GET (fc->ra, 1); ++ } ++ else ++ { ++ fc->ra = LEB (); ++ } ++ ++ if (fc->augmentation[0] == 'z') ++ { ++ augmentation_data_len = LEB (); ++ augmentation_data = start; ++ start += augmentation_data_len; ++ } ++ ++ if (augmentation_data_len) ++ { ++ unsigned char *p, *q; ++ p = (unsigned char *) fc->augmentation + 1; ++ q = augmentation_data; ++ ++ while (1) ++ { ++ if (*p == 'L') ++ q++; ++ else if (*p == 'P') ++ q += 1 + size_of_encoded_value (*q); ++ else if (*p == 'R') ++ fc->fde_encoding = *q++; ++ else if (*p == 'S') ++ ; ++ else ++ break; ++ p++; ++ } ++ } ++ ++ *p_cie = fc; ++ if (p_version) ++ *p_version = version; ++ if (p_aug_len) ++ { ++ *p_aug_len = augmentation_data_len; ++ *p_aug = augmentation_data; ++ } ++ return start; ++} + + static int + display_debug_frames (struct dwarf_section *section, +@@ -4669,7 +4835,7 @@ display_debug_frames (struct dwarf_secti + unsigned char *start = section->start; + unsigned char *end = start + section->size; + unsigned char *section_start = start; +- Frame_Chunk *chunks = 0; ++ Frame_Chunk *chunks = 0, *forward_refs = 0; + Frame_Chunk *remembered_state = 0; + Frame_Chunk *rs; + int is_eh = strcmp (section->name, ".eh_frame") == 0; +@@ -4696,8 +4862,8 @@ display_debug_frames (struct dwarf_secti + int initial_length_size; + + saved_start = start; +- length = byte_get (start, 4); start += 4; + ++ SAFE_BYTE_GET_AND_INC (length, start, 4, end); + if (length == 0) + { + printf ("\n%08lx ZERO terminator\n\n", +@@ -4707,8 +4873,7 @@ display_debug_frames (struct dwarf_secti + + if (length == 0xffffffff) + { +- length = byte_get (start, 8); +- start += 8; ++ SAFE_BYTE_GET_AND_INC (length, start, 8, end); + offset_size = 8; + initial_length_size = 12; + } +@@ -4725,60 +4890,26 @@ display_debug_frames (struct dwarf_secti + length, (unsigned long)(saved_start - section_start)); + block_end = end; + } +- cie_id = byte_get (start, offset_size); start += offset_size; ++ ++ SAFE_BYTE_GET_AND_INC (cie_id, start, offset_size, end); + + if (is_eh ? (cie_id == 0) : (cie_id == DW_CIE_ID)) + { + int version; ++ int mreg; + +- fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); +- memset (fc, 0, sizeof (Frame_Chunk)); +- ++ start = read_cie (start, end, &cie, &version, ++ &augmentation_data_len, &augmentation_data); ++ fc = cie; + fc->next = chunks; + chunks = fc; + fc->chunk_start = saved_start; +- fc->ncols = 0; +- fc->col_type = (short int *) xmalloc (sizeof (short int)); +- fc->col_offset = (int *) xmalloc (sizeof (int)); +- frame_need_space (fc, max_regs - 1); +- +- version = *start++; +- +- fc->augmentation = (char *) start; +- start = (unsigned char *) strchr ((char *) start, '\0') + 1; +- +- if (strcmp (fc->augmentation, "eh") == 0) +- start += eh_addr_size; +- +- if (version >= 4) +- { +- fc->ptr_size = GET (1); +- fc->segment_size = GET (1); +- eh_addr_size = fc->ptr_size; +- } +- else +- { +- fc->ptr_size = eh_addr_size; +- fc->segment_size = 0; +- } +- fc->code_factor = LEB (); +- fc->data_factor = SLEB (); +- if (version == 1) +- { +- fc->ra = GET (1); +- } +- else +- { +- fc->ra = LEB (); +- } +- +- if (fc->augmentation[0] == 'z') +- { +- augmentation_data_len = LEB (); +- augmentation_data = start; +- start += augmentation_data_len; +- } +- cie = fc; ++ mreg = max_regs - 1; ++ if (mreg < fc->ra) ++ mreg = fc->ra; ++ frame_need_space (fc, mreg); ++ if (fc->fde_encoding) ++ encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); + + if (do_debug_frames_interp) + printf ("\n%08lx %08lx %08lx CIE \"%s\" cf=%d df=%d ra=%d\n", +@@ -4810,33 +4941,6 @@ display_debug_frames (struct dwarf_secti + } + putchar ('\n'); + } +- +- if (augmentation_data_len) +- { +- unsigned char *p, *q; +- p = (unsigned char *) fc->augmentation + 1; +- q = augmentation_data; +- +- while (1) +- { +- if (*p == 'L') +- q++; +- else if (*p == 'P') +- q += 1 + size_of_encoded_value (*q); +- else if (*p == 'R') +- fc->fde_encoding = *q++; +- else if (*p == 'S') +- ; +- else +- break; +- p++; +- } +- +- if (fc->fde_encoding) +- encoded_ptr_size = size_of_encoded_value (fc->fde_encoding); +- } +- +- frame_need_space (fc, fc->ra); + } + else + { +@@ -4844,14 +4948,70 @@ display_debug_frames (struct dwarf_secti + static Frame_Chunk fde_fc; + unsigned long segment_selector; + +- fc = & fde_fc; +- memset (fc, 0, sizeof (Frame_Chunk)); ++ if (is_eh) ++ { ++ dwarf_vma sign = (dwarf_vma) 1 << (offset_size * 8 - 1); ++ look_for = start - 4 - ((cie_id ^ sign) - sign); ++ } ++ else ++ look_for = section_start + cie_id; ++ ++ if (look_for <= saved_start) ++ { ++ for (cie = chunks; cie ; cie = cie->next) ++ if (cie->chunk_start == look_for) ++ break; ++ } ++ else ++ { ++ for (cie = forward_refs; cie ; cie = cie->next) ++ if (cie->chunk_start == look_for) ++ break; ++ if (!cie) ++ { ++ unsigned int off_size; ++ unsigned char *cie_scan; + +- look_for = is_eh ? start - 4 - cie_id : section_start + cie_id; ++ cie_scan = look_for; ++ off_size = 4; ++ SAFE_BYTE_GET_AND_INC (length, cie_scan, 4, end); ++ if (length == 0xffffffff) ++ { ++ SAFE_BYTE_GET_AND_INC (length, cie_scan, 8, end); ++ off_size = 8; ++ } ++ if (length != 0) ++ { ++ dwarf_vma c_id; + +- for (cie = chunks; cie ; cie = cie->next) +- if (cie->chunk_start == look_for) +- break; ++ SAFE_BYTE_GET_AND_INC (c_id, cie_scan, off_size, end); ++ if (is_eh ++ ? c_id == 0 ++ : ((off_size == 4 && c_id == DW_CIE_ID) ++ || (off_size == 8 && c_id == DW64_CIE_ID))) ++ { ++ int version; ++ int mreg; ++ ++ read_cie (cie_scan, end, &cie, &version, ++ &augmentation_data_len, &augmentation_data); ++ cie->next = forward_refs; ++ forward_refs = cie; ++ cie->chunk_start = look_for; ++ mreg = max_regs - 1; ++ if (mreg < cie->ra) ++ mreg = cie->ra; ++ frame_need_space (cie, mreg); ++ if (cie->fde_encoding) ++ encoded_ptr_size ++ = size_of_encoded_value (cie->fde_encoding); ++ } ++ } ++ } ++ } ++ ++ fc = &fde_fc; ++ memset (fc, 0, sizeof (Frame_Chunk)); + + if (!cie) + { +@@ -4893,14 +5053,17 @@ display_debug_frames (struct dwarf_secti + segment_selector = 0; + if (fc->segment_size) + { +- segment_selector = byte_get (start, fc->segment_size); +- start += fc->segment_size; ++ SAFE_BYTE_GET_AND_INC (segment_selector, start, fc->segment_size, end); + } + fc->pc_begin = get_encoded_value (start, fc->fde_encoding, section); + start += encoded_ptr_size; +- fc->pc_range = byte_get (start, encoded_ptr_size); +- start += encoded_ptr_size; + ++ /* FIXME: It appears that sometimes the final pc_range value is ++ encoded in less than encoded_ptr_size bytes. See the x86_64 ++ run of the "objcopy on compressed debug sections" test for an ++ example of this. */ ++ SAFE_BYTE_GET_AND_INC (fc->pc_range, start, encoded_ptr_size, end); ++ + if (cie->augmentation[0] == 'z') + { + augmentation_data_len = LEB (); +@@ -5124,7 +5287,7 @@ display_debug_frames (struct dwarf_secti + break; + + case DW_CFA_advance_loc1: +- ofs = byte_get (start, 1); start += 1; ++ SAFE_BYTE_GET_AND_INC (ofs, start, 1, end); + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else +@@ -5135,7 +5298,7 @@ display_debug_frames (struct dwarf_secti + break; + + case DW_CFA_advance_loc2: +- ofs = byte_get (start, 2); start += 2; ++ SAFE_BYTE_GET_AND_INC (ofs, start, 2, end); + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else +@@ -5146,7 +5309,7 @@ display_debug_frames (struct dwarf_secti + break; + + case DW_CFA_advance_loc4: +- ofs = byte_get (start, 4); start += 4; ++ SAFE_BYTE_GET_AND_INC (ofs, start, 4, end); + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else +@@ -5409,7 +5572,7 @@ display_debug_frames (struct dwarf_secti + break; + + case DW_CFA_MIPS_advance_loc8: +- ofs = byte_get (start, 8); start += 8; ++ SAFE_BYTE_GET_AND_INC (ofs, start, 8, end); + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else +Index: b/binutils/dwarf.h +=================================================================== +--- a/binutils/dwarf.h ++++ b/binutils/dwarf.h +@@ -1,6 +1,5 @@ + /* dwarf.h - DWARF support header file +- Copyright 2005, 2007, 2008, 2009, 2010, 2011 +- Free Software Foundation, Inc. ++ Copyright 2005-2013 Free Software Foundation, Inc. + + This file is part of GNU Binutils. + +@@ -221,4 +220,4 @@ void * cmalloc (size_t, size_t); + void * xcmalloc (size_t, size_t); + void * xcrealloc (void *, size_t, size_t); + +-dwarf_vma read_leb128 (unsigned char *, unsigned int *, int); ++extern dwarf_vma read_leb128 (unsigned char *, unsigned int *, bfd_boolean, const unsigned char * const); +Index: b/binutils/readelf.c +=================================================================== +--- a/binutils/readelf.c ++++ b/binutils/readelf.c +@@ -518,10 +518,12 @@ find_section_by_address (bfd_vma addr) + /* Read an unsigned LEB128 encoded value from p. Set *PLEN to the number of + bytes read. */ + +-static unsigned long +-read_uleb128 (unsigned char *data, unsigned int *length_return) ++static inline unsigned long ++read_uleb128 (unsigned char *data, ++ unsigned int *length_return, ++ const unsigned char * const end) + { +- return read_leb128 (data, length_return, 0); ++ return read_leb128 (data, length_return, FALSE, end); + } + + /* Return true if the current file is for IA-64 machine and OpenVMS ABI. +@@ -6736,7 +6738,7 @@ decode_arm_unwind_bytecode (struct arm_u + break; + } + assert (i < sizeof (buf)); +- offset = read_uleb128 (buf, &len); ++ offset = read_uleb128 (buf, &len, buf + i + 1); + assert (len == i + 1); + offset = offset * 4 + 0x204; + printf ("vsp = vsp + %ld", offset); +@@ -6930,7 +6932,7 @@ decode_tic6x_unwind_bytecode (struct arm + break; + } + assert (i < sizeof (buf)); +- offset = read_uleb128 (buf, &len); ++ offset = read_uleb128 (buf, &len, buf + i + 1); + assert (len == i + 1); + offset = offset * 8 + 0x408; + printf (_("sp = sp + %ld"), offset); +@@ -10806,6 +10808,52 @@ process_mips_fpe_exception (int mask) + fputs ("0", stdout); + } + ++/* Display's the value of TAG at location P. If TAG is ++ greater than 0 it is assumed to be an unknown tag, and ++ a message is printed to this effect. Otherwise it is ++ assumed that a message has already been printed. ++ ++ If the bottom bit of TAG is set it assumed to have a ++ string value, otherwise it is assumed to have an integer ++ value. ++ ++ Returns an updated P pointing to the first unread byte ++ beyond the end of TAG's value. ++ ++ Reads at or beyond END will not be made. */ ++ ++static unsigned char * ++display_tag_value (int tag, ++ unsigned char * p, ++ const unsigned char * const end) ++{ ++ unsigned long val; ++ ++ if (tag > 0) ++ printf (" Tag_unknown_%d: ", tag); ++ ++ if (p >= end) ++ { ++ warn (_("corrupt tag\n")); ++ } ++ else if (tag & 1) ++ { ++ /* FIXME: we could read beyond END here. */ ++ printf ("\"%s\"\n", p); ++ p += strlen ((char *) p) + 1; ++ } ++ else ++ { ++ unsigned int len; ++ ++ val = read_uleb128 (p, &len, end); ++ p += len; ++ printf ("%ld (0x%lx)\n", val, val); ++ } ++ ++ return p; ++} ++ + /* ARM EABI attributes section. */ + typedef struct + { +@@ -10926,7 +10974,8 @@ static arm_attr_public_tag arm_attr_publ + #undef LOOKUP + + static unsigned char * +-display_arm_attribute (unsigned char * p) ++display_arm_attribute (unsigned char * p, ++ const unsigned char * const end) + { + int tag; + unsigned int len; +@@ -10935,7 +10984,7 @@ display_arm_attribute (unsigned char * p + unsigned i; + int type; + +- tag = read_uleb128 (p, &len); ++ tag = read_uleb128 (p, &len, end); + p += len; + attr = NULL; + for (i = 0; i < ARRAY_SIZE (arm_attr_public_tags); i++) +@@ -10956,7 +11005,7 @@ display_arm_attribute (unsigned char * p + switch (tag) + { + case 7: /* Tag_CPU_arch_profile. */ +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + switch (val) + { +@@ -10970,7 +11019,7 @@ display_arm_attribute (unsigned char * p + break; + + case 24: /* Tag_align_needed. */ +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + switch (val) + { +@@ -10989,7 +11038,7 @@ display_arm_attribute (unsigned char * p + break; + + case 25: /* Tag_align_preserved. */ +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + switch (val) + { +@@ -11008,7 +11057,7 @@ display_arm_attribute (unsigned char * p + break; + + case 32: /* Tag_compatibility. */ +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (_("flag = %d, vendor = %s\n"), val, p); + p += strlen ((char *) p) + 1; +@@ -11020,11 +11069,11 @@ display_arm_attribute (unsigned char * p + break; + + case 65: /* Tag_also_compatible_with. */ +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + if (val == 6 /* Tag_CPU_arch. */) + { +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + if ((unsigned int)val >= ARRAY_SIZE (arm_attr_tag_CPU_arch)) + printf ("??? (%d)\n", val); +@@ -11042,13 +11091,13 @@ display_arm_attribute (unsigned char * p + return p; + + case 1: ++ return display_tag_value (-1, p, end); + case 2: +- type = attr->type; +- break; ++ return display_tag_value (0, p, end); + + default: + assert (attr->type & 0x80); +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + type = attr->type & 0x7f; + if (val >= type) +@@ -11058,87 +11107,58 @@ display_arm_attribute (unsigned char * p + return p; + } + } +- else +- { +- if (tag & 1) +- type = 1; /* String. */ +- else +- type = 2; /* uleb128. */ +- printf (" Tag_unknown_%d: ", tag); +- } +- +- if (type == 1) +- { +- printf ("\"%s\"\n", p); +- p += strlen ((char *) p) + 1; +- } +- else +- { +- val = read_uleb128 (p, &len); +- p += len; +- printf ("%d (0x%x)\n", val, val); +- } + +- return p; ++ return display_tag_value (tag, p, end); + } + + static unsigned char * + display_gnu_attribute (unsigned char * p, +- unsigned char * (* display_proc_gnu_attribute) (unsigned char *, int)) ++ unsigned char * (* display_proc_gnu_attribute) (unsigned char *, int, const unsigned char * const), ++ const unsigned char * const end) + { + int tag; + unsigned int len; + int val; +- int type; + +- tag = read_uleb128 (p, &len); ++ tag = read_uleb128 (p, &len, end); + p += len; + + /* Tag_compatibility is the only generic GNU attribute defined at + present. */ + if (tag == 32) + { +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; +- printf (_("flag = %d, vendor = %s\n"), val, p); +- p += strlen ((char *) p) + 1; ++ if (p == end) ++ { ++ printf (_("flag = %d, vendor = \n"), val); ++ warn (_("corrupt vendor attribute\n")); ++ } ++ else ++ { ++ printf (_("flag = %d, vendor = %s\n"), val, p); ++ p += strlen ((char *) p) + 1; ++ } + return p; + } + + if ((tag & 2) == 0 && display_proc_gnu_attribute) +- return display_proc_gnu_attribute (p, tag); +- +- if (tag & 1) +- type = 1; /* String. */ +- else +- type = 2; /* uleb128. */ +- printf (" Tag_unknown_%d: ", tag); +- +- if (type == 1) +- { +- printf ("\"%s\"\n", p); +- p += strlen ((char *) p) + 1; +- } +- else +- { +- val = read_uleb128 (p, &len); +- p += len; +- printf ("%d (0x%x)\n", val, val); +- } ++ return display_proc_gnu_attribute (p, tag, end); + +- return p; ++ return display_tag_value (tag, p, end); + } + + static unsigned char * +-display_power_gnu_attribute (unsigned char * p, int tag) ++display_power_gnu_attribute (unsigned char * p, ++ int tag, ++ const unsigned char * const end) + { +- int type; + unsigned int len; + int val; + + if (tag == Tag_GNU_Power_ABI_FP) + { +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_Power_ABI_FP: "); + +@@ -11165,7 +11185,7 @@ display_power_gnu_attribute (unsigned ch + + if (tag == Tag_GNU_Power_ABI_Vector) + { +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_Power_ABI_Vector: "); + switch (val) +@@ -11191,7 +11211,13 @@ display_power_gnu_attribute (unsigned ch + + if (tag == Tag_GNU_Power_ABI_Struct_Return) + { +- val = read_uleb128 (p, &len); ++ if (p == end) ++ { ++ warn (_("corrupt Tag_GNU_Power_ABI_Struct_Return")); ++ return p; ++ } ++ ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_Power_ABI_Struct_Return: "); + switch (val) +@@ -11212,25 +11238,7 @@ display_power_gnu_attribute (unsigned ch + return p; + } + +- if (tag & 1) +- type = 1; /* String. */ +- else +- type = 2; /* uleb128. */ +- printf (" Tag_unknown_%d: ", tag); +- +- if (type == 1) +- { +- printf ("\"%s\"\n", p); +- p += strlen ((char *) p) + 1; +- } +- else +- { +- val = read_uleb128 (p, &len); +- p += len; +- printf ("%d (0x%x)\n", val, val); +- } +- +- return p; ++ return display_tag_value (tag & 1, p, end); + } + + static void +@@ -11278,53 +11286,36 @@ display_sparc_hwcaps (int mask) + } + + static unsigned char * +-display_sparc_gnu_attribute (unsigned char * p, int tag) ++display_sparc_gnu_attribute (unsigned char * p, ++ int tag, ++ const unsigned char * const end) + { +- int type; +- unsigned int len; +- int val; +- + if (tag == Tag_GNU_Sparc_HWCAPS) + { +- val = read_uleb128 (p, &len); ++ unsigned int len; ++ int val; ++ ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_Sparc_HWCAPS: "); +- + display_sparc_hwcaps (val); + return p; + } + +- if (tag & 1) +- type = 1; /* String. */ +- else +- type = 2; /* uleb128. */ +- printf (" Tag_unknown_%d: ", tag); +- +- if (type == 1) +- { +- printf ("\"%s\"\n", p); +- p += strlen ((char *) p) + 1; +- } +- else +- { +- val = read_uleb128 (p, &len); +- p += len; +- printf ("%d (0x%x)\n", val, val); +- } +- +- return p; ++ return display_tag_value (tag, p, end); + } + + static unsigned char * +-display_mips_gnu_attribute (unsigned char * p, int tag) ++display_mips_gnu_attribute (unsigned char * p, ++ int tag, ++ const unsigned char * const end) + { +- int type; +- unsigned int len; +- int val; +- + if (tag == Tag_GNU_MIPS_ABI_FP) + { +- val = read_uleb128 (p, &len); ++ unsigned int len; ++ int val; ++ ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_GNU_MIPS_ABI_FP: "); + +@@ -11352,41 +11343,24 @@ display_mips_gnu_attribute (unsigned cha + return p; + } + +- if (tag & 1) +- type = 1; /* String. */ +- else +- type = 2; /* uleb128. */ +- printf (" Tag_unknown_%d: ", tag); +- +- if (type == 1) +- { +- printf ("\"%s\"\n", p); +- p += strlen ((char *) p) + 1; +- } +- else +- { +- val = read_uleb128 (p, &len); +- p += len; +- printf ("%d (0x%x)\n", val, val); +- } +- +- return p; ++ return display_tag_value (tag & 1, p, end); + } + + static unsigned char * +-display_tic6x_attribute (unsigned char * p) ++display_tic6x_attribute (unsigned char * p, ++ const unsigned char * const end) + { + int tag; + unsigned int len; + int val; + +- tag = read_uleb128 (p, &len); ++ tag = read_uleb128 (p, &len, end); + p += len; + + switch (tag) + { + case Tag_ISA: +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ISA: "); + +@@ -11420,7 +11394,7 @@ display_tic6x_attribute (unsigned char * + return p; + + case Tag_ABI_wchar_t: +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_wchar_t: "); + switch (val) +@@ -11441,7 +11415,7 @@ display_tic6x_attribute (unsigned char * + return p; + + case Tag_ABI_stack_align_needed: +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_stack_align_needed: "); + switch (val) +@@ -11459,7 +11433,7 @@ display_tic6x_attribute (unsigned char * + return p; + + case Tag_ABI_stack_align_preserved: +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_stack_align_preserved: "); + switch (val) +@@ -11477,7 +11451,7 @@ display_tic6x_attribute (unsigned char * + return p; + + case Tag_ABI_DSBT: +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_DSBT: "); + switch (val) +@@ -11495,7 +11469,7 @@ display_tic6x_attribute (unsigned char * + return p; + + case Tag_ABI_PID: +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_PID: "); + switch (val) +@@ -11516,7 +11490,7 @@ display_tic6x_attribute (unsigned char * + return p; + + case Tag_ABI_PIC: +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_PIC: "); + switch (val) +@@ -11534,7 +11508,7 @@ display_tic6x_attribute (unsigned char * + return p; + + case Tag_ABI_array_object_alignment: +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_array_object_alignment: "); + switch (val) +@@ -11555,7 +11529,7 @@ display_tic6x_attribute (unsigned char * + return p; + + case Tag_ABI_array_object_align_expected: +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_array_object_align_expected: "); + switch (val) +@@ -11576,7 +11550,7 @@ display_tic6x_attribute (unsigned char * + return p; + + case Tag_ABI_compatibility: +- val = read_uleb128 (p, &len); ++ val = read_uleb128 (p, &len, end); + p += len; + printf (" Tag_ABI_compatibility: "); + printf (_("flag = %d, vendor = %s\n"), val, p); +@@ -11590,29 +11564,59 @@ display_tic6x_attribute (unsigned char * + return p; + } + +- printf (" Tag_unknown_%d: ", tag); ++ return display_tag_value (tag, p, end); ++} + +- if (tag & 1) +- { +- printf ("\"%s\"\n", p); +- p += strlen ((char *) p) + 1; +- } +- else ++static void ++display_raw_attribute (unsigned char * p, unsigned char * end) ++{ ++ unsigned long addr = 0; ++ size_t bytes = end - p; ++ ++ while (bytes) + { +- val = read_uleb128 (p, &len); +- p += len; +- printf ("%d (0x%x)\n", val, val); ++ int j; ++ int k; ++ int lbytes = (bytes > 16 ? 16 : bytes); ++ ++ printf (" 0x%8.8lx ", addr); ++ ++ for (j = 0; j < 16; j++) ++ { ++ if (j < lbytes) ++ printf ("%2.2x", p[j]); ++ else ++ printf (" "); ++ ++ if ((j & 3) == 3) ++ printf (" "); ++ } ++ ++ for (j = 0; j < lbytes; j++) ++ { ++ k = p[j]; ++ if (k >= ' ' && k < 0x7f) ++ printf ("%c", k); ++ else ++ printf ("."); ++ } ++ ++ putchar ('\n'); ++ ++ p += lbytes; ++ bytes -= lbytes; ++ addr += lbytes; + } + +- return p; ++ putchar ('\n'); + } + + static int + process_attributes (FILE * file, + const char * public_name, + unsigned int proc_type, +- unsigned char * (* display_pub_attribute) (unsigned char *), +- unsigned char * (* display_proc_gnu_attribute) (unsigned char *, int)) ++ unsigned char * (* display_pub_attribute) (unsigned char *, const unsigned char * const), ++ unsigned char * (* display_proc_gnu_attribute) (unsigned char *, int, const unsigned char * const)) + { + Elf_Internal_Shdr * sect; + unsigned char * contents; +@@ -11707,7 +11711,7 @@ process_attributes (FILE * file, + { + unsigned int j; + +- val = read_uleb128 (p, &j); ++ val = read_uleb128 (p, &j, end); + p += j; + if (val == 0) + break; +@@ -11724,18 +11728,19 @@ process_attributes (FILE * file, + if (public_section) + { + while (p < end) +- p = display_pub_attribute (p); ++ p = display_pub_attribute (p, end); + } + else if (gnu_section) + { + while (p < end) + p = display_gnu_attribute (p, +- display_proc_gnu_attribute); ++ display_proc_gnu_attribute, ++ end); + } + else + { +- /* ??? Do something sensible, like dump hex. */ + printf (_(" Unknown section contexts\n")); ++ display_raw_attribute (p, end); + p = end; + } + } +Index: b/bfd/bfd-in2.h +=================================================================== +--- a/bfd/bfd-in2.h ++++ b/bfd/bfd-in2.h +@@ -1714,6 +1714,8 @@ void bfd_section_list_clear (bfd *); + + asection *bfd_get_section_by_name (bfd *abfd, const char *name); + ++asection *bfd_get_next_section_by_name (asection *sec); ++ + asection *bfd_get_section_by_name_if + (bfd *abfd, + const char *name, +Index: b/bfd/elflink.c +=================================================================== +--- a/bfd/elflink.c ++++ b/bfd/elflink.c +@@ -12508,8 +12508,8 @@ bfd_elf_discard_info (bfd *output_bfd, s + fini_reloc_cookie_rels (&cookie, stab); + } + +- if (eh != NULL +- && init_reloc_cookie_rels (&cookie, info, abfd, eh)) ++ while (eh != NULL ++ && init_reloc_cookie_rels (&cookie, info, abfd, eh)) + { + _bfd_elf_parse_eh_frame (abfd, info, eh, &cookie); + if (_bfd_elf_discard_section_eh_frame (abfd, info, eh, +@@ -12517,6 +12517,7 @@ bfd_elf_discard_info (bfd *output_bfd, s + &cookie)) + ret = TRUE; + fini_reloc_cookie_rels (&cookie, eh); ++ eh = bfd_get_next_section_by_name (eh); + } + + if (bed->elf_backend_discard_info != NULL +Index: b/bfd/section.c +=================================================================== +--- a/bfd/section.c ++++ b/bfd/section.c +@@ -852,14 +852,8 @@ SYNOPSIS + asection *bfd_get_section_by_name (bfd *abfd, const char *name); + + DESCRIPTION +- Run through @var{abfd} and return the one of the +- <>s whose name matches @var{name}, otherwise <>. +- @xref{Sections}, for more information. +- +- This should only be used in special cases; the normal way to process +- all sections of a given name is to use <> and +- <> on the name (or better yet, base it on the section flags +- or something else) for each section. ++ Return the most recently created section attached to @var{abfd} ++ named @var{name}. Return NULL if no such section exists. + */ + + asection * +@@ -873,6 +867,41 @@ bfd_get_section_by_name (bfd *abfd, cons + + return NULL; + } ++ ++/* ++FUNCTION ++ bfd_get_next_section_by_name ++ ++SYNOPSIS ++ asection *bfd_get_next_section_by_name (asection *sec); ++ ++DESCRIPTION ++ Given @var{sec} is a section returned by @code{bfd_get_section_by_name}, ++ return the next most recently created section attached to the same ++ BFD with the same name. Return NULL if no such section exists. ++*/ ++ ++asection * ++bfd_get_next_section_by_name (asection *sec) ++{ ++ struct section_hash_entry *sh; ++ const char *name; ++ unsigned long hash; ++ ++ sh = ((struct section_hash_entry *) ++ ((char *) sec - offsetof (struct section_hash_entry, section))); ++ ++ hash = sh->root.hash; ++ name = sec->name; ++ for (sh = (struct section_hash_entry *) sh->root.next; ++ sh != NULL; ++ sh = (struct section_hash_entry *) sh->root.next) ++ if (sh->root.hash == hash ++ && strcmp (sh->root.string, name) == 0) ++ return &sh->section; ++ ++ return NULL; ++} + + /* + FUNCTION --- binutils-2.22.orig/debian/patches/156_pr10144.patch +++ binutils-2.22/debian/patches/156_pr10144.patch @@ -0,0 +1,315 @@ +## DP: Description: http://sourceware.org/ml/binutils/2010-09/msg00216.html + +2010-09-15 Maciej W. Rozycki + + PR ld/10144 + + bfd/ + * elfxx-mips.c (_bfd_mips_elf_check_relocs) + [R_MIPS_32, R_MIPS_REL32, R_MIPS_64]: Ignore relocs from + SEC_DEBUGGING sections. + + ld/testsuite/ + * lib/ld-lib.exp (run_ld_link_tests): Handle sources from other + directories. + (run_ld_link_exec_tests): Likewise. + (run_cc_link_tests): Likewise. + * ld-elf/comm-data1.sd: New test. + * ld-elf/comm-data1.s: Source for the new test. + * ld-elf/comm-data2.sd: New test. + * ld-elf/comm-data2.rd: Likewise. + * ld-elf/comm-data2.xd: Likewise. + * ld-elf/comm-data2.s: Source for the new tests. + * ld-elf/comm-data.exp: Run the new tests. + * ld-mips-elf/comm-data.exp: Likewise. + +--- /dev/null ++++ b/ld/testsuite/ld-elf/comm-data1.s +@@ -0,0 +1,6 @@ ++ .section .rodata,"a",%progbits ++ .balign 8 ++ .globl foo ++ .type foo,%object ++foo: ++ .skip 4, 0 +--- /dev/null ++++ b/ld/testsuite/ld-elf/comm-data2.xd +@@ -0,0 +1,2 @@ ++Hex dump of section '\.debug_foo': ++ +0x0+ +00000000 00000000 00000000 00000000 +\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\. +--- /dev/null ++++ b/ld/testsuite/ld-elf/comm-data2.s +@@ -0,0 +1,14 @@ ++ .text ++ .globl _start ++ .globl __start ++_start: ++__start: ++ .comm foo, 4, 4 ++ .section .debug_foo,"",%progbits ++ .balign 16 ++ .ifdef ELF64 ++ .8byte foo ++ .else ++ .4byte foo ++ .endif ++ .balign 16 +--- /dev/null ++++ b/ld/testsuite/ld-elf/comm-data.exp +@@ -0,0 +1,76 @@ ++# Expect script for common symbol override. ++# ++# Copyright 2010 Free Software Foundation, Inc. ++# ++# This file is part of the GNU Binutils. ++# ++# 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 3 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., 51 Franklin Street - Fifth Floor, Boston, ++# MA 02110-1301, USA. ++# ++ ++# ++# Written by Maciej W. Rozycki ++# ++ ++# Exclude non-ELF targets. ++if ![is_elf_format] { ++ return ++} ++ ++# Exclude non-Linux targets; feel free to include your favourite one ++# if you like. ++if ![istarget *-*-linux*] { ++ return ++} ++ ++set testname "Common symbol override test" ++ ++# Define a global symbol. ++run_ld_link_tests [list \ ++ [list \ ++ "$testname (auxiliary shared object build)" \ ++ "-shared" \ ++ "" \ ++ { comm-data1.s } \ ++ { \ ++ { readelf -s comm-data1.sd } \ ++ } \ ++ "libcomm-data.so" \ ++ ] \ ++] ++ ++# Set the pointer size according to the ELF flavour. ++set AFLAGS "" ++if [is_elf64 "tmpdir/libcomm-data.so"] { ++ append AFLAGS " --defsym ELF64=1" ++} ++ ++# Verify that a common symbol has been converted to an undefined ++# reference to the global symbol of the same name defined above ++# and that the debug reference has been dropped. ++run_ld_link_tests [list \ ++ [list \ ++ "$testname" \ ++ "-Ltmpdir -lcomm-data" \ ++ "$AFLAGS" \ ++ { comm-data2.s } \ ++ { \ ++ { readelf -s comm-data2.sd } \ ++ { readelf -r comm-data2.rd } \ ++ { readelf "-x .debug_foo" comm-data2.xd } \ ++ } \ ++ "comm-data" \ ++ ] \ ++] +--- /dev/null ++++ b/ld/testsuite/ld-elf/comm-data1.sd +@@ -0,0 +1,10 @@ ++Symbol table '\.dynsym' contains [0-9]+ entries: ++ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name ++#... ++ +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo ++#... ++Symbol table '\.symtab' contains [0-9]+ entries: ++ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name ++#... ++ +[0-9]+: +[0-9a-f]+ +0 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo ++#pass +--- /dev/null ++++ b/ld/testsuite/ld-elf/comm-data2.rd +@@ -0,0 +1 @@ ++There are no relocations in this file\. +--- /dev/null ++++ b/ld/testsuite/ld-elf/comm-data2.sd +@@ -0,0 +1,10 @@ ++Symbol table '\.dynsym' contains [0-9]+ entries: ++ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name ++#... ++ +[0-9]+: +0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +foo ++#... ++Symbol table '\.symtab' contains [0-9]+ entries: ++ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name ++#... ++ +[0-9]+: +0+ +0 +OBJECT +GLOBAL +DEFAULT +UND +foo ++#pass +--- a/ld/testsuite/lib/ld-lib.exp ++++ b/ld/testsuite/lib/ld-lib.exp +@@ -1252,11 +1252,12 @@ + + # Assemble each file in the test. + foreach src_file $src_files { +- set objfile "tmpdir/[file rootname $src_file].o" ++ set fileroot "[file rootname [file tail $src_file]]" ++ set objfile "tmpdir/$fileroot.o" + lappend objfiles $objfile + + if { [file extension $src_file] == ".c" } { +- set as_file "tmpdir/[file rootname $src_file].s" ++ set as_file "tmpdir/$fileroot.s" + if ![ld_compile "$CC -S $CFLAGS $cflags" $srcdir/$subdir/$src_file $as_file] { + set is_unresolved 1 + break +@@ -1446,7 +1447,8 @@ + + # Assemble each file in the test. + foreach src_file $src_files { +- set objfile "tmpdir/[file rootname $src_file].o" ++ set fileroot "[file rootname [file tail $src_file]]" ++ set objfile "tmpdir/$fileroot.o" + lappend objfiles $objfile + + # We ignore warnings since some compilers may generate +@@ -1565,7 +1567,8 @@ + + # Compile each file in the test. + foreach src_file $src_files { +- set objfile "tmpdir/[file rootname $src_file].o" ++ set fileroot "[file rootname [file tail $src_file]]" ++ set objfile "tmpdir/$fileroot.o" + lappend objfiles $objfile + + # We ignore warnings since some compilers may generate +--- /dev/null ++++ b/ld/testsuite/ld-mips-elf/comm-data.exp +@@ -0,0 +1,88 @@ ++# Expect script for common symbol override, MIPS variation. ++# ++# Copyright 2010 Free Software Foundation, Inc. ++# ++# This file is part of the GNU Binutils. ++# ++# 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 3 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., 51 Franklin Street - Fifth Floor, Boston, ++# MA 02110-1301, USA. ++# ++ ++# ++# Written by Maciej W. Rozycki ++# ++ ++# Exclude non-ELF targets. ++if ![is_elf_format] { ++ return ++} ++ ++# Exclude non-Linux targets; feel free to include your favourite one ++# if you like. ++if ![istarget mips*-*-linux*] { ++ return ++} ++ ++proc mips_comm_data_test { abi flag emul reloc } { ++ ++ set testname "MIPS $abi/$reloc common symbol override test" ++ set AFLAGS "$flag -EB" ++ set LDFLAGS "-m$emul" ++ ++ # Define a global symbol. ++ run_ld_link_tests [list \ ++ [list \ ++ "$testname (auxiliary shared object build)" \ ++ "$LDFLAGS -shared" \ ++ "$AFLAGS -call_shared" \ ++ { ../ld-elf/comm-data1.s } \ ++ { \ ++ { readelf -s ../ld-elf/comm-data1.sd } \ ++ } \ ++ "libmips-$abi-$reloc-comm-data.so" \ ++ ] \ ++ ] ++ ++ # Set the pointer size according to the ABI. ++ if { $abi == "n64" } { ++ append AFLAGS " --defsym ELF64=1" ++ } ++ ++ # Verify that a common symbol has been converted to an undefined ++ # reference to the global symbol of the same name defined above ++ # and that the debug reference has been dropped. ++ run_ld_link_tests [list \ ++ [list \ ++ "$testname" \ ++ "$LDFLAGS -z $reloc -Ltmpdir -lmips-$abi-$reloc-comm-data" \ ++ "$AFLAGS -call_nonpic" \ ++ { ../ld-elf/comm-data2.s } \ ++ { \ ++ { readelf -s ../ld-elf/comm-data2.sd } \ ++ { readelf -r ../ld-elf/comm-data2.rd } \ ++ { readelf "-x .debug_foo" ../ld-elf/comm-data2.xd } \ ++ } \ ++ "mips-$abi-$reloc-comm-data" \ ++ ] \ ++ ] ++} ++ ++set abis { o32 -32 elf32btsmip n32 -n32 elf32btsmipn32 n64 -64 elf64btsmip } ++set relocs { copyreloc nocopyreloc } ++foreach { abi flag emul } $abis { ++ foreach reloc $relocs { ++ mips_comm_data_test $abi $flag $emul $reloc ++ } ++} +--- a/bfd/elfxx-mips.c ++++ b/bfd/elfxx-mips.c +@@ -7583,6 +7583,19 @@ + elf_hash_table (info)->dynobj = dynobj = abfd; + break; + } ++ /* Ignore relocs from SEC_DEBUGGING sections because such ++ sections are not SEC_ALLOC and thus ld.so will not process ++ them. Don't set has_static_relocs for the corresponding ++ symbol. ++ ++ This is needed in cases such as a global symbol definition ++ in a shared library causing a common symbol from an object ++ file to be converted to an undefined reference. If that ++ happens, then all the relocations against this symbol from ++ SEC_DEBUGGING sections in the object file will resolve to ++ nil. */ ++ if ((sec->flags & SEC_DEBUGGING) != 0) ++ break; + /* Fall through. */ + + default: --- binutils-2.22.orig/debian/patches/209-hjl-binutils-error.patch +++ binutils-2.22/debian/patches/209-hjl-binutils-error.patch @@ -0,0 +1,1175 @@ +Description: PR ld/4409: --unresolved-symbols=ignore-all issues on ia64 +Author: H.J. Lu +Upstream status: hjl 2.21.51.0.8 +Original patch: binutils-error-12.patch + +2010-07-01 H.J. Lu + + * elf-bfd.h (RELOC_FOR_GLOBAL_SYMBOL): Silence unused warning + on ignored. + + * elf32-tic6x.c (elf32_tic6x_relocate_section): Add an argument for + error ignored. + +bfd/ + +2007-07-03 H.J. Lu + + PR ld/4409 + * elf-bfd.h (RELOC_FOR_GLOBAL_SYMBOL): Add an argument for + error ignored. + * elf-m10200.c (mn10200_elf_relocate_section): Updated. + * elf-m10300.c (mn10300_elf_relocate_section): Likewise. + * elf32-arm.c (elf32_arm_relocate_section): Likewise. + * elf32-avr.c (elf32_avr_relocate_section): Likewise. + * elf32-bfin.c (bfinfdpic_relocate_section): Likewise. + (bfin_relocate_section): Likewise. + * elf32-cr16.c (elf32_cr16_relocate_section): Likewise. + * elf32-cr16c.c (elf32_cr16c_relocate_section): Likewise. + * elf32-cris.c (cris_elf_relocate_section): Likewise. + * elf32-crx.c (elf32_crx_relocate_section): Likewise. + * elf32-d10v.c (elf32_d10v_relocate_section): Likewise. + * elf32-fr30.c (fr30_elf_relocate_section): Likewise. + * elf32-frv.c (elf32_frv_relocate_section): Likewise. + * elf32-h8300.c (elf32_h8_relocate_section): Likewise. + * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. + * elf32-i386.c (elf_i386_relocate_section): Likewise. + * elf32-i860.c (elf32_i860_relocate_section): Likewise. + * elf32-ip2k.c (ip2k_elf_relocate_section): Likewise. + * elf32-iq2000.c (iq2000_elf_relocate_section): Likewise. + * elf32-lm32.c (lm32_elf_relocate_section): Likewise. + * elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Likewise. + * elf32-m68k.c (elf_m68k_relocate_section): Likewise. + * elf32-microblaze.c (microblaze_elf_relocate_section): Likewise. + * elf32-mcore.c (mcore_elf_relocate_section): Likewise. + * elf32-mep.c (mep_elf_relocate_section): Likewise. + * elf32-moxie.c (moxie_elf_relocate_section): Likewise. + * elf32-msp430.c (elf32_msp430_relocate_section): Likewise. + * elf32-mt.c (mt_elf_relocate_section): Likewise. + * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. + * elf32-ppc.c (ppc_elf_relocate_section): Likewise. + * elf32-rx.c (rx_elf_relocate_section): Likewise. + * elf32-s390.c (elf_s390_relocate_section): Likewise. + * elf32-v850.c (v850_elf_relocate_section): Likewise. + * elf32-vax.c (elf_vax_relocate_section): Likewise. + * elf32-xc16x.c (elf32_xc16x_relocate_section): Likewise. + * elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise. + * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise. + * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. + * elf64-mmix.c (mmix_elf_relocate_section): Likewise. + * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. + * elf64-s390.c (elf_s390_relocate_section): Likewise. + * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. + * elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise. + + * elfxx-ia64.c (elfNN_ia64_relocate_section): Skip if error + from RELOC_FOR_GLOBAL_SYMBOL in executable is ignored. + +ld/ + +2007-07-03 H.J. Lu + + PR ld/4409 + * ldmain.c (how_to_report_unresolved_symbols): New. + (main): Set link_info.unresolved_syms_in_objects and + link_info.unresolved_syms_in_shared_libs if they aren't set + yet. + + * ldmain.h (how_to_report_unresolved_symbols): New. + + * lexsup.c (how_to_report_unresolved_symbols): Removed. + (parse_args): Set link_info.pie to FALSE for -shared. Don't + set default values for link_info.unresolved_syms_in_objects nor + link_info.unresolved_syms_in_shared_libs. + +ld/testsuite/ + +2007-07-03 H.J. Lu + + PR ld/4409 + * ld-ia64/error1.d: New file. + * ld-ia64/error1.s: Likewise. + * ld-ia64/error2.d: Likewise. + * ld-ia64/error3.d: Likewise. + * ld-ia64/error4.d: Likewise. + +diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h +index 66dcbcd..7e36cfe 100644 +--- a/bfd/elf-bfd.h ++++ b/bfd/elf-bfd.h +@@ -2285,7 +2285,7 @@ extern asection _bfd_elf_large_com_section; + #define RELOC_FOR_GLOBAL_SYMBOL(info, input_bfd, input_section, rel, \ + r_symndx, symtab_hdr, sym_hashes, \ + h, sec, relocation, \ +- unresolved_reloc, warned) \ ++ unresolved_reloc, warned, ignored) \ + do \ + { \ + /* It seems this can happen with erroneous or unsupported \ +@@ -2300,6 +2300,7 @@ extern asection _bfd_elf_large_com_section; + h = (struct elf_link_hash_entry *) h->root.u.i.link; \ + \ + warned = FALSE; \ ++ ignored = FALSE; \ + unresolved_reloc = FALSE; \ + relocation = 0; \ + if (h->root.type == bfd_link_hash_defined \ +@@ -2322,7 +2323,7 @@ extern asection _bfd_elf_large_com_section; + ; \ + else if (info->unresolved_syms_in_objects == RM_IGNORE \ + && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) \ +- ; \ ++ ignored = TRUE; \ + else if (!info->relocatable) \ + { \ + bfd_boolean err; \ +@@ -2338,6 +2339,7 @@ extern asection _bfd_elf_large_com_section; + } \ + (void) unresolved_reloc; \ + (void) warned; \ ++ (void) ignored; \ + } \ + while (0) + +diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c +index 0fafe55..9e6b071 100644 +--- a/bfd/elf-m10200.c ++++ b/bfd/elf-m10200.c +@@ -393,12 +393,12 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c +index a4da9d5..a527fe0 100644 +--- a/bfd/elf-m10300.c ++++ b/bfd/elf-m10300.c +@@ -1457,13 +1457,13 @@ mn10300_elf_relocate_section (bfd *output_bfd, + else + { + bfd_boolean unresolved_reloc; +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + struct elf_link_hash_entry *hh; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + hh, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + h = (struct elf32_mn10300_link_hash_entry *) hh; + +diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c +index 9fce4b0..964d45c 100644 +--- a/bfd/elf32-arm.c ++++ b/bfd/elf32-arm.c +@@ -9022,12 +9022,12 @@ elf32_arm_relocate_section (bfd * output_bfd, + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + sym_type = h->type; + } +diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c +index 7334340..9320e63 100644 +--- a/bfd/elf32-avr.c ++++ b/bfd/elf32-avr.c +@@ -1221,12 +1221,12 @@ elf32_avr_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + name = h->root.root.string; + } +diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c +index ac41d63..905ad02 100644 +--- a/bfd/elf32-bfin.c ++++ b/bfd/elf32-bfin.c +@@ -1420,12 +1420,12 @@ bfin_relocate_section (bfd * output_bfd, + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +@@ -2644,13 +2644,13 @@ bfinfdpic_relocate_section (bfd * output_bfd, + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + bfd_boolean unresolved_reloc; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + osec = sec; + } + +diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c +index 4c6e3c0..5a10251 100644 +--- a/bfd/elf32-cr16.c ++++ b/bfd/elf32-cr16.c +@@ -1423,12 +1423,12 @@ elf32_cr16_relocate_section (bfd *output_bfd, struct bfd_link_info *info, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-cr16c.c b/bfd/elf32-cr16c.c +index 5016c6e..ef7e743 100644 +--- a/bfd/elf32-cr16c.c ++++ b/bfd/elf32-cr16c.c +@@ -715,12 +715,12 @@ elf32_cr16c_relocate_section (bfd *output_bfd, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c +index f3ed80d..a61e572 100644 +--- a/bfd/elf32-cris.c ++++ b/bfd/elf32-cris.c +@@ -1106,13 +1106,13 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + bfd_boolean unresolved_reloc; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + symname = h->root.root.string; + +diff --git a/bfd/elf32-crx.c b/bfd/elf32-crx.c +index 11c1f56..ec02f5a 100644 +--- a/bfd/elf32-crx.c ++++ b/bfd/elf32-crx.c +@@ -865,12 +865,12 @@ elf32_crx_relocate_section (bfd *output_bfd, struct bfd_link_info *info, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-d10v.c b/bfd/elf32-d10v.c +index a5e5395..c404ceb 100644 +--- a/bfd/elf32-d10v.c ++++ b/bfd/elf32-d10v.c +@@ -455,12 +455,12 @@ elf32_d10v_relocate_section (bfd *output_bfd, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c +index f96b1f6..66af8d2 100644 +--- a/bfd/elf32-fr30.c ++++ b/bfd/elf32-fr30.c +@@ -567,12 +567,12 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + name = h->root.root.string; + } +diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c +index f6975f3..e1b0d05 100644 +--- a/bfd/elf32-frv.c ++++ b/bfd/elf32-frv.c +@@ -2801,13 +2801,13 @@ elf32_frv_relocate_section (output_bfd, info, input_bfd, input_section, + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + bfd_boolean unresolved_reloc; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + osec = sec; + name = h->root.root.string; + } +diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c +index e05efbd..dc02000 100644 +--- a/bfd/elf32-h8300.c ++++ b/bfd/elf32-h8300.c +@@ -452,12 +452,12 @@ elf32_h8_relocate_section (bfd *output_bfd, struct bfd_link_info *info, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c +index 3a3a355..546df99 100644 +--- a/bfd/elf32-hppa.c ++++ b/bfd/elf32-hppa.c +@@ -3712,13 +3712,14 @@ elf32_hppa_relocate_section (bfd *output_bfd, + else + { + struct elf_link_hash_entry *eh; +- bfd_boolean unresolved_reloc; ++ bfd_boolean unresolved_reloc, ignored; + struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd); + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rela, + r_symndx, symtab_hdr, sym_hashes, + eh, sym_sec, relocation, +- unresolved_reloc, warned_undef); ++ unresolved_reloc, warned_undef, ++ ignored); + + if (!info->relocatable + && relocation == 0 +diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c +index 8d8bc85..37700a9 100644 +--- a/bfd/elf32-i386.c ++++ b/bfd/elf32-i386.c +@@ -3008,11 +3008,12 @@ elf_i386_relocate_section (bfd *output_bfd, + else + { + bfd_boolean warned ATTRIBUTE_UNUSED; ++ bfd_boolean ignored ATTRIBUTE_UNUSED; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c +index 41d5e93..7096b5f 100644 +--- a/bfd/elf32-i860.c ++++ b/bfd/elf32-i860.c +@@ -1120,12 +1120,12 @@ elf32_i860_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-ip2k.c b/bfd/elf32-ip2k.c +index 2ef22b6..a69f993 100644 +--- a/bfd/elf32-ip2k.c ++++ b/bfd/elf32-ip2k.c +@@ -1425,13 +1425,13 @@ ip2k_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + bfd_boolean unresolved_reloc; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + name = h->root.root.string; + } +diff --git a/bfd/elf32-iq2000.c b/bfd/elf32-iq2000.c +index 4dcc866..afb8142 100644 +--- a/bfd/elf32-iq2000.c ++++ b/bfd/elf32-iq2000.c +@@ -623,12 +623,12 @@ iq2000_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, + else + { + bfd_boolean unresolved_reloc; +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + name = h->root.root.string; + } +diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c +index 49b2130..7defbad 100644 +--- a/bfd/elf32-lm32.c ++++ b/bfd/elf32-lm32.c +@@ -884,12 +884,12 @@ lm32_elf_relocate_section (bfd *output_bfd, + { + /* It's a global symbol. */ + bfd_boolean unresolved_reloc; +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + name = h->root.root.string; + } + +diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c +index 2107486..f3b6bd8 100644 +--- a/bfd/elf32-m68hc1x.c ++++ b/bfd/elf32-m68hc1x.c +@@ -960,12 +960,12 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, unresolved_reloc, +- warned); ++ warned, ignored); + + is_far = (h && (h->other & STO_M68HC12_FAR)); + } +diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c +index 8d1ee7f..d30ba7a 100644 +--- a/bfd/elf32-m68k.c ++++ b/bfd/elf32-m68k.c +@@ -3707,12 +3707,12 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section, + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c +index 8bdb266..f1c7289 100644 +--- a/bfd/elf32-mcore.c ++++ b/bfd/elf32-mcore.c +@@ -458,12 +458,12 @@ mcore_elf_relocate_section (bfd * output_bfd, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-mep.c b/bfd/elf32-mep.c +index 1993b03..1ce5ef2 100644 +--- a/bfd/elf32-mep.c ++++ b/bfd/elf32-mep.c +@@ -489,12 +489,12 @@ mep_elf_relocate_section + } + else + { +- bfd_boolean warned, unresolved_reloc; ++ bfd_boolean warned, unresolved_reloc, ignored; + + RELOC_FOR_GLOBAL_SYMBOL(info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + name = h->root.root.string; + } +diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c +index f32e06e..0ea88db 100644 +--- a/bfd/elf32-microblaze.c ++++ b/bfd/elf32-microblaze.c +@@ -815,11 +815,12 @@ microblaze_elf_relocate_section (bfd *output_bfd, + { + /* External symbol. */ + bfd_boolean warned ATTRIBUTE_UNUSED; ++ bfd_boolean ignored ATTRIBUTE_UNUSED; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + sym_name = h->root.root.string; + } + +diff --git a/bfd/elf32-moxie.c b/bfd/elf32-moxie.c +index b43f396..509eb6d 100644 +--- a/bfd/elf32-moxie.c ++++ b/bfd/elf32-moxie.c +@@ -240,12 +240,12 @@ moxie_elf_relocate_section (bfd *output_bfd, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + name = h->root.root.string; + } +diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c +index 285475c..280f0fa 100644 +--- a/bfd/elf32-msp430.c ++++ b/bfd/elf32-msp430.c +@@ -446,12 +446,12 @@ elf32_msp430_relocate_section (bfd * output_bfd ATTRIBUTE_UNUSED, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-mt.c b/bfd/elf32-mt.c +index 9b2758e..93ff007 100644 +--- a/bfd/elf32-mt.c ++++ b/bfd/elf32-mt.c +@@ -344,12 +344,12 @@ mt_elf_relocate_section + else + { + bfd_boolean unresolved_reloc; +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + name = h->root.root.string; + } +diff --git a/bfd/elf32-openrisc.c b/bfd/elf32-openrisc.c +index af7bc25..a6f7f96 100644 +--- a/bfd/elf32-openrisc.c ++++ b/bfd/elf32-openrisc.c +@@ -365,12 +365,12 @@ openrisc_elf_relocate_section (bfd *output_bfd, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c +index 58e9807..dd5b1e4 100644 +--- a/bfd/elf32-ppc.c ++++ b/bfd/elf32-ppc.c +@@ -6801,10 +6801,12 @@ ppc_elf_relocate_section (bfd *output_bfd, + } + else + { ++ bfd_boolean ignored; ++ + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + sym_name = h->root.root.string; + } +diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c +index 4b31a35..e66bd1a 100644 +--- a/bfd/elf32-rx.c ++++ b/bfd/elf32-rx.c +@@ -491,12 +491,12 @@ rx_elf_relocate_section + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, h, + sec, relocation, unresolved_reloc, +- warned); ++ warned, ignored); + + name = h->root.root.string; + } +diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c +index bc8e054..c143863 100644 +--- a/bfd/elf32-s390.c ++++ b/bfd/elf32-s390.c +@@ -2284,11 +2284,12 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, + else + { + bfd_boolean warned ATTRIBUTE_UNUSED; ++ bfd_boolean ignored ATTRIBUTE_UNUSED; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c +index a570f88..a3f51fb 100644 +--- a/bfd/elf32-tic6x.c ++++ b/bfd/elf32-tic6x.c +@@ -1458,12 +1458,12 @@ elf32_tic6x_relocate_section (bfd *output_bfd, + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c +index e153e83..21ad9c7 100644 +--- a/bfd/elf32-v850.c ++++ b/bfd/elf32-v850.c +@@ -2073,7 +2073,7 @@ v850_elf_relocate_section (bfd *output_bfd, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + /* Note - this check is delayed until now as it is possible and + valid to have a file without any symbols but with relocs that +@@ -2090,7 +2090,7 @@ v850_elf_relocate_section (bfd *output_bfd, + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c +index db67faf..b78d8ba 100644 +--- a/bfd/elf32-vax.c ++++ b/bfd/elf32-vax.c +@@ -1412,12 +1412,12 @@ elf_vax_relocate_section (bfd *output_bfd, + else + { + bfd_boolean unresolved_reloc; +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + if ((h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) +diff --git a/bfd/elf32-xc16x.c b/bfd/elf32-xc16x.c +index 4d7ee99..ffb6b3c 100644 +--- a/bfd/elf32-xc16x.c ++++ b/bfd/elf32-xc16x.c +@@ -373,12 +373,12 @@ elf32_xc16x_relocate_section (bfd *output_bfd, + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c +index 53c40ad..b4088f2 100644 +--- a/bfd/elf32-xstormy16.c ++++ b/bfd/elf32-xstormy16.c +@@ -823,12 +823,12 @@ xstormy16_elf_relocate_section (bfd * output_bfd ATTRIBUTE_UNU + } + else + { +- bfd_boolean unresolved_reloc, warned; ++ bfd_boolean unresolved_reloc, warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c +index 6cd396a..78f236d 100644 +--- a/bfd/elf32-xtensa.c ++++ b/bfd/elf32-xtensa.c +@@ -2646,10 +2646,12 @@ elf_xtensa_relocate_section (bfd *output_bfd, + } + else + { ++ bfd_boolean ignored; ++ + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + if (relocation == 0 + && !unresolved_reloc +diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c +index a6a795d..0c627eb 100644 +--- a/bfd/elf64-alpha.c ++++ b/bfd/elf64-alpha.c +@@ -4216,7 +4216,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + bfd_boolean unresolved_reloc; + struct elf_link_hash_entry *hh; + struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd); +@@ -4224,7 +4224,7 @@ elf64_alpha_relocate_section (bfd *output_bfd, struct bfd_link_info *info, + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + hh, sec, value, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + if (warned) + continue; +diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c +index 3ac4950..0004749 100644 +--- a/bfd/elf64-mmix.c ++++ b/bfd/elf64-mmix.c +@@ -1398,12 +1398,13 @@ mmix_elf_relocate_section (output_bfd, info, input_bfd, input_section, + } + else + { +- bfd_boolean unresolved_reloc; ++ bfd_boolean unresolved_reloc, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, undefined_signalled); ++ unresolved_reloc, undefined_signalled, ++ ignored); + name = h->root.root.string; + } + +diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c +index 2cdb0a2..628b74f 100644 +--- a/bfd/elf64-ppc.c ++++ b/bfd/elf64-ppc.c +@@ -11614,10 +11614,12 @@ ppc64_elf_relocate_section (bfd *output_bfd, + } + else + { ++ bfd_boolean ignored; ++ + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h_elf, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + sym_name = h_elf->root.root.string; + sym_type = h_elf->type; + } +diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c +index 2f253b9..c9e1039 100644 +--- a/bfd/elf64-s390.c ++++ b/bfd/elf64-s390.c +@@ -2272,11 +2272,12 @@ elf_s390_relocate_section (bfd *output_bfd, + else + { + bfd_boolean warned ATTRIBUTE_UNUSED; ++ bfd_boolean ignored ATTRIBUTE_UNUSED; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c +index 677d9c4..acc9278 100644 +--- a/bfd/elf64-x86-64.c ++++ b/bfd/elf64-x86-64.c +@@ -2730,11 +2730,12 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, + else + { + bfd_boolean warned ATTRIBUTE_UNUSED; ++ bfd_boolean ignored ATTRIBUTE_UNUSED; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + } + + if (sec != NULL && elf_discarded_section (sec)) +diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c +index 6b52bc6..4db0427 100644 +--- a/bfd/elfxx-ia64.c ++++ b/bfd/elfxx-ia64.c +@@ -4648,17 +4648,17 @@ elfNN_ia64_relocate_section (bfd *output_bfd, + else + { + bfd_boolean unresolved_reloc; +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd); + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sym_sec, value, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + + if (h->root.type == bfd_link_hash_undefweak) + undef_weak_ref = TRUE; +- else if (warned) ++ else if (warned || (ignored && info->executable)) + continue; + } + +diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c +index 979505a..1593f58 100644 +--- a/bfd/elfxx-sparc.c ++++ b/bfd/elfxx-sparc.c +@@ -2940,12 +2940,12 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd, + } + else + { +- bfd_boolean warned; ++ bfd_boolean warned, ignored; + + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, +- unresolved_reloc, warned); ++ unresolved_reloc, warned, ignored); + if (warned) + { + /* To avoid generating warning messages about truncated +diff --git a/ld/ldmain.c b/ld/ldmain.c +index 04b5633..fd9e9fd 100644 +--- a/ld/ldmain.c ++++ b/ld/ldmain.c +@@ -110,6 +110,9 @@ bfd_boolean add_DT_NEEDED_for_dynamic = TRUE; + /* TRUE if we should demangle symbol names. */ + bfd_boolean demangling; + ++/* How to report unresolved symbols. */ ++enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR; ++ + args_type command_line; + + ld_config_type config; +@@ -355,6 +358,27 @@ main (int argc, char **argv) + if (! link_info.shared || link_info.pie) + link_info.executable = TRUE; + ++ /* When creating a shared library, the default behaviour is to ++ ignore any unresolved references. */ ++ ++ if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET) ++ { ++ if (link_info.shared && !link_info.pie) ++ link_info.unresolved_syms_in_objects = RM_IGNORE; ++ else ++ link_info.unresolved_syms_in_objects ++ = how_to_report_unresolved_symbols; ++ } ++ ++ if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET) ++ { ++ if (link_info.shared && !link_info.pie) ++ link_info.unresolved_syms_in_shared_libs = RM_IGNORE; ++ else ++ link_info.unresolved_syms_in_shared_libs ++ = how_to_report_unresolved_symbols; ++ } ++ + /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I + don't see how else this can be handled, since in this case we + must preserve all externally visible symbols. */ +diff --git a/ld/ldmain.h b/ld/ldmain.h +index 57ce8d7..fcf4adb 100644 +--- a/ld/ldmain.h ++++ b/ld/ldmain.h +@@ -37,6 +37,7 @@ extern bfd_boolean whole_archive; + extern bfd_boolean add_DT_NEEDED_for_regular; + extern bfd_boolean add_DT_NEEDED_for_dynamic; + extern bfd_boolean demangling; ++extern enum report_method how_to_report_unresolved_symbols; + extern int g_switch_value; + extern const char *output_filename; + extern struct bfd_link_info link_info; +diff --git a/ld/lexsup.c b/ld/lexsup.c +index 0c44151..cc42b87 100644 +--- a/ld/lexsup.c ++++ b/ld/lexsup.c +@@ -618,7 +618,6 @@ parse_args (unsigned argc, char **argv) + struct option *longopts; + struct option *really_longopts; + int last_optind; +- enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR; + + shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2); + longopts = (struct option *) +@@ -1183,12 +1182,7 @@ parse_args (unsigned argc, char **argv) + if (config.has_shared) + { + link_info.shared = TRUE; +- /* When creating a shared library, the default +- behaviour is to ignore any unresolved references. */ +- if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET) +- link_info.unresolved_syms_in_objects = RM_IGNORE; +- if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET) +- link_info.unresolved_syms_in_shared_libs = RM_IGNORE; ++ link_info.pie = FALSE; + } + else + einfo (_("%P%F: -shared not supported\n")); +@@ -1533,14 +1527,6 @@ parse_args (unsigned argc, char **argv) + free (default_dirlist); + } + +- if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET) +- /* FIXME: Should we allow emulations a chance to set this ? */ +- link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols; +- +- if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET) +- /* FIXME: Should we allow emulations a chance to set this ? */ +- link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols; +- + #ifdef ENABLE_PLUGINS + /* Now all the plugin arguments have been gathered, we can load them. */ + if (plugin_load_plugins ()) +diff --git a/ld/testsuite/ld-ia64/error1.d b/ld/testsuite/ld-ia64/error1.d +new file mode 100644 +index 0000000..82142b6 +--- /dev/null ++++ b/ld/testsuite/ld-ia64/error1.d +@@ -0,0 +1,7 @@ ++#source: error1.s ++#ld: -unresolved-symbols=ignore-all ++#readelf: -s ++ ++#... ++[ ]+[0-9]+:[ ]+[0]+[ ]+0[ ]+NOTYPE[ ]+GLOBAL DEFAULT[ ]+UND[ ]+foo ++#pass +diff --git a/ld/testsuite/ld-ia64/error1.s b/ld/testsuite/ld-ia64/error1.s +new file mode 100644 +index 0000000..fd48eae +--- /dev/null ++++ b/ld/testsuite/ld-ia64/error1.s +@@ -0,0 +1,30 @@ ++ .explicit ++ .pred.safe_across_calls p1-p5,p16-p63 ++ .text ++ .align 16 ++ .global _start# ++ .proc _start# ++_start: ++ .prologue 12, 32 ++ .mii ++ .save ar.pfs, r33 ++ alloc r33 = ar.pfs, 0, 3, 0, 0 ++ .save rp, r32 ++ mov r32 = b0 ++ mov r34 = r1 ++ .body ++ ;; ++ .bbb ++ nop 0 ++ nop 0 ++ br.call.sptk.many b0 = foo# ++ ;; ++ .mmi ++ nop 0 ++ mov r1 = r34 ++ mov b0 = r32 ++ .mib ++ nop 0 ++ mov ar.pfs = r33 ++ br.ret.sptk.many b0 ++ .endp _start# +diff --git a/ld/testsuite/ld-ia64/error2.d b/ld/testsuite/ld-ia64/error2.d +new file mode 100644 +index 0000000..764ba66 +--- /dev/null ++++ b/ld/testsuite/ld-ia64/error2.d +@@ -0,0 +1,7 @@ ++#source: error1.s ++#ld: -pie -unresolved-symbols=ignore-all ++#readelf: -s ++ ++#... ++[ ]+[0-9]+:[ ]+[0]+[ ]+0[ ]+NOTYPE[ ]+GLOBAL DEFAULT[ ]+UND[ ]+foo ++#pass +diff --git a/ld/testsuite/ld-ia64/error3.d b/ld/testsuite/ld-ia64/error3.d +new file mode 100644 +index 0000000..e14d451 +--- /dev/null ++++ b/ld/testsuite/ld-ia64/error3.d +@@ -0,0 +1,7 @@ ++#source: error1.s ++#ld: -pie -shared ++#readelf: -s ++ ++#... ++[ ]+[0-9]+:[ ]+[0]+[ ]+0[ ]+NOTYPE[ ]+GLOBAL DEFAULT[ ]+UND[ ]+foo ++#pass +diff --git a/ld/testsuite/ld-ia64/error4.d b/ld/testsuite/ld-ia64/error4.d +new file mode 100644 +index 0000000..881e671 +--- /dev/null ++++ b/ld/testsuite/ld-ia64/error4.d +@@ -0,0 +1,3 @@ ++#source: error1.s ++#ld: -shared -pie ++#error: .*undefined reference to `foo' --- binutils-2.22.orig/debian/patches/201-hjl-ld-needed.patch +++ binutils-2.22/debian/patches/201-hjl-ld-needed.patch @@ -0,0 +1,49 @@ +Description: Handle LD_SYMBOLIC and LD_SYMBOLIC_FUNCTIONS env vars +Author: H.J. Lu +Upstream status: hjl 2.20.51.0.7 +Original patch: ld-needed-4.patch + +2009-05-06 H.J. Lu + + * NEWS: Mention LD_AS_NEEDED. + + * ld.texinfo: Document LD_AS_NEEDED. + + * ldmain.c (main): Handle LD_AS_NEEDED. + +--- ./ld/NEWS.needed 2009-11-06 09:47:23.000000000 -0800 ++++ ./ld/NEWS 2009-11-06 09:47:25.000000000 -0800 +@@ -73,6 +73,8 @@ Changes in 2.20: + For the switch --enable-runtime-pseudo-reloc it uses for 32-bit + runtime pseudo relocation version one, for 64-bit the version two. + ++* ELF: Support environment variable LD_AS_NEEDED for --as-needed. ++ + * ELF: Support environment variables, LD_SYMBOLIC for -Bsymbolic and + LD_SYMBOLIC_FUNCTIONS for -Bsymbolic-functions. + +--- ./ld/ld.texinfo.needed 2009-11-06 09:47:23.000000000 -0800 ++++ ./ld/ld.texinfo 2009-11-06 09:48:25.000000000 -0800 +@@ -1151,6 +1151,10 @@ their names to the @option{--as-needed} + options. They have been replaced by @option{--copy-dt-needed-entries} + and @option{--no-copy-dt-needed-entries}. + ++If the environment variable @code{LD_AS_NEEDED} is set, the linker ++will behave as if the @option{--as-needed} option is passed to the ++linker as the first command line option. ++ + @kindex -assert @var{keyword} + @item -assert @var{keyword} + This option is ignored for SunOS compatibility. +--- ./ld/ldmain.c.needed 2009-11-06 09:47:24.000000000 -0800 ++++ ./ld/ldmain.c 2009-11-06 09:49:24.000000000 -0800 +@@ -262,6 +262,9 @@ main (int argc, char **argv) + else if (getenv ("LD_SYMBOLIC_FUNCTIONS") != NULL) + command_line.symbolic = symbolic_functions; + ++ if (getenv ("LD_AS_NEEDED") != NULL) ++ add_DT_NEEDED_for_regular = TRUE; ++ + /* We initialize DEMANGLING based on the environment variable + COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the + output of the linker, unless COLLECT_NO_DEMANGLE is set in the --- binutils-2.22.orig/debian/patches/013_bash_in_ld_testsuite.patch +++ binutils-2.22/debian/patches/013_bash_in_ld_testsuite.patch @@ -0,0 +1,26 @@ +Author: Matthias Klose +Description: Explicitely use bash for the ld testsuite. +--- a/ld/testsuite/config/default.exp ++++ b/ld/testsuite/config/default.exp +@@ -119,10 +119,10 @@ + #makefile rules, with embedded shell variable expansions. + #make wants $$shell_var, we want $shell_var ... + set cmd "host='$target_triplet' && . $srcdir/../configure.host && sed -e 's,\\\$\\\$,\$,g' < +Description: Don't mention monitor(3) which doesn't exist in Debian. (#160654) +--- a/gprof/gprof.texi ++++ b/gprof/gprof.texi +@@ -197,7 +197,7 @@ + @c man end + + @c man begin SEEALSO +-monitor(3), profil(2), cc(1), prof(1), and the Info entry for @file{gprof}. ++cc(1), prof(1), and the Info entry for @file{gprof}. + + ``An Execution Profiler for Modular Programs'', + by S. Graham, P. Kessler, M. McKusick; --- binutils-2.22.orig/debian/patches/140_pr10340.patch +++ binutils-2.22/debian/patches/140_pr10340.patch @@ -0,0 +1,35 @@ +# DP: Proposed patch for PR ld/10340, ld doesn't honor sysroot prefix for ldscripts + +Signed-off-by: Sven Rebhan + +Always try to prepend the sysroot prefix to absolute filenames first. + +--- a/ld/ldfile.c ++++ b/ld/ldfile.c +@@ -308,18 +308,24 @@ + directory first. */ + if (! entry->is_archive) + { +- if (entry->sysrooted && IS_ABSOLUTE_PATH (entry->filename)) ++ /* For absolute pathnames, try to always open the file in the ++ sysroot first. If this fails, try to open the file at the ++ given location. */ ++ entry->sysrooted = is_sysrooted_pathname(entry->filename, FALSE); ++ if (IS_ABSOLUTE_PATH (entry->filename) && ld_sysroot && ! entry->sysrooted) + { + char *name = concat (ld_sysroot, entry->filename, + (const char *) NULL); + if (ldfile_try_open_bfd (name, entry)) + { + entry->filename = name; ++ entry->sysrooted = TRUE; + return TRUE; + } + free (name); + } +- else if (ldfile_try_open_bfd (entry->filename, entry)) ++ ++ if (ldfile_try_open_bfd (entry->filename, entry)) + { + entry->sysrooted = IS_ABSOLUTE_PATH (entry->filename) + && is_sysrooted_pathname (entry->filename, TRUE); --- binutils-2.22.orig/debian/patches/binutils-CVE-2014-8485.patch +++ binutils-2.22/debian/patches/binutils-CVE-2014-8485.patch @@ -0,0 +1,90 @@ +From 493a33860c71cac998f1a56d6d87d6faa801fbaa Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Mon, 27 Oct 2014 12:43:16 +0000 +Subject: [PATCH] This patch closes a potential security hole in applications that use + the bfd library to parse binaries containing maliciously corrupt section + group headers. + + PR binutils/17510 + * elf.c (setup_group): Improve handling of corrupt group + sections. + +[Ubuntu note: this patch differs from upstream by dropping the Changelog +entry to reduce patch conflicts. -- sbeattie] + +CVE-2014-8485 + +--- + bfd/elf.c | 34 ++++++++++++++++++++++++++++++---- + 2 files changed, 36 insertions(+), 4 deletions(-) + +diff --git a/bfd/elf.c b/bfd/elf.c +index c884d1d..c8ac826 100644 +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -608,9 +608,10 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) + if (shdr->contents == NULL) + { + _bfd_error_handler +- (_("%B: Corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size); ++ (_("%B: corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size); + bfd_set_error (bfd_error_bad_value); +- return FALSE; ++ -- num_group; ++ continue; + } + + memset (shdr->contents, 0, amt); +@@ -618,8 +619,17 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) + if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0 + || (bfd_bread (shdr->contents, shdr->sh_size, abfd) + != shdr->sh_size)) +- return FALSE; +- ++ { ++ _bfd_error_handler ++ (_("%B: invalid size field in group section header: 0x%lx"), abfd, shdr->sh_size); ++ bfd_set_error (bfd_error_bad_value); ++ -- num_group; ++ /* PR 17510: If the group contents are even partially ++ corrupt, do not allow any of the contents to be used. */ ++ memset (shdr->contents, 0, amt); ++ continue; ++ } ++ + /* Translate raw contents, a flag word followed by an + array of elf section indices all in target byte order, + to the flag word followed by an array of elf section +@@ -651,6 +661,21 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) + } + } + } ++ ++ /* PR 17510: Corrupt binaries might contain invalid groups. */ ++ if (num_group != (unsigned) elf_tdata (abfd)->num_group) ++ { ++ elf_tdata (abfd)->num_group = num_group; ++ ++ /* If all groups are invalid then fail. */ ++ if (num_group == 0) ++ { ++ elf_tdata (abfd)->group_sect_ptr = NULL; ++ elf_tdata (abfd)->num_group = num_group = -1; ++ (*_bfd_error_handler) (_("%B: no valid group sections found"), abfd); ++ bfd_set_error (bfd_error_bad_value); ++ } ++ } + } + } + +@@ -716,6 +741,7 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect) + { + (*_bfd_error_handler) (_("%B: no group info for section %A"), + abfd, newsect); ++ return FALSE; + } + return TRUE; + } +-- +1.7.1 + --- binutils-2.22.orig/debian/patches/002_gprof_profile_arcs.patch +++ binutils-2.22/debian/patches/002_gprof_profile_arcs.patch @@ -0,0 +1,27 @@ +Author: Chris Chimelis +Description: Add more documentation about profiling and -fprofile-arcs. +--- a/gprof/gprof.texi ++++ b/gprof/gprof.texi +@@ -149,6 +149,10 @@ + If more than one profile file is specified, the @code{gprof} + output shows the sum of the profile information in the given profile files. + ++If you use gcc 2.95.x or 3.0 to compile your binaries, you may need ++to add the @samp{-fprofile-arcs} to the compile command line in order ++for the call graphs to be properly stored in gmon.out. ++ + @code{Gprof} calculates the amount of time spent in each routine. + Next, these times are propagated along the edges of the call graph. + Cycles are discovered, and calls into a cycle are made to share the time +@@ -280,6 +284,11 @@ + options. The same option, @samp{-pg}, alters either compilation or linking + to do what is necessary for profiling. Here are examples: + ++If you use gcc 2.95.x or 3.0.x, you may need to add the ++@samp{-fprofile-arcs} option to the compile line along with @samp{-pg} ++in order to allow the call-graphs to be properly included in the gmon.out ++file. ++ + @example + cc -g -c myprog.c utils.c -pg + cc -o myprog myprog.o utils.o -pg --- binutils-2.22.orig/debian/patches/161_gold_dummy_zoption.diff +++ binutils-2.22/debian/patches/161_gold_dummy_zoption.diff @@ -0,0 +1,25 @@ +# DP: let gold accept a dummy -z buildd- option. + +--- a/gold/options.h ++++ b/gold/options.h +@@ -1162,6 +1162,9 @@ + DEFINE_bool_alias(textoff, text, options::DASH_Z, '\0', + N_("Permit relocations in read-only segments (default)"), + NULL, true); ++ DEFINE_bool(buildd, options::DASH_Z, '\0', false, ++ N_("Dummy z option"), ++ NULL); + + public: + typedef options::Dir_list Dir_list; +--- a/gold/options.cc ++++ b/gold/options.cc +@@ -859,6 +859,8 @@ + { + int dummy_i = 0; + const char* dash_z_arg = *arg; ++ if (strncmp(dash_z_arg, "buildd", strlen("buildd")) == 0) ++ *arg = "buildd"; + retval = parse_long_option(1, arg, true, arg, &dummy_i); + if (retval == NULL) + usage(_("unknown -z option"), dash_z_arg); --- binutils-2.22.orig/debian/patches/binutils-CVE-2014-8738.patch +++ binutils-2.22/debian/patches/binutils-CVE-2014-8738.patch @@ -0,0 +1,49 @@ +From bb0d867169d7e9743d229804106a8fbcab7f3b3f Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Tue, 4 Nov 2014 13:15:37 +0000 +Subject: [PATCH] Fix a seg-fault triggered by reading a mal-formed archive. + + PR binutils/17533 + * archive.c (_bfd_slurp_extended_name_table): Handle archives with + corrupt extended name tables. + +[Ubuntu note: patch differs from upstream commit in that it drops the +changelog entry and cosmetic changes to reduce patch conflicts. + -- sbeattie] + +CVE-2014-8738 +--- + bfd/archive.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +Index: b/bfd/archive.c +=================================================================== +--- a/bfd/archive.c ++++ b/bfd/archive.c +@@ -1292,6 +1292,9 @@ _bfd_slurp_extended_name_table (bfd *abf + amt = namedata->parsed_size; + if (amt + 1 == 0) + goto byebye; ++ /* PR binutils/17533: A corrupt archive can contain an invalid size. */ ++ if (amt > (bfd_size_type) bfd_get_size (abfd)) ++ goto byebye; + + bfd_ardata (abfd)->extended_names_size = amt; + bfd_ardata (abfd)->extended_names = (char *) bfd_zalloc (abfd, amt + 1); +@@ -1299,6 +1302,8 @@ _bfd_slurp_extended_name_table (bfd *abf + { + byebye: + bfd_release (abfd, namedata); ++ bfd_ardata (abfd)->extended_names = NULL; ++ bfd_ardata (abfd)->extended_names_size = 0; + return FALSE; + } + +@@ -1307,7 +1312,6 @@ _bfd_slurp_extended_name_table (bfd *abf + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_malformed_archive); + bfd_release (abfd, (bfd_ardata (abfd)->extended_names)); +- bfd_ardata (abfd)->extended_names = NULL; + goto byebye; + } + --- binutils-2.22.orig/debian/patches/pr13534-02.diff +++ binutils-2.22/debian/patches/pr13534-02.diff @@ -0,0 +1,136 @@ +commit 433cc73f9df08a1435b4d07a7bd3eed20f0c3dcd +Author: Francois Gouget +Date: Tue Dec 20 19:39:41 2011 +0100 + + bfd: Refuse to create an invalid archive when an archive element is too big. + + The archive format stores element sizes as a 10 character string and thus cannot handle anything 10GB or more. + +diff --git a/bfd/archive.c b/bfd/archive.c +index 5c5b3d4..05aba6c 100644 +--- a/bfd/archive.c ++++ b/bfd/archive.c +@@ -179,13 +179,18 @@ _bfd_ar_spacepad (char *p, size_t n, const char *fmt, long val) + memcpy (p, buf, n); + } + +-void ++int + _bfd_ar_sizepad (char *p, size_t n, bfd_size_type size) + { + static char buf[21]; + size_t len; + snprintf (buf, sizeof (buf), "%-10" BFD_VMA_FMT "u", size); + len = strlen (buf); ++ if (len > n) ++ { ++ bfd_set_error(bfd_error_file_too_big); ++ return 0; ++ } + if (len < n) + { + memcpy (p, buf, len); +@@ -193,6 +198,7 @@ _bfd_ar_sizepad (char *p, size_t n, bfd_size_type size) + } + else + memcpy (p, buf, n); ++ return 1; + } + + bfd_boolean +@@ -1786,8 +1792,9 @@ _bfd_bsd44_write_ar_hdr (bfd *archive, bfd *abfd) + + BFD_ASSERT (padded_len == arch_eltdata (abfd)->extra_size); + +- _bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size), +- arch_eltdata (abfd)->parsed_size + padded_len); ++ if (!_bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size), ++ arch_eltdata (abfd)->parsed_size + padded_len)) ++ return FALSE; + + if (bfd_bwrite (hdr, sizeof (*hdr), archive) != sizeof (*hdr)) + return FALSE; +@@ -1907,8 +1914,8 @@ bfd_ar_hdr_from_filesystem (bfd *abfd, const char *filename, bfd *member) + status.st_gid); + _bfd_ar_spacepad (hdr->ar_mode, sizeof (hdr->ar_mode), "%-8lo", + status.st_mode); +- _bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size), +- status.st_size); ++ if (!_bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size), status.st_size)) ++ return NULL; + memcpy (hdr->ar_fmag, ARFMAG, 2); + ared->parsed_size = status.st_size; + ared->arch_header = (char *) hdr; +@@ -2148,8 +2155,9 @@ _bfd_write_archive_contents (bfd *arch) + memset (&hdr, ' ', sizeof (struct ar_hdr)); + memcpy (hdr.ar_name, ename, strlen (ename)); + /* Round size up to even number in archive header. */ +- _bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), +- (elength + 1) & ~(bfd_size_type) 1); ++ if (!_bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), ++ (elength + 1) & ~(bfd_size_type) 1)) ++ return FALSE; + memcpy (hdr.ar_fmag, ARFMAG, 2); + if ((bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch) + != sizeof (struct ar_hdr)) +@@ -2425,7 +2433,8 @@ bsd_write_armap (bfd *arch, + bfd_ardata (arch)->armap_timestamp); + _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", uid); + _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", gid); +- _bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize); ++ if (!_bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize)) ++ return FALSE; + memcpy (hdr.ar_fmag, ARFMAG, 2); + if (bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch) + != sizeof (struct ar_hdr)) +@@ -2580,7 +2589,8 @@ coff_write_armap (bfd *arch, + + memset (&hdr, ' ', sizeof (struct ar_hdr)); + hdr.ar_name[0] = '/'; +- _bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize); ++ if (!_bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize)) ++ return FALSE; + _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld", + ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0 + ? time (NULL) : 0)); +diff --git a/bfd/archive64.c b/bfd/archive64.c +index a906508..bdbda0a 100644 +--- a/bfd/archive64.c ++++ b/bfd/archive64.c +@@ -169,8 +169,8 @@ bfd_elf64_archive_write_armap (bfd *arch, + + memset (&hdr, ' ', sizeof (struct ar_hdr)); + memcpy (hdr.ar_name, "/SYM64/", strlen ("/SYM64/")); +- _bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), +- mapsize); ++ if (!_bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize)) ++ return FALSE; + _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld", + time (NULL)); + /* This, at least, is what Intel coff sets the values to.: */ +diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h +index 57197ac..a4ba4b6 100644 +--- a/bfd/libbfd-in.h ++++ b/bfd/libbfd-in.h +@@ -203,7 +203,7 @@ extern void *_bfd_generic_read_ar_hdr + (bfd *); + extern void _bfd_ar_spacepad + (char *, size_t, const char *, long); +-extern void _bfd_ar_sizepad ++extern int _bfd_ar_sizepad + (char *, size_t, bfd_size_type); + + extern void *_bfd_generic_read_ar_hdr_mag +diff --git a/bfd/libbfd.h b/bfd/libbfd.h +index 121e865..7f142d0 100644 +--- a/bfd/libbfd.h ++++ b/bfd/libbfd.h +@@ -208,7 +208,7 @@ extern void *_bfd_generic_read_ar_hdr + (bfd *); + extern void _bfd_ar_spacepad + (char *, size_t, const char *, long); +-extern void _bfd_ar_sizepad ++extern int _bfd_ar_sizepad + (char *, size_t, bfd_size_type); + + extern void *_bfd_generic_read_ar_hdr_mag --- binutils-2.22.orig/debian/patches/binutils-harden_strings.patch +++ binutils-2.22/debian/patches/binutils-harden_strings.patch @@ -0,0 +1,274 @@ +From b0b93f3592f3d165896e8dc8186a7ba285f0f3e4 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Fri, 31 Oct 2014 10:21:57 +0000 +Subject: [PATCH] Import a security patch from the mainline which changes the default behaviour + of the strings program to be --all rather then --data. This avoids using the + BFD library by default, and so avoids exposing strings to any memory bugs + present in BFD. + + * strings.c: Add new command line option --data to only scan the + initialized, loadable data secions of binaries. Choose the + default behaviour of --all or --data based upon a configure + option. + * doc/binutils.texi (strings): Update documentation. Include + description of why the --data option might be unsafe. + * configure.ac: Add new option --disable-default-strings-all which + restores the old behaviour of strings using --data by default. If + the option is not used make strings use --all by default. + * NEWS: Mention the new behaviour of strings. + * configure: Regenerate. + * config.in: Regenerate. + +[Ubuntu note: patch differs from upstream commit in that it drops the +update to the changelog to avoid patch conflicts. -- sbeattie] + +diff --git a/binutils/NEWS b/binutils/NEWS +index 126219b..9054494 100644 +--- a/binutils/NEWS ++++ b/binutils/NEWS +@@ -1,5 +1,12 @@ + -*- text -*- + ++Changes in 2.22-6ubuntu1.2: ++ ++* Add --data option to strings to only print strings in loadable, initialized ++ data sections. Change the default behaviour to be --all, but add a new ++ configure time option of --disable-default-strings-all to restore the old ++ default behaviour. ++ + Changes in 2.22: + + * Add support for displaying the contents of .debug.macro sections. +diff --git a/binutils/config.in b/binutils/config.in +index d43b748..076f514 100644 +--- a/binutils/config.in ++++ b/binutils/config.in +@@ -18,6 +18,9 @@ + /* Define to 1 if using `alloca.c'. */ + #undef C_ALLOCA + ++/* Should strings use -a behavior by default? */ ++#undef DEFAULT_STRINGS_ALL ++ + /* Define to 1 if translation of program messages to the user's native + language is requested. */ + #undef ENABLE_NLS +diff --git a/binutils/configure b/binutils/configure +index 063ad72..07551c3 100755 +--- a/binutils/configure ++++ b/binutils/configure +@@ -772,6 +772,7 @@ enable_plugins + with_gnu_ld + enable_libtool_lock + enable_targets ++enable_default_strings_all + enable_werror + enable_build_warnings + enable_nls +@@ -1423,6 +1424,8 @@ Optional Features: + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) + --enable-targets alternative target configurations ++ --disable-default-strings-all ++ strings defaults to --data behavior + --enable-werror treat compile warnings as errors + --enable-build-warnings enable build-time compiler warnings + --disable-nls do not use Native Language Support +@@ -11681,6 +11684,25 @@ cat >>confdefs.h <<_ACEOF + esac + fi + ++# Check whether --enable-default-strings-all was given. ++if test "${enable_default_strings_all+set}" = set; then : ++ enableval=$enable_default_strings_all; ++if test "${enableval}" = no; then ++ default_strings_all=0 ++else ++ default_strings_all=1 ++fi ++else ++ default_strings_all=1 ++fi ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define DEFAULT_STRINGS_ALL $default_strings_all ++_ACEOF ++ ++ + + GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +diff --git a/binutils/configure.ac b/binutils/configure.in +index c5da20d..c5aadd8 100644 +--- a/binutils/configure.in ++++ b/binutils/configure.in +@@ -55,6 +55,18 @@ fi], [default_ar_deterministic=0]) + *) enable_targets=$enableval ;; + esac])dnl + ++AC_ARG_ENABLE(default-strings-all, ++[AS_HELP_STRING([--disable-default-strings-all], ++ [strings defaults to --data behavior])], [ ++if test "${enableval}" = no; then ++ default_strings_all=0 ++else ++ default_strings_all=1 ++fi], [default_strings_all=1]) ++ ++AC_DEFINE_UNQUOTED(DEFAULT_STRINGS_ALL, $default_strings_all, ++ [Should strings use -a behavior by default?]) ++ + AM_BINUTILS_WARNINGS + + AC_CONFIG_HEADERS(config.h:config.in) +diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi +index 3874f25..eee77b1 100644 +--- a/binutils/doc/binutils.texi ++++ b/binutils/doc/binutils.texi +@@ -2672,15 +2672,24 @@ strings [@option{-afovV}] [@option{-}@var{min-len}] + + @c man begin DESCRIPTION strings + +-For each @var{file} given, @sc{gnu} @command{strings} prints the printable +-character sequences that are at least 4 characters long (or the number +-given with the options below) and are followed by an unprintable +-character. By default, it only prints the strings from the initialized +-and loaded sections of object files; for other types of files, it prints +-the strings from the whole file. ++For each @var{file} given, @sc{gnu} @command{strings} prints the ++printable character sequences that are at least 4 characters long (or ++the number given with the options below) and are followed by an ++unprintable character. + +-@command{strings} is mainly useful for determining the contents of non-text +-files. ++Depending upon how the strings program was configured it will default ++to either displaying all the printable sequences that it can find in ++each file, or only those sequences that are in loadable, initialized ++data sections. If the file type in unrecognizable, or if strings is ++reading from stdin then it will always display all of the printable ++sequences that it can find. ++ ++For backwards compatibility any file that occurs after a command line ++option of just @option{-} will also be scanned in full, regardless of ++the presence of any @option{-d} option. ++ ++@command{strings} is mainly useful for determining the contents of ++non-text files. + + @c man end + +@@ -2690,8 +2699,25 @@ files. + @item -a + @itemx --all + @itemx - +-Do not scan only the initialized and loaded sections of object files; +-scan the whole files. ++Scan the whole file, regardless of what sections it contains or ++whether those sections are loaded or initialized. Normally this is ++the default behaviour, but strings can be configured so that the ++@option{-d} is the default instead. ++ ++The @option{-} option is position dependent and forces strings to ++perform full scans of any file that is mentioned after the @option{-} ++on the command line, even if the @option{-d} option has been ++specified. ++ ++@item -d ++@itemx --data ++Only print strings from initialized, loaded data sections in the ++file. This may reduce the amount of garbage in the output, but it ++also exposes the strings program to any security flaws that may be ++present in the BFD library used to scan and load sections. Strings ++can be configured so that this option is the default behaviour. In ++such cases the @option{-a} option can be used to avoid using the BFD ++library and instead just print all of the strings found in the file. + + @item -f + @itemx --print-file-name +diff --git a/binutils/strings.c b/binutils/strings.c +index f92132b..2cf046f 100644 +--- a/binutils/strings.c ++++ b/binutils/strings.c +@@ -21,7 +21,10 @@ + Options: + --all + -a +- - Do not scan only the initialized data section of object files. ++ - Scan each file in its entirety. ++ ++ --data ++ -d Scan only the initialized data section(s) of object files. + + --print-file-name + -f Print the name of the file before each string. +@@ -114,6 +117,7 @@ static int encoding_bytes; + static struct option long_options[] = + { + {"all", no_argument, NULL, 'a'}, ++ {"data", no_argument, NULL, 'd'}, + {"print-file-name", no_argument, NULL, 'f'}, + {"bytes", required_argument, NULL, 'n'}, + {"radix", required_argument, NULL, 't'}, +@@ -136,7 +140,7 @@ typedef struct + + static void strings_a_section (bfd *, asection *, void *); + static bfd_boolean strings_object_file (const char *); +-static bfd_boolean strings_file (char *file); ++static bfd_boolean strings_file (char *); + static void print_strings (const char *, FILE *, file_ptr, int, int, char *); + static void usage (FILE *, int); + static long get_char (FILE *, file_ptr *, int *, char **); +@@ -167,11 +171,14 @@ main (int argc, char **argv) + string_min = 4; + print_addresses = FALSE; + print_filenames = FALSE; +- datasection_only = TRUE; ++ if (DEFAULT_STRINGS_ALL) ++ datasection_only = FALSE; ++ else ++ datasection_only = TRUE; + target = NULL; + encoding = 's'; + +- while ((optc = getopt_long (argc, argv, "afhHn:ot:e:T:Vv0123456789", ++ while ((optc = getopt_long (argc, argv, "adfhHn:ot:e:T:Vv0123456789", + long_options, (int *) 0)) != EOF) + { + switch (optc) +@@ -180,6 +187,10 @@ main (int argc, char **argv) + datasection_only = FALSE; + break; + ++ case 'd': ++ datasection_only = TRUE; ++ break; ++ + case 'f': + print_filenames = TRUE; + break; +@@ -648,8 +659,18 @@ usage (FILE *stream, int status) + { + fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name); + fprintf (stream, _(" Display printable strings in [file(s)] (stdin by default)\n")); +- fprintf (stream, _(" The options are:\n\ ++ fprintf (stream, _(" The options are:\n")); ++ ++ if (DEFAULT_STRINGS_ALL) ++ fprintf (stream, _("\ ++ -a - --all Scan the entire file, not just the data section [default]\n\ ++ -d --data Only scan the data sections in the file\n")); ++ else ++ fprintf (stream, _("\ + -a - --all Scan the entire file, not just the data section\n\ ++ -d --data Only scan the data sections in the file [default]\n")); ++ ++ fprintf (stream, _("\ + -f --print-file-name Print the name of the file before each string\n\ + -n --bytes=[number] Locate & print any NUL-terminated sequence of at\n\ + - least [number] characters (default 4).\n\ +-- +1.7.1 + --- binutils-2.22.orig/debian/patches/binutils-CVE-2014-8501.patch +++ binutils-2.22/debian/patches/binutils-CVE-2014-8501.patch @@ -0,0 +1,53 @@ +From: Kai Tietz +Date: Thu, 21 Mar 2013 14:07:08 +0000 (+0000) +Subject: * coffgen.c (coff_real_object_p): Make global. +X-Git-Tag: sid-snapshot-20130401~137 +X-Git-Url: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff_plain;h=ce63b7b388b808bf574fe2d1de675b038857312e + + * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Just handle amount + of directory-entiries as specified in pe-header. + +From 7e1e19887abd24aeb15066b141cdff5541e0ec8e Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Mon, 27 Oct 2014 14:45:06 +0000 +Subject: [PATCH] Fix a seg-fault in strings and other binutuils when parsing a corrupt PE + executable with an invalid value in the NumberOfRvaAndSizes field of the + AOUT header. + + PR binutils/17512 + * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Handle corrupt binaries + with an invalid value for NumberOfRvaAndSizes. + +[Ubuntu note: patch differs from upstream commit in that it drops the +changelog update to reduce patch conflicts and incorporates the +bfd/peXXigen.c fix from the first commit. --sbeattie] + +CVE-2014-8501 +--- + bfd/peXXigen.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +Index: b/bfd/peXXigen.c +=================================================================== +--- a/bfd/peXXigen.c ++++ b/bfd/peXXigen.c +@@ -461,7 +461,18 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, + { + int idx; + +- for (idx = 0; idx < 16; idx++) ++ /* PR 17512: Corrupt PE binaries can cause seg-faults. */ ++ if (a->NumberOfRvaAndSizes > 16) ++ { ++ (*_bfd_error_handler) ++ (_("%B: aout header specifies an invalid number of data-directory entries: %d"), ++ abfd, a->NumberOfRvaAndSizes); ++ /* Paranoia: If the number is corrupt, then assume that the ++ actual entries themselves might be corrupt as well. */ ++ a->NumberOfRvaAndSizes = 0; ++ } ++ ++ for (idx = 0; idx < a->NumberOfRvaAndSizes; idx++) + { + /* If data directory is empty, rva also should be 0. */ + int size = --- binutils-2.22.orig/debian/patches/binutils-CVE-2014-8737.patch +++ binutils-2.22/debian/patches/binutils-CVE-2014-8737.patch @@ -0,0 +1,208 @@ +From dd9b91de2149ee81d47f708e7b0bbf57da10ad42 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Thu, 6 Nov 2014 14:49:10 +0000 +Subject: [PATCH] Prevent archive memebers with illegal pathnames from being extracted from an archive. + + PR binutils/17552, binutils/17533 + * bucomm.c (is_valid_archive_path): New function. Returns false + for absolute pathnames and pathnames that include /../. + * bucomm.h (is_valid_archive_path): Add prototype. + * ar.c (extract_file): Use new function to check for valid + pathnames when extracting files from an archive. + * objcopy.c (copy_archive): Likewise. + * doc/binutils.texi: Update documentation to mention the + limitation on pathname of archive members. + +From 5e186ece2feebb46e63ff6bb2d2490aad0d5a724 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Mon, 10 Nov 2014 14:28:43 +0000 +Subject: [PATCH] Fix objcopy and strip so that they remove their temporary files even if an error occurs. + + PR binutils/17552 + * (copy_archive): Clean up temporary files even if an error + occurs. + +[Ubuntu note: patches differ from upstream commit by dropping the +changelog updates to reduce patch conflicts. -- sbeattie] + +CVE-2014-8737 + fix to clean up temporary files on error +--- + binutils/ar.c | 9 +++++++++ + binutils/bucomm.c | 26 ++++++++++++++++++++++++++ + binutils/bucomm.h | 12 ++++++++---- + binutils/doc/binutils.texi | 3 ++- + binutils/objcopy.c | 23 ++++++++++++++++++----- + 5 files changed, 63 insertions(+), 10 deletions(-) + +Index: b/binutils/ar.c +=================================================================== +--- a/binutils/ar.c ++++ b/binutils/ar.c +@@ -938,6 +938,15 @@ extract_file (bfd *abfd) + bfd_size_type size; + struct stat buf; + ++ /* PR binutils/17533: Do not allow directory traversal ++ outside of the current directory tree. */ ++ if (! is_valid_archive_path (bfd_get_filename (abfd))) ++ { ++ non_fatal (_("illegal pathname found in archive member: %s"), ++ bfd_get_filename (abfd)); ++ return; ++ } ++ + if (bfd_stat_arch_elt (abfd, &buf) != 0) + /* xgettext:c-format */ + fatal (_("internal stat error on %s"), bfd_get_filename (abfd)); +Index: b/binutils/bucomm.c +=================================================================== +--- a/binutils/bucomm.c ++++ b/binutils/bucomm.c +@@ -623,3 +623,29 @@ bfd_get_archive_filename (const bfd *abf + bfd_get_filename (abfd)); + return buf; + } ++ ++/* Returns TRUE iff PATHNAME, a filename of an archive member, ++ is valid for writing. For security reasons absolute paths ++ and paths containing /../ are not allowed. See PR 17533. */ ++ ++bfd_boolean ++is_valid_archive_path (char const * pathname) ++{ ++ const char * n = pathname; ++ ++ if (IS_ABSOLUTE_PATH (n)) ++ return FALSE; ++ ++ while (*n) ++ { ++ if (*n == '.' && *++n == '.' && ( ! *++n || IS_DIR_SEPARATOR (*n))) ++ return FALSE; ++ ++ while (*n && ! IS_DIR_SEPARATOR (*n)) ++ n++; ++ while (IS_DIR_SEPARATOR (*n)) ++ n++; ++ } ++ ++ return TRUE; ++} +Index: b/binutils/bucomm.h +=================================================================== +--- a/binutils/bucomm.h ++++ b/binutils/bucomm.h +@@ -23,6 +23,8 @@ + #ifndef _BUCOMM_H + #define _BUCOMM_H + ++/* In bucomm.c. */ ++ + /* Return the filename in a static buffer. */ + const char *bfd_get_archive_filename (const bfd *); + +@@ -58,20 +60,22 @@ bfd_vma parse_vma (const char *, const c + + off_t get_file_size (const char *); + ++bfd_boolean is_valid_archive_path (char const *); ++ + extern char *program_name; + +-/* filemode.c */ ++/* In filemode.c. */ + void mode_string (unsigned long, char *); + +-/* version.c */ ++/* In version.c. */ + extern void print_version (const char *); + +-/* rename.c */ ++/* In rename.c. */ + extern void set_times (const char *, const struct stat *); + + extern int smart_rename (const char *, const char *, int); + +-/* libiberty. */ ++/* In libiberty. */ + void *xmalloc (size_t); + + void *xrealloc (void *, size_t); +Index: b/binutils/doc/binutils.texi +=================================================================== +--- a/binutils/doc/binutils.texi ++++ b/binutils/doc/binutils.texi +@@ -227,7 +227,8 @@ contents of each object would only waste + are also @emph{flattened}, so that adding one or more archives to a + thin archive will add the elements of the nested archive individually. + The paths to the elements of the archive are stored relative to the +-archive itself. ++archive itself. For security reasons absolute paths and paths with a ++@code{/../} component are not allowed. + + @cindex compatibility, @command{ar} + @cindex @command{ar} compatibility +Index: b/binutils/objcopy.c +=================================================================== +--- a/binutils/objcopy.c ++++ b/binutils/objcopy.c +@@ -2051,6 +2051,16 @@ copy_archive (bfd *ibfd, bfd *obfd, cons + bfd_boolean del = TRUE; + bfd_boolean ok_object; + ++ /* PR binutils/17533: Do not allow directory traversal ++ outside of the current directory tree by archive members. */ ++ if (! is_valid_archive_path (bfd_get_filename (this_element))) ++ { ++ non_fatal (_("illegal pathname found in archive member: %s"), ++ bfd_get_filename (this_element)); ++ status = 1; ++ goto cleanup_and_exit; ++ } ++ + /* Create an output file for this member. */ + output_name = concat (dir, "/", + bfd_get_filename (this_element), (char *) 0); +@@ -2060,8 +2070,12 @@ copy_archive (bfd *ibfd, bfd *obfd, cons + { + output_name = make_tempdir (output_name); + if (output_name == NULL) +- fatal (_("cannot create tempdir for archive copying (error: %s)"), +- strerror (errno)); ++ { ++ non_fatal (_("cannot create tempdir for archive copying (error: %s)"), ++ strerror (errno)); ++ status = 1; ++ goto cleanup_and_exit; ++ } + + l = (struct name_list *) xmalloc (sizeof (struct name_list)); + l->name = output_name; +@@ -2103,7 +2117,7 @@ copy_archive (bfd *ibfd, bfd *obfd, cons + { + bfd_nonfatal_message (output_name, NULL, NULL, NULL); + status = 1; +- return; ++ goto cleanup_and_exit; + } + + if (ok_object) +@@ -2164,7 +2178,6 @@ copy_archive (bfd *ibfd, bfd *obfd, cons + { + status = 1; + bfd_nonfatal_message (filename, NULL, NULL, NULL); +- return; + } + + filename = bfd_get_filename (ibfd); +@@ -2172,9 +2185,9 @@ copy_archive (bfd *ibfd, bfd *obfd, cons + { + status = 1; + bfd_nonfatal_message (filename, NULL, NULL, NULL); +- return; + } + ++ cleanup_and_exit: + /* Delete all the files that we opened. */ + for (l = list; l != NULL; l = l->next) + { --- binutils-2.22.orig/debian/patches/213-gold-arm-pie-fix.patch +++ binutils-2.22/debian/patches/213-gold-arm-pie-fix.patch @@ -0,0 +1,63 @@ +Author: Doug Kwan +Description: arm.cc (Reloc_stub::stub_type_for_reloc): Use PIC stubs in all position independent outputs, not just shared objects. +Origin: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/arm.cc.diff?r1=1.144&r2=1.145&cvsroot=src + + +Index: binutils-2.22/gold/arm.cc +=================================================================== +--- binutils-2.22.orig/gold/arm.cc 2011-11-21 09:40:12.000000000 +0000 ++++ binutils-2.22/gold/arm.cc 2013-02-21 16:56:19.498723185 +0000 +@@ -4499,6 +4499,8 @@ + } + + int64_t branch_offset; ++ bool output_is_position_independent = ++ parameters->options().output_is_position_independent(); + if (r_type == elfcpp::R_ARM_THM_CALL || r_type == elfcpp::R_ARM_THM_JUMP24) + { + // For THUMB BLX instruction, bit 1 of target comes from bit 1 of the +@@ -4527,7 +4529,7 @@ + // Thumb to thumb. + if (!thumb_only) + { +- stub_type = (parameters->options().shared() ++ stub_type = (output_is_position_independent + || should_force_pic_veneer) + // PIC stubs. + ? ((may_use_blx +@@ -4548,7 +4550,7 @@ + } + else + { +- stub_type = (parameters->options().shared() ++ stub_type = (output_is_position_independent + || should_force_pic_veneer) + ? arm_stub_long_branch_thumb_only_pic // PIC stub. + : arm_stub_long_branch_thumb_only; // non-PIC stub. +@@ -4561,7 +4563,7 @@ + // FIXME: We should check that the input section is from an + // object that has interwork enabled. + +- stub_type = (parameters->options().shared() ++ stub_type = (output_is_position_independent + || should_force_pic_veneer) + // PIC stubs. + ? ((may_use_blx +@@ -4603,7 +4605,7 @@ + || (r_type == elfcpp::R_ARM_JUMP24) + || (r_type == elfcpp::R_ARM_PLT32)) + { +- stub_type = (parameters->options().shared() ++ stub_type = (output_is_position_independent + || should_force_pic_veneer) + // PIC stubs. + ? (may_use_blx +@@ -4622,7 +4624,7 @@ + if (branch_offset > ARM_MAX_FWD_BRANCH_OFFSET + || (branch_offset < ARM_MAX_BWD_BRANCH_OFFSET)) + { +- stub_type = (parameters->options().shared() ++ stub_type = (output_is_position_independent + || should_force_pic_veneer) + ? arm_stub_long_branch_any_arm_pic // PIC stubs. + : arm_stub_long_branch_any_any; /// non-PIC. --- binutils-2.22.orig/debian/patches/167_pr13302.diff +++ binutils-2.22/debian/patches/167_pr13302.diff @@ -0,0 +1,532 @@ +# DP: Fix PR ld/13302, taken from the trunk + +bfd/ + +2012-03-06 Jakub Jelinek + + * elf64-x86-64.c (elf_x86_64_relocate_section): For R_X86_64_RELATIVE + set relocate to TRUE. + +2011-10-21 H.J. Lu + + PR ld/13302 + * elf32-i386.c (elf_i386_relocate_section): Replace + R_386_IRELATIVE with R_386_RELATIVE. + + * elf64-x86-64.c (elf_x86_64_relocate_section): Replace + R_X86_64_IRELATIVE with R_X86_64_RELATIVE. + +2011-10-21 H.J. Lu . + + * elf32-i386.c (elf_i386_relocate_section): Fix a typo in + comments. + * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise. + +2011-10-21 H.J. Lu + + PR ld/13302 + * elf32-i386.c (elf_i386_link_hash_table): Add next_jump_slot_index + and next_irelative_index. + (elf_i386_link_hash_table_create): Initialize next_jump_slot_index + and next_irelative_index. + (elf_i386_allocate_dynrelocs): Increment reloc_count instead of + next_tls_desc_index. + (elf_i386_size_dynamic_sections): Set next_tls_desc_index and + next_irelative_index from reloc_count. + (elf_i386_finish_dynamic_symbol): Put R_386_IRELATIVE after + R_386_JUMP_SLOT. + + * elf64-x86-64.c (elf_x86_64_link_hash_table): Add + next_jump_slot_index and next_irelative_index. + (elf_x86_64_link_hash_table_create): Initialize + next_jump_slot_index and next_irelative_index. + (elf_x86_64_size_dynamic_sections): Set next_irelative_index + from reloc_count. + (elf_x86_64_finish_dynamic_symbol): Put R_X86_64_IRELATIVE after + R_X86_64_JUMP_SLOT. + +ld/testsuite + +2011-10-21 H.J. Lu + + PR ld/13302 + * ld-i386/i386.exp: Run pr13302. + + * ld-i386/pr13302.d: New. + * ld-i386/pr13302.s: Likewise. + + * ld-x86-64/pr13082-5b.d: Updated. + * ld-x86-64/pr13082-6a.d: Likewise. + * ld-x86-64/pr13082-6b.d: Likewise. + +2011-10-21 H.J. Lu + + PR ld/13302 + * ld-ifunc/ifunc-16-i386.d: New. + * ld-ifunc/ifunc-16-x86-64.d: Likewise. + * ld-ifunc/ifunc-16-x86.s: Likewise. + +diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c +index 7ef1fc1..d187305 100644 +--- a/bfd/elf32-i386.c ++++ b/bfd/elf32-i386.c +@@ -806,6 +806,12 @@ struct elf_i386_link_hash_table + + /* The index of the next unused R_386_TLS_DESC slot in .rel.plt. */ + bfd_vma next_tls_desc_index; ++ ++ /* The index of the next unused R_386_JUMP_SLOT slot in .rel.plt. */ ++ bfd_vma next_jump_slot_index; ++ ++ /* The index of the next unused R_386_IRELATIVE slot in .rel.plt. */ ++ bfd_vma next_irelative_index; + }; + + /* Get the i386 ELF linker hash table from a link_info structure. */ +@@ -946,6 +952,8 @@ elf_i386_link_hash_table_create (bfd *abfd) + ret->sym_cache.abfd = NULL; + ret->srelplt2 = NULL; + ret->tls_module_base = NULL; ++ ret->next_jump_slot_index = 0; ++ ret->next_irelative_index = 0; + + ret->loc_hash_table = htab_try_create (1024, + elf_i386_local_htab_hash, +@@ -2275,7 +2283,7 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) + + /* We also need to make an entry in the .rel.plt section. */ + htab->elf.srelplt->size += sizeof (Elf32_External_Rel); +- htab->next_tls_desc_index++; ++ htab->elf.srelplt->reloc_count++; + + if (get_elf_i386_backend_data (info->output_bfd)->is_vxworks + && !info->shared) +@@ -2700,9 +2708,19 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) + incremented. However, when we reserve space for TLS descriptors, + it's not incremented, so in order to compute the space reserved + for them, it suffices to multiply the reloc count by the jump +- slot size. */ ++ slot size. ++ ++ PR ld/13302: We start next_irelative_index at the end of .rela.plt ++ so that R_386_IRELATIVE entries come last. */ + if (htab->elf.srelplt) +- htab->sgotplt_jump_table_size = htab->next_tls_desc_index * 4; ++ { ++ htab->next_tls_desc_index = htab->elf.srelplt->reloc_count; ++ htab->sgotplt_jump_table_size = htab->next_tls_desc_index * 4; ++ htab->next_irelative_index = htab->elf.srelplt->reloc_count - 1; ++ } ++ else if (htab->elf.irelplt) ++ htab->next_irelative_index = htab->elf.irelplt->reloc_count - 1; ++ + + if (htab->elf.sgotplt) + { +@@ -3232,13 +3250,14 @@ elf_i386_relocate_section (bfd *output_bfd, + + case R_386_32: + /* Generate dynamic relcoation only when there is a +- non-GOF reference in a shared object. */ ++ non-GOT reference in a shared object. */ + if (info->shared && h->non_got_ref) + { + Elf_Internal_Rela outrel; + bfd_byte *loc; + asection *sreloc; + bfd_vma offset; ++ bfd_boolean relocate; + + /* Need a dynamic relocation to get the real function + adddress. */ +@@ -3259,15 +3278,14 @@ elf_i386_relocate_section (bfd *output_bfd, + || info->executable) + { + /* This symbol is resolved locally. */ +- outrel.r_info = ELF32_R_INFO (0, R_386_IRELATIVE); +- bfd_put_32 (output_bfd, +- (h->root.u.def.value +- + h->root.u.def.section->output_section->vma +- + h->root.u.def.section->output_offset), +- contents + offset); ++ outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE); ++ relocate = TRUE; + } + else +- outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); ++ { ++ outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); ++ relocate = FALSE; ++ } + + sreloc = htab->elf.irelifunc; + loc = sreloc->contents; +@@ -3280,7 +3298,8 @@ elf_i386_relocate_section (bfd *output_bfd, + we need to include the symbol value so that it + becomes an addend for the dynamic reloc. For an + internal symbol, we have updated addend. */ +- continue; ++ if (! relocate) ++ continue; + } + /* FALLTHROUGH */ + case R_386_PC32: +@@ -4364,13 +4383,13 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd, + + if (plt == htab->elf.splt) + { +- plt_index = h->plt.offset / plt_entry_size - 1; +- got_offset = (plt_index + 3) * 4; ++ got_offset = h->plt.offset / plt_entry_size - 1; ++ got_offset = (got_offset + 3) * 4; + } + else + { +- plt_index = h->plt.offset / plt_entry_size; +- got_offset = plt_index * 4; ++ got_offset = h->plt.offset / plt_entry_size; ++ got_offset = got_offset * 4; + } + + /* Fill in the entry in the procedure linkage table. */ +@@ -4431,18 +4450,6 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd, + + abed->plt->plt_got_offset); + } + +- /* Don't fill PLT entry for static executables. */ +- if (plt == htab->elf.splt) +- { +- bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rel), +- plt->contents + h->plt.offset +- + abed->plt->plt_reloc_offset); +- bfd_put_32 (output_bfd, - (h->plt.offset +- + abed->plt->plt_plt_offset + 4), +- plt->contents + h->plt.offset +- + abed->plt->plt_plt_offset); +- } +- + /* Fill in the entry in the global offset table. */ + bfd_put_32 (output_bfd, + (plt->output_section->vma +@@ -4470,12 +4477,29 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd, + + h->root.u.def.section->output_offset), + gotplt->contents + got_offset); + rel.r_info = ELF32_R_INFO (0, R_386_IRELATIVE); ++ /* R_386_IRELATIVE comes last. */ ++ plt_index = htab->next_irelative_index--; + } + else +- rel.r_info = ELF32_R_INFO (h->dynindx, R_386_JUMP_SLOT); ++ { ++ rel.r_info = ELF32_R_INFO (h->dynindx, R_386_JUMP_SLOT); ++ plt_index = htab->next_jump_slot_index++; ++ } + loc = relplt->contents + plt_index * sizeof (Elf32_External_Rel); + bfd_elf32_swap_reloc_out (output_bfd, &rel, loc); + ++ /* Don't fill PLT entry for static executables. */ ++ if (plt == htab->elf.splt) ++ { ++ bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rel), ++ plt->contents + h->plt.offset ++ + abed->plt->plt_reloc_offset); ++ bfd_put_32 (output_bfd, - (h->plt.offset ++ + abed->plt->plt_plt_offset + 4), ++ plt->contents + h->plt.offset ++ + abed->plt->plt_plt_offset); ++ } ++ + if (!h->def_regular) + { + /* Mark the symbol as undefined, rather than as defined in +diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c +index e4c3946..2206dd4 100644 +--- a/bfd/elf64-x86-64.c ++++ b/bfd/elf64-x86-64.c +@@ -698,6 +698,11 @@ struct elf_x86_64_link_hash_table + /* The offset into sgot of the GOT entry used by the PLT entry + above. */ + bfd_vma tlsdesc_got; ++ ++ /* The index of the next R_X86_64_JUMP_SLOT entry in .rela.plt. */ ++ bfd_vma next_jump_slot_index; ++ /* The index of the next R_X86_64_IRELATIVE entry in .rela.plt. */ ++ bfd_vma next_irelative_index; + }; + + /* Get the x86-64 ELF linker hash table from a link_info structure. */ +@@ -839,6 +844,8 @@ elf_x86_64_link_hash_table_create (bfd *abfd) + ret->tls_ld_got.refcount = 0; + ret->sgotplt_jump_table_size = 0; + ret->tls_module_base = NULL; ++ ret->next_jump_slot_index = 0; ++ ret->next_irelative_index = 0; + + if (ABI_64_P (abfd)) + { +@@ -2667,10 +2674,18 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd, + incremented. However, when we reserve space for TLS descriptors, + it's not incremented, so in order to compute the space reserved + for them, it suffices to multiply the reloc count by the jump +- slot size. */ ++ slot size. ++ ++ PR ld/13302: We start next_irelative_index at the end of .rela.plt ++ so that R_X86_64_IRELATIVE entries come last. */ + if (htab->elf.srelplt) +- htab->sgotplt_jump_table_size +- = elf_x86_64_compute_jump_table_size (htab); ++ { ++ htab->sgotplt_jump_table_size ++ = elf_x86_64_compute_jump_table_size (htab); ++ htab->next_irelative_index = htab->elf.srelplt->reloc_count - 1; ++ } ++ else if (htab->elf.irelplt) ++ htab->next_irelative_index = htab->elf.irelplt->reloc_count - 1; + + if (htab->tlsdesc_plt) + { +@@ -3141,11 +3156,12 @@ elf_x86_64_relocate_section (bfd *output_bfd, + } + + /* Generate dynamic relcoation only when there is a +- non-GOF reference in a shared object. */ ++ non-GOT reference in a shared object. */ + if (info->shared && h->non_got_ref) + { + Elf_Internal_Rela outrel; + asection *sreloc; ++ bfd_boolean relocate; + + /* Need a dynamic relocation to get the real function + address. */ +@@ -3165,15 +3181,15 @@ elf_x86_64_relocate_section (bfd *output_bfd, + || info->executable) + { + /* This symbol is resolved locally. */ +- outrel.r_info = htab->r_info (0, R_X86_64_IRELATIVE); +- outrel.r_addend = (h->root.u.def.value +- + h->root.u.def.section->output_section->vma +- + h->root.u.def.section->output_offset); ++ outrel.r_info = htab->r_info (0, R_X86_64_RELATIVE); ++ outrel.r_addend = relocation; ++ relocate = TRUE; + } + else + { + outrel.r_info = htab->r_info (h->dynindx, r_type); + outrel.r_addend = 0; ++ relocate = FALSE; + } + + sreloc = htab->elf.irelifunc; +@@ -3184,7 +3200,8 @@ elf_x86_64_relocate_section (bfd *output_bfd, + we need to include the symbol value so that it + becomes an addend for the dynamic reloc. For an + internal symbol, we have updated addend. */ +- continue; ++ if (! relocate) ++ continue; + } + /* FALLTHROUGH */ + case R_X86_64_PC32: +@@ -4205,13 +4222,13 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd, + + if (plt == htab->elf.splt) + { +- plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; +- got_offset = (plt_index + 3) * GOT_ENTRY_SIZE; ++ got_offset = h->plt.offset / PLT_ENTRY_SIZE - 1; ++ got_offset = (got_offset + 3) * GOT_ENTRY_SIZE; + } + else + { +- plt_index = h->plt.offset / PLT_ENTRY_SIZE; +- got_offset = plt_index * GOT_ENTRY_SIZE; ++ got_offset = h->plt.offset / PLT_ENTRY_SIZE; ++ got_offset = got_offset * GOT_ENTRY_SIZE; + } + + /* Fill in the entry in the procedure linkage table. */ +@@ -4233,17 +4250,6 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd, + - 6), + plt->contents + h->plt.offset + 2); + +- /* Don't fill PLT entry for static executables. */ +- if (plt == htab->elf.splt) +- { +- /* Put relocation index. */ +- bfd_put_32 (output_bfd, plt_index, +- plt->contents + h->plt.offset + 7); +- /* Put offset for jmp .PLT0. */ +- bfd_put_32 (output_bfd, - (h->plt.offset + PLT_ENTRY_SIZE), +- plt->contents + h->plt.offset + 12); +- } +- + /* Fill in the entry in the global offset table, initially this + points to the pushq instruction in the PLT which is at offset 6. */ + bfd_put_64 (output_bfd, (plt->output_section->vma +@@ -4267,11 +4273,25 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd, + rela.r_addend = (h->root.u.def.value + + h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset); ++ /* R_X86_64_IRELATIVE comes last. */ ++ plt_index = htab->next_irelative_index--; + } + else + { + rela.r_info = htab->r_info (h->dynindx, R_X86_64_JUMP_SLOT); + rela.r_addend = 0; ++ plt_index = htab->next_jump_slot_index++; ++ } ++ ++ /* Don't fill PLT entry for static executables. */ ++ if (plt == htab->elf.splt) ++ { ++ /* Put relocation index. */ ++ bfd_put_32 (output_bfd, plt_index, ++ plt->contents + h->plt.offset + 7); ++ /* Put offset for jmp .PLT0. */ ++ bfd_put_32 (output_bfd, - (h->plt.offset + PLT_ENTRY_SIZE), ++ plt->contents + h->plt.offset + 12); + } + + bed = get_elf_backend_data (output_bfd); +diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp +index 68b71fb..1727922 100644 +--- a/ld/testsuite/ld-i386/i386.exp ++++ b/ld/testsuite/ld-i386/i386.exp +@@ -210,3 +210,4 @@ if { !([istarget "i?86-*-linux*"] + + run_dump_test "compressed1" + run_dump_test "pr12627" ++run_dump_test "pr13302" +diff --git a/ld/testsuite/ld-i386/pr13302.d b/ld/testsuite/ld-i386/pr13302.d +new file mode 100644 +index 0000000..3d85d08 +--- /dev/null ++++ b/ld/testsuite/ld-i386/pr13302.d +@@ -0,0 +1,12 @@ ++#name: PR ld/13302 ++#as: --32 ++#ld: -pie -melf_i386 ++#readelf: -r --wide ++ ++Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entries: ++ Offset Info Type Sym. Value Symbol's Name ++[0-9a-f]+ +[0-9a-f]+ +R_386_RELATIVE + ++ ++Relocation section '.rel.plt' at offset 0x[0-9a-f]+ contains 1 entries: ++ Offset Info Type Sym. Value Symbol's Name ++[0-9a-f]+ +[0-9a-f]+ +R_386_IRELATIVE + +diff --git a/ld/testsuite/ld-i386/pr13302.s b/ld/testsuite/ld-i386/pr13302.s +new file mode 100644 +index 0000000..cfd2717 +--- /dev/null ++++ b/ld/testsuite/ld-i386/pr13302.s +@@ -0,0 +1,11 @@ ++ .text ++ .globl _start ++ .type ifunc, @gnu_indirect_function ++_start: ++ lea .Ljmp@GOTOFF(%ebx), %eax ++ifunc: ++ jmp *(%eax) ++ .section .data.rel.ro.local,"aw",@progbits ++ .align 4 ++.Ljmp: ++ .long ifunc +diff --git a/ld/testsuite/ld-ifunc/ifunc-16-i386.d b/ld/testsuite/ld-ifunc/ifunc-16-i386.d +new file mode 100644 +index 0000000..8ae3d0a +--- /dev/null ++++ b/ld/testsuite/ld-ifunc/ifunc-16-i386.d +@@ -0,0 +1,10 @@ ++#source: ifunc-16-x86.s ++#ld: -shared -m elf_i386 ++#as: --32 ++#readelf: -r --wide ++#target: x86_64-*-* i?86-*-* ++ ++Relocation section '.rel.plt' at .* ++[ ]+Offset[ ]+Info[ ]+Type[ ]+.* ++[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_JUMP_SLOT[ ]+0+[ ]+ifunc ++[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_IRELATIVE[ ]* +diff --git a/ld/testsuite/ld-ifunc/ifunc-16-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-16-x86-64.d +new file mode 100644 +index 0000000..d69626d +--- /dev/null ++++ b/ld/testsuite/ld-ifunc/ifunc-16-x86-64.d +@@ -0,0 +1,10 @@ ++#source: ifunc-16-x86.s ++#as: --64 ++#ld: -shared -melf_x86_64 ++#readelf: -r --wide ++#target: x86_64-*-* ++ ++Relocation section '.rela.plt' at .* ++[ ]+Offset[ ]+Info[ ]+Type[ ]+.* ++[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_JUMP_SLOT[ ]+0+[ ]+ifunc \+ 0 ++[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_IRELATIVE[ ]+[0-9a-f]* +diff --git a/ld/testsuite/ld-ifunc/ifunc-16-x86.s b/ld/testsuite/ld-ifunc/ifunc-16-x86.s +new file mode 100644 +index 0000000..fb38253 +--- /dev/null ++++ b/ld/testsuite/ld-ifunc/ifunc-16-x86.s +@@ -0,0 +1,17 @@ ++ .text ++ .globl fct ++ .type fct, @gnu_indirect_function ++ .set fct,resolve ++ .hidden int_fct ++ .globl int_fct ++ .set int_fct,fct ++ .p2align 4,,15 ++ .type resolve, @function ++resolve: ++ call ifunc@PLT ++ .size resolve, .-resolve ++ .globl g ++ .type g, @function ++g: ++ jmp int_fct@PLT ++ .size g, .-g +diff --git a/ld/testsuite/ld-x86-64/pr13082-5b.d b/ld/testsuite/ld-x86-64/pr13082-5b.d +index 1c5a5e7..48e37c3 100644 +--- a/ld/testsuite/ld-x86-64/pr13082-5b.d ++++ b/ld/testsuite/ld-x86-64/pr13082-5b.d +@@ -6,7 +6,7 @@ + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries: + Offset Info Type Sym. Value Symbol's Name \+ Addend +-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+ ++[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+ + + Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries: + Offset Info Type Sym. Value Symbol's Name \+ Addend +diff --git a/ld/testsuite/ld-x86-64/pr13082-6a.d b/ld/testsuite/ld-x86-64/pr13082-6a.d +index 9a1a655..de90bb8 100644 +--- a/ld/testsuite/ld-x86-64/pr13082-6a.d ++++ b/ld/testsuite/ld-x86-64/pr13082-6a.d +@@ -6,7 +6,7 @@ + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries: + Offset Info Type Sym. Value Symbol's Name \+ Addend +-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+ ++[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+ + + Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries: + Offset Info Type Sym. Value Symbol's Name \+ Addend +diff --git a/ld/testsuite/ld-x86-64/pr13082-6b.d b/ld/testsuite/ld-x86-64/pr13082-6b.d +index 792c348..66ff59b 100644 +--- a/ld/testsuite/ld-x86-64/pr13082-6b.d ++++ b/ld/testsuite/ld-x86-64/pr13082-6b.d +@@ -6,7 +6,7 @@ + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries: + Offset Info Type Sym. Value Symbol's Name \+ Addend +-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+ ++[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+ + + Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries: + Offset Info Type Sym. Value Symbol's Name \+ Addend --- binutils-2.22.orig/debian/patches/pr13534-01.diff +++ binutils-2.22/debian/patches/pr13534-01.diff @@ -0,0 +1,118 @@ +commit 75bf1d978bc03a07ad59a3f983c806bb5899c28c +Author: Francois Gouget +Date: Tue Dec 20 18:37:16 2011 +0100 + + bfd: Fix writing the size of 2+GB elements in the archive. + +diff --git a/bfd/archive.c b/bfd/archive.c +index 3e333c7..5c5b3d4 100644 +--- a/bfd/archive.c ++++ b/bfd/archive.c +@@ -179,6 +179,22 @@ _bfd_ar_spacepad (char *p, size_t n, const char *fmt, long val) + memcpy (p, buf, n); + } + ++void ++_bfd_ar_sizepad (char *p, size_t n, bfd_size_type size) ++{ ++ static char buf[21]; ++ size_t len; ++ snprintf (buf, sizeof (buf), "%-10" BFD_VMA_FMT "u", size); ++ len = strlen (buf); ++ if (len < n) ++ { ++ memcpy (p, buf, len); ++ memset (p + len, ' ', n - len); ++ } ++ else ++ memcpy (p, buf, n); ++} ++ + bfd_boolean + _bfd_generic_mkarchive (bfd *abfd) + { +@@ -1770,7 +1786,7 @@ _bfd_bsd44_write_ar_hdr (bfd *archive, bfd *abfd) + + BFD_ASSERT (padded_len == arch_eltdata (abfd)->extra_size); + +- _bfd_ar_spacepad (hdr->ar_size, sizeof (hdr->ar_size), "%-10ld", ++ _bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size), + arch_eltdata (abfd)->parsed_size + padded_len); + + if (bfd_bwrite (hdr, sizeof (*hdr), archive) != sizeof (*hdr)) +@@ -1891,7 +1907,7 @@ bfd_ar_hdr_from_filesystem (bfd *abfd, const char *filename, bfd *member) + status.st_gid); + _bfd_ar_spacepad (hdr->ar_mode, sizeof (hdr->ar_mode), "%-8lo", + status.st_mode); +- _bfd_ar_spacepad (hdr->ar_size, sizeof (hdr->ar_size), "%-10ld", ++ _bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size), + status.st_size); + memcpy (hdr->ar_fmag, ARFMAG, 2); + ared->parsed_size = status.st_size; +@@ -2132,7 +2148,7 @@ _bfd_write_archive_contents (bfd *arch) + memset (&hdr, ' ', sizeof (struct ar_hdr)); + memcpy (hdr.ar_name, ename, strlen (ename)); + /* Round size up to even number in archive header. */ +- _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld", ++ _bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), + (elength + 1) & ~(bfd_size_type) 1); + memcpy (hdr.ar_fmag, ARFMAG, 2); + if ((bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch) +@@ -2409,7 +2425,7 @@ bsd_write_armap (bfd *arch, + bfd_ardata (arch)->armap_timestamp); + _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", uid); + _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", gid); +- _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld", mapsize); ++ _bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize); + memcpy (hdr.ar_fmag, ARFMAG, 2); + if (bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch) + != sizeof (struct ar_hdr)) +@@ -2564,8 +2580,7 @@ coff_write_armap (bfd *arch, + + memset (&hdr, ' ', sizeof (struct ar_hdr)); + hdr.ar_name[0] = '/'; +- _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld", +- mapsize); ++ _bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize); + _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld", + ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0 + ? time (NULL) : 0)); +diff --git a/bfd/archive64.c b/bfd/archive64.c +index bbc4c3f..a906508 100644 +--- a/bfd/archive64.c ++++ b/bfd/archive64.c +@@ -169,7 +169,7 @@ bfd_elf64_archive_write_armap (bfd *arch, + + memset (&hdr, ' ', sizeof (struct ar_hdr)); + memcpy (hdr.ar_name, "/SYM64/", strlen ("/SYM64/")); +- _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld", ++ _bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), + mapsize); + _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld", + time (NULL)); +diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h +index 7db09e4..57197ac 100644 +--- a/bfd/libbfd-in.h ++++ b/bfd/libbfd-in.h +@@ -203,6 +203,8 @@ extern void *_bfd_generic_read_ar_hdr + (bfd *); + extern void _bfd_ar_spacepad + (char *, size_t, const char *, long); ++extern void _bfd_ar_sizepad ++ (char *, size_t, bfd_size_type); + + extern void *_bfd_generic_read_ar_hdr_mag + (bfd *, const char *); +diff --git a/bfd/libbfd.h b/bfd/libbfd.h +index 0beddb6..121e865 100644 +--- a/bfd/libbfd.h ++++ b/bfd/libbfd.h +@@ -208,6 +208,8 @@ extern void *_bfd_generic_read_ar_hdr + (bfd *); + extern void _bfd_ar_spacepad + (char *, size_t, const char *, long); ++extern void _bfd_ar_sizepad ++ (char *, size_t, bfd_size_type); + + extern void *_bfd_generic_read_ar_hdr_mag + (bfd *, const char *); --- binutils-2.22.orig/debian/patches/branch-updates.diff +++ binutils-2.22/debian/patches/branch-updates.diff @@ -0,0 +1,4709 @@ +# DP: updates from the binutils-2.22 branch + +# git diff 10968a312d8c536be9993ed06bc88fbe0860d95d 0add40a869f7ebc0403de8aea5429b858f8e30da +# exclude bfd/{configure{,.ac},Makefile.{am,in}} + +diff --git a/bfd/ChangeLog b/bfd/ChangeLog +index 65db027..87498f0 100644 +--- a/bfd/ChangeLog ++++ b/bfd/ChangeLog +@@ -1,3 +1,160 @@ ++2012-02-01 Nick Clifton ++ ++ * Import this patch from the mainline: ++ 2012-01-05 Nick Clifton ++ ++ PR ld/12161 ++ * elf32-avr.c (elf32_avr_relax_delete_bytes): Read in relocs if ++ necessary. ++ ++2012-01-27 John David Anglin ++ ++ Backport from mainline: ++ 2011-12-11 John Davis Anglin ++ ++ PR binutils/13476 ++ * elf32-hppa.c (final_link_relocate): Convert R_PARISC_TLS_GD21L, ++ R_PARISC_TLS_LDM21L and R_PARISC_TLS_IE21L relocations to ++ R_PARISC_DPREL21L when not doing a shared link. Likewise convert ++ R_PARISC_TLS_GD14R, R_PARISC_TLS_LDM14R and R_PARISC_TLS_IE14R to ++ R_PARISC_DPREL14R. Handle R_PARISC_TLS_GD21L, R_PARISC_TLS_LDM21L ++ and R_PARISC_TLS_IE21L with R_PARISC_DLTIND21L. ++ ++ Backport from mainline: ++ 2011-11-06 John David Anglin ++ ++ PR ld/13387 ++ * elf32-hppa.c (elf32_hppa_hide_symbol): Make STT_GNU_IFUNC symbol ++ go through PLT. Reset plt field with init_plt_offset. ++ (elf32_hppa_adjust_dynamic_symbol): Ensure that a PLT slot is ++ allocated for symbols referenced by a plabel. ++ ++2012-01-10 H.J. Lu ++ ++ Backport from mainline: ++ PR ld/13581 ++ * elf64-x86-64.c (elf_x86_64_relocate_section): Remove ABI_64_P ++ check on R_X86_64_PCXX. ++ ++2011-12-19 Chung-Lin Tang ++ ++ Backport from mainline: ++ ++ 2011-12-19 Chung-Lin Tang ++ ++ * reloc.c (BFD_RELOC_MIPS16_TLS_GD,BFD_RELOC_MIPS16_TLS_LDM, ++ BFD_RELOC_MIPS16_TLS_DTPREL_HI16,BFD_RELOC_MIPS16_TLS_DTPREL_LO16, ++ BFD_RELOC_MIPS16_TLS_GOTTPREL,BFD_RELOC_MIPS16_TLS_TPREL_HI16, ++ BFD_RELOC_MIPS16_TLS_TPREL_LO16): New relocations for MIPS16 TLS. ++ * bfd-in2.h (bfd_reloc_code_real): Regenerate. ++ * libbfd.h (bfd_reloc_code_real_names): Regenerate. ++ * elf32-mips.c (elf_mips16_howto_table_rel): Add R_MIPS16_TLS_* ++ entries. ++ (mips16_reloc_map): Add BFD_RELOC_MIPS16_TLS_* to R_MIPS16_TLS_* ++ mappings. ++ * elfn32-mips.c (elf_mips16_howto_table_rel, ++ elf_mips16_howto_table_rela): Add R_MIPS16_TLS_* entries. ++ (mips16_reloc_map): Add BFD_RELOC_MIPS16_TLS_* to R_MIPS16_TLS_* ++ mappings. ++ * elf64-mips.c (mips16_elf64_howto_table_rel, ++ mips16_elf64_howto_table_rela): Add R_MIPS16_TLS_* entries. ++ (mips16_reloc_map): Add BFD_RELOC_MIPS16_TLS_* to R_MIPS16_TLS_* ++ mappings. ++ * elfxx-mips.c (TLS_RELOC_P,mips16_reloc_p, ++ _bfd_mips_elf_check_relocs): Add cases for R_MIPS16_TLS_* relocations. ++ (tls_gd_reloc_p): Add R_MIPS16_TLS_GD case. ++ (tls_ldm_reloc_p): Add R_MIPS16_TLS_LDM case. ++ (tls_gottprel_reloc_p): Add R_MIPS16_TLS_GOTTPREL case. ++ (mips_elf_calculate_relocation): Add cases for R_MIPS16_TLS_*, ++ R_MIPS_TLS_DTPREL32/64, and R_MIPS_TLS_TPREL32/64 relocations. ++ ++2011-12-19 Chung-Lin Tang ++ ++ Backport from mainline: ++ ++ 2011-12-19 Chung-Lin Tang ++ Catherine Moore ++ Sandra Loosemore ++ Richard Sandiford ++ ++ * elfxx-mips.c (mips_elf_local_pic_function_p): Return true when ++ H is a MIPS16 function with a kept 32-bit stub. Update comments. ++ (mips_elf_get_la25_target): New function. ++ (mips_elf_add_la25_intro): Change to use mips_elf_get_la25_target(). ++ (mips_elf_add_la25_stub): Move compute of use_trampoline_p down, ++ change to use mips_elf_get_la25_target(). ++ (mips_elf_relocation_needs_la25_stub): Add target_is_16_bit_code_p ++ parameter, add switch case for R_MIPS16_26. ++ (mips_elf_calculate_relocation): Redirect relocation to point to the ++ LA25 stub if it exists, instead of the MIPS16 stub. Update arguments ++ of call to mips_elf_relocation_needs_la25_stub(), don't use la25 stub ++ for mips16->mips16 calls. ++ (_bfd_mips_elf_check_relocs): Update arguments of call to ++ mips_elf_relocation_needs_la25_stub(). ++ (mips_elf_create_la25_stub): Change to use mips_elf_get_la25_target(). ++ ++2011-12-19 Chung-Lin Tang ++ ++ Backport from mainline: ++ ++ 2011-12-13 Chung-Lin Tang ++ ++ * elfxx-mips.c (mips_elf_calculate_relocation): Correct ++ R_MIPS16_HI16/R_MIPS16_LO16 handling of two cleared lower bits, ++ update comments. ++ ++2011-12-10 David Daney ++ ++ Backport from mainline: ++ ++ 2011-12-10 David Daney ++ ++ * elfxx-mips.c (mips_elf_link_hash_table.rld_value): Remove. ++ (mips_elf_link_hash_table.rld_symbol): New field; ++ (MIPS_ELF_RLD_MAP_SIZE): New macro. ++ (_bfd_mips_elf_add_symbol_hook): Remember __rld_obj_head symbol ++ in rld_symbol. ++ (_bfd_mips_elf_create_dynamic_sections): Remember __rld_map symbol ++ in rld_symbol. ++ (_bfd_mips_elf_size_dynamic_sections): Set correct size for .rld_map. ++ (_bfd_mips_elf_finish_dynamic_symbol): Remove .rld_map handling. ++ (_bfd_mips_elf_finish_dynamic_sections): Use rld_symbol to ++ calculate DT_MIPS_RLD_MAP value. ++ (_bfd_mips_elf_link_hash_table_create): Initialize rld_symbol, ++ quit initializing rld_value. ++ ++2011-12-03 Alan Modra ++ ++ PR ld/13468 ++ * elflink.c (bfd_elf_final_link): Don't segfault when checking ++ for DT_TEXTREL and .dynamic does not exist. ++ ++2011-12-03 Alan Modra ++ ++ PR ld/13470 ++ * elf32-ppc.c (ppc_elf_copy_indirect_symbol): Revert substantive ++ change in 2011-07-01 commit. Comment. ++ * elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Likewise. ++ ++2011-12-01 Mikael Pettersson ++ ++ Apply mainline patches ++ * elf32-m68k.c (elf_m68k_check_relocs) : For ++ non-SEC_ALLOC sections break before GOT and PLT accounting. ++ ++2011-12-01 Hans-Peter Nilsson ++ ++ Apply mainline patches ++ * elf32-cris.c (cris_elf_check_relocs) : Move early break for ++ non-SEC_ALLOC sections before GOT and PLT accounting. ++ ++2011-11-21 Tristan Gingold ++ ++ * configure.in: Bump version to 2.22.0 ++ * Makefile.am (RELEASE): Unset. ++ * configure, Makefile.in: Regenerate. ++ + 2011-11-21 Tristan Gingold + + * configure.in: Bump version to 2.22 +diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h +index 22fcdf6..cd90740 100644 +--- a/bfd/bfd-in2.h ++++ b/bfd/bfd-in2.h +@@ -2780,6 +2780,15 @@ to compensate for the borrow when the low bits are added. */ + /* MIPS16 low 16 bits. */ + BFD_RELOC_MIPS16_LO16, + ++/* MIPS16 TLS relocations */ ++ BFD_RELOC_MIPS16_TLS_GD, ++ BFD_RELOC_MIPS16_TLS_LDM, ++ BFD_RELOC_MIPS16_TLS_DTPREL_HI16, ++ BFD_RELOC_MIPS16_TLS_DTPREL_LO16, ++ BFD_RELOC_MIPS16_TLS_GOTTPREL, ++ BFD_RELOC_MIPS16_TLS_TPREL_HI16, ++ BFD_RELOC_MIPS16_TLS_TPREL_LO16, ++ + /* Relocation against a MIPS literal section. */ + BFD_RELOC_MIPS_LITERAL, + BFD_RELOC_MICROMIPS_LITERAL, +diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c +index 6d20aef..a7f9217 100644 +--- a/bfd/elf32-avr.c ++++ b/bfd/elf32-avr.c +@@ -1503,11 +1503,18 @@ elf32_avr_relax_delete_bytes (bfd *abfd, + bfd_vma symval; + bfd_vma shrinked_insn_address; + ++ if (isec->reloc_count == 0) ++ continue; ++ + shrinked_insn_address = (sec->output_section->vma + + sec->output_offset + addr - count); + +- irelend = elf_section_data (isec)->relocs + isec->reloc_count; +- for (irel = elf_section_data (isec)->relocs; ++ irel = elf_section_data (isec)->relocs; ++ /* PR 12161: Read in the relocs for this section if necessary. */ ++ if (irel == NULL) ++ irel = _bfd_elf_link_read_relocs (abfd, isec, NULL, NULL, FALSE); ++ ++ for (irelend = irel + isec->reloc_count; + irel < irelend; + irel++) + { +@@ -1564,6 +1571,9 @@ elf32_avr_relax_delete_bytes (bfd *abfd, + /* else...Reference symbol is extern. No need for adjusting + the addend. */ + } ++ ++ if (elf_section_data (isec)->relocs == NULL) ++ free (irelend - isec->reloc_count); + } + } + +diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c +index 243a8ec..310f6d1 100644 +--- a/bfd/elf32-cris.c ++++ b/bfd/elf32-cris.c +@@ -3579,6 +3579,12 @@ cris_elf_check_relocs (bfd *abfd, + sec, + cris_elf_howto_table[r_type].name); + } ++ ++ /* We don't need to handle relocs into sections not going into ++ the "real" output. */ ++ if ((sec->flags & SEC_ALLOC) == 0) ++ break; ++ + if (h != NULL) + { + h->non_got_ref = 1; +@@ -3608,11 +3614,6 @@ cris_elf_check_relocs (bfd *abfd, + if (! info->shared) + break; + +- /* We don't need to handle relocs into sections not going into +- the "real" output. */ +- if ((sec->flags & SEC_ALLOC) == 0) +- break; +- + /* We may need to create a reloc section in the dynobj and made room + for this reloc. */ + if (sreloc == NULL) +diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c +index 7f0f2cb..dcf6df0 100644 +--- a/bfd/elf32-hppa.c ++++ b/bfd/elf32-hppa.c +@@ -1789,10 +1789,12 @@ elf32_hppa_hide_symbol (struct bfd_link_info *info, + } + } + +- if (! hppa_elf_hash_entry (eh)->plabel) ++ /* STT_GNU_IFUNC symbol must go through PLT. */ ++ if (! hppa_elf_hash_entry (eh)->plabel ++ && eh->type != STT_GNU_IFUNC) + { + eh->needs_plt = 0; +- eh->plt = elf_hash_table (info)->init_plt_refcount; ++ eh->plt = elf_hash_table (info)->init_plt_offset; + } + } + +@@ -1814,6 +1816,13 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, + if (eh->type == STT_FUNC + || eh->needs_plt) + { ++ /* If the symbol is used by a plabel, we must allocate a PLT slot. ++ The refcounts are not reliable when it has been hidden since ++ hide_symbol can be called before the plabel flag is set. */ ++ if (hppa_elf_hash_entry (eh)->plabel ++ && eh->plt.refcount <= 0) ++ eh->plt.refcount = 1; ++ + if (eh->plt.refcount <= 0 + || (eh->def_regular + && eh->root.type != bfd_link_hash_defweak +@@ -3340,10 +3349,16 @@ final_link_relocate (asection *input_section, + switch (r_type) + { + case R_PARISC_DLTIND21L: ++ case R_PARISC_TLS_GD21L: ++ case R_PARISC_TLS_LDM21L: ++ case R_PARISC_TLS_IE21L: + r_type = R_PARISC_DPREL21L; + break; + + case R_PARISC_DLTIND14R: ++ case R_PARISC_TLS_GD14R: ++ case R_PARISC_TLS_LDM14R: ++ case R_PARISC_TLS_IE14R: + r_type = R_PARISC_DPREL14R; + break; + +@@ -3409,53 +3424,48 @@ final_link_relocate (asection *input_section, + case R_PARISC_DPREL21L: + case R_PARISC_DPREL14R: + case R_PARISC_DPREL14F: +- case R_PARISC_TLS_GD21L: +- case R_PARISC_TLS_LDM21L: +- case R_PARISC_TLS_IE21L: + /* Convert instructions that use the linkage table pointer (r19) to + instructions that use the global data pointer (dp). This is the + most efficient way of using PIC code in an incomplete executable, + but the user must follow the standard runtime conventions for + accessing data for this to work. */ +- if (orig_r_type == R_PARISC_DLTIND21L +- || (!info->shared +- && (r_type == R_PARISC_TLS_GD21L +- || r_type == R_PARISC_TLS_LDM21L +- || r_type == R_PARISC_TLS_IE21L))) ++ if (orig_r_type != r_type) + { +- /* Convert addil instructions if the original reloc was a +- DLTIND21L. GCC sometimes uses a register other than r19 for +- the operation, so we must convert any addil instruction +- that uses this relocation. */ +- if ((insn & 0xfc000000) == ((int) OP_ADDIL << 26)) +- insn = ADDIL_DP; +- else +- /* We must have a ldil instruction. It's too hard to find +- and convert the associated add instruction, so issue an +- error. */ +- (*_bfd_error_handler) +- (_("%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"), +- input_bfd, +- input_section, +- (long) offset, +- howto->name, +- insn); +- } +- else if (orig_r_type == R_PARISC_DLTIND14F) +- { +- /* This must be a format 1 load/store. Change the base +- register to dp. */ +- insn = (insn & 0xfc1ffff) | (27 << 21); ++ if (r_type == R_PARISC_DPREL21L) ++ { ++ /* GCC sometimes uses a register other than r19 for the ++ operation, so we must convert any addil instruction ++ that uses this relocation. */ ++ if ((insn & 0xfc000000) == ((int) OP_ADDIL << 26)) ++ insn = ADDIL_DP; ++ else ++ /* We must have a ldil instruction. It's too hard to find ++ and convert the associated add instruction, so issue an ++ error. */ ++ (*_bfd_error_handler) ++ (_("%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"), ++ input_bfd, ++ input_section, ++ (long) offset, ++ howto->name, ++ insn); ++ } ++ else if (r_type == R_PARISC_DPREL14F) ++ { ++ /* This must be a format 1 load/store. Change the base ++ register to dp. */ ++ insn = (insn & 0xfc1ffff) | (27 << 21); ++ } + } + +- /* For all the DP relative relocations, we need to examine the symbol's +- section. If it has no section or if it's a code section, then +- "data pointer relative" makes no sense. In that case we don't +- adjust the "value", and for 21 bit addil instructions, we change the +- source addend register from %dp to %r0. This situation commonly +- arises for undefined weak symbols and when a variable's "constness" +- is declared differently from the way the variable is defined. For +- instance: "extern int foo" with foo defined as "const int foo". */ ++ /* For all the DP relative relocations, we need to examine the symbol's ++ section. If it has no section or if it's a code section, then ++ "data pointer relative" makes no sense. In that case we don't ++ adjust the "value", and for 21 bit addil instructions, we change the ++ source addend register from %dp to %r0. This situation commonly ++ arises for undefined weak symbols and when a variable's "constness" ++ is declared differently from the way the variable is defined. For ++ instance: "extern int foo" with foo defined as "const int foo". */ + if (sym_sec == NULL || (sym_sec->flags & SEC_CODE) != 0) + { + if ((insn & ((0x3f << 26) | (0x1f << 21))) +@@ -3472,6 +3482,9 @@ final_link_relocate (asection *input_section, + case R_PARISC_DLTIND21L: + case R_PARISC_DLTIND14R: + case R_PARISC_DLTIND14F: ++ case R_PARISC_TLS_GD21L: ++ case R_PARISC_TLS_LDM21L: ++ case R_PARISC_TLS_IE21L: + case R_PARISC_TLS_GD14R: + case R_PARISC_TLS_LDM14R: + case R_PARISC_TLS_IE14R: +diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c +index 612525c..3e9ada9 100644 +--- a/bfd/elf32-m68k.c ++++ b/bfd/elf32-m68k.c +@@ -2816,6 +2816,11 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) + case R_68K_8: + case R_68K_16: + case R_68K_32: ++ /* We don't need to handle relocs into sections not going into ++ the "real" output. */ ++ if ((sec->flags & SEC_ALLOC) == 0) ++ break; ++ + if (h != NULL) + { + /* Make sure a plt entry is created for this symbol if it +@@ -2829,8 +2834,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) + + /* If we are creating a shared library, we need to copy the + reloc into the shared library. */ +- if (info->shared +- && (sec->flags & SEC_ALLOC) != 0) ++ if (info->shared) + { + /* When creating a shared object, we must copy these + reloc types into the output file. We create a reloc +diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c +index fd3d4ba..61e8b45 100644 +--- a/bfd/elf32-mips.c ++++ b/bfd/elf32-mips.c +@@ -830,6 +830,111 @@ static reloc_howto_type elf_mips16_howto_table_rel[] = + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS general dynamic variable reference. */ ++ HOWTO (R_MIPS16_TLS_GD, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_GD", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic variable reference. */ ++ HOWTO (R_MIPS16_TLS_LDM, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_LDM", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic offset. */ ++ HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_DTPREL_HI16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic offset. */ ++ HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_DTPREL_LO16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_GOTTPREL", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_TPREL_HI16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_TPREL_LO16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ + }; + + static reloc_howto_type elf_micromips_howto_table_rel[] = +@@ -1796,6 +1901,15 @@ static const struct elf_reloc_map mips16_reloc_map[] = + { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min }, + { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min }, + { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_DTPREL_HI16, ++ R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_DTPREL_LO16, ++ R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min } + }; + + static const struct elf_reloc_map micromips_reloc_map[] = +diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c +index 0c25c3e..574cd98 100644 +--- a/bfd/elf32-ppc.c ++++ b/bfd/elf32-ppc.c +@@ -2987,10 +2987,6 @@ ppc_elf_copy_indirect_symbol (struct bfd_link_info *info, + edir->elf.needs_plt |= eind->elf.needs_plt; + edir->elf.pointer_equality_needed |= eind->elf.pointer_equality_needed; + +- /* If we were called to copy over info for a weak sym, that's all. */ +- if (eind->elf.root.type != bfd_link_hash_indirect) +- return; +- + if (eind->dyn_relocs != NULL) + { + if (edir->dyn_relocs != NULL) +@@ -3022,6 +3018,16 @@ ppc_elf_copy_indirect_symbol (struct bfd_link_info *info, + eind->dyn_relocs = NULL; + } + ++ /* If we were called to copy over info for a weak sym, that's all. ++ You might think dyn_relocs need not be copied over; After all, ++ both syms will be dynamic or both non-dynamic so we're just ++ moving reloc accounting around. However, ELIMINATE_COPY_RELOCS ++ code in ppc_elf_adjust_dynamic_symbol needs to check for ++ dyn_relocs in read-only sections, and it does so on what is the ++ DIR sym here. */ ++ if (eind->elf.root.type != bfd_link_hash_indirect) ++ return; ++ + /* Copy over the GOT refcount entries that we may have already seen to + the symbol which just became indirect. */ + edir->elf.got.refcount += eind->elf.got.refcount; +diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c +index 3feb1bb..bdd0c19 100644 +--- a/bfd/elf64-mips.c ++++ b/bfd/elf64-mips.c +@@ -1590,6 +1590,111 @@ static reloc_howto_type mips16_elf64_howto_table_rel[] = + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS general dynamic variable reference. */ ++ HOWTO (R_MIPS16_TLS_GD, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_GD", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic variable reference. */ ++ HOWTO (R_MIPS16_TLS_LDM, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_LDM", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic offset. */ ++ HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_DTPREL_HI16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic offset. */ ++ HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_DTPREL_LO16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_GOTTPREL", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_TPREL_HI16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_TPREL_LO16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ + }; + + static reloc_howto_type mips16_elf64_howto_table_rela[] = +@@ -1686,6 +1791,111 @@ static reloc_howto_type mips16_elf64_howto_table_rela[] = + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS general dynamic variable reference. */ ++ HOWTO (R_MIPS16_TLS_GD, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_GD", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic variable reference. */ ++ HOWTO (R_MIPS16_TLS_LDM, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_LDM", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic offset. */ ++ HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_DTPREL_HI16", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic offset. */ ++ HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_DTPREL_LO16", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_GOTTPREL", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_TPREL_HI16", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_TPREL_LO16", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ + }; + + static reloc_howto_type micromips_elf64_howto_table_rel[] = +@@ -2908,6 +3118,15 @@ static const struct elf_reloc_map mips16_reloc_map[] = + { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min }, + { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min }, + { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_DTPREL_HI16, ++ R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_DTPREL_LO16, ++ R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min } + }; + + static const struct elf_reloc_map micromips_reloc_map[] = +diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c +index 93d1314..32a3430 100644 +--- a/bfd/elf64-ppc.c ++++ b/bfd/elf64-ppc.c +@@ -4435,10 +4435,6 @@ ppc64_elf_copy_indirect_symbol (struct bfd_link_info *info, + edir->elf.ref_regular_nonweak |= eind->elf.ref_regular_nonweak; + edir->elf.needs_plt |= eind->elf.needs_plt; + +- /* If we were called to copy over info for a weak sym, that's all. */ +- if (eind->elf.root.type != bfd_link_hash_indirect) +- return; +- + /* Copy over any dynamic relocs we may have on the indirect sym. */ + if (eind->dyn_relocs != NULL) + { +@@ -4471,6 +4467,16 @@ ppc64_elf_copy_indirect_symbol (struct bfd_link_info *info, + eind->dyn_relocs = NULL; + } + ++ /* If we were called to copy over info for a weak sym, that's all. ++ You might think dyn_relocs need not be copied over; After all, ++ both syms will be dynamic or both non-dynamic so we're just ++ moving reloc accounting around. However, ELIMINATE_COPY_RELOCS ++ code in ppc64_elf_adjust_dynamic_symbol needs to check for ++ dyn_relocs in read-only sections, and it does so on what is the ++ DIR sym here. */ ++ if (eind->elf.root.type != bfd_link_hash_indirect) ++ return; ++ + /* Copy over got entries that we may have already seen to the + symbol which just became indirect. */ + if (eind->elf.got.glist != NULL) +diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c +index 3a2444b..bdb3ae6 100644 +--- a/bfd/elf64-x86-64.c ++++ b/bfd/elf64-x86-64.c +@@ -3460,7 +3460,6 @@ elf_x86_64_relocate_section (bfd *output_bfd, + case R_X86_64_PC16: + case R_X86_64_PC32: + if (info->shared +- && ABI_64_P (output_bfd) + && (input_section->flags & SEC_ALLOC) != 0 + && (input_section->flags & SEC_READONLY) != 0 + && h != NULL) +diff --git a/bfd/elflink.c b/bfd/elflink.c +index fc4266b..8556cec 100644 +--- a/bfd/elflink.c ++++ b/bfd/elflink.c +@@ -11188,15 +11188,12 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) + goto error_return; + + /* Check for DT_TEXTREL (late, in case the backend removes it). */ +- if ((info->warn_shared_textrel && info->shared) +- || info->error_textrel) ++ if (((info->warn_shared_textrel && info->shared) ++ || info->error_textrel) ++ && (o = bfd_get_section_by_name (dynobj, ".dynamic")) != NULL) + { + bfd_byte *dyncon, *dynconend; + +- /* Fix up .dynamic entries. */ +- o = bfd_get_section_by_name (dynobj, ".dynamic"); +- BFD_ASSERT (o != NULL); +- + dyncon = o->contents; + dynconend = o->contents + o->size; + for (; dyncon < dynconend; dyncon += bed->s->sizeof_dyn) +diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c +index 00ec8b0..2189566 100644 +--- a/bfd/elfn32-mips.c ++++ b/bfd/elfn32-mips.c +@@ -1555,6 +1555,111 @@ static reloc_howto_type elf_mips16_howto_table_rel[] = + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS general dynamic variable reference. */ ++ HOWTO (R_MIPS16_TLS_GD, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_GD", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic variable reference. */ ++ HOWTO (R_MIPS16_TLS_LDM, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_LDM", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic offset. */ ++ HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_DTPREL_HI16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic offset. */ ++ HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_DTPREL_LO16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_GOTTPREL", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_TPREL_HI16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_TPREL_LO16", /* name */ ++ TRUE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ + }; + + static reloc_howto_type elf_mips16_howto_table_rela[] = +@@ -1651,6 +1756,111 @@ static reloc_howto_type elf_mips16_howto_table_rela[] = + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS general dynamic variable reference. */ ++ HOWTO (R_MIPS16_TLS_GD, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_GD", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic variable reference. */ ++ HOWTO (R_MIPS16_TLS_LDM, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_LDM", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic offset. */ ++ HOWTO (R_MIPS16_TLS_DTPREL_HI16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_DTPREL_HI16", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS local dynamic offset. */ ++ HOWTO (R_MIPS16_TLS_DTPREL_LO16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_DTPREL_LO16", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_GOTTPREL, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_GOTTPREL", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_TPREL_HI16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_TPREL_HI16", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ ++ ++ /* MIPS16 TLS thread pointer offset. */ ++ HOWTO (R_MIPS16_TLS_TPREL_LO16, /* type */ ++ 0, /* rightshift */ ++ 2, /* size (0 = byte, 1 = short, 2 = long) */ ++ 16, /* bitsize */ ++ FALSE, /* pc_relative */ ++ 0, /* bitpos */ ++ complain_overflow_signed, /* complain_on_overflow */ ++ _bfd_mips_elf_generic_reloc, /* special_function */ ++ "R_MIPS16_TLS_TPREL_LO16", /* name */ ++ FALSE, /* partial_inplace */ ++ 0x0000ffff, /* src_mask */ ++ 0x0000ffff, /* dst_mask */ ++ FALSE), /* pcrel_offset */ + }; + + static reloc_howto_type elf_micromips_howto_table_rel[] = +@@ -2724,6 +2934,15 @@ static const struct elf_reloc_map mips16_reloc_map[] = + { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min }, + { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min }, + { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_DTPREL_HI16, ++ R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_DTPREL_LO16, ++ R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min }, ++ { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min } + }; + + static const struct elf_reloc_map micromips_reloc_map[] = +diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c +index 33a454d..fa906cd 100644 +--- a/bfd/elfxx-mips.c ++++ b/bfd/elfxx-mips.c +@@ -436,8 +436,8 @@ struct mips_elf_link_hash_table + entry is set to the address of __rld_obj_head as in IRIX5. */ + bfd_boolean use_rld_obj_head; + +- /* This is the value of the __rld_map or __rld_obj_head symbol. */ +- bfd_vma rld_value; ++ /* The __rld_map or __rld_obj_head symbol. */ ++ struct elf_link_hash_entry *rld_symbol; + + /* This is set if we see any mips16 stub sections. */ + bfd_boolean mips16_stubs_seen; +@@ -529,6 +529,13 @@ struct mips_htab_traverse_info + || r_type == R_MIPS_TLS_TPREL64 \ + || r_type == R_MIPS_TLS_TPREL_HI16 \ + || r_type == R_MIPS_TLS_TPREL_LO16 \ ++ || r_type == R_MIPS16_TLS_GD \ ++ || r_type == R_MIPS16_TLS_LDM \ ++ || r_type == R_MIPS16_TLS_DTPREL_HI16 \ ++ || r_type == R_MIPS16_TLS_DTPREL_LO16 \ ++ || r_type == R_MIPS16_TLS_GOTTPREL \ ++ || r_type == R_MIPS16_TLS_TPREL_HI16 \ ++ || r_type == R_MIPS16_TLS_TPREL_LO16 \ + || r_type == R_MICROMIPS_TLS_GD \ + || r_type == R_MICROMIPS_TLS_LDM \ + || r_type == R_MICROMIPS_TLS_DTPREL_HI16 \ +@@ -768,6 +775,10 @@ static bfd *reldyn_sorting_bfd; + #define MIPS_ELF_GOT_SIZE(abfd) \ + (get_elf_backend_data (abfd)->s->arch_size / 8) + ++/* The size of the .rld_map section. */ ++#define MIPS_ELF_RLD_MAP_SIZE(abfd) \ ++ (get_elf_backend_data (abfd)->s->arch_size / 8) ++ + /* The size of a symbol-table entry. */ + #define MIPS_ELF_SYM_SIZE(abfd) \ + (get_elf_backend_data (abfd)->s->sizeof_sym) +@@ -1571,9 +1582,10 @@ _bfd_mips_elf_init_stubs (struct bfd_link_info *info, + } + + /* Return true if H is a locally-defined PIC function, in the sense +- that it might need $25 to be valid on entry. Note that MIPS16 +- functions never need $25 to be valid on entry; they set up $gp +- using PC-relative instructions instead. */ ++ that it or its fn_stub might need $25 to be valid on entry. ++ Note that MIPS16 functions set up $gp using PC-relative instructions, ++ so they themselves never need $25 to be valid. Only non-MIPS16 ++ entry points are of interest here. */ + + static bfd_boolean + mips_elf_local_pic_function_p (struct mips_elf_link_hash_entry *h) +@@ -1582,11 +1594,32 @@ mips_elf_local_pic_function_p (struct mips_elf_link_hash_entry *h) + || h->root.root.type == bfd_link_hash_defweak) + && h->root.def_regular + && !bfd_is_abs_section (h->root.root.u.def.section) +- && !ELF_ST_IS_MIPS16 (h->root.other) ++ && (!ELF_ST_IS_MIPS16 (h->root.other) ++ || (h->fn_stub && h->need_fn_stub)) + && (PIC_OBJECT_P (h->root.root.u.def.section->owner) + || ELF_ST_IS_MIPS_PIC (h->root.other))); + } + ++/* Set *SEC to the input section that contains the target of STUB. ++ Return the offset of the target from the start of that section. */ ++ ++static bfd_vma ++mips_elf_get_la25_target (struct mips_elf_la25_stub *stub, ++ asection **sec) ++{ ++ if (ELF_ST_IS_MIPS16 (stub->h->root.other)) ++ { ++ BFD_ASSERT (stub->h->need_fn_stub); ++ *sec = stub->h->fn_stub; ++ return 0; ++ } ++ else ++ { ++ *sec = stub->h->root.root.u.def.section; ++ return stub->h->root.root.u.def.value; ++ } ++} ++ + /* STUB describes an la25 stub that we have decided to implement + by inserting an LUI/ADDIU pair before the target function. + Create the section and redirect the function symbol to it. */ +@@ -1611,7 +1644,7 @@ mips_elf_add_la25_intro (struct mips_elf_la25_stub *stub, + sprintf (name, ".text.stub.%d", (int) htab_elements (htab->la25_stubs)); + + /* Create the section. */ +- input_section = stub->h->root.root.u.def.section; ++ mips_elf_get_la25_target (stub, &input_section); + s = htab->add_stub_section (name, input_section, + input_section->output_section); + if (s == NULL) +@@ -1685,12 +1718,6 @@ mips_elf_add_la25_stub (struct bfd_link_info *info, + bfd_vma value; + void **slot; + +- /* Prefer to use LUI/ADDIU stubs if the function is at the beginning +- of the section and if we would need no more than 2 nops. */ +- s = h->root.root.u.def.section; +- value = h->root.root.u.def.value; +- use_trampoline_p = (value != 0 || s->alignment_power > 4); +- + /* Describe the stub we want. */ + search.stub_section = NULL; + search.offset = 0; +@@ -1720,6 +1747,11 @@ mips_elf_add_la25_stub (struct bfd_link_info *info, + *stub = search; + *slot = stub; + ++ /* Prefer to use LUI/ADDIU stubs if the function is at the beginning ++ of the section and if we would need no more than 2 nops. */ ++ value = mips_elf_get_la25_target (stub, &s); ++ use_trampoline_p = (value != 0 || s->alignment_power > 4); ++ + h->la25_stub = stub; + return (use_trampoline_p + ? mips_elf_add_la25_trampoline (stub, info) +@@ -1860,6 +1892,13 @@ mips16_reloc_p (int r_type) + case R_MIPS16_CALL16: + case R_MIPS16_HI16: + case R_MIPS16_LO16: ++ case R_MIPS16_TLS_GD: ++ case R_MIPS16_TLS_LDM: ++ case R_MIPS16_TLS_DTPREL_HI16: ++ case R_MIPS16_TLS_DTPREL_LO16: ++ case R_MIPS16_TLS_GOTTPREL: ++ case R_MIPS16_TLS_TPREL_HI16: ++ case R_MIPS16_TLS_TPREL_LO16: + return TRUE; + + default: +@@ -1987,19 +2026,25 @@ micromips_branch_reloc_p (int r_type) + static inline bfd_boolean + tls_gd_reloc_p (unsigned int r_type) + { +- return r_type == R_MIPS_TLS_GD || r_type == R_MICROMIPS_TLS_GD; ++ return (r_type == R_MIPS_TLS_GD ++ || r_type == R_MIPS16_TLS_GD ++ || r_type == R_MICROMIPS_TLS_GD); + } + + static inline bfd_boolean + tls_ldm_reloc_p (unsigned int r_type) + { +- return r_type == R_MIPS_TLS_LDM || r_type == R_MICROMIPS_TLS_LDM; ++ return (r_type == R_MIPS_TLS_LDM ++ || r_type == R_MIPS16_TLS_LDM ++ || r_type == R_MICROMIPS_TLS_LDM); + } + + static inline bfd_boolean + tls_gottprel_reloc_p (unsigned int r_type) + { +- return r_type == R_MIPS_TLS_GOTTPREL || r_type == R_MICROMIPS_TLS_GOTTPREL; ++ return (r_type == R_MIPS_TLS_GOTTPREL ++ || r_type == R_MIPS16_TLS_GOTTPREL ++ || r_type == R_MICROMIPS_TLS_GOTTPREL); + } + + void +@@ -4907,7 +4952,8 @@ is_gott_symbol (struct bfd_link_info *info, struct elf_link_hash_entry *h) + stub. */ + + static bfd_boolean +-mips_elf_relocation_needs_la25_stub (bfd *input_bfd, int r_type) ++mips_elf_relocation_needs_la25_stub (bfd *input_bfd, int r_type, ++ bfd_boolean target_is_16_bit_code_p) + { + /* We specifically ignore branches and jumps from EF_PIC objects, + where the onus is on the compiler or programmer to perform any +@@ -4921,7 +4967,6 @@ mips_elf_relocation_needs_la25_stub (bfd *input_bfd, int r_type) + { + case R_MIPS_26: + case R_MIPS_PC16: +- case R_MIPS16_26: + case R_MICROMIPS_26_S1: + case R_MICROMIPS_PC7_S1: + case R_MICROMIPS_PC10_S1: +@@ -4929,6 +4974,9 @@ mips_elf_relocation_needs_la25_stub (bfd *input_bfd, int r_type) + case R_MICROMIPS_PC23_S2: + return TRUE; + ++ case R_MIPS16_26: ++ return !target_is_16_bit_code_p; ++ + default: + return FALSE; + } +@@ -5189,14 +5237,28 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, + have already noticed that we were going to need the + stub. */ + if (local_p) +- sec = elf_tdata (input_bfd)->local_stubs[r_symndx]; ++ { ++ sec = elf_tdata (input_bfd)->local_stubs[r_symndx]; ++ value = 0; ++ } + else + { + BFD_ASSERT (h->need_fn_stub); +- sec = h->fn_stub; ++ if (h->la25_stub) ++ { ++ /* If a LA25 header for the stub itself exists, point to the ++ prepended LUI/ADDIU sequence. */ ++ sec = h->la25_stub->stub_section; ++ value = h->la25_stub->offset; ++ } ++ else ++ { ++ sec = h->fn_stub; ++ value = 0; ++ } + } + +- symbol = sec->output_section->vma + sec->output_offset; ++ symbol = sec->output_section->vma + sec->output_offset + value; + /* The target is 16-bit, but the stub isn't. */ + target_is_16_bit_code_p = FALSE; + } +@@ -5246,7 +5308,8 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, + /* If this is a direct call to a PIC function, redirect to the + non-PIC stub. */ + else if (h != NULL && h->la25_stub +- && mips_elf_relocation_needs_la25_stub (input_bfd, r_type)) ++ && mips_elf_relocation_needs_la25_stub (input_bfd, r_type, ++ target_is_16_bit_code_p)) + symbol = (h->la25_stub->stub_section->output_section->vma + + h->la25_stub->stub_section->output_offset + + h->la25_stub->offset); +@@ -5318,6 +5381,9 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, + case R_MIPS_TLS_GD: + case R_MIPS_TLS_GOTTPREL: + case R_MIPS_TLS_LDM: ++ case R_MIPS16_TLS_GD: ++ case R_MIPS16_TLS_GOTTPREL: ++ case R_MIPS16_TLS_LDM: + case R_MICROMIPS_TLS_GD: + case R_MICROMIPS_TLS_GOTTPREL: + case R_MICROMIPS_TLS_LDM: +@@ -5487,6 +5553,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, + break; + + case R_MIPS_TLS_DTPREL_HI16: ++ case R_MIPS16_TLS_DTPREL_HI16: + case R_MICROMIPS_TLS_DTPREL_HI16: + value = (mips_elf_high (addend + symbol - dtprel_base (info)) + & howto->dst_mask); +@@ -5495,17 +5562,22 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, + case R_MIPS_TLS_DTPREL_LO16: + case R_MIPS_TLS_DTPREL32: + case R_MIPS_TLS_DTPREL64: ++ case R_MIPS16_TLS_DTPREL_LO16: + case R_MICROMIPS_TLS_DTPREL_LO16: + value = (symbol + addend - dtprel_base (info)) & howto->dst_mask; + break; + + case R_MIPS_TLS_TPREL_HI16: ++ case R_MIPS16_TLS_TPREL_HI16: + case R_MICROMIPS_TLS_TPREL_HI16: + value = (mips_elf_high (addend + symbol - tprel_base (info)) + & howto->dst_mask); + break; + + case R_MIPS_TLS_TPREL_LO16: ++ case R_MIPS_TLS_TPREL32: ++ case R_MIPS_TLS_TPREL64: ++ case R_MIPS16_TLS_TPREL_LO16: + case R_MICROMIPS_TLS_TPREL_LO16: + value = (symbol + addend - tprel_base (info)) & howto->dst_mask; + break; +@@ -5527,10 +5599,11 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, + 12: addu $v0,$v1 + 14: move $gp,$v0 + So the offsets of hi and lo relocs are the same, but the +- $pc is four higher than $t9 would be, so reduce +- both reloc addends by 4. */ ++ base $pc is that used by the ADDIUPC instruction at $t9 + 4. ++ ADDIUPC clears the low two bits of the instruction address, ++ so the base is ($t9 + 4) & ~3. */ + if (r_type == R_MIPS16_HI16) +- value = mips_elf_high (addend + gp - p - 4); ++ value = mips_elf_high (addend + gp - ((p + 4) & ~(bfd_vma) 0x3)); + /* The microMIPS .cpload sequence uses the same assembly + instructions as the traditional psABI version, but the + incoming $t9 has the low bit set. */ +@@ -5553,7 +5626,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, + /* See the comment for R_MIPS16_HI16 above for the reason + for this conditional. */ + if (r_type == R_MIPS16_LO16) +- value = addend + gp - p; ++ value = addend + gp - (p & ~(bfd_vma) 0x3); + else if (r_type == R_MICROMIPS_LO16 + || r_type == R_MICROMIPS_HI0_LO16) + value = addend + gp - p + 3; +@@ -5637,6 +5710,9 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, + case R_MIPS_TLS_GOTTPREL: + case R_MIPS_TLS_LDM: + case R_MIPS_GOT_DISP: ++ case R_MIPS16_TLS_GD: ++ case R_MIPS16_TLS_GOTTPREL: ++ case R_MIPS16_TLS_LDM: + case R_MICROMIPS_TLS_GD: + case R_MICROMIPS_TLS_GOTTPREL: + case R_MICROMIPS_TLS_LDM: +@@ -7081,6 +7157,7 @@ _bfd_mips_elf_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, + return FALSE; + + mips_elf_hash_table (info)->use_rld_obj_head = TRUE; ++ mips_elf_hash_table (info)->rld_symbol = h; + } + + /* If this is a mips16 text symbol, add 1 to the value to make it +@@ -7266,6 +7343,7 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) + + if (! bfd_elf_link_record_dynamic_symbol (info, h)) + return FALSE; ++ mips_elf_hash_table (info)->rld_symbol = h; + } + } + +@@ -7767,8 +7845,6 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, + can_make_dynamic_p = FALSE; + switch (r_type) + { +- case R_MIPS16_GOT16: +- case R_MIPS16_CALL16: + case R_MIPS_GOT16: + case R_MIPS_CALL16: + case R_MIPS_CALL_HI16: +@@ -7781,6 +7857,11 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, + case R_MIPS_TLS_GOTTPREL: + case R_MIPS_TLS_GD: + case R_MIPS_TLS_LDM: ++ case R_MIPS16_GOT16: ++ case R_MIPS16_CALL16: ++ case R_MIPS16_TLS_GOTTPREL: ++ case R_MIPS16_TLS_GD: ++ case R_MIPS16_TLS_LDM: + case R_MICROMIPS_GOT16: + case R_MICROMIPS_CALL16: + case R_MICROMIPS_CALL_HI16: +@@ -7918,7 +7999,9 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, + return FALSE; + } + +- if (h != NULL && mips_elf_relocation_needs_la25_stub (abfd, r_type)) ++ if (h != NULL ++ && mips_elf_relocation_needs_la25_stub (abfd, r_type, ++ ELF_ST_IS_MIPS16 (h->other))) + ((struct mips_elf_link_hash_entry *) h)->has_nonpic_branches = TRUE; + + switch (r_type) +@@ -8015,12 +8098,14 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, + break; + + case R_MIPS_TLS_GOTTPREL: ++ case R_MIPS16_TLS_GOTTPREL: + case R_MICROMIPS_TLS_GOTTPREL: + if (info->shared) + info->flags |= DF_STATIC_TLS; + /* Fall through */ + + case R_MIPS_TLS_LDM: ++ case R_MIPS16_TLS_LDM: + case R_MICROMIPS_TLS_LDM: + if (tls_ldm_reloc_p (r_type)) + { +@@ -8030,6 +8115,7 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, + /* Fall through */ + + case R_MIPS_TLS_GD: ++ case R_MIPS16_TLS_GD: + case R_MICROMIPS_TLS_GD: + /* This symbol requires a global offset table entry, or two + for TLS GD relocations. */ +@@ -9027,7 +9113,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, + { + /* We add a room for __rld_map. It will be filled in by the + rtld to contain a pointer to the _r_debug structure. */ +- s->size += 4; ++ s->size += MIPS_ELF_RLD_MAP_SIZE (output_bfd); + } + else if (SGI_COMPAT (output_bfd) + && CONST_STRNEQ (name, ".compact_rel")) +@@ -9615,9 +9701,9 @@ mips_elf_create_la25_stub (void **slot, void *data) + offset = stub->offset; + + /* Work out the target address. */ +- target = (stub->h->root.root.u.def.section->output_section->vma +- + stub->h->root.root.u.def.section->output_offset +- + stub->h->root.root.u.def.value); ++ target = mips_elf_get_la25_target (stub, &s); ++ target += s->output_section->vma + s->output_offset; ++ + target_high = ((target + 0x8000) >> 16) & 0xffff; + target_low = (target & 0xffff); + +@@ -10030,31 +10116,6 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd, + if (IRIX_COMPAT (output_bfd) == ict_irix6) + mips_elf_irix6_finish_dynamic_symbol (output_bfd, name, sym); + +- if (! info->shared) +- { +- if (! mips_elf_hash_table (info)->use_rld_obj_head +- && (strcmp (name, "__rld_map") == 0 +- || strcmp (name, "__RLD_MAP") == 0)) +- { +- asection *s = bfd_get_section_by_name (dynobj, ".rld_map"); +- BFD_ASSERT (s != NULL); +- sym->st_value = s->output_section->vma + s->output_offset; +- bfd_put_32 (output_bfd, 0, s->contents); +- if (mips_elf_hash_table (info)->rld_value == 0) +- mips_elf_hash_table (info)->rld_value = sym->st_value; +- } +- else if (mips_elf_hash_table (info)->use_rld_obj_head +- && strcmp (name, "__rld_obj_head") == 0) +- { +- /* IRIX6 does not use a .rld_map section. */ +- if (IRIX_COMPAT (output_bfd) == ict_irix5 +- || IRIX_COMPAT (output_bfd) == ict_none) +- BFD_ASSERT (bfd_get_section_by_name (dynobj, ".rld_map") +- != NULL); +- mips_elf_hash_table (info)->rld_value = sym->st_value; +- } +- } +- + /* Keep dynamic MIPS16 symbols odd. This allows the dynamic linker to + treat MIPS16 symbols like any other. */ + if (ELF_ST_IS_MIPS16 (sym->st_other)) +@@ -10517,7 +10578,19 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, + break; + + case DT_MIPS_RLD_MAP: +- dyn.d_un.d_ptr = mips_elf_hash_table (info)->rld_value; ++ { ++ struct elf_link_hash_entry *h; ++ h = mips_elf_hash_table (info)->rld_symbol; ++ if (!h) ++ { ++ dyn_to_skip = MIPS_ELF_DYN_SIZE (dynobj); ++ swap_out_p = FALSE; ++ break; ++ } ++ s = h->root.u.def.section; ++ dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset ++ + h->root.u.def.value); ++ } + break; + + case DT_MIPS_OPTIONS: +@@ -12794,7 +12867,7 @@ _bfd_mips_elf_link_hash_table_create (bfd *abfd) + ret->procedure_count = 0; + ret->compact_rel_size = 0; + ret->use_rld_obj_head = FALSE; +- ret->rld_value = 0; ++ ret->rld_symbol = NULL; + ret->mips16_stubs_seen = FALSE; + ret->use_plts_and_copy_relocs = FALSE; + ret->is_vxworks = FALSE; +diff --git a/bfd/libbfd.h b/bfd/libbfd.h +index 200a6fa..0395ec2 100644 +--- a/bfd/libbfd.h ++++ b/bfd/libbfd.h +@@ -1086,6 +1086,13 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", + "BFD_RELOC_MIPS16_HI16", + "BFD_RELOC_MIPS16_HI16_S", + "BFD_RELOC_MIPS16_LO16", ++ "BFD_RELOC_MIPS16_TLS_GD", ++ "BFD_RELOC_MIPS16_TLS_LDM", ++ "BFD_RELOC_MIPS16_TLS_DTPREL_HI16", ++ "BFD_RELOC_MIPS16_TLS_DTPREL_LO16", ++ "BFD_RELOC_MIPS16_TLS_GOTTPREL", ++ "BFD_RELOC_MIPS16_TLS_TPREL_HI16", ++ "BFD_RELOC_MIPS16_TLS_TPREL_LO16", + "BFD_RELOC_MIPS_LITERAL", + "BFD_RELOC_MICROMIPS_LITERAL", + "BFD_RELOC_MICROMIPS_7_PCREL_S1", +diff --git a/bfd/reloc.c b/bfd/reloc.c +index 6ac7148..ef55cc3 100644 +--- a/bfd/reloc.c ++++ b/bfd/reloc.c +@@ -2247,6 +2247,23 @@ ENUMDOC + MIPS16 low 16 bits. + + ENUM ++ BFD_RELOC_MIPS16_TLS_GD ++ENUMX ++ BFD_RELOC_MIPS16_TLS_LDM ++ENUMX ++ BFD_RELOC_MIPS16_TLS_DTPREL_HI16 ++ENUMX ++ BFD_RELOC_MIPS16_TLS_DTPREL_LO16 ++ENUMX ++ BFD_RELOC_MIPS16_TLS_GOTTPREL ++ENUMX ++ BFD_RELOC_MIPS16_TLS_TPREL_HI16 ++ENUMX ++ BFD_RELOC_MIPS16_TLS_TPREL_LO16 ++ENUMDOC ++ MIPS16 TLS relocations ++ ++ENUM + BFD_RELOC_MIPS_LITERAL + ENUMX + BFD_RELOC_MICROMIPS_LITERAL +diff --git a/bfd/version.h b/bfd/version.h +index c6800ec..1024911 100644 +--- a/bfd/version.h ++++ b/bfd/version.h +@@ -1,4 +1,4 @@ +-#define BFD_VERSION_DATE 20111121 ++#define BFD_VERSION_DATE 20120308 + #define BFD_VERSION @bfd_version@ + #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@ + #define REPORT_BUGS_TO @report_bugs_to@ +diff --git a/binutils/ChangeLog b/binutils/ChangeLog +index 2f5af61..30101e5 100644 +--- a/binutils/ChangeLog ++++ b/binutils/ChangeLog +@@ -1,3 +1,10 @@ ++2012-01-26 Nick Clifton ++ ++ PR binutils/13622 ++ * readelf.c (process_section_groups): If there are no section ++ headers do not scan for section groups. ++ (process_note_sections): Likewise for note sections. ++ + 2011-10-25 Alan Modra + + Apply mainline patches +diff --git a/binutils/readelf.c b/binutils/readelf.c +index 9e13190..bf053d9 100644 +--- a/binutils/readelf.c ++++ b/binutils/readelf.c +@@ -4937,7 +4937,8 @@ process_section_groups (FILE * file) + if (section_headers == NULL) + { + error (_("Section headers are not available!\n")); +- abort (); ++ /* PR 13622: This can happen with a corrupt ELF header. */ ++ return 0; + } + + section_headers_groups = (struct group **) calloc (elf_header.e_shnum, +@@ -12942,7 +12943,7 @@ process_note_sections (FILE * file) + int res = 1; + + for (i = 0, section = section_headers; +- i < elf_header.e_shnum; ++ i < elf_header.e_shnum && section != NULL; + i++, section++) + if (section->sh_type == SHT_NOTE) + res &= process_corefile_note_segment (file, +diff --git a/gas/ChangeLog b/gas/ChangeLog +index b29f95f..df24933 100644 +--- a/gas/ChangeLog ++++ b/gas/ChangeLog +@@ -1,3 +1,23 @@ ++2012-01-08 Richard Sandiford ++ ++ * config/tc-mips.c (s_tls_rel_directive): Call mips_clear_insn_labels. ++ ++2011-12-19 Chung-Lin Tang ++ ++ Backport from mainline: ++ ++ 2011-12-19 Chung-Lin Tang ++ ++ * config/tc-mips.c (mips_pseudo_table): Add tprelword/tpreldword ++ entries. ++ (mips16_percent_op): Add MIPS16 TLS relocation ops. ++ (md_apply_fix): Add BFD_RELOC_MIPS16_TLS_* switch cases. ++ (s_tls_rel_directive): Rename from s_dtprel_internal(). Abstract out ++ directive string and reloc type as function parameters. Update ++ comments. ++ (s_dtprelword,s_dtpreldword): Change to use s_tls_rel_directive(). ++ (s_tprelword,s_tpreldword): New functions. ++ + 2011-11-15 Maciej W. Rozycki + + Apply mainline patches +diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c +index 0e4c66e..5324450 100644 +--- a/gas/config/tc-mips.c ++++ b/gas/config/tc-mips.c +@@ -1352,6 +1352,8 @@ static void s_cprestore (int); + static void s_cpreturn (int); + static void s_dtprelword (int); + static void s_dtpreldword (int); ++static void s_tprelword (int); ++static void s_tpreldword (int); + static void s_gpvalue (int); + static void s_gpword (int); + static void s_gpdword (int); +@@ -1431,6 +1433,8 @@ static const pseudo_typeS mips_pseudo_table[] = + {"cpreturn", s_cpreturn, 0}, + {"dtprelword", s_dtprelword, 0}, + {"dtpreldword", s_dtpreldword, 0}, ++ {"tprelword", s_tprelword, 0}, ++ {"tpreldword", s_tpreldword, 0}, + {"gpvalue", s_gpvalue, 0}, + {"gpword", s_gpword, 0}, + {"gpdword", s_gpdword, 0}, +@@ -14040,7 +14044,14 @@ static const struct percent_op_match mips16_percent_op[] = + {"%gprel", BFD_RELOC_MIPS16_GPREL}, + {"%got", BFD_RELOC_MIPS16_GOT16}, + {"%call16", BFD_RELOC_MIPS16_CALL16}, +- {"%hi", BFD_RELOC_MIPS16_HI16_S} ++ {"%hi", BFD_RELOC_MIPS16_HI16_S}, ++ {"%tlsgd", BFD_RELOC_MIPS16_TLS_GD}, ++ {"%tlsldm", BFD_RELOC_MIPS16_TLS_LDM}, ++ {"%dtprel_hi", BFD_RELOC_MIPS16_TLS_DTPREL_HI16}, ++ {"%dtprel_lo", BFD_RELOC_MIPS16_TLS_DTPREL_LO16}, ++ {"%tprel_hi", BFD_RELOC_MIPS16_TLS_TPREL_HI16}, ++ {"%tprel_lo", BFD_RELOC_MIPS16_TLS_TPREL_LO16}, ++ {"%gottprel", BFD_RELOC_MIPS16_TLS_GOTTPREL} + }; + + +@@ -15369,6 +15380,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) + case BFD_RELOC_MIPS_TLS_DTPREL_HI16: + case BFD_RELOC_MIPS_TLS_DTPREL_LO16: + case BFD_RELOC_MIPS_TLS_GOTTPREL: ++ case BFD_RELOC_MIPS_TLS_TPREL32: ++ case BFD_RELOC_MIPS_TLS_TPREL64: + case BFD_RELOC_MIPS_TLS_TPREL_HI16: + case BFD_RELOC_MIPS_TLS_TPREL_LO16: + case BFD_RELOC_MICROMIPS_TLS_GD: +@@ -15378,6 +15391,13 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) + case BFD_RELOC_MICROMIPS_TLS_GOTTPREL: + case BFD_RELOC_MICROMIPS_TLS_TPREL_HI16: + case BFD_RELOC_MICROMIPS_TLS_TPREL_LO16: ++ case BFD_RELOC_MIPS16_TLS_GD: ++ case BFD_RELOC_MIPS16_TLS_LDM: ++ case BFD_RELOC_MIPS16_TLS_DTPREL_HI16: ++ case BFD_RELOC_MIPS16_TLS_DTPREL_LO16: ++ case BFD_RELOC_MIPS16_TLS_GOTTPREL: ++ case BFD_RELOC_MIPS16_TLS_TPREL_HI16: ++ case BFD_RELOC_MIPS16_TLS_TPREL_LO16: + S_SET_THREAD_LOCAL (fixP->fx_addsy); + /* fall through */ + +@@ -16547,12 +16567,14 @@ s_cpreturn (int ignore ATTRIBUTE_UNUSED) + demand_empty_rest_of_line (); + } + +-/* Handle the .dtprelword and .dtpreldword pseudo-ops. They generate +- a 32-bit or 64-bit DTP-relative relocation (BYTES says which) for +- use in DWARF debug information. */ ++/* Handle a .dtprelword, .dtpreldword, .tprelword, or .tpreldword ++ pseudo-op; DIRSTR says which. The pseudo-op generates a BYTES-size ++ DTP- or TP-relative relocation of type RTYPE, for use in either DWARF ++ debug information or MIPS16 TLS. */ + + static void +-s_dtprel_internal (size_t bytes) ++s_tls_rel_directive (const size_t bytes, const char *dirstr, ++ bfd_reloc_code_real_type rtype) + { + expressionS ex; + char *p; +@@ -16561,20 +16583,15 @@ s_dtprel_internal (size_t bytes) + + if (ex.X_op != O_symbol) + { +- as_bad (_("Unsupported use of %s"), (bytes == 8 +- ? ".dtpreldword" +- : ".dtprelword")); ++ as_bad (_("Unsupported use of %s"), dirstr); + ignore_rest_of_line (); + } + + p = frag_more (bytes); + md_number_to_chars (p, 0, bytes); +- fix_new_exp (frag_now, p - frag_now->fr_literal, bytes, &ex, FALSE, +- (bytes == 8 +- ? BFD_RELOC_MIPS_TLS_DTPREL64 +- : BFD_RELOC_MIPS_TLS_DTPREL32)); +- ++ fix_new_exp (frag_now, p - frag_now->fr_literal, bytes, &ex, FALSE, rtype); + demand_empty_rest_of_line (); ++ mips_clear_insn_labels (); + } + + /* Handle .dtprelword. */ +@@ -16582,7 +16599,7 @@ s_dtprel_internal (size_t bytes) + static void + s_dtprelword (int ignore ATTRIBUTE_UNUSED) + { +- s_dtprel_internal (4); ++ s_tls_rel_directive (4, ".dtprelword", BFD_RELOC_MIPS_TLS_DTPREL32); + } + + /* Handle .dtpreldword. */ +@@ -16590,7 +16607,23 @@ s_dtprelword (int ignore ATTRIBUTE_UNUSED) + static void + s_dtpreldword (int ignore ATTRIBUTE_UNUSED) + { +- s_dtprel_internal (8); ++ s_tls_rel_directive (8, ".dtpreldword", BFD_RELOC_MIPS_TLS_DTPREL64); ++} ++ ++/* Handle .tprelword. */ ++ ++static void ++s_tprelword (int ignore ATTRIBUTE_UNUSED) ++{ ++ s_tls_rel_directive (4, ".tprelword", BFD_RELOC_MIPS_TLS_TPREL32); ++} ++ ++/* Handle .tpreldword. */ ++ ++static void ++s_tpreldword (int ignore ATTRIBUTE_UNUSED) ++{ ++ s_tls_rel_directive (8, ".tpreldword", BFD_RELOC_MIPS_TLS_TPREL64); + } + + /* Handle the .gpvalue pseudo-op. This is used when generating NewABI PIC +diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog +index 0631572..cbb2309 100644 +--- a/gas/testsuite/ChangeLog ++++ b/gas/testsuite/ChangeLog +@@ -1,3 +1,8 @@ ++2012-01-08 Richard Sandiford ++ ++ * gas/mips/tls-relw.s, gas/mips/tls-relw.d: New test. ++ * gas/mips/mips.exp: Run it. ++ + 2011-11-14 Maciej W. Rozycki + + Apply mainline patches +diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp +index cbaaa70..2f49a2a 100644 +--- a/gas/testsuite/gas/mips/mips.exp ++++ b/gas/testsuite/gas/mips/mips.exp +@@ -878,6 +878,7 @@ if { [istarget mips*-*-vxworks*] } { + + run_list_test "tls-ill" "-32" + run_dump_test "tls-o32" ++ run_dump_test "tls-relw" + run_dump_test "jalr2" + + run_dump_test_arches "aent" [mips_arch_list_matching mips1] +diff --git a/gas/testsuite/gas/mips/tls-relw.d b/gas/testsuite/gas/mips/tls-relw.d +new file mode 100644 +index 0000000..bc13b43 +--- /dev/null ++++ b/gas/testsuite/gas/mips/tls-relw.d +@@ -0,0 +1,8 @@ ++# as: -EB ++# objdump: -sj.data ++ ++.* ++ ++Contents of section \.data: ++ 0000 00000001 00000000 00000002 00000004 ................ ++ 0010 00000000 00000003 00000010 00000000 ................ +diff --git a/gas/testsuite/gas/mips/tls-relw.s b/gas/testsuite/gas/mips/tls-relw.s +new file mode 100644 +index 0000000..6890685 +--- /dev/null ++++ b/gas/testsuite/gas/mips/tls-relw.s +@@ -0,0 +1,12 @@ ++ .data ++start: ++ .word 1 ++a: ++ .tprelword t1 ++ .word 2 ++ .word a-start ++b: ++ .dtprelword t2 ++ .word 3 ++ .word b-start ++ .word 0 +diff --git a/gold/ChangeLog b/gold/ChangeLog +index 7f91606..25ebc87 100644 +--- a/gold/ChangeLog ++++ b/gold/ChangeLog +@@ -1,3 +1,166 @@ ++2011-12-19 Ian Lance Taylor ++ ++ Copy from mainline to binutils 2.22 branch: ++ ++ 2011-12-17 Cary Coutant ++ ++ * dwarf_reader.cc (Sized_dwarf_line_info::read_lines): Add casts. ++ * resolve.cc (Symbol_table::resolve): Likewise. ++ * i386.cc (Target_i386::do_code_fill): Use char constants for nop ++ arrays. ++ * x86_64.cc (Target_x86_64::do_code_fill): Likewise. ++ ++ 2011-10-31 Cary Coutant ++ ++ PR gold/13023 ++ * expression.cc (Expression::eval_with_dot): Add ++ is_section_dot_assignment parameter. ++ (Expression::eval_maybe_dot): Likewise. Adjust value when rhs is ++ absolute and assigning to dot within a section. ++ * script-sections.cc ++ (Output_section_element_assignment::set_section_addresses): Pass ++ dot_section to set_if_absolute. ++ (Output_section_element_dot_assignment::finalize_symbols): Pass TRUE ++ as is_section_dot_assignment flag to eval_with_dot. ++ (Output_section_element_dot_assignment::set_section_addresses): ++ Likewise. ++ * script.cc (Symbol_assignment::set_if_absolute): Add dot_section ++ parameter. Also set value if relative to dot_section; set the ++ symbol's output_section. ++ * script.h (Expression::eval_with_dot): Add is_section_dot_assignment ++ parameter. Adjust all callers. ++ (Expression::eval_maybe_dot): Likewise. ++ (Symbol_assignment::set_if_absolute): Add dot_section parameter. ++ Adjust all callers. ++ * testsuite/script_test_2.t: Test assignment of an absolute value ++ to dot within an output section element. ++ ++ 2011-10-31 Cary Coutant ++ ++ * options.h (class General_options): Add --[no-]gnu-unique options. ++ * symtab.cc (Symbol_table::sized_write_globals): Convert ++ STB_GNU_UNIQUE to STB_GLOBAL if --no-gnu-unique. ++ ++ 2011-10-31 Cary Coutant ++ ++ PR gold/13359 ++ * i386.cc (Target_i386::Relocate::relocate_tls): Remove ++ unnecessary assertion. ++ * x86_64.cc (Target_x86_64::Relocate::relocate_tls): Likewise. ++ ++ 2011-10-31 Sriraman Tallam ++ ++ * symtab.h (Symbol_table::gc_mark_symbol_for_shlib): Rename to ++ gc_mark_symbol. ++ * symtab.cc (Symbol_table::gc_mark_symbol_for_shlib): Rename to ++ gc_mark_symbol. ++ Change to just keep the section associated with symbol. ++ (Symbol_table::add_from_relobj): Mark symbols as not garbage when ++ they are externally visible and --export-dynamic is turned on. ++ (Symbol_table::gc_mark_dyn_syms): Call gc_mark_symbol. ++ ++ 2011-10-19 Ian Lance Taylor ++ ++ PR gold/13163 ++ * script-sections.cc ++ (Output_section_element_dot_assignment::needs_output_section): New ++ function. ++ ++ 2011-10-19 Ian Lance Taylor ++ ++ PR gold/13204 ++ * layout.cc (Layout::segment_precedes): Don't assert failure if a ++ --section-start option was seen. ++ * options.h (General_options::any_section_start): New function. ++ ++ 2011-10-18 Cary Coutant ++ ++ * output.cc (posix_fallocate): Return 0 on success, errno on failure. ++ (Output_file::map_no_anonymous): Check for non-zero ++ return code from posix_fallocate. ++ ++ 2011-10-17 Cary Coutant ++ ++ PR gold/13245 ++ * plugin.cc (is_visible_from_outside): Check for symbols ++ referenced from dynamic objects. ++ * resolve.cc (Symbol_table::resolve): Don't count references ++ from dynamic objects as references from real ELF files. ++ * testsuite/plugin_test_2.sh: Adjust expected result. ++ ++ 2011-10-17 Cary Coutant ++ ++ * readsyms.cc (Read_symbols::run): Don't queue an unblocker ++ task for members of lib groups. ++ ++ 2011-10-17 Cary Coutant ++ ++ PR gold/13288 ++ * fileread.cc (File_read::find_view): Add assert. ++ (File_read::make_view): Move bounds check (replace with assert)... ++ (File_read::find_or_make_view): ... to here. ++ ++ 2011-10-12 Cary Coutant ++ ++ * output.cc (Output_file::open_base_file): Handle case where ++ ::read returns less than requested size. ++ ++ 2011-10-10 Cary Coutant ++ ++ * incremental.cc (Sized_relobj_incr::Sized_relobj_incr): ++ Initialize defined_count_. ++ (Sized_relobj_incr::do_add_symbols): Count defined symbols. ++ (Sized_relobj_incr::do_get_global_symbol_counts): Rewrite. ++ (Sized_incr_dynobj::Sized_incr_dynobj): Initialize defined_count_. ++ (Sized_incr_dynobj::do_add_symbols): Count defined symbols. ++ (Sized_incr_dynobj::do_get_global_symbol_counts): Rewrite. ++ * incremental.h (Sized_relobj_incr::defined_count_): New data ++ member. ++ (Sized_incr_dynobj::defined_count_): New data member. ++ * plugin.cc (Sized_pluginobj::do_get_global_symbol_counts): ++ Return zeroes instead of internal error. ++ ++ 2011-10-10 Cary Coutant ++ ++ PR gold/13249 ++ * output.cc (Output_reloc::Output_reloc): Add use_plt_offset flag. ++ (Output_reloc::symbol_value): Return PLT offset if flag is set. ++ * output.h (class Output_reloc): Add use_plt_offset flag. ++ (Output_reloc::type_): Adjust size of bit field. ++ (Output_reloc::use_plt_offset_): New bit field. ++ (class Output_data_reloc): Adjust all calls to Output_reloc_type. ++ (Output_data_reloc::add_local_relative): (RELA only) Add use_plt_offset ++ flag. Adjust all callers. ++ * x86_64.cc (Target_x86_64::Scan::local): Check for IFUNC when ++ creating RELATIVE relocations. ++ ++ 2011-10-03 Diego Novillo ++ ++ * options.cc (parse_uint): Fix dereference of RETVAL. ++ ++ 2011-09-29 Cary Coutant ++ ++ * incremental.cc (Sized_incremental_binary::do_process_got_plt): ++ Check for NULL. ++ * symtab.cc (Symbol_table::add_from_relobj): Ignore version ++ symbols during incremental update. ++ (Symbol_table::add_from_dynobj): Likewise. ++ ++ 2011-09-26 Cary Coutant ++ ++ * gold.cc (queue_initial_tasks): Move option checks ... ++ * options.cc (General_options::finalize): ... to here. Disable ++ some options; make others fatal. ++ ++ 2011-09-23 Simon Baldwin ++ ++ * configure.ac: Add new --with-gold-ldadd and --with-gold-ldflags ++ configuration options. ++ * configure: Regenerate. ++ * Makefile.am: Handle GOLD_LDADD and GOLD_LDFLAGS. ++ * Makefile.in: Regenerate. ++ * testsuite/Makefile.in: Regenerate. ++ + 2011-11-11 Doug Kwan + + * arm.cc (Target_arm::do_make_elf_object): Allow executable also +diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc +index 3dc33e4..2b47a28 100644 +--- a/gold/dwarf_reader.cc ++++ b/gold/dwarf_reader.cc +@@ -1,6 +1,6 @@ + // dwarf_reader.cc -- parse dwarf2/3 debug information + +-// Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ++// Copyright 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + // Written by Ian Lance Taylor . + + // This file is part of gold. +@@ -491,8 +491,10 @@ Sized_dwarf_line_info::read_lines(unsigned const char* lineptr + && (shndx == -1U || lsm.shndx == -1U || shndx == lsm.shndx)) + { + Offset_to_lineno_entry entry +- = { lsm.address, this->current_header_index_, +- lsm.file_num, true, lsm.line_num }; ++ = { static_cast(lsm.address), ++ this->current_header_index_, ++ static_cast(lsm.file_num), ++ true, lsm.line_num }; + std::vector& + map(this->line_number_map_[lsm.shndx]); + // If we see two consecutive entries with the same +diff --git a/gold/expression.cc b/gold/expression.cc +index e527b5e..e31c151 100644 +--- a/gold/expression.cc ++++ b/gold/expression.cc +@@ -1,6 +1,6 @@ + // expression.cc -- expressions in linker scripts for gold + +-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. ++// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + // Written by Ian Lance Taylor . + + // This file is part of gold. +@@ -77,7 +77,7 @@ Expression::eval(const Symbol_table* symtab, const Layout* layout, + bool check_assertions) + { + return this->eval_maybe_dot(symtab, layout, check_assertions, +- false, 0, NULL, NULL, NULL); ++ false, 0, NULL, NULL, NULL, false); + } + + // Evaluate an expression which may refer to the dot symbol. +@@ -87,11 +87,13 @@ Expression::eval_with_dot(const Symbol_table* symtab, const Layout* layout, + bool check_assertions, uint64_t dot_value, + Output_section* dot_section, + Output_section** result_section_pointer, +- uint64_t* result_alignment_pointer) ++ uint64_t* result_alignment_pointer, ++ bool is_section_dot_assignment) + { + return this->eval_maybe_dot(symtab, layout, check_assertions, true, + dot_value, dot_section, result_section_pointer, +- result_alignment_pointer); ++ result_alignment_pointer, ++ is_section_dot_assignment); + } + + // Evaluate an expression which may or may not refer to the dot +@@ -102,7 +104,8 @@ Expression::eval_maybe_dot(const Symbol_table* symtab, const Layout* layout, + bool check_assertions, bool is_dot_available, + uint64_t dot_value, Output_section* dot_section, + Output_section** result_section_pointer, +- uint64_t* result_alignment_pointer) ++ uint64_t* result_alignment_pointer, ++ bool is_section_dot_assignment) + { + Expression_eval_info eei; + eei.symtab = symtab; +@@ -113,14 +116,24 @@ Expression::eval_maybe_dot(const Symbol_table* symtab, const Layout* layout, + eei.dot_section = dot_section; + + // We assume the value is absolute, and only set this to a section +- // if we find a section relative reference. ++ // if we find a section-relative reference. + if (result_section_pointer != NULL) + *result_section_pointer = NULL; + eei.result_section_pointer = result_section_pointer; + + eei.result_alignment_pointer = result_alignment_pointer; + +- return this->value(&eei); ++ uint64_t val = this->value(&eei); ++ ++ // If this is an assignment to dot within a section, and the value ++ // is absolute, treat it as a section-relative offset. ++ if (is_section_dot_assignment && *result_section_pointer == NULL) ++ { ++ gold_assert(dot_section != NULL); ++ val += dot_section->address(); ++ *result_section_pointer = dot_section; ++ } ++ return val; + } + + // A number. +@@ -257,7 +270,8 @@ class Unary_expression : public Expression + eei->dot_value, + eei->dot_section, + arg_section_pointer, +- eei->result_alignment_pointer); ++ eei->result_alignment_pointer, ++ false); + } + + void +@@ -336,7 +350,8 @@ class Binary_expression : public Expression + eei->dot_value, + eei->dot_section, + section_pointer, +- alignment_pointer); ++ alignment_pointer, ++ false); + } + + uint64_t +@@ -350,7 +365,8 @@ class Binary_expression : public Expression + eei->dot_value, + eei->dot_section, + section_pointer, +- alignment_pointer); ++ alignment_pointer, ++ false); + } + + void +@@ -500,7 +516,8 @@ class Trinary_expression : public Expression + eei->dot_value, + eei->dot_section, + section_pointer, +- NULL); ++ NULL, ++ false); + } + + uint64_t +@@ -514,7 +531,8 @@ class Trinary_expression : public Expression + eei->dot_value, + eei->dot_section, + section_pointer, +- alignment_pointer); ++ alignment_pointer, ++ false); + } + + uint64_t +@@ -528,7 +546,8 @@ class Trinary_expression : public Expression + eei->dot_value, + eei->dot_section, + section_pointer, +- alignment_pointer); ++ alignment_pointer, ++ false); + } + + void +diff --git a/gold/fileread.cc b/gold/fileread.cc +index 80ddfbc..c5dc320 100644 +--- a/gold/fileread.cc ++++ b/gold/fileread.cc +@@ -329,6 +329,10 @@ inline File_read::View* + File_read::find_view(off_t start, section_size_type size, + unsigned int byteshift, File_read::View** vshifted) const + { ++ gold_assert(start <= this->size_ ++ && (static_cast(size) ++ <= static_cast(this->size_ - start))); ++ + if (vshifted != NULL) + *vshifted = NULL; + +@@ -456,16 +460,9 @@ File_read::make_view(off_t start, section_size_type size, + unsigned int byteshift, bool cache) + { + gold_assert(size > 0); +- +- // Check that start and end of the view are within the file. +- if (start > this->size_ +- || (static_cast(size) +- > static_cast(this->size_ - start))) +- gold_fatal(_("%s: attempt to map %lld bytes at offset %lld exceeds " +- "size of file; the file may be corrupt"), +- this->filename().c_str(), +- static_cast(size), +- static_cast(start)); ++ gold_assert(start <= this->size_ ++ && (static_cast(size) ++ <= static_cast(this->size_ - start))); + + off_t poff = File_read::page_offset(start); + +@@ -523,6 +520,16 @@ File_read::View* + File_read::find_or_make_view(off_t offset, off_t start, + section_size_type size, bool aligned, bool cache) + { ++ // Check that start and end of the view are within the file. ++ if (start > this->size_ ++ || (static_cast(size) ++ > static_cast(this->size_ - start))) ++ gold_fatal(_("%s: attempt to map %lld bytes at offset %lld exceeds " ++ "size of file; the file may be corrupt"), ++ this->filename().c_str(), ++ static_cast(size), ++ static_cast(start)); ++ + unsigned int byteshift; + if (offset == 0) + byteshift = 0; +diff --git a/gold/gold.cc b/gold/gold.cc +index 12f25b7..693ff79 100644 +--- a/gold/gold.cc ++++ b/gold/gold.cc +@@ -197,46 +197,29 @@ queue_initial_tasks(const General_options& options, + // For incremental links, the base output file. + Incremental_binary* ibase = NULL; + +- if (parameters->incremental()) +- { +- if (options.relocatable()) +- gold_error(_("incremental linking is incompatible with -r")); +- if (options.emit_relocs()) +- gold_error(_("incremental linking is incompatible with --emit-relocs")); +- if (options.gc_sections()) +- gold_error(_("incremental linking is incompatible with --gc-sections")); +- if (options.icf_enabled()) +- gold_error(_("incremental linking is incompatible with --icf")); +- if (options.has_plugins()) +- gold_error(_("incremental linking is incompatible with --plugin")); +- if (strcmp(options.compress_debug_sections(), "none") != 0) +- gold_error(_("incremental linking is incompatible with " +- "--compress-debug-sections")); +- +- if (parameters->incremental_update()) ++ if (parameters->incremental_update()) ++ { ++ Output_file* of = new Output_file(options.output_file_name()); ++ if (of->open_base_file(options.incremental_base(), true)) + { +- Output_file* of = new Output_file(options.output_file_name()); +- if (of->open_base_file(options.incremental_base(), true)) +- { +- ibase = open_incremental_binary(of); +- if (ibase != NULL +- && ibase->check_inputs(cmdline, layout->incremental_inputs())) +- ibase->init_layout(layout); +- else +- { +- delete ibase; +- ibase = NULL; +- of->close(); +- } +- } +- if (ibase == NULL) ++ ibase = open_incremental_binary(of); ++ if (ibase != NULL ++ && ibase->check_inputs(cmdline, layout->incremental_inputs())) ++ ibase->init_layout(layout); ++ else + { +- if (set_parameters_incremental_full()) +- gold_info(_("linking with --incremental-full")); +- else +- gold_fallback(_("restart link with --incremental-full")); ++ delete ibase; ++ ibase = NULL; ++ of->close(); + } + } ++ if (ibase == NULL) ++ { ++ if (set_parameters_incremental_full()) ++ gold_info(_("linking with --incremental-full")); ++ else ++ gold_fallback(_("restart link with --incremental-full")); ++ } + } + + // Read the input files. We have to add the symbols to the symbol +diff --git a/gold/i386.cc b/gold/i386.cc +index 445bc68..efb6248 100644 +--- a/gold/i386.cc ++++ b/gold/i386.cc +@@ -2709,12 +2709,6 @@ Target_i386::Relocate::relocate_tls(const Relocate_info<32, false>* relinfo, + } + if (optimized_type == tls::TLSOPT_TO_IE) + { +- if (tls_segment == NULL) +- { +- gold_assert(parameters->errors()->error_count() > 0 +- || issue_undefined_symbol_error(gsym)); +- return; +- } + this->tls_gd_to_ie(relinfo, relnum, tls_segment, rel, r_type, + got_offset, view, view_size); + break; +@@ -3480,42 +3474,51 @@ Target_i386::do_code_fill(section_size_type length) const + } + + // Nop sequences of various lengths. +- const char nop1[1] = { 0x90 }; // nop +- const char nop2[2] = { 0x66, 0x90 }; // xchg %ax %ax +- const char nop3[3] = { 0x8d, 0x76, 0x00 }; // leal 0(%esi),%esi +- const char nop4[4] = { 0x8d, 0x74, 0x26, 0x00}; // leal 0(%esi,1),%esi +- const char nop5[5] = { 0x90, 0x8d, 0x74, 0x26, // nop +- 0x00 }; // leal 0(%esi,1),%esi +- const char nop6[6] = { 0x8d, 0xb6, 0x00, 0x00, // leal 0L(%esi),%esi +- 0x00, 0x00 }; +- const char nop7[7] = { 0x8d, 0xb4, 0x26, 0x00, // leal 0L(%esi,1),%esi +- 0x00, 0x00, 0x00 }; +- const char nop8[8] = { 0x90, 0x8d, 0xb4, 0x26, // nop +- 0x00, 0x00, 0x00, 0x00 }; // leal 0L(%esi,1),%esi +- const char nop9[9] = { 0x89, 0xf6, 0x8d, 0xbc, // movl %esi,%esi +- 0x27, 0x00, 0x00, 0x00, // leal 0L(%edi,1),%edi +- 0x00 }; +- const char nop10[10] = { 0x8d, 0x76, 0x00, 0x8d, // leal 0(%esi),%esi +- 0xbc, 0x27, 0x00, 0x00, // leal 0L(%edi,1),%edi +- 0x00, 0x00 }; +- const char nop11[11] = { 0x8d, 0x74, 0x26, 0x00, // leal 0(%esi,1),%esi +- 0x8d, 0xbc, 0x27, 0x00, // leal 0L(%edi,1),%edi +- 0x00, 0x00, 0x00 }; +- const char nop12[12] = { 0x8d, 0xb6, 0x00, 0x00, // leal 0L(%esi),%esi +- 0x00, 0x00, 0x8d, 0xbf, // leal 0L(%edi),%edi +- 0x00, 0x00, 0x00, 0x00 }; +- const char nop13[13] = { 0x8d, 0xb6, 0x00, 0x00, // leal 0L(%esi),%esi +- 0x00, 0x00, 0x8d, 0xbc, // leal 0L(%edi,1),%edi +- 0x27, 0x00, 0x00, 0x00, +- 0x00 }; +- const char nop14[14] = { 0x8d, 0xb4, 0x26, 0x00, // leal 0L(%esi,1),%esi +- 0x00, 0x00, 0x00, 0x8d, // leal 0L(%edi,1),%edi +- 0xbc, 0x27, 0x00, 0x00, +- 0x00, 0x00 }; +- const char nop15[15] = { 0xeb, 0x0d, 0x90, 0x90, // jmp .+15 +- 0x90, 0x90, 0x90, 0x90, // nop,nop,nop,... +- 0x90, 0x90, 0x90, 0x90, +- 0x90, 0x90, 0x90 }; ++ const char nop1[1] = { '\x90' }; // nop ++ const char nop2[2] = { '\x66', '\x90' }; // xchg %ax %ax ++ const char nop3[3] = { '\x8d', '\x76', '\x00' }; // leal 0(%esi),%esi ++ const char nop4[4] = { '\x8d', '\x74', '\x26', // leal 0(%esi,1),%esi ++ '\x00'}; ++ const char nop5[5] = { '\x90', '\x8d', '\x74', // nop ++ '\x26', '\x00' }; // leal 0(%esi,1),%esi ++ const char nop6[6] = { '\x8d', '\xb6', '\x00', // leal 0L(%esi),%esi ++ '\x00', '\x00', '\x00' }; ++ const char nop7[7] = { '\x8d', '\xb4', '\x26', // leal 0L(%esi,1),%esi ++ '\x00', '\x00', '\x00', ++ '\x00' }; ++ const char nop8[8] = { '\x90', '\x8d', '\xb4', // nop ++ '\x26', '\x00', '\x00', // leal 0L(%esi,1),%esi ++ '\x00', '\x00' }; ++ const char nop9[9] = { '\x89', '\xf6', '\x8d', // movl %esi,%esi ++ '\xbc', '\x27', '\x00', // leal 0L(%edi,1),%edi ++ '\x00', '\x00', '\x00' }; ++ const char nop10[10] = { '\x8d', '\x76', '\x00', // leal 0(%esi),%esi ++ '\x8d', '\xbc', '\x27', // leal 0L(%edi,1),%edi ++ '\x00', '\x00', '\x00', ++ '\x00' }; ++ const char nop11[11] = { '\x8d', '\x74', '\x26', // leal 0(%esi,1),%esi ++ '\x00', '\x8d', '\xbc', // leal 0L(%edi,1),%edi ++ '\x27', '\x00', '\x00', ++ '\x00', '\x00' }; ++ const char nop12[12] = { '\x8d', '\xb6', '\x00', // leal 0L(%esi),%esi ++ '\x00', '\x00', '\x00', // leal 0L(%edi),%edi ++ '\x8d', '\xbf', '\x00', ++ '\x00', '\x00', '\x00' }; ++ const char nop13[13] = { '\x8d', '\xb6', '\x00', // leal 0L(%esi),%esi ++ '\x00', '\x00', '\x00', // leal 0L(%edi,1),%edi ++ '\x8d', '\xbc', '\x27', ++ '\x00', '\x00', '\x00', ++ '\x00' }; ++ const char nop14[14] = { '\x8d', '\xb4', '\x26', // leal 0L(%esi,1),%esi ++ '\x00', '\x00', '\x00', // leal 0L(%edi,1),%edi ++ '\x00', '\x8d', '\xbc', ++ '\x27', '\x00', '\x00', ++ '\x00', '\x00' }; ++ const char nop15[15] = { '\xeb', '\x0d', '\x90', // jmp .+15 ++ '\x90', '\x90', '\x90', // nop,nop,nop,... ++ '\x90', '\x90', '\x90', ++ '\x90', '\x90', '\x90', ++ '\x90', '\x90', '\x90' }; + + const char* nops[16] = { + NULL, +diff --git a/gold/incremental.cc b/gold/incremental.cc +index b422827..75e44c5 100644 +--- a/gold/incremental.cc ++++ b/gold/incremental.cc +@@ -685,7 +685,7 @@ Sized_incremental_binary::do_process_got_plt( + gold_assert(plt_desc >= first_global && plt_desc < symtab_count); + Symbol* sym = this->global_symbol(plt_desc - first_global); + // Add the PLT entry only if the symbol is still referenced. +- if (sym->in_reg()) ++ if (sym != NULL && sym->in_reg()) + { + gold_debug(DEBUG_INCREMENTAL, + "PLT entry %d: %s", +@@ -1966,8 +1966,9 @@ Sized_relobj_incr::Sized_relobj_incr( + input_reader_(ibase->inputs_reader().input_file(input_file_index)), + local_symbol_count_(0), output_local_dynsym_count_(0), + local_symbol_index_(0), local_symbol_offset_(0), local_dynsym_offset_(0), +- symbols_(), incr_reloc_offset_(-1U), incr_reloc_count_(0), +- incr_reloc_output_index_(0), incr_relocs_(NULL), local_symbols_() ++ symbols_(), defined_count_(0), incr_reloc_offset_(-1U), ++ incr_reloc_count_(0), incr_reloc_output_index_(0), incr_relocs_(NULL), ++ local_symbols_() + { + if (this->input_reader_.is_in_system_directory()) + this->set_is_in_system_directory(); +@@ -2120,6 +2121,9 @@ Sized_relobj_incr::do_add_symbols( + + Symbol* res = symtab->add_from_incrobj(this, name, NULL, &sym); + ++ if (shndx != elfcpp::SHN_UNDEF) ++ ++this->defined_count_; ++ + // If this is a linker-defined symbol that hasn't yet been defined, + // define it now. + if (input_shndx == -1U && !res->is_defined()) +@@ -2283,9 +2287,21 @@ Sized_relobj_incr::do_initialize_xindex() + template + void + Sized_relobj_incr::do_get_global_symbol_counts( +- const Symbol_table*, size_t*, size_t*) const +-{ +- gold_unreachable(); ++ const Symbol_table*, ++ size_t* defined, ++ size_t* used) const ++{ ++ *defined = this->defined_count_; ++ size_t count = 0; ++ for (typename Symbols::const_iterator p = this->symbols_.begin(); ++ p != this->symbols_.end(); ++ ++p) ++ if (*p != NULL ++ && (*p)->source() == Symbol::FROM_OBJECT ++ && (*p)->object() == this ++ && (*p)->is_defined()) ++ ++count; ++ *used = count; + } + + // Read the relocs. +@@ -2579,7 +2595,7 @@ Sized_incr_dynobj::Sized_incr_dynobj( + : Dynobj(name, NULL), ibase_(ibase), + input_file_index_(input_file_index), + input_reader_(ibase->inputs_reader().input_file(input_file_index)), +- symbols_() ++ symbols_(), defined_count_(0) + { + if (this->input_reader_.is_in_system_directory()) + this->set_is_in_system_directory(); +@@ -2677,6 +2693,7 @@ Sized_incr_dynobj::do_add_symbols( + // is meaningless, as long as it's not SHN_UNDEF. + shndx = 1; + v = gsym.get_st_value(); ++ ++this->defined_count_; + } + + osym.put_st_name(0); +@@ -2845,9 +2862,22 @@ Sized_incr_dynobj::do_initialize_xindex() + template + void + Sized_incr_dynobj::do_get_global_symbol_counts( +- const Symbol_table*, size_t*, size_t*) const +-{ +- gold_unreachable(); ++ const Symbol_table*, ++ size_t* defined, ++ size_t* used) const ++{ ++ *defined = this->defined_count_; ++ size_t count = 0; ++ for (typename Symbols::const_iterator p = this->symbols_.begin(); ++ p != this->symbols_.end(); ++ ++p) ++ if (*p != NULL ++ && (*p)->source() == Symbol::FROM_OBJECT ++ && (*p)->object() == this ++ && (*p)->is_defined() ++ && (*p)->dynsym_index() != -1U) ++ ++count; ++ *used = count; + } + + // Allocate an incremental object of the appropriate size and endianness. +diff --git a/gold/incremental.h b/gold/incremental.h +index e6732df..56fc52b 100644 +--- a/gold/incremental.h ++++ b/gold/incremental.h +@@ -1996,6 +1996,8 @@ class Sized_relobj_incr : public Sized_relobj + unsigned int local_dynsym_offset_; + // The entries in the symbol table for the external symbols. + Symbols symbols_; ++ // Number of symbols defined in object file itself. ++ size_t defined_count_; + // The offset of the first incremental relocation for this object. + unsigned int incr_reloc_offset_; + // The number of incremental relocations for this object. +@@ -2127,6 +2129,8 @@ class Sized_incr_dynobj : public Dynobj + Input_entry_reader input_reader_; + // The entries in the symbol table for the external symbols. + Symbols symbols_; ++ // Number of symbols defined in object file itself. ++ size_t defined_count_; + }; + + // Allocate an incremental object of the appropriate size and endianness. +diff --git a/gold/layout.cc b/gold/layout.cc +index 1c32bcf..9d8a43a 100644 +--- a/gold/layout.cc ++++ b/gold/layout.cc +@@ -2975,8 +2975,9 @@ Layout::segment_precedes(const Output_segment* seg1, + + // We shouldn't get here--we shouldn't create segments which we + // can't distinguish. Unless of course we are using a weird linker +- // script. +- gold_assert(this->script_options_->saw_phdrs_clause()); ++ // script or overlapping --section-start options. ++ gold_assert(this->script_options_->saw_phdrs_clause() ++ || parameters->options().any_section_start()); + return false; + } + +diff --git a/gold/options.cc b/gold/options.cc +index be32645..dcf6ba7 100644 +--- a/gold/options.cc ++++ b/gold/options.cc +@@ -198,7 +198,7 @@ parse_uint(const char* option_name, const char* arg, int* retval) + { + char* endptr; + *retval = strtol(arg, &endptr, 0); +- if (*endptr != '\0' || retval < 0) ++ if (*endptr != '\0' || *retval < 0) + gold_fatal(_("%s: invalid option value (expected an integer): %s"), + option_name, arg); + } +@@ -1224,6 +1224,37 @@ General_options::finalize() + gold_fatal(_("Options --incremental-changed, --incremental-unchanged, " + "--incremental-unknown require the use of --incremental")); + ++ // Check for options that are not compatible with incremental linking. ++ // Where an option can be disabled without seriously changing the semantics ++ // of the link, we turn the option off; otherwise, we issue a fatal error. ++ ++ if (this->incremental_mode_ != INCREMENTAL_OFF) ++ { ++ if (this->relocatable()) ++ gold_fatal(_("incremental linking is not compatible with -r")); ++ if (this->emit_relocs()) ++ gold_fatal(_("incremental linking is not compatible with " ++ "--emit-relocs")); ++ if (this->has_plugins()) ++ gold_fatal(_("incremental linking is not compatible with --plugin")); ++ if (this->gc_sections()) ++ { ++ gold_warning(_("ignoring --gc-sections for an incremental link")); ++ this->set_gc_sections(false); ++ } ++ if (this->icf_enabled()) ++ { ++ gold_warning(_("ignoring --icf for an incremental link")); ++ this->set_icf_status(ICF_NONE); ++ } ++ if (strcmp(this->compress_debug_sections(), "none") != 0) ++ { ++ gold_warning(_("ignoring --compress-debug-sections for an " ++ "incremental link")); ++ this->set_compress_debug_sections("none"); ++ } ++ } ++ + // FIXME: we can/should be doing a lot more sanity checking here. + } + +diff --git a/gold/options.h b/gold/options.h +index 768df9c..8876a1e 100644 +--- a/gold/options.h ++++ b/gold/options.h +@@ -791,6 +791,10 @@ class General_options + DEFINE_bool(g, options::EXACTLY_ONE_DASH, '\0', false, + N_("Ignored"), NULL); + ++ DEFINE_bool(gnu_unique, options::TWO_DASHES, '\0', true, ++ N_("Enable STB_GNU_UNIQUE symbol binding (default)"), ++ N_("Disable STB_GNU_UNIQUE symbol binding")); ++ + DEFINE_string(soname, options::ONE_DASH, 'h', NULL, + N_("Set shared library name"), N_("FILENAME")); + +@@ -1385,6 +1389,11 @@ class General_options + bool + section_start(const char* secname, uint64_t* paddr) const; + ++ // Return whether any --section-start option was used. ++ bool ++ any_section_start() const ++ { return !this->section_starts_.empty(); } ++ + enum Fix_v4bx + { + // Leave original instruction. +diff --git a/gold/output.cc b/gold/output.cc +index 29d8e3d..a7e1e9a 100644 +--- a/gold/output.cc ++++ b/gold/output.cc +@@ -119,7 +119,9 @@ extern "C" void *gold_mremap(void *, size_t, size_t, int); + static int + posix_fallocate(int o, off_t offset, off_t len) + { +- return ftruncate(o, offset + len); ++ if (ftruncate(o, offset + len) < 0) ++ return errno; ++ return 0; + } + #endif // !defined(HAVE_POSIX_FALLOCATE) + +@@ -706,7 +708,7 @@ Output_reloc::Output_reloc( + bool is_symbolless) + : address_(address), local_sym_index_(GSYM_CODE), type_(type), + is_relative_(is_relative), is_symbolless_(is_symbolless), +- is_section_symbol_(false), shndx_(INVALID_CODE) ++ is_section_symbol_(false), use_plt_offset_(false), shndx_(INVALID_CODE) + { + // this->type_ is a bitfield; make sure TYPE fits. + gold_assert(this->type_ == type); +@@ -727,7 +729,7 @@ Output_reloc::Output_reloc( + bool is_symbolless) + : address_(address), local_sym_index_(GSYM_CODE), type_(type), + is_relative_(is_relative), is_symbolless_(is_symbolless), +- is_section_symbol_(false), shndx_(shndx) ++ is_section_symbol_(false), use_plt_offset_(false), shndx_(shndx) + { + gold_assert(shndx != INVALID_CODE); + // this->type_ is a bitfield; make sure TYPE fits. +@@ -749,10 +751,12 @@ Output_reloc::Output_reloc( + Address address, + bool is_relative, + bool is_symbolless, +- bool is_section_symbol) ++ bool is_section_symbol, ++ bool use_plt_offset) + : address_(address), local_sym_index_(local_sym_index), type_(type), + is_relative_(is_relative), is_symbolless_(is_symbolless), +- is_section_symbol_(is_section_symbol), shndx_(INVALID_CODE) ++ is_section_symbol_(is_section_symbol), use_plt_offset_(use_plt_offset), ++ shndx_(INVALID_CODE) + { + gold_assert(local_sym_index != GSYM_CODE + && local_sym_index != INVALID_CODE); +@@ -773,10 +777,12 @@ Output_reloc::Output_reloc( + Address address, + bool is_relative, + bool is_symbolless, +- bool is_section_symbol) ++ bool is_section_symbol, ++ bool use_plt_offset) + : address_(address), local_sym_index_(local_sym_index), type_(type), + is_relative_(is_relative), is_symbolless_(is_symbolless), +- is_section_symbol_(is_section_symbol), shndx_(shndx) ++ is_section_symbol_(is_section_symbol), use_plt_offset_(use_plt_offset), ++ shndx_(shndx) + { + gold_assert(local_sym_index != GSYM_CODE + && local_sym_index != INVALID_CODE); +@@ -799,7 +805,7 @@ Output_reloc::Output_reloc( + Address address) + : address_(address), local_sym_index_(SECTION_CODE), type_(type), + is_relative_(false), is_symbolless_(false), +- is_section_symbol_(true), shndx_(INVALID_CODE) ++ is_section_symbol_(true), use_plt_offset_(false), shndx_(INVALID_CODE) + { + // this->type_ is a bitfield; make sure TYPE fits. + gold_assert(this->type_ == type); +@@ -820,7 +826,7 @@ Output_reloc::Output_reloc( + Address address) + : address_(address), local_sym_index_(SECTION_CODE), type_(type), + is_relative_(false), is_symbolless_(false), +- is_section_symbol_(true), shndx_(shndx) ++ is_section_symbol_(true), use_plt_offset_(false), shndx_(shndx) + { + gold_assert(shndx != INVALID_CODE); + // this->type_ is a bitfield; make sure TYPE fits. +@@ -842,7 +848,7 @@ Output_reloc::Output_reloc( + Address address) + : address_(address), local_sym_index_(0), type_(type), + is_relative_(false), is_symbolless_(false), +- is_section_symbol_(false), shndx_(INVALID_CODE) ++ is_section_symbol_(false), use_plt_offset_(false), shndx_(INVALID_CODE) + { + // this->type_ is a bitfield; make sure TYPE fits. + gold_assert(this->type_ == type); +@@ -858,7 +864,7 @@ Output_reloc::Output_reloc( + Address address) + : address_(address), local_sym_index_(0), type_(type), + is_relative_(false), is_symbolless_(false), +- is_section_symbol_(false), shndx_(shndx) ++ is_section_symbol_(false), use_plt_offset_(false), shndx_(shndx) + { + gold_assert(shndx != INVALID_CODE); + // this->type_ is a bitfield; make sure TYPE fits. +@@ -877,7 +883,7 @@ Output_reloc::Output_reloc( + Address address) + : address_(address), local_sym_index_(TARGET_CODE), type_(type), + is_relative_(false), is_symbolless_(false), +- is_section_symbol_(false), shndx_(INVALID_CODE) ++ is_section_symbol_(false), use_plt_offset_(false), shndx_(INVALID_CODE) + { + // this->type_ is a bitfield; make sure TYPE fits. + gold_assert(this->type_ == type); +@@ -894,7 +900,7 @@ Output_reloc::Output_reloc( + Address address) + : address_(address), local_sym_index_(TARGET_CODE), type_(type), + is_relative_(false), is_symbolless_(false), +- is_section_symbol_(false), shndx_(shndx) ++ is_section_symbol_(false), use_plt_offset_(false), shndx_(shndx) + { + gold_assert(shndx != INVALID_CODE); + // this->type_ is a bitfield; make sure TYPE fits. +@@ -1121,6 +1127,12 @@ Output_reloc::symbol_value( + Sized_relobj_file* relobj = + this->u1_.relobj->sized_relobj(); + gold_assert(relobj != NULL); ++ if (this->use_plt_offset_) ++ { ++ uint64_t plt_address = ++ parameters->target().plt_address_for_local(relobj, lsi); ++ return plt_address + relobj->local_plt_offset(lsi); ++ } + const Symbol_value* symval = relobj->local_symbol(lsi); + return symval->value(relobj, addend); + } +@@ -4880,17 +4892,27 @@ Output_file::open_base_file(const char* base_name, bool writable) + if (use_base_file) + { + this->open(s.st_size); +- ssize_t len = ::read(o, this->base_, s.st_size); +- if (len < 0) +- { +- gold_info(_("%s: read failed: %s"), base_name, strerror(errno)); +- return false; +- } +- if (len < s.st_size) +- { +- gold_info(_("%s: file too short"), base_name); +- return false; +- } ++ ssize_t bytes_to_read = s.st_size; ++ unsigned char* p = this->base_; ++ while (bytes_to_read > 0) ++ { ++ ssize_t len = ::read(o, p, bytes_to_read); ++ if (len < 0) ++ { ++ gold_info(_("%s: read failed: %s"), base_name, strerror(errno)); ++ return false; ++ } ++ if (len == 0) ++ { ++ gold_info(_("%s: file too short: read only %lld of %lld bytes"), ++ base_name, ++ static_cast(s.st_size - bytes_to_read), ++ static_cast(s.st_size)); ++ return false; ++ } ++ p += len; ++ bytes_to_read -= len; ++ } + ::close(o); + return true; + } +@@ -5052,8 +5074,12 @@ Output_file::map_no_anonymous(bool writable) + // output file will wind up incomplete, but we will have already + // exited. The alternative to fallocate would be to use fdatasync, + // but that would be a more significant performance hit. +- if (writable && ::posix_fallocate(o, 0, this->file_size_) < 0) +- gold_fatal(_("%s: %s"), this->name_, strerror(errno)); ++ if (writable) ++ { ++ int err = ::posix_fallocate(o, 0, this->file_size_); ++ if (err != 0) ++ gold_fatal(_("%s: %s"), this->name_, strerror(err)); ++ } + + // Map the file into memory. + int prot = PROT_READ; +diff --git a/gold/output.h b/gold/output.h +index 1bec2c0..e2d35e2 100644 +--- a/gold/output.h ++++ b/gold/output.h +@@ -1033,12 +1033,14 @@ class Output_reloc + Output_reloc(Sized_relobj* relobj, + unsigned int local_sym_index, unsigned int type, + Output_data* od, Address address, bool is_relative, +- bool is_symbolless, bool is_section_symbol); ++ bool is_symbolless, bool is_section_symbol, ++ bool use_plt_offset); + + Output_reloc(Sized_relobj* relobj, + unsigned int local_sym_index, unsigned int type, + unsigned int shndx, Address address, bool is_relative, +- bool is_symbolless, bool is_section_symbol); ++ bool is_symbolless, bool is_section_symbol, ++ bool use_plt_offset); + + // A reloc against the STT_SECTION symbol of an output section. + +@@ -1216,7 +1218,7 @@ class Output_reloc + // input file. + unsigned int local_sym_index_; + // The reloc type--a processor specific code. +- unsigned int type_ : 29; ++ unsigned int type_ : 28; + // True if the relocation is a RELATIVE relocation. + bool is_relative_ : 1; + // True if the relocation is one which should not use +@@ -1224,6 +1226,10 @@ class Output_reloc + bool is_symbolless_ : 1; + // True if the relocation is against a section symbol. + bool is_section_symbol_ : 1; ++ // True if the addend should be the PLT offset. This is used only ++ // for RELATIVE relocations to local symbols. ++ // (Used only for RELA, but stored here for space.) ++ bool use_plt_offset_ : 1; + // If the reloc address is an input section in an object, the + // section index. This is INVALID_CODE if the reloc address is + // specified in some other way. +@@ -1268,9 +1274,10 @@ class Output_reloc + unsigned int local_sym_index, unsigned int type, + Output_data* od, Address address, + Addend addend, bool is_relative, +- bool is_symbolless, bool is_section_symbol) ++ bool is_symbolless, bool is_section_symbol, ++ bool use_plt_offset) + : rel_(relobj, local_sym_index, type, od, address, is_relative, +- is_symbolless, is_section_symbol), ++ is_symbolless, is_section_symbol, use_plt_offset), + addend_(addend) + { } + +@@ -1278,9 +1285,10 @@ class Output_reloc + unsigned int local_sym_index, unsigned int type, + unsigned int shndx, Address address, + Addend addend, bool is_relative, +- bool is_symbolless, bool is_section_symbol) ++ bool is_symbolless, bool is_section_symbol, ++ bool use_plt_offset) + : rel_(relobj, local_sym_index, type, shndx, address, is_relative, +- is_symbolless, is_section_symbol), ++ is_symbolless, is_section_symbol, use_plt_offset), + addend_(addend) + { } + +@@ -1571,7 +1579,7 @@ class Output_data_reloc + Output_data* od, Address address) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, od, +- address, false, false, false)); ++ address, false, false, false, false)); + } + + void +@@ -1580,7 +1588,7 @@ class Output_data_reloc + Output_data* od, unsigned int shndx, Address address) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, shndx, +- address, false, false, false)); ++ address, false, false, false, false)); + } + + // Add a RELATIVE reloc against a local symbol. +@@ -1591,7 +1599,7 @@ class Output_data_reloc + Output_data* od, Address address) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, od, +- address, true, true, false)); ++ address, true, true, false, false)); + } + + void +@@ -1600,7 +1608,7 @@ class Output_data_reloc + Output_data* od, unsigned int shndx, Address address) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, shndx, +- address, true, true, false)); ++ address, true, true, false, false)); + } + + // Add a local relocation which does not use a symbol for the relocation, +@@ -1612,7 +1620,7 @@ class Output_data_reloc + Output_data* od, Address address) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, od, +- address, false, true, false)); ++ address, false, true, false, false)); + } + + void +@@ -1622,7 +1630,7 @@ class Output_data_reloc + Address address) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, shndx, +- address, false, true, false)); ++ address, false, true, false, false)); + } + + // Add a reloc against a local section symbol. This will be +@@ -1635,7 +1643,7 @@ class Output_data_reloc + Output_data* od, Address address) + { + this->add(od, Output_reloc_type(relobj, input_shndx, type, od, +- address, false, false, true)); ++ address, false, false, true, false)); + } + + void +@@ -1644,7 +1652,7 @@ class Output_data_reloc + Output_data* od, unsigned int shndx, Address address) + { + this->add(od, Output_reloc_type(relobj, input_shndx, type, shndx, +- address, false, false, true)); ++ address, false, false, true, false)); + } + + // A reloc against the STT_SECTION symbol of an output section. +@@ -1767,7 +1775,7 @@ class Output_data_reloc + Output_data* od, Address address, Addend addend) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, od, address, +- addend, false, false, false)); ++ addend, false, false, false, false)); + } + + void +@@ -1777,7 +1785,8 @@ class Output_data_reloc + Addend addend) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, shndx, +- address, addend, false, false, false)); ++ address, addend, false, false, false, ++ false)); + } + + // Add a RELATIVE reloc against a local symbol. +@@ -1785,20 +1794,23 @@ class Output_data_reloc + void + add_local_relative(Sized_relobj* relobj, + unsigned int local_sym_index, unsigned int type, +- Output_data* od, Address address, Addend addend) ++ Output_data* od, Address address, Addend addend, ++ bool use_plt_offset) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, od, address, +- addend, true, true, false)); ++ addend, true, true, false, ++ use_plt_offset)); + } + + void + add_local_relative(Sized_relobj* relobj, + unsigned int local_sym_index, unsigned int type, + Output_data* od, unsigned int shndx, Address address, +- Addend addend) ++ Addend addend, bool use_plt_offset) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, shndx, +- address, addend, true, true, false)); ++ address, addend, true, true, false, ++ use_plt_offset)); + } + + // Add a local relocation which does not use a symbol for the relocation, +@@ -1810,7 +1822,7 @@ class Output_data_reloc + Output_data* od, Address address, Addend addend) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, od, address, +- addend, false, true, false)); ++ addend, false, true, false, false)); + } + + void +@@ -1820,7 +1832,8 @@ class Output_data_reloc + Address address, Addend addend) + { + this->add(od, Output_reloc_type(relobj, local_sym_index, type, shndx, +- address, addend, false, true, false)); ++ address, addend, false, true, false, ++ false)); + } + + // Add a reloc against a local section symbol. This will be +@@ -1833,7 +1846,7 @@ class Output_data_reloc + Output_data* od, Address address, Addend addend) + { + this->add(od, Output_reloc_type(relobj, input_shndx, type, od, address, +- addend, false, false, true)); ++ addend, false, false, true, false)); + } + + void +@@ -1843,7 +1856,8 @@ class Output_data_reloc + Addend addend) + { + this->add(od, Output_reloc_type(relobj, input_shndx, type, shndx, +- address, addend, false, false, true)); ++ address, addend, false, false, true, ++ false)); + } + + // A reloc against the STT_SECTION symbol of an output section. +diff --git a/gold/plugin.cc b/gold/plugin.cc +index 3ccd8d0..b4e68f8 100644 +--- a/gold/plugin.cc ++++ b/gold/plugin.cc +@@ -818,7 +818,9 @@ Pluginobj::Pluginobj(const std::string& name, Input_file* input_file, + } + + // Return TRUE if a defined symbol is referenced from outside the +-// universe of claimed objects. ++// universe of claimed objects. Only references from relocatable, ++// non-IR (unclaimed) objects count as a reference. References from ++// dynamic objects count only as "visible". + + static inline bool + is_referenced_from_outside(Symbol* lsym) +@@ -838,6 +840,8 @@ is_referenced_from_outside(Symbol* lsym) + static inline bool + is_visible_from_outside(Symbol* lsym) + { ++ if (lsym->in_dyn()) ++ return true; + if (parameters->options().export_dynamic() || parameters->options().shared()) + return lsym->is_externally_visible(); + return false; +@@ -1244,14 +1248,18 @@ Sized_pluginobj::do_initialize_xindex() + return NULL; + } + +-// Get symbol counts. Not used for plugin objects. ++// Get symbol counts. Don't count plugin objects; the replacement ++// files will provide the counts. + + template + void +-Sized_pluginobj::do_get_global_symbol_counts(const Symbol_table*, +- size_t*, size_t*) const ++Sized_pluginobj::do_get_global_symbol_counts( ++ const Symbol_table*, ++ size_t* defined, ++ size_t* used) const + { +- gold_unreachable(); ++ *defined = 0; ++ *used = 0; + } + + // Get symbols. Not used for plugin objects. +diff --git a/gold/powerpc.cc b/gold/powerpc.cc +index 45783c3..62a17ca 100644 +--- a/gold/powerpc.cc ++++ b/gold/powerpc.cc +@@ -1329,7 +1329,7 @@ Target_powerpc::Scan::local( + rela_dyn->add_local_relative(object, r_sym, r_type, + output_section, data_shndx, + reloc.get_r_offset(), +- reloc.get_r_addend()); ++ reloc.get_r_addend(), false); + } + } + break; +@@ -1372,7 +1372,7 @@ Target_powerpc::Scan::local( + object->set_local_got_offset(r_sym, GOT_TYPE_STANDARD, off); + rela_dyn->add_local_relative(object, r_sym, + elfcpp::R_POWERPC_RELATIVE, +- got, off, 0); ++ got, off, 0, false); + } + } + else +diff --git a/gold/readsyms.cc b/gold/readsyms.cc +index 1e50942..9974722 100644 +--- a/gold/readsyms.cc ++++ b/gold/readsyms.cc +@@ -161,8 +161,10 @@ void + Read_symbols::run(Workqueue* workqueue) + { + // If we didn't queue a new task, then we need to explicitly unblock +- // the token. +- if (!this->do_read_symbols(workqueue)) ++ // the token. If the object is a member of a lib group, however, ++ // the token was already added to the list of locks for the task, ++ // and it will be unblocked automatically at the end of the task. ++ if (!this->do_read_symbols(workqueue) && this->member_ == NULL) + workqueue->queue_soon(new Unblock_token(this->this_blocker_, + this->next_blocker_)); + } +diff --git a/gold/resolve.cc b/gold/resolve.cc +index 03288ec..780038a 100644 +--- a/gold/resolve.cc ++++ b/gold/resolve.cc +@@ -296,7 +296,7 @@ Symbol_table::resolve(Sized_symbol* to, + + // Record if we've seen this symbol in a real ELF object (i.e., the + // symbol is referenced from outside the world known to the plugin). +- if (object->pluginobj() == NULL) ++ if (object->pluginobj() == NULL && !object->is_dynamic()) + to->set_in_real_elf(); + + // If we're processing replacement files, allow new symbols to override +@@ -336,9 +336,9 @@ Symbol_table::resolve(Sized_symbol* to, + && to->name()[0] == '_' && to->name()[1] == 'Z') + { + Symbol_location fromloc +- = { object, orig_st_shndx, sym.get_st_value() }; ++ = { object, orig_st_shndx, static_cast(sym.get_st_value()) }; + Symbol_location toloc = { to->object(), to->shndx(&to_is_ordinary), +- to->value() }; ++ static_cast(to->value()) }; + this->candidate_odr_violations_[to->name()].insert(fromloc); + this->candidate_odr_violations_[to->name()].insert(toloc); + } +diff --git a/gold/script-sections.cc b/gold/script-sections.cc +index 1fad88d..f90c0b3 100644 +--- a/gold/script-sections.cc ++++ b/gold/script-sections.cc +@@ -680,7 +680,7 @@ class Sections_element_assignment : public Sections_element + set_section_addresses(Symbol_table* symtab, Layout* layout, + uint64_t* dot_value, uint64_t*, uint64_t*) + { +- this->assignment_.set_if_absolute(symtab, layout, true, *dot_value); ++ this->assignment_.set_if_absolute(symtab, layout, true, *dot_value, NULL); + } + + // Print for debugging. +@@ -714,7 +714,7 @@ class Sections_element_dot_assignment : public Sections_element + // output section definition the dot symbol is always considered + // to be absolute. + *dot_value = this->val_->eval_with_dot(symtab, layout, true, *dot_value, +- NULL, NULL, NULL); ++ NULL, NULL, NULL, false); + } + + // Update the dot symbol while setting section addresses. +@@ -724,7 +724,7 @@ class Sections_element_dot_assignment : public Sections_element + uint64_t* load_address) + { + *dot_value = this->val_->eval_with_dot(symtab, layout, false, *dot_value, +- NULL, NULL, dot_alignment); ++ NULL, NULL, dot_alignment, false); + *load_address = *dot_value; + } + +@@ -866,9 +866,11 @@ class Output_section_element_assignment : public Output_section_element + void + set_section_addresses(Symbol_table* symtab, Layout* layout, Output_section*, + uint64_t, uint64_t* dot_value, uint64_t*, +- Output_section**, std::string*, Input_section_list*) ++ Output_section** dot_section, std::string*, ++ Input_section_list*) + { +- this->assignment_.set_if_absolute(symtab, layout, true, *dot_value); ++ this->assignment_.set_if_absolute(symtab, layout, true, *dot_value, ++ *dot_section); + } + + // Print for debugging. +@@ -892,20 +894,28 @@ class Output_section_element_dot_assignment : public Output_section_element + : val_(val) + { } + ++ // An assignment to dot within an output section is enough to force ++ // the output section to exist. ++ bool ++ needs_output_section() const ++ { return true; } ++ + // Finalize the symbol. + void + finalize_symbols(Symbol_table* symtab, const Layout* layout, + uint64_t* dot_value, Output_section** dot_section) + { + *dot_value = this->val_->eval_with_dot(symtab, layout, true, *dot_value, +- *dot_section, dot_section, NULL); ++ *dot_section, dot_section, NULL, ++ true); + } + + // Update the dot symbol while setting section addresses. + void + set_section_addresses(Symbol_table* symtab, Layout* layout, Output_section*, + uint64_t, uint64_t* dot_value, uint64_t*, +- Output_section**, std::string*, Input_section_list*); ++ Output_section** dot_section, std::string*, ++ Input_section_list*); + + // Print for debugging. + void +@@ -936,7 +946,8 @@ Output_section_element_dot_assignment::set_section_addresses( + { + uint64_t next_dot = this->val_->eval_with_dot(symtab, layout, false, + *dot_value, *dot_section, +- dot_section, dot_alignment); ++ dot_section, dot_alignment, ++ true); + if (next_dot < *dot_value) + gold_error(_("dot may not move backward")); + if (next_dot > *dot_value && output_section != NULL) +@@ -1037,7 +1048,8 @@ Output_data_expression::do_write_to_buffer(unsigned char* buf) + { + uint64_t val = this->val_->eval_with_dot(this->symtab_, this->layout_, + true, this->dot_value_, +- this->dot_section_, NULL, NULL); ++ this->dot_section_, NULL, NULL, ++ false); + + if (parameters->target().is_big_endian()) + this->endian_write_to_buffer(val, buf); +@@ -1187,7 +1199,7 @@ class Output_section_element_fill : public Output_section_element + Output_section* fill_section; + uint64_t fill_val = this->val_->eval_with_dot(symtab, layout, false, + *dot_value, *dot_section, +- &fill_section, NULL); ++ &fill_section, NULL, false); + if (fill_section != NULL) + gold_warning(_("fill value is not absolute")); + // FIXME: The GNU linker supports fill values of arbitrary length. +@@ -2108,13 +2120,13 @@ Output_section_definition::finalize_symbols(Symbol_table* symtab, + { + address = this->address_->eval_with_dot(symtab, layout, true, + *dot_value, NULL, +- NULL, NULL); ++ NULL, NULL, false); + } + if (this->align_ != NULL) + { + uint64_t align = this->align_->eval_with_dot(symtab, layout, true, + *dot_value, NULL, +- NULL, NULL); ++ NULL, NULL, false); + address = align_address(address, align); + } + *dot_value = address; +@@ -2303,7 +2315,7 @@ Output_section_definition::set_section_addresses(Symbol_table* symtab, + else + address = this->address_->eval_with_dot(symtab, layout, true, + *dot_value, NULL, NULL, +- dot_alignment); ++ dot_alignment, false); + uint64_t align; + if (this->align_ == NULL) + { +@@ -2316,7 +2328,7 @@ Output_section_definition::set_section_addresses(Symbol_table* symtab, + { + Output_section* align_section; + align = this->align_->eval_with_dot(symtab, layout, true, *dot_value, +- NULL, &align_section, NULL); ++ NULL, &align_section, NULL, false); + if (align_section != NULL) + gold_warning(_("alignment of section %s is not absolute"), + this->name_.c_str()); +@@ -2401,7 +2413,7 @@ Output_section_definition::set_section_addresses(Symbol_table* symtab, + laddr = this->load_address_->eval_with_dot(symtab, layout, true, + *dot_value, + this->output_section_, +- NULL, NULL); ++ NULL, NULL, false); + if (this->output_section_ != NULL) + this->output_section_->set_load_address(laddr); + } +@@ -2416,7 +2428,8 @@ Output_section_definition::set_section_addresses(Symbol_table* symtab, + Output_section* subalign_section; + subalign = this->subalign_->eval_with_dot(symtab, layout, true, + *dot_value, NULL, +- &subalign_section, NULL); ++ &subalign_section, NULL, ++ false); + if (subalign_section != NULL) + gold_warning(_("subalign of section %s is not absolute"), + this->name_.c_str()); +@@ -2431,7 +2444,7 @@ Output_section_definition::set_section_addresses(Symbol_table* symtab, + uint64_t fill_val = this->fill_->eval_with_dot(symtab, layout, true, + *dot_value, + NULL, &fill_section, +- NULL); ++ NULL, false); + if (fill_section != NULL) + gold_warning(_("fill of section %s is not absolute"), + this->name_.c_str()); +diff --git a/gold/script.cc b/gold/script.cc +index 7df0c9e..b471cf9 100644 +--- a/gold/script.cc ++++ b/gold/script.cc +@@ -983,18 +983,20 @@ Symbol_assignment::sized_finalize(Symbol_table* symtab, const Layout* layout, + uint64_t final_val = this->val_->eval_maybe_dot(symtab, layout, true, + is_dot_available, + dot_value, dot_section, +- §ion, NULL); ++ §ion, NULL, false); + Sized_symbol* ssym = symtab->get_sized_symbol(this->sym_); + ssym->set_value(final_val); + if (section != NULL) + ssym->set_output_section(section); + } + +-// Set the symbol value if the expression yields an absolute value. ++// Set the symbol value if the expression yields an absolute value or ++// a value relative to DOT_SECTION. + + void + Symbol_assignment::set_if_absolute(Symbol_table* symtab, const Layout* layout, +- bool is_dot_available, uint64_t dot_value) ++ bool is_dot_available, uint64_t dot_value, ++ Output_section* dot_section) + { + if (this->sym_ == NULL) + return; +@@ -1002,8 +1004,9 @@ Symbol_assignment::set_if_absolute(Symbol_table* symtab, const Layout* layout, + Output_section* val_section; + uint64_t val = this->val_->eval_maybe_dot(symtab, layout, false, + is_dot_available, dot_value, +- NULL, &val_section, NULL); +- if (val_section != NULL) ++ dot_section, &val_section, NULL, ++ false); ++ if (val_section != NULL && val_section != dot_section) + return; + + if (parameters->target().get_size() == 32) +@@ -1026,6 +1029,8 @@ Symbol_assignment::set_if_absolute(Symbol_table* symtab, const Layout* layout, + } + else + gold_unreachable(); ++ if (val_section != NULL) ++ this->sym_->set_output_section(val_section); + } + + // Print for debugging. +@@ -1215,7 +1220,7 @@ Script_options::set_section_addresses(Symbol_table* symtab, Layout* layout) + for (Symbol_assignments::iterator p = this->symbol_assignments_.begin(); + p != this->symbol_assignments_.end(); + ++p) +- (*p)->set_if_absolute(symtab, layout, false, 0); ++ (*p)->set_if_absolute(symtab, layout, false, 0, NULL); + + return this->script_sections_.set_section_addresses(symtab, layout); + } +diff --git a/gold/script.h b/gold/script.h +index 73079a4..f41f438 100644 +--- a/gold/script.h ++++ b/gold/script.h +@@ -90,20 +90,28 @@ class Expression + // the section address. If RESULT_ALIGNMENT is not NULL, this sets + // *RESULT_ALIGNMENT to the alignment of the value of that alignment + // is larger than *RESULT_ALIGNMENT; this will only be non-zero if +- // this is an ALIGN expression. ++ // this is an ALIGN expression. If IS_SECTION_DOT_ASSIGMENT is true, ++ // we are evaluating an assignment to dot within an output section, ++ // and an absolute value should be interpreted as an offset within ++ // the section. + uint64_t + eval_with_dot(const Symbol_table*, const Layout*, bool check_assertions, + uint64_t dot_value, Output_section* dot_section, +- Output_section** result_section, uint64_t* result_alignment); ++ Output_section** result_section, uint64_t* result_alignment, ++ bool is_section_dot_assignment); + + // Return the value of an expression which may or may not be + // permitted to refer to the dot symbol, depending on +- // is_dot_available. ++ // is_dot_available. If IS_SECTION_DOT_ASSIGMENT is true, ++ // we are evaluating an assignment to dot within an output section, ++ // and an absolute value should be interpreted as an offset within ++ // the section. + uint64_t + eval_maybe_dot(const Symbol_table*, const Layout*, bool check_assertions, + bool is_dot_available, uint64_t dot_value, + Output_section* dot_section, +- Output_section** result_section, uint64_t* result_alignment); ++ Output_section** result_section, uint64_t* result_alignment, ++ bool is_section_dot_assignment); + + // Print the expression to the FILE. This is for debugging. + virtual void +@@ -339,12 +347,12 @@ class Symbol_assignment + finalize_with_dot(Symbol_table*, const Layout*, uint64_t dot_value, + Output_section* dot_section); + +- // Set the symbol value, but only if the value is absolute. This is +- // used while processing a SECTIONS clause. We assume that dot is +- // an absolute value here. We do not check assertions. ++ // Set the symbol value, but only if the value is absolute or relative to ++ // DOT_SECTION. This is used while processing a SECTIONS clause. ++ // We assume that dot is an absolute value here. We do not check assertions. + void + set_if_absolute(Symbol_table*, const Layout*, bool is_dot_available, +- uint64_t dot_value); ++ uint64_t dot_value, Output_section* dot_section); + + const std::string& + name() const +diff --git a/gold/sparc.cc b/gold/sparc.cc +index 5f67a4e..12e1dee 100644 +--- a/gold/sparc.cc ++++ b/gold/sparc.cc +@@ -1855,7 +1855,7 @@ Target_sparc::Scan::local( + rela_dyn->add_local_relative(object, r_sym, elfcpp::R_SPARC_RELATIVE, + output_section, data_shndx, + reloc.get_r_offset(), +- reloc.get_r_addend()); ++ reloc.get_r_addend(), false); + } + break; + +@@ -1946,7 +1946,7 @@ Target_sparc::Scan::local( + object->set_local_got_offset(r_sym, GOT_TYPE_STANDARD, off); + rela_dyn->add_local_relative(object, r_sym, + elfcpp::R_SPARC_RELATIVE, +- got, off, 0); ++ got, off, 0, false); + } + } + else +diff --git a/gold/symtab.cc b/gold/symtab.cc +index ff1b5ca..f0ba1d5 100644 +--- a/gold/symtab.cc ++++ b/gold/symtab.cc +@@ -602,20 +602,16 @@ Symbol_table::gc_mark_undef_symbols(Layout* layout) + } + + void +-Symbol_table::gc_mark_symbol_for_shlib(Symbol* sym) ++Symbol_table::gc_mark_symbol(Symbol* sym) + { +- if (!sym->is_from_dynobj() +- && sym->is_externally_visible()) ++ // Add the object and section to the work list. ++ Relobj* obj = static_cast(sym->object()); ++ bool is_ordinary; ++ unsigned int shndx = sym->shndx(&is_ordinary); ++ if (is_ordinary && shndx != elfcpp::SHN_UNDEF) + { +- //Add the object and section to the work list. +- Relobj* obj = static_cast(sym->object()); +- bool is_ordinary; +- unsigned int shndx = sym->shndx(&is_ordinary); +- if (is_ordinary && shndx != elfcpp::SHN_UNDEF) +- { +- gold_assert(this->gc_!= NULL); +- this->gc_->worklist().push(Section_id(obj, shndx)); +- } ++ gold_assert(this->gc_!= NULL); ++ this->gc_->worklist().push(Section_id(obj, shndx)); + } + } + +@@ -626,16 +622,7 @@ Symbol_table::gc_mark_dyn_syms(Symbol* sym) + { + if (sym->in_dyn() && sym->source() == Symbol::FROM_OBJECT + && !sym->object()->is_dynamic()) +- { +- Relobj* obj = static_cast(sym->object()); +- bool is_ordinary; +- unsigned int shndx = sym->shndx(&is_ordinary); +- if (is_ordinary && shndx != elfcpp::SHN_UNDEF) +- { +- gold_assert(this->gc_ != NULL); +- this->gc_->worklist().push(Section_id(obj, shndx)); +- } +- } ++ this->gc_mark_symbol(sym); + } + + // Make TO a symbol which forwards to FROM. +@@ -1143,6 +1130,14 @@ Symbol_table::add_from_relobj( + bool is_default_version = false; + bool is_forced_local = false; + ++ // FIXME: For incremental links, we don't store version information, ++ // so we need to ignore version symbols for now. ++ if (parameters->incremental_update() && ver != NULL) ++ { ++ namelen = ver - name; ++ ver = NULL; ++ } ++ + if (ver != NULL) + { + // The symbol name is of the form foo@VERSION or foo@@VERSION +@@ -1243,11 +1238,16 @@ Symbol_table::add_from_relobj( + if (is_forced_local) + this->force_local(res); + +- // If building a shared library using garbage collection, do not +- // treat externally visible symbols as garbage. +- if (parameters->options().gc_sections() +- && parameters->options().shared()) +- this->gc_mark_symbol_for_shlib(res); ++ // Do not treat this symbol as garbage if this symbol will be ++ // exported to the dynamic symbol table. This is true when ++ // building a shared library or using --export-dynamic and ++ // the symbol is externally visible. ++ if (parameters->options().gc_sections() ++ && res->is_externally_visible() ++ && !res->is_from_dynobj() ++ && (parameters->options().shared() ++ || parameters->options().export_dynamic())) ++ this->gc_mark_symbol(res); + + if (is_defined_in_discarded_section) + res->set_is_defined_in_discarded_section(); +@@ -1346,6 +1346,11 @@ Symbol_table::add_from_dynobj( + return; + } + ++ // FIXME: For incremental links, we don't store version information, ++ // so we need to ignore version symbols for now. ++ if (parameters->incremental_update()) ++ versym = NULL; ++ + if (versym != NULL && versym_size / 2 < count) + { + dynobj->error(_("too few symbol versions")); +@@ -2809,6 +2814,12 @@ Symbol_table::sized_write_globals(const Stringpool* sympool, + typename elfcpp::Elf_types::Elf_Addr sym_value = sym->value(); + typename elfcpp::Elf_types::Elf_Addr dynsym_value = sym_value; + elfcpp::STB binding = sym->binding(); ++ ++ // If --no-gnu-unique is set, change STB_GNU_UNIQUE to STB_GLOBAL. ++ if (binding == elfcpp::STB_GNU_UNIQUE ++ && !parameters->options().gnu_unique()) ++ binding = elfcpp::STB_GLOBAL; ++ + switch (sym->source()) + { + case Symbol::FROM_OBJECT: +diff --git a/gold/symtab.h b/gold/symtab.h +index b9b9e00..427f72f 100644 +--- a/gold/symtab.h ++++ b/gold/symtab.h +@@ -1308,10 +1308,9 @@ class Symbol_table + void + gc_mark_undef_symbols(Layout*); + +- // During garbage collection, this ensures externally visible symbols +- // are not treated as garbage while building shared objects. ++ // This tells garbage collection that this symbol is referenced. + void +- gc_mark_symbol_for_shlib(Symbol* sym); ++ gc_mark_symbol(Symbol* sym); + + // During garbage collection, this keeps sections that correspond to + // symbols seen in dynamic objects. +diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in +index 67149fb..785dcdd 100644 +--- a/gold/testsuite/Makefile.in ++++ b/gold/testsuite/Makefile.in +@@ -1844,6 +1844,8 @@ EGREP = @EGREP@ + EXEEXT = @EXEEXT@ + GENCAT = @GENCAT@ + GMSGFMT = @GMSGFMT@ ++GOLD_LDADD = @GOLD_LDADD@ ++GOLD_LDFLAGS = @GOLD_LDFLAGS@ + GREP = @GREP@ + INCINTL = @INCINTL@ + INSTALL = @INSTALL@ +diff --git a/gold/testsuite/plugin_test_2.sh b/gold/testsuite/plugin_test_2.sh +index a47d22a..293b1f0 100755 +--- a/gold/testsuite/plugin_test_2.sh ++++ b/gold/testsuite/plugin_test_2.sh +@@ -45,7 +45,7 @@ check plugin_test_2.err "two_file_test_main.o: claim file hook called" + check plugin_test_2.err "two_file_test_1.syms: claim file hook called" + check plugin_test_2.err "two_file_test_1b.syms: claim file hook called" + check plugin_test_2.err "two_file_shared_2.so: claim file hook called" +-check plugin_test_2.err "two_file_test_1.syms: _Z4f13iv: PREVAILING_DEF_REG" ++check plugin_test_2.err "two_file_test_1.syms: _Z4f13iv: PREVAILING_DEF_IRONLY_EXP" + check plugin_test_2.err "two_file_test_1.syms: _Z2t2v: PREVAILING_DEF_REG" + check plugin_test_2.err "two_file_test_1.syms: v2: RESOLVED_DYN" + check plugin_test_2.err "two_file_test_1.syms: t17data: RESOLVED_DYN" +diff --git a/gold/testsuite/script_test_2.t b/gold/testsuite/script_test_2.t +index 73d39df..6a0188f 100644 +--- a/gold/testsuite/script_test_2.t ++++ b/gold/testsuite/script_test_2.t +@@ -49,7 +49,7 @@ SECTIONS + /* This should match the remaining sections. */ + *(.gold_test) + +- . = . + 4; ++ . = 60; + start_data = .; + BYTE(1) + SHORT(2) +diff --git a/gold/x86_64.cc b/gold/x86_64.cc +index e6b0021..e7c981b 100644 +--- a/gold/x86_64.cc ++++ b/gold/x86_64.cc +@@ -1549,7 +1549,7 @@ Target_x86_64::reserve_local_got_entry( + case GOT_TYPE_STANDARD: + if (parameters->options().output_is_position_independent()) + rela_dyn->add_local_relative(obj, r_sym, elfcpp::R_X86_64_RELATIVE, +- this->got_, got_offset, 0); ++ this->got_, got_offset, 0, false); + break; + case GOT_TYPE_TLS_OFFSET: + rela_dyn->add_local(obj, r_sym, elfcpp::R_X86_64_TPOFF64, +@@ -1953,8 +1953,8 @@ Target_x86_64::Scan::local(Symbol_table* symtab, + const elfcpp::Sym<64, false>& lsym) + { + // A local STT_GNU_IFUNC symbol may require a PLT entry. +- if (lsym.get_st_type() == elfcpp::STT_GNU_IFUNC +- && this->reloc_needs_plt_for_ifunc(object, r_type)) ++ bool is_ifunc = lsym.get_st_type() == elfcpp::STT_GNU_IFUNC; ++ if (is_ifunc && this->reloc_needs_plt_for_ifunc(object, r_type)) + { + unsigned int r_sym = elfcpp::elf_r_sym<64>(reloc.get_r_info()); + target->make_local_ifunc_plt_entry(symtab, layout, object, r_sym); +@@ -1982,7 +1982,7 @@ Target_x86_64::Scan::local(Symbol_table* symtab, + elfcpp::R_X86_64_RELATIVE, + output_section, data_shndx, + reloc.get_r_offset(), +- reloc.get_r_addend()); ++ reloc.get_r_addend(), is_ifunc); + } + break; + +@@ -2058,7 +2058,7 @@ Target_x86_64::Scan::local(Symbol_table* symtab, + // lets function pointers compare correctly with shared + // libraries. Otherwise we would need an IRELATIVE reloc. + bool is_new; +- if (lsym.get_st_type() == elfcpp::STT_GNU_IFUNC) ++ if (is_ifunc) + is_new = got->add_local_plt(object, r_sym, GOT_TYPE_STANDARD); + else + is_new = got->add_local(object, r_sym, GOT_TYPE_STANDARD); +@@ -2076,7 +2076,7 @@ Target_x86_64::Scan::local(Symbol_table* symtab, + object->local_got_offset(r_sym, GOT_TYPE_STANDARD); + rela_dyn->add_local_relative(object, r_sym, + elfcpp::R_X86_64_RELATIVE, +- got, got_offset, 0); ++ got, got_offset, 0, is_ifunc); + } + else + { +@@ -3181,12 +3181,6 @@ Target_x86_64::Relocate::relocate_tls(const Relocate_info<64, false>* relinfo, + } + if (optimized_type == tls::TLSOPT_TO_IE) + { +- if (tls_segment == NULL) +- { +- gold_assert(parameters->errors()->error_count() > 0 +- || issue_undefined_symbol_error(gsym)); +- return; +- } + value = target->got_plt_section()->address() + got_offset; + this->tls_gd_to_ie(relinfo, relnum, tls_segment, rela, r_type, + value, view, address, view_size); +@@ -3867,42 +3861,51 @@ Target_x86_64::do_code_fill(section_size_type length) const + } + + // Nop sequences of various lengths. +- const char nop1[1] = { 0x90 }; // nop +- const char nop2[2] = { 0x66, 0x90 }; // xchg %ax %ax +- const char nop3[3] = { 0x0f, 0x1f, 0x00 }; // nop (%rax) +- const char nop4[4] = { 0x0f, 0x1f, 0x40, 0x00}; // nop 0(%rax) +- const char nop5[5] = { 0x0f, 0x1f, 0x44, 0x00, // nop 0(%rax,%rax,1) +- 0x00 }; +- const char nop6[6] = { 0x66, 0x0f, 0x1f, 0x44, // nopw 0(%rax,%rax,1) +- 0x00, 0x00 }; +- const char nop7[7] = { 0x0f, 0x1f, 0x80, 0x00, // nopl 0L(%rax) +- 0x00, 0x00, 0x00 }; +- const char nop8[8] = { 0x0f, 0x1f, 0x84, 0x00, // nopl 0L(%rax,%rax,1) +- 0x00, 0x00, 0x00, 0x00 }; +- const char nop9[9] = { 0x66, 0x0f, 0x1f, 0x84, // nopw 0L(%rax,%rax,1) +- 0x00, 0x00, 0x00, 0x00, +- 0x00 }; +- const char nop10[10] = { 0x66, 0x2e, 0x0f, 0x1f, // nopw %cs:0L(%rax,%rax,1) +- 0x84, 0x00, 0x00, 0x00, +- 0x00, 0x00 }; +- const char nop11[11] = { 0x66, 0x66, 0x2e, 0x0f, // data16 +- 0x1f, 0x84, 0x00, 0x00, // nopw %cs:0L(%rax,%rax,1) +- 0x00, 0x00, 0x00 }; +- const char nop12[12] = { 0x66, 0x66, 0x66, 0x2e, // data16; data16 +- 0x0f, 0x1f, 0x84, 0x00, // nopw %cs:0L(%rax,%rax,1) +- 0x00, 0x00, 0x00, 0x00 }; +- const char nop13[13] = { 0x66, 0x66, 0x66, 0x66, // data16; data16; data16 +- 0x2e, 0x0f, 0x1f, 0x84, // nopw %cs:0L(%rax,%rax,1) +- 0x00, 0x00, 0x00, 0x00, +- 0x00 }; +- const char nop14[14] = { 0x66, 0x66, 0x66, 0x66, // data16; data16; data16 +- 0x66, 0x2e, 0x0f, 0x1f, // data16 +- 0x84, 0x00, 0x00, 0x00, // nopw %cs:0L(%rax,%rax,1) +- 0x00, 0x00 }; +- const char nop15[15] = { 0x66, 0x66, 0x66, 0x66, // data16; data16; data16 +- 0x66, 0x66, 0x2e, 0x0f, // data16; data16 +- 0x1f, 0x84, 0x00, 0x00, // nopw %cs:0L(%rax,%rax,1) +- 0x00, 0x00, 0x00 }; ++ const char nop1[1] = { '\x90' }; // nop ++ const char nop2[2] = { '\x66', '\x90' }; // xchg %ax %ax ++ const char nop3[3] = { '\x0f', '\x1f', '\x00' }; // nop (%rax) ++ const char nop4[4] = { '\x0f', '\x1f', '\x40', // nop 0(%rax) ++ '\x00'}; ++ const char nop5[5] = { '\x0f', '\x1f', '\x44', // nop 0(%rax,%rax,1) ++ '\x00', '\x00' }; ++ const char nop6[6] = { '\x66', '\x0f', '\x1f', // nopw 0(%rax,%rax,1) ++ '\x44', '\x00', '\x00' }; ++ const char nop7[7] = { '\x0f', '\x1f', '\x80', // nopl 0L(%rax) ++ '\x00', '\x00', '\x00', ++ '\x00' }; ++ const char nop8[8] = { '\x0f', '\x1f', '\x84', // nopl 0L(%rax,%rax,1) ++ '\x00', '\x00', '\x00', ++ '\x00', '\x00' }; ++ const char nop9[9] = { '\x66', '\x0f', '\x1f', // nopw 0L(%rax,%rax,1) ++ '\x84', '\x00', '\x00', ++ '\x00', '\x00', '\x00' }; ++ const char nop10[10] = { '\x66', '\x2e', '\x0f', // nopw %cs:0L(%rax,%rax,1) ++ '\x1f', '\x84', '\x00', ++ '\x00', '\x00', '\x00', ++ '\x00' }; ++ const char nop11[11] = { '\x66', '\x66', '\x2e', // data16 ++ '\x0f', '\x1f', '\x84', // nopw %cs:0L(%rax,%rax,1) ++ '\x00', '\x00', '\x00', ++ '\x00', '\x00' }; ++ const char nop12[12] = { '\x66', '\x66', '\x66', // data16; data16 ++ '\x2e', '\x0f', '\x1f', // nopw %cs:0L(%rax,%rax,1) ++ '\x84', '\x00', '\x00', ++ '\x00', '\x00', '\x00' }; ++ const char nop13[13] = { '\x66', '\x66', '\x66', // data16; data16; data16 ++ '\x66', '\x2e', '\x0f', // nopw %cs:0L(%rax,%rax,1) ++ '\x1f', '\x84', '\x00', ++ '\x00', '\x00', '\x00', ++ '\x00' }; ++ const char nop14[14] = { '\x66', '\x66', '\x66', // data16; data16; data16 ++ '\x66', '\x66', '\x2e', // data16 ++ '\x0f', '\x1f', '\x84', // nopw %cs:0L(%rax,%rax,1) ++ '\x00', '\x00', '\x00', ++ '\x00', '\x00' }; ++ const char nop15[15] = { '\x66', '\x66', '\x66', // data16; data16; data16 ++ '\x66', '\x66', '\x66', // data16; data16 ++ '\x2e', '\x0f', '\x1f', // nopw %cs:0L(%rax,%rax,1) ++ '\x84', '\x00', '\x00', ++ '\x00', '\x00', '\x00' }; + + const char* nops[16] = { + NULL, +diff --git a/include/ChangeLog b/include/ChangeLog +index af96977..e32f0f9 100644 +--- a/include/ChangeLog ++++ b/include/ChangeLog +@@ -1,3 +1,11 @@ ++2011-12-19 Chung-Lin Tang ++ ++ Backport from mainline: ++ ++ 2011-12-19 Chung-Lin Tang ++ ++ * elf/mips.h (elf_mips_reloc_type): Add R_MIPS16_TLS_* entries. ++ + 2011-10-25 Alan Modra + + Apply mainline patches. +diff --git a/include/elf/mips.h b/include/elf/mips.h +index db5fa54..c2c5922 100644 +--- a/include/elf/mips.h ++++ b/include/elf/mips.h +@@ -98,7 +98,14 @@ START_RELOC_NUMBERS (elf_mips_reloc_type) + RELOC_NUMBER (R_MIPS16_CALL16, 103) + RELOC_NUMBER (R_MIPS16_HI16, 104) + RELOC_NUMBER (R_MIPS16_LO16, 105) +- FAKE_RELOC (R_MIPS16_max, 106) ++ RELOC_NUMBER (R_MIPS16_TLS_GD, 106) ++ RELOC_NUMBER (R_MIPS16_TLS_LDM, 107) ++ RELOC_NUMBER (R_MIPS16_TLS_DTPREL_HI16, 108) ++ RELOC_NUMBER (R_MIPS16_TLS_DTPREL_LO16, 109) ++ RELOC_NUMBER (R_MIPS16_TLS_GOTTPREL, 110) ++ RELOC_NUMBER (R_MIPS16_TLS_TPREL_HI16, 111) ++ RELOC_NUMBER (R_MIPS16_TLS_TPREL_LO16, 112) ++ FAKE_RELOC (R_MIPS16_max, 113) + /* These relocations are specific to VxWorks. */ + RELOC_NUMBER (R_MIPS_COPY, 126) + RELOC_NUMBER (R_MIPS_JUMP_SLOT, 127) +diff --git a/ld/ChangeLog b/ld/ChangeLog +index f5fa6ff..c290a68 100644 +--- a/ld/ChangeLog ++++ b/ld/ChangeLog +@@ -1,3 +1,8 @@ ++2011-12-20 Joseph Myers ++ ++ * emulparams/elf32bmip.sh (OTHER_SECTIONS): Put .mdebug.* and ++ .gcc_compiled_long* sections at address 0. ++ + 2011-11-02 Rainer Orth + + Backport from mainline: +diff --git a/ld/emulparams/elf32bmip.sh b/ld/emulparams/elf32bmip.sh +index 44a0b8a..f0fcd2c 100644 +--- a/ld/emulparams/elf32bmip.sh ++++ b/ld/emulparams/elf32bmip.sh +@@ -64,14 +64,14 @@ OTHER_BSS_SYMBOLS='_fbss = .;' + OTHER_SECTIONS=' + .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } + .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } +- .mdebug.abi32 : { KEEP(*(.mdebug.abi32)) } +- .mdebug.abiN32 : { KEEP(*(.mdebug.abiN32)) } +- .mdebug.abi64 : { KEEP(*(.mdebug.abi64)) } +- .mdebug.abiO64 : { KEEP(*(.mdebug.abiO64)) } +- .mdebug.eabi32 : { KEEP(*(.mdebug.eabi32)) } +- .mdebug.eabi64 : { KEEP(*(.mdebug.eabi64)) } +- .gcc_compiled_long32 : { KEEP(*(.gcc_compiled_long32)) } +- .gcc_compiled_long64 : { KEEP(*(.gcc_compiled_long64)) } ++ .mdebug.abi32 0 : { KEEP(*(.mdebug.abi32)) } ++ .mdebug.abiN32 0 : { KEEP(*(.mdebug.abiN32)) } ++ .mdebug.abi64 0 : { KEEP(*(.mdebug.abi64)) } ++ .mdebug.abiO64 0 : { KEEP(*(.mdebug.abiO64)) } ++ .mdebug.eabi32 0 : { KEEP(*(.mdebug.eabi32)) } ++ .mdebug.eabi64 0 : { KEEP(*(.mdebug.eabi64)) } ++ .gcc_compiled_long32 0 : { KEEP(*(.gcc_compiled_long32)) } ++ .gcc_compiled_long64 0 : { KEEP(*(.gcc_compiled_long64)) } + ' + ARCH=mips + MACHINE= +diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog +index 233d962..6318c4f 100644 +--- a/ld/testsuite/ChangeLog ++++ b/ld/testsuite/ChangeLog +@@ -1,3 +1,22 @@ ++2012-01-10 H.J. Lu ++ ++ Backport from mainline: ++ PR ld/13581 ++ * ld-x86-64/ilp32-4.s: New. ++ * ld-x86-64/ilp32-10.d: Likewise. ++ * ld-x86-64/ilp32-10.s: Likewise. ++ ++ * ld-x86-64/ilp32-4.d: Adjusted. ++ * ld-x86-64/ilp32-5.d: Likewise. ++ * ld-x86-64/ilp32-5.s: Likewise. ++ ++ * ld-x86-64/x86-64.exp: Run ilp32-10. ++ ++2011-12-01 Hans-Peter Nilsson ++ ++ * ld-cris/pic-gc-72.d: Revert last change to adjust for reverted ++ cause for last change. ++ + 2011-11-10 Matthew Gretton-Dann + + Apply mainline patches. +diff --git a/ld/testsuite/ld-cris/pic-gc-72.d b/ld/testsuite/ld-cris/pic-gc-72.d +index 7e72752..7c30980 100644 +--- a/ld/testsuite/ld-cris/pic-gc-72.d ++++ b/ld/testsuite/ld-cris/pic-gc-72.d +@@ -19,11 +19,10 @@ Contents of section .dynsym: + Contents of section .dynstr: + #... + Contents of section .text: +- 016e 0f050f05 .* ++ 0188 0f050f05 .* + Contents of section .dynamic: +- 2174 .* + #... + Contents of section .got: +- 21cc 74210000 00000000 00000000 .* ++ 21e4 8c210000 00000000 00000000 .* + Contents of section .data: +- 21d8 00000000 .* ++ 21f0 00000000 .* +diff --git a/ld/testsuite/ld-x86-64/ilp32-10.d b/ld/testsuite/ld-x86-64/ilp32-10.d +new file mode 100644 +index 0000000..43d9fbd +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/ilp32-10.d +@@ -0,0 +1,3 @@ ++#as: --x32 ++#ld: -shared -melf32_x86_64 ++#error: .*relocation R_X86_64_PC32 against undefined symbol `bar' can not be used when making a shared object; recompile with -fPIC +diff --git a/ld/testsuite/ld-x86-64/ilp32-10.s b/ld/testsuite/ld-x86-64/ilp32-10.s +new file mode 100644 +index 0000000..70e4a90 +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/ilp32-10.s +@@ -0,0 +1,3 @@ ++ .globl foo ++foo: ++ mov bar(%rip), %rax +diff --git a/ld/testsuite/ld-x86-64/ilp32-4.d b/ld/testsuite/ld-x86-64/ilp32-4.d +index 84dc7b2..92d8a67 100644 +--- a/ld/testsuite/ld-x86-64/ilp32-4.d ++++ b/ld/testsuite/ld-x86-64/ilp32-4.d +@@ -1,36 +1,30 @@ +-#source: start.s + #as: --x32 + #ld: -m elf32_x86_64 -shared --no-ld-generated-unwind-info + #readelf: -d -S --wide + +-There are 10 section headers, starting at offset 0x22c: ++There are 9 section headers, starting at offset 0x1d8: + + Section Headers: + \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al + \[ 0\] NULL 00000000 000000 000000 00 0 0 0 +- \[ 1\] .hash HASH 00000094 000094 000030 04 A 2 0 4 +- \[ 2\] .dynsym DYNSYM 000000c4 0000c4 000070 10 A 3 2 4 +- \[ 3\] .dynstr STRTAB 00000134 000134 00001d 00 A 0 0 1 +- \[ 4\] .rela.dyn RELA 00000154 000154 00000c 0c A 2 0 4 +- \[ 5\] .text PROGBITS 00000160 000160 000005 00 AX 0 0 4 +- \[ 6\] .dynamic DYNAMIC 00200168 000168 000078 08 WA 3 0 4 +- \[ 7\] .shstrtab STRTAB 00000000 0001e0 00004a 00 0 0 1 +- \[ 8\] .symtab SYMTAB 00000000 0003bc 0000e0 10 9 9 4 +- \[ 9\] .strtab STRTAB 00000000 00049c 000043 00 0 0 1 ++ \[ 1\] .hash HASH 00000094 000094 00002c 04 A 2 0 4 ++ \[ 2\] .dynsym DYNSYM 000000c0 0000c0 000060 10 A 3 2 4 ++ \[ 3\] .dynstr STRTAB 00000120 000120 000019 00 A 0 0 1 ++ \[ 4\] .text PROGBITS 0000013c 00013c 000001 00 AX 0 0 4 ++ \[ 5\] .dynamic DYNAMIC 00200140 000140 000058 08 WA 3 0 4 ++ \[ 6\] .shstrtab STRTAB 00000000 000198 000040 00 0 0 1 ++ \[ 7\] .symtab SYMTAB 00000000 000340 0000c0 10 8 8 4 ++ \[ 8\] .strtab STRTAB 00000000 000400 00003f 00 0 0 1 + Key to Flags: + W \(write\), A \(alloc\), X \(execute\), M \(merge\), S \(strings\), l \(large\) + I \(info\), L \(link order\), G \(group\), T \(TLS\), E \(exclude\), x \(unknown\) + O \(extra OS processing required\) o \(OS specific\), p \(processor specific\) + +-Dynamic section at offset 0x168 contains 10 entries: ++Dynamic section at offset 0x140 contains 6 entries: + Tag Type Name/Value + 0x00000004 \(HASH\) 0x94 +- 0x00000005 \(STRTAB\) 0x134 +- 0x00000006 \(SYMTAB\) 0xc4 +- 0x0000000a \(STRSZ\) 29 \(bytes\) ++ 0x00000005 \(STRTAB\) 0x120 ++ 0x00000006 \(SYMTAB\) 0xc0 ++ 0x0000000a \(STRSZ\) 25 \(bytes\) + 0x0000000b \(SYMENT\) 16 \(bytes\) +- 0x00000007 \(RELA\) 0x154 +- 0x00000008 \(RELASZ\) 12 \(bytes\) +- 0x00000009 \(RELAENT\) 12 \(bytes\) +- 0x00000016 \(TEXTREL\) 0x0 + 0x00000000 \(NULL\) 0x0 +diff --git a/ld/testsuite/ld-x86-64/ilp32-4.s b/ld/testsuite/ld-x86-64/ilp32-4.s +new file mode 100644 +index 0000000..5f270c7 +--- /dev/null ++++ b/ld/testsuite/ld-x86-64/ilp32-4.s +@@ -0,0 +1,3 @@ ++ .globl _start ++_start: ++ ret +diff --git a/ld/testsuite/ld-x86-64/ilp32-5.d b/ld/testsuite/ld-x86-64/ilp32-5.d +index e4673e5..4870c2b 100644 +--- a/ld/testsuite/ld-x86-64/ilp32-5.d ++++ b/ld/testsuite/ld-x86-64/ilp32-5.d +@@ -4,5 +4,5 @@ + + #... + [0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+ +-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_PC32 +[0-9a-f]+ +foo - 4 ++[0-9a-f]+ +[0-9a-f]+ +R_X86_64_GLOB_DAT +[0-9a-f]+ +foo \+ 0 + [0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +[0-9a-f]+ +foo \+ 0 +diff --git a/ld/testsuite/ld-x86-64/ilp32-5.s b/ld/testsuite/ld-x86-64/ilp32-5.s +index 0d97807..ef0c60e 100644 +--- a/ld/testsuite/ld-x86-64/ilp32-5.s ++++ b/ld/testsuite/ld-x86-64/ilp32-5.s +@@ -1,6 +1,6 @@ + .globl bar + bar: +- mov foo(%rip), %rax ++ mov foo@GOTPCREL(%rip), %rax + + .data + xxx: +diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp +index 77b081b..44d3e07 100644 +--- a/ld/testsuite/ld-x86-64/x86-64.exp ++++ b/ld/testsuite/ld-x86-64/x86-64.exp +@@ -207,6 +207,7 @@ run_dump_test "ilp32-6" + run_dump_test "ilp32-7" + run_dump_test "ilp32-8" + run_dump_test "ilp32-9" ++run_dump_test "ilp32-10" + run_dump_test "ia32-1" + run_dump_test "ia32-2" + run_dump_test "ia32-3" +diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog +index a445030..26f759e 100644 +--- a/opcodes/ChangeLog ++++ b/opcodes/ChangeLog +@@ -1,3 +1,8 @@ ++2011-11-25 Pierre Muller ++ ++ * mips-dis.c (print_insn_micromips): Rename local variable iprintf ++ to infprintf to avoid shadow warning. ++ + 2011-10-27 Peter Bergner + + * ppc-opc.c (powerpc_opcodes) fprintf_func; ++ const fprintf_ftype infprintf = info->fprintf_func; + const struct mips_opcode *op, *opend; + unsigned int lsb, msbd, msb; + void *is = info->stream; +@@ -2307,7 +2307,7 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + status = (*info->read_memory_func) (memaddr + 2, buffer, 2, info); + if (status != 0) + { +- iprintf (is, "micromips 0x%x", higher); ++ infprintf (is, "micromips 0x%x", higher); + (*info->memory_error_func) (status, memaddr + 2, info); + return -1; + } +@@ -2320,7 +2320,7 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + status = (*info->read_memory_func) (memaddr + 4, buffer, 2, info); + if (status != 0) + { +- iprintf (is, "micromips 0x%x", higher); ++ infprintf (is, "micromips 0x%x", higher); + (*info->memory_error_func) (status, memaddr + 4, info); + return -1; + } +@@ -2328,7 +2328,7 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + insn = bfd_getb16 (buffer); + else + insn = bfd_getl16 (buffer); +- iprintf (is, "0x%x%04x (48-bit insn)", higher, insn); ++ infprintf (is, "0x%x%04x (48-bit insn)", higher, insn); + + info->insn_type = dis_noninsn; + return 6; +@@ -2341,7 +2341,7 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + status = (*info->read_memory_func) (memaddr + 2, buffer, 2, info); + if (status != 0) + { +- iprintf (is, "micromips 0x%x", higher); ++ infprintf (is, "micromips 0x%x", higher); + (*info->memory_error_func) (status, memaddr + 2, info); + return -1; + } +@@ -2371,9 +2371,9 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + { + const char *s; + +- iprintf (is, "%s", op->name); ++ infprintf (is, "%s", op->name); + if (op->args[0] != '\0') +- iprintf (is, "\t"); ++ infprintf (is, "\t"); + + for (s = op->args; *s != '\0'; s++) + { +@@ -2382,37 +2382,37 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + case ',': + case '(': + case ')': +- iprintf (is, "%c", *s); ++ infprintf (is, "%c", *s); + break; + + case '.': + delta = GET_OP (insn, OFFSET10); + if (delta & 0x200) + delta |= ~0x3ff; +- iprintf (is, "%d", delta); ++ infprintf (is, "%d", delta); + break; + + case '1': +- iprintf (is, "0x%lx", GET_OP (insn, STYPE)); ++ infprintf (is, "0x%lx", GET_OP (insn, STYPE)); + break; + + case '<': +- iprintf (is, "0x%lx", GET_OP (insn, SHAMT)); ++ infprintf (is, "0x%lx", GET_OP (insn, SHAMT)); + break; + + case '\\': +- iprintf (is, "0x%lx", GET_OP (insn, 3BITPOS)); ++ infprintf (is, "0x%lx", GET_OP (insn, 3BITPOS)); + break; + + case '|': +- iprintf (is, "0x%lx", GET_OP (insn, TRAP)); ++ infprintf (is, "0x%lx", GET_OP (insn, TRAP)); + break; + + case '~': + delta = GET_OP (insn, OFFSET12); + if (delta & 0x800) + delta |= ~0x7ff; +- iprintf (is, "%d", delta); ++ infprintf (is, "%d", delta); + break; + + case 'a': +@@ -2433,34 +2433,34 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + case 'r': + case 's': + case 'v': +- iprintf (is, "%s", mips_gpr_names[GET_OP (insn, RS)]); ++ infprintf (is, "%s", mips_gpr_names[GET_OP (insn, RS)]); + break; + + case 'c': +- iprintf (is, "0x%lx", GET_OP (insn, CODE)); ++ infprintf (is, "0x%lx", GET_OP (insn, CODE)); + break; + + case 'd': +- iprintf (is, "%s", mips_gpr_names[GET_OP (insn, RD)]); ++ infprintf (is, "%s", mips_gpr_names[GET_OP (insn, RD)]); + break; + + case 'h': +- iprintf (is, "0x%lx", GET_OP (insn, PREFX)); ++ infprintf (is, "0x%lx", GET_OP (insn, PREFX)); + break; + + case 'i': + case 'u': +- iprintf (is, "0x%lx", GET_OP (insn, IMMEDIATE)); ++ infprintf (is, "0x%lx", GET_OP (insn, IMMEDIATE)); + break; + + case 'j': /* Same as i, but sign-extended. */ + case 'o': + delta = (GET_OP (insn, DELTA) ^ 0x8000) - 0x8000; +- iprintf (is, "%d", delta); ++ infprintf (is, "%d", delta); + break; + + case 'k': +- iprintf (is, "0x%x", GET_OP (insn, CACHE)); ++ infprintf (is, "0x%x", GET_OP (insn, CACHE)); + break; + + case 'n': +@@ -2472,26 +2472,26 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + if (s_reg_encode != 0) + { + if (s_reg_encode == 1) +- iprintf (is, "%s", mips_gpr_names[16]); ++ infprintf (is, "%s", mips_gpr_names[16]); + else if (s_reg_encode < 9) +- iprintf (is, "%s-%s", ++ infprintf (is, "%s-%s", + mips_gpr_names[16], + mips_gpr_names[15 + s_reg_encode]); + else if (s_reg_encode == 9) +- iprintf (is, "%s-%s,%s", ++ infprintf (is, "%s-%s,%s", + mips_gpr_names[16], + mips_gpr_names[23], + mips_gpr_names[30]); + else +- iprintf (is, "UNKNOWN"); ++ infprintf (is, "UNKNOWN"); + } + + if (immed & 0x10) /* For ra. */ + { + if (s_reg_encode == 0) +- iprintf (is, "%s", mips_gpr_names[31]); ++ infprintf (is, "%s", mips_gpr_names[31]); + else +- iprintf (is, ",%s", mips_gpr_names[31]); ++ infprintf (is, ",%s", mips_gpr_names[31]); + } + break; + } +@@ -2504,32 +2504,32 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + break; + + case 'q': +- iprintf (is, "0x%lx", GET_OP (insn, CODE2)); ++ infprintf (is, "0x%lx", GET_OP (insn, CODE2)); + break; + + case 't': + case 'w': +- iprintf (is, "%s", mips_gpr_names[GET_OP (insn, RT)]); ++ infprintf (is, "%s", mips_gpr_names[GET_OP (insn, RT)]); + break; + + case 'y': +- iprintf (is, "%s", mips_gpr_names[GET_OP (insn, RS3)]); ++ infprintf (is, "%s", mips_gpr_names[GET_OP (insn, RS3)]); + break; + + case 'z': +- iprintf (is, "%s", mips_gpr_names[0]); ++ infprintf (is, "%s", mips_gpr_names[0]); + break; + + case 'B': +- iprintf (is, "0x%lx", GET_OP (insn, CODE10)); ++ infprintf (is, "0x%lx", GET_OP (insn, CODE10)); + break; + + case 'C': +- iprintf (is, "0x%lx", GET_OP (insn, COPZ)); ++ infprintf (is, "0x%lx", GET_OP (insn, COPZ)); + break; + + case 'D': +- iprintf (is, "%s", mips_fpr_names[GET_OP (insn, FD)]); ++ infprintf (is, "%s", mips_fpr_names[GET_OP (insn, FD)]); + break; + + case 'E': +@@ -2540,7 +2540,7 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + 'T' format. Therefore, until we gain understanding of + cp2 register names, we can simply print the register + numbers. */ +- iprintf (is, "$%ld", GET_OP (insn, RT)); ++ infprintf (is, "$%ld", GET_OP (insn, RT)); + break; + + case 'G': +@@ -2559,44 +2559,44 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + case 0x000002fc: /* mtc0 */ + case 0x580000fc: /* dmfc0 */ + case 0x580002fc: /* dmtc0 */ +- iprintf (is, "%s", mips_cp0_names[GET_OP (insn, RS)]); ++ infprintf (is, "%s", mips_cp0_names[GET_OP (insn, RS)]); + break; + default: +- iprintf (is, "$%ld", GET_OP (insn, RS)); ++ infprintf (is, "$%ld", GET_OP (insn, RS)); + break; + } + break; + + case 'H': +- iprintf (is, "%ld", GET_OP (insn, SEL)); ++ infprintf (is, "%ld", GET_OP (insn, SEL)); + break; + + case 'K': +- iprintf (is, "%s", mips_hwr_names[GET_OP (insn, RS)]); ++ infprintf (is, "%s", mips_hwr_names[GET_OP (insn, RS)]); + break; + + case 'M': +- iprintf (is, "$fcc%ld", GET_OP (insn, CCC)); ++ infprintf (is, "$fcc%ld", GET_OP (insn, CCC)); + break; + + case 'N': +- iprintf (is, ++ infprintf (is, + (op->pinfo & (FP_D | FP_S)) != 0 + ? "$fcc%ld" : "$cc%ld", + GET_OP (insn, BCC)); + break; + + case 'R': +- iprintf (is, "%s", mips_fpr_names[GET_OP (insn, FR)]); ++ infprintf (is, "%s", mips_fpr_names[GET_OP (insn, FR)]); + break; + + case 'S': + case 'V': +- iprintf (is, "%s", mips_fpr_names[GET_OP (insn, FS)]); ++ infprintf (is, "%s", mips_fpr_names[GET_OP (insn, FS)]); + break; + + case 'T': +- iprintf (is, "%s", mips_fpr_names[GET_OP (insn, FT)]); ++ infprintf (is, "%s", mips_fpr_names[GET_OP (insn, FT)]); + break; + + case '+': +@@ -2606,18 +2606,18 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + { + case 'A': + lsb = GET_OP (insn, EXTLSB); +- iprintf (is, "0x%x", lsb); ++ infprintf (is, "0x%x", lsb); + break; + + case 'B': + msb = GET_OP (insn, INSMSB); +- iprintf (is, "0x%x", msb - lsb + 1); ++ infprintf (is, "0x%x", msb - lsb + 1); + break; + + case 'C': + case 'H': + msbd = GET_OP (insn, EXTMSBD); +- iprintf (is, "0x%x", msbd + 1); ++ infprintf (is, "0x%x", msbd + 1); + break; + + case 'D': +@@ -2637,30 +2637,30 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + mips_cp0sel_names_len, + cp0reg, sel); + if (n != NULL) +- iprintf (is, "%s", n->name); ++ infprintf (is, "%s", n->name); + else +- iprintf (is, "$%d,%d", cp0reg, sel); ++ infprintf (is, "$%d,%d", cp0reg, sel); + break; + } + + case 'E': + lsb = GET_OP (insn, EXTLSB) + 32; +- iprintf (is, "0x%x", lsb); ++ infprintf (is, "0x%x", lsb); + break; + + case 'F': + msb = GET_OP (insn, INSMSB) + 32; +- iprintf (is, "0x%x", msb - lsb + 1); ++ infprintf (is, "0x%x", msb - lsb + 1); + break; + + case 'G': + msbd = GET_OP (insn, EXTMSBD) + 32; +- iprintf (is, "0x%x", msbd + 1); ++ infprintf (is, "0x%x", msbd + 1); + break; + + default: + /* xgettext:c-format */ +- iprintf (is, ++ infprintf (is, + _("# internal disassembler error, " + "unrecognized modifier (+%c)"), + *s); +@@ -2674,111 +2674,111 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + switch (*s) + { + case 'a': /* global pointer. */ +- iprintf (is, "%s", mips_gpr_names[28]); ++ infprintf (is, "%s", mips_gpr_names[28]); + break; + + case 'b': + regno = micromips_to_32_reg_b_map[GET_OP (insn, MB)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'c': + regno = micromips_to_32_reg_c_map[GET_OP (insn, MC)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'd': + regno = micromips_to_32_reg_d_map[GET_OP (insn, MD)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'e': + regno = micromips_to_32_reg_e_map[GET_OP (insn, ME)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'f': + /* Save lastregno for "mt" to print out later. */ + lastregno = micromips_to_32_reg_f_map[GET_OP (insn, MF)]; +- iprintf (is, "%s", mips_gpr_names[lastregno]); ++ infprintf (is, "%s", mips_gpr_names[lastregno]); + break; + + case 'g': + regno = micromips_to_32_reg_g_map[GET_OP (insn, MG)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'h': + regno = micromips_to_32_reg_h_map[GET_OP (insn, MH)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'i': + regno = micromips_to_32_reg_i_map[GET_OP (insn, MI)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'j': +- iprintf (is, "%s", mips_gpr_names[GET_OP (insn, MJ)]); ++ infprintf (is, "%s", mips_gpr_names[GET_OP (insn, MJ)]); + break; + + case 'l': + regno = micromips_to_32_reg_l_map[GET_OP (insn, ML)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'm': + regno = micromips_to_32_reg_m_map[GET_OP (insn, MM)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'n': + regno = micromips_to_32_reg_n_map[GET_OP (insn, MN)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'p': + /* Save lastregno for "mt" to print out later. */ + lastregno = GET_OP (insn, MP); +- iprintf (is, "%s", mips_gpr_names[lastregno]); ++ infprintf (is, "%s", mips_gpr_names[lastregno]); + break; + + case 'q': + regno = micromips_to_32_reg_q_map[GET_OP (insn, MQ)]; +- iprintf (is, "%s", mips_gpr_names[regno]); ++ infprintf (is, "%s", mips_gpr_names[regno]); + break; + + case 'r': /* program counter. */ +- iprintf (is, "$pc"); ++ infprintf (is, "$pc"); + break; + + case 's': /* stack pointer. */ + lastregno = 29; +- iprintf (is, "%s", mips_gpr_names[29]); ++ infprintf (is, "%s", mips_gpr_names[29]); + break; + + case 't': +- iprintf (is, "%s", mips_gpr_names[lastregno]); ++ infprintf (is, "%s", mips_gpr_names[lastregno]); + break; + + case 'z': /* $0. */ +- iprintf (is, "%s", mips_gpr_names[0]); ++ infprintf (is, "%s", mips_gpr_names[0]); + break; + + case 'A': + /* Sign-extend the immediate. */ + immed = ((GET_OP (insn, IMMA) ^ 0x40) - 0x40) << 2; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'B': + immed = micromips_imm_b_map[GET_OP (insn, IMMB)]; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'C': + immed = micromips_imm_c_map[GET_OP (insn, IMMC)]; +- iprintf (is, "0x%lx", immed); ++ infprintf (is, "0x%lx", immed); + break; + + case 'D': +@@ -2797,50 +2797,50 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + + case 'F': + immed = GET_OP (insn, IMMF); +- iprintf (is, "0x%x", immed); ++ infprintf (is, "0x%x", immed); + break; + + case 'G': + immed = (insn >> MICROMIPSOP_SH_IMMG) + 1; + immed = (immed & MICROMIPSOP_MASK_IMMG) - 1; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'H': + immed = GET_OP (insn, IMMH) << 1; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'I': + immed = (insn >> MICROMIPSOP_SH_IMMI) + 1; + immed = (immed & MICROMIPSOP_MASK_IMMI) - 1; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'J': + immed = GET_OP (insn, IMMJ) << 2; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'L': + immed = GET_OP (insn, IMML); +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'M': + immed = (insn >> MICROMIPSOP_SH_IMMM) - 1; + immed = (immed & MICROMIPSOP_MASK_IMMM) + 1; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'N': + immed = GET_OP (insn, IMMN); + if (immed == 0) +- iprintf (is, "%s,%s", ++ infprintf (is, "%s,%s", + mips_gpr_names[16], + mips_gpr_names[31]); + else +- iprintf (is, "%s-%s,%s", ++ infprintf (is, "%s-%s,%s", + mips_gpr_names[16], + mips_gpr_names[16 + immed], + mips_gpr_names[31]); +@@ -2848,35 +2848,35 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + + case 'O': + immed = GET_OP (insn, IMMO); +- iprintf (is, "0x%x", immed); ++ infprintf (is, "0x%x", immed); + break; + + case 'P': + immed = GET_OP (insn, IMMP) << 2; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'Q': + /* Sign-extend the immediate. */ + immed = (GET_OP (insn, IMMQ) ^ 0x400000) - 0x400000; + immed <<= 2; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'U': + immed = GET_OP (insn, IMMU) << 2; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'W': + immed = GET_OP (insn, IMMW) << 2; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'X': + /* Sign-extend the immediate. */ + immed = (GET_OP (insn, IMMX) ^ 0x8) - 0x8; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + case 'Y': +@@ -2885,12 +2885,12 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + if (immed >= -2 && immed <= 1) + immed ^= 0x100; + immed = immed << 2; +- iprintf (is, "%d", immed); ++ infprintf (is, "%d", immed); + break; + + default: + /* xgettext:c-format */ +- iprintf (is, ++ infprintf (is, + _("# internal disassembler error, " + "unrecognized modifier (m%c)"), + *s); +@@ -2900,7 +2900,7 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + + default: + /* xgettext:c-format */ +- iprintf (is, ++ infprintf (is, + _("# internal disassembler error, " + "unrecognized modifier (%c)"), + *s); +@@ -2937,7 +2937,7 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info) + } + #undef GET_OP + +- iprintf (is, "0x%x", insn); ++ infprintf (is, "0x%x", insn); + info->insn_type = dis_noninsn; + + return length; --- binutils-2.22.orig/debian/patches/binutils-CVE-2014-8504.patch +++ binutils-2.22/debian/patches/binutils-CVE-2014-8504.patch @@ -0,0 +1,48 @@ +From 708d7d0d11f0f2d776171979aa3479e8e12a38a0 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Tue, 28 Oct 2014 10:48:14 +0000 +Subject: [PATCH] This patch fixes a flaw in the SREC parser which could cause a stack overflow + and potential secuiryt breach. + + PR binutils/17510 + * srec.c (srec_bad_byte): Increase size of buf to allow for + negative values. + (srec_scan): Use an unsigned char buffer to hold header bytes. + +[Ubuntu note: patch differs from upstream commit in that it drops the +changelog entry and the cosmetic whitespace changes to reduce patch +conflicts. -- sbeattie] + +CVE-2014-8504 +--- + bfd/ChangeLog | 8 ++++++++ + bfd/elf.c | 2 +- + bfd/peXXigen.c | 1 - + bfd/srec.c | 4 ++-- + 4 files changed, 11 insertions(+), 4 deletions(-) + +diff --git a/bfd/srec.c b/bfd/srec.c +index 9ed2080..5f9a546 100644 +--- a/bfd/srec.c ++++ b/bfd/srec.c +@@ -246,7 +246,7 @@ srec_bad_byte (bfd *abfd, + } + else + { +- char buf[10]; ++ char buf[40]; + + if (! ISPRINT (c)) + sprintf (buf, "\\%03o", (unsigned int) c); +@@ -452,7 +452,7 @@ srec_scan (bfd *abfd) + case 'S': + { + file_ptr pos; +- char hdr[3]; ++ unsigned char hdr[3]; + unsigned int bytes, min_bytes; + bfd_vma address; + bfd_byte *data; +-- +1.7.1 + --- binutils-2.22.orig/debian/patches/014_hash_style-gnu.patch +++ binutils-2.22/debian/patches/014_hash_style-gnu.patch @@ -0,0 +1,31 @@ +# DP: Default to --hash-gnu=both in ld.bfd and ld.gold. + +--- a/ld/ldmain.c ++++ b/ld/ldmain.c +@@ -287,6 +288,15 @@ + emulation = get_emulation (argc, argv); + ldemul_choose_mode (emulation); + default_target = ldemul_choose_target (argc, argv); ++ ++ /* Default to --hash-style=gnu */ ++ if (strcmp (default_target, "elf32-tradbigmips") != 0 ++ && strcmp (default_target, "elf32-tradlittlemips") != 0) ++ { ++ link_info.emit_gnu_hash = TRUE; ++ link_info.emit_hash = FALSE; ++ } ++ + config.maxpagesize = bfd_emul_get_maxpagesize (default_target); + config.commonpagesize = bfd_emul_get_commonpagesize (default_target); + lang_init (); +--- a/gold/options.h ++++ b/gold/options.h +@@ -794,7 +794,7 @@ + N_("Min fraction of empty buckets in dynamic hash"), + N_("FRACTION")); + +- DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "sysv", ++ DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "gnu", + N_("Dynamic hash style"), N_("[sysv,gnu,both]"), + {"sysv", "gnu", "both"}); + --- binutils-2.22.orig/debian/patches/binutils-CVE-2014-8503.patch +++ binutils-2.22/debian/patches/binutils-CVE-2014-8503.patch @@ -0,0 +1,33 @@ +From 0102ea8cec5fc509bba6c91df61b7ce23a799d32 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Thu, 30 Oct 2014 17:16:17 +0000 +Subject: [PATCH] Fixes a seg-fault in the ihex parser when it encounters a malformed ihex file. + + PR binutils/17512 + * ihex.c (ihex_scan): Fix typo in invocation of ihex_bad_byte. + +[Ubuntu note: patch differs from upstream commit in that it drops the +changelog entry to reduce patch conflicts. -- sbeattie] + +CVE-2014-8503 +--- + bfd/ChangeLog | 1 + + bfd/ihex.c | 2 +- + 2 files changed, 2 insertions(+), 1 deletions(-) + +diff --git a/bfd/ihex.c b/bfd/ihex.c +index 8d3590d..9b3b813 100644 +--- a/bfd/ihex.c ++++ b/bfd/ihex.c +@@ -321,7 +321,7 @@ ihex_scan (bfd *abfd) + { + if (! ISHEX (buf[i])) + { +- ihex_bad_byte (abfd, lineno, hdr[i], error); ++ ihex_bad_byte (abfd, lineno, buf[i], error); + goto error_return; + } + } +-- +1.7.1 + --- binutils-2.22.orig/debian/patches/gold-fuse-ld.diff +++ binutils-2.22/debian/patches/gold-fuse-ld.diff @@ -0,0 +1,22 @@ +# DP: gold: Add -fuse-ld= for GCC linker option compatibility. + +gold/ + +2013-01-07 H.J. Lu + + * options.h (General_options): Add -fuse-ld= for GCC linker + option compatibility. + +--- a/gold/options.h ++++ b/gold/options.h +@@ -1199,6 +1199,10 @@ class General_options + DEFINE_special(end_lib, options::TWO_DASHES, '\0', + N_("End a library "), NULL); + ++ DEFINE_string(fuse_ld, options::ONE_DASH, '\0', "", ++ N_("Ignored for GCC linker option compatibility"), ++ ""); ++ + // The -z options. + + DEFINE_bool(combreloc, options::DASH_Z, '\0', true, --- binutils-2.22.orig/debian/patches/pr13534-05.diff +++ binutils-2.22/debian/patches/pr13534-05.diff @@ -0,0 +1,61 @@ +commit 1c9170065b107672a47e467abb6807bba8adf28e +Author: Francois Gouget +Date: Tue Dec 20 18:48:52 2011 +0100 + + ar: Fix handling of archive elements larger than 2GB. + +diff --git a/binutils/ar.c b/binutils/ar.c +index 0310b6f..e47779f 100644 +--- a/binutils/ar.c ++++ b/binutils/ar.c +@@ -927,10 +927,10 @@ open_inarch (const char *archive_filename, const char *file) + static void + print_contents (bfd *abfd) + { +- size_t ncopied = 0; ++ bfd_size_type ncopied = 0; + char *cbuf = (char *) xmalloc (BUFSIZE); + struct stat buf; +- size_t size; ++ bfd_size_type size; + if (bfd_stat_arch_elt (abfd, &buf) != 0) + /* xgettext:c-format */ + fatal (_("internal stat error on %s"), bfd_get_filename (abfd)); +@@ -944,12 +944,12 @@ print_contents (bfd *abfd) + while (ncopied < size) + { + +- size_t nread; +- size_t tocopy = size - ncopied; ++ bfd_size_type nread; ++ bfd_size_type tocopy = size - ncopied; + if (tocopy > BUFSIZE) + tocopy = BUFSIZE; + +- nread = bfd_bread (cbuf, (bfd_size_type) tocopy, abfd); ++ nread = bfd_bread (cbuf, tocopy, abfd); + if (nread != tocopy) + /* xgettext:c-format */ + fatal (_("%s is not a valid archive"), +@@ -980,9 +980,9 @@ extract_file (bfd *abfd) + { + FILE *ostream; + char *cbuf = (char *) xmalloc (BUFSIZE); +- size_t nread, tocopy; +- size_t ncopied = 0; +- size_t size; ++ bfd_size_type nread, tocopy; ++ bfd_size_type ncopied = 0; ++ bfd_size_type size; + struct stat buf; + + if (bfd_stat_arch_elt (abfd, &buf) != 0) +@@ -1017,7 +1017,7 @@ extract_file (bfd *abfd) + if (tocopy > BUFSIZE) + tocopy = BUFSIZE; + +- nread = bfd_bread (cbuf, (bfd_size_type) tocopy, abfd); ++ nread = bfd_bread (cbuf, tocopy, abfd); + if (nread != tocopy) + /* xgettext:c-format */ + fatal (_("%s is not a valid archive"), --- binutils-2.22.orig/debian/patches/210-hjl-binutils-signed.patch +++ binutils-2.22/debian/patches/210-hjl-binutils-signed.patch @@ -0,0 +1,816 @@ +Description: objdump.c (disassemble_bytes,dump_reloc_set): Print addend as signed. +Author: H.J. Lu +Upstream status: hjl 2.21.51.0.8 +Original patch: binutils-signed-8.patch + +diff --git a/binutils/ChangeLog.addend b/binutils/ChangeLog.addend +new file mode 100644 +index 0000000..e0bd096 +--- /dev/null ++++ b/binutils/ChangeLog.addend +@@ -0,0 +1,4 @@ ++2007-06-22 H.J. Lu ++ ++ * objdump.c (disassemble_bytes): Print addend as signed. ++ (dump_reloc_set): Likewise. +diff --git a/binutils/objdump.c b/binutils/objdump.c +index 0be662f..dbbdad1 100644 +--- a/binutils/objdump.c ++++ b/binutils/objdump.c +@@ -1806,8 +1806,15 @@ disassemble_bytes (struct disassemble_info * inf, + + if (q->addend) + { +- printf ("+0x"); +- objdump_print_value (q->addend, inf, TRUE); ++ bfd_signed_vma addend = q->addend; ++ if (addend < 0) ++ { ++ printf ("-0x"); ++ addend = -addend; ++ } ++ else ++ printf ("+0x"); ++ objdump_print_value (addend, inf, TRUE); + } + + printf ("\n"); +@@ -2901,8 +2908,15 @@ dump_reloc_set (bfd *abfd, asection *sec, arelent **relpp, long relcount) + + if (q->addend) + { +- printf ("+0x"); +- bfd_printf_vma (abfd, q->addend); ++ bfd_signed_vma addend = q->addend; ++ if (addend < 0) ++ { ++ printf ("-0x"); ++ addend = -addend; ++ } ++ else ++ printf ("+0x"); ++ bfd_printf_vma (abfd, addend); + } + + printf ("\n"); +diff --git a/gas/testsuite/ChangeLog.addend b/gas/testsuite/ChangeLog.addend +new file mode 100644 +index 0000000..7b10497 +--- /dev/null ++++ b/gas/testsuite/ChangeLog.addend +@@ -0,0 +1,26 @@ ++2011-01-01 H.J. Lu ++ ++ * gas/i386/ilp32/mixed-mode-reloc64.d: Expect addend as signed. ++ * gas/i386/ilp32/reloc64.d: Likewise. ++ ++2010-10-01 H.J. Lu ++ ++ * gas/all/fwdexp.d: Expect addend as signed. ++ ++2007-06-22 H.J. Lu ++ ++ * gas/alpha/elf-reloc-1.d: Expect addend as signed. ++ * gas/i386/mixed-mode-reloc64.d: Likewise. ++ * gas/i386/reloc64.d: Likewise. ++ * gas/ia64/pcrel.d: Likewise. ++ * gas/mips/branch-misc-2-64.d: Likewise. ++ * gas/mips/branch-misc-2pic-64.d: Likewise. ++ * gas/mips/ldstla-n64-sym32.d: Likewise. ++ * gas/mips/mips16-hilo-n32.d: Likewise. ++ * gas/ppc/astest.d: Likewise. ++ * gas/ppc/astest2.d: Likewise. ++ * gas/ppc/astest2_64.d: Likewise. ++ * gas/ppc/astest64.d: Likewise. ++ * gas/ppc/test1elf32.d: Likewise. ++ * gas/ppc/test1elf64.d: Likewise. ++ * gas/sparc/reloc64.d: Likewise. +diff --git a/gas/testsuite/gas/all/fwdexp.d b/gas/testsuite/gas/all/fwdexp.d +index 222dab2..5c16ea9 100644 +--- a/gas/testsuite/gas/all/fwdexp.d ++++ b/gas/testsuite/gas/all/fwdexp.d +@@ -5,7 +5,7 @@ + + RELOCATION RECORDS FOR .* + OFFSET +TYPE +VALUE +-0+ .*(\.data|i)(|\+0xf+e|\+0xf+c|\+0xf+8) ++0+ .*(\.data|i)(|\+0xf+e|\+0xf+c|\+0xf+8|-0x0*2|-0x0*4|-0x0*8) + + Contents of section .* + 0+ (0+|feff|fffe|fcffffff|fffffffc|f8ffffff|f8ffffff ffffffff|ffffffff fffffff8) .* +diff --git a/gas/testsuite/gas/alpha/elf-reloc-1.d b/gas/testsuite/gas/alpha/elf-reloc-1.d +index 3985975..69a16b7 100644 +--- a/gas/testsuite/gas/alpha/elf-reloc-1.d ++++ b/gas/testsuite/gas/alpha/elf-reloc-1.d +@@ -16,6 +16,6 @@ OFFSET TYPE VALUE + 0*000001c GPRELHIGH d + 0*0000020 GPRELLOW e + 0*0000024 GPDISP \.text\+0x0*0000008 +-0*0000030 GPDISP \.text\+0xf*ffffff8 ++0*0000030 GPDISP \.text-0x0*0000008 + + +diff --git a/gas/testsuite/gas/i386/ilp32/mixed-mode-reloc64.d b/gas/testsuite/gas/i386/ilp32/mixed-mode-reloc64.d +index c54b7d3..a48c502 100644 +--- a/gas/testsuite/gas/i386/ilp32/mixed-mode-reloc64.d ++++ b/gas/testsuite/gas/i386/ilp32/mixed-mode-reloc64.d +@@ -7,8 +7,8 @@ + RELOCATION RECORDS FOR \[.text\]: + OFFSET[ ]+TYPE[ ]+VALUE[ ]* + [0-9a-f]+[ ]+R_X86_64_GOT32[ ]+xtrn[ ]* +-[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn\+0xf+c[ ]* ++[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn-0x0*4[ ]* + [0-9a-f]+[ ]+R_X86_64_GOT32[ ]+xtrn[ ]* +-[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn\+0xf+c[ ]* ++[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn-0x0*4[ ]* + [0-9a-f]+[ ]+R_X86_64_GOT32[ ]+xtrn[ ]* +-[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn\+0xf+c[ ]* ++[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn-0x0*4[ ]* +diff --git a/gas/testsuite/gas/i386/ilp32/reloc64.d b/gas/testsuite/gas/i386/ilp32/reloc64.d +index 08c15e4..af75c51 100644 +--- a/gas/testsuite/gas/i386/ilp32/reloc64.d ++++ b/gas/testsuite/gas/i386/ilp32/reloc64.d +@@ -14,10 +14,10 @@ Disassembly of section \.text: + .*[ ]+R_X86_64_PC32[ ]+xtrn\+0x0*2 + .*[ ]+R_X86_64_PC16[ ]+xtrn\+0x0*2 + .*[ ]+R_X86_64_PC8[ ]+xtrn\+0x0*1 +-.*[ ]+R_X86_64_PC32[ ]+xtrn\+0xf+c +-.*[ ]+R_X86_64_PC32[ ]+xtrn\+0xf+c +-.*[ ]+R_X86_64_PC32[ ]+xtrn\+0xf+c +-.*[ ]+R_X86_64_PC8[ ]+xtrn\+0xf+f ++.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4 ++.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4 ++.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4 ++.*[ ]+R_X86_64_PC8[ ]+xtrn-0x0*1 + .*[ ]+R_X86_64_GOT32[ ]+xtrn + .*[ ]+R_X86_64_GOT32[ ]+xtrn + .*[ ]+R_X86_64_GOT32[ ]+xtrn +@@ -26,31 +26,31 @@ Disassembly of section \.text: + .*[ ]+R_X86_64_GOTPCREL[ ]+xtrn + .*[ ]+R_X86_64_GOTPCREL[ ]+xtrn + .*[ ]+R_X86_64_GOTPCREL[ ]+xtrn +-.*[ ]+R_X86_64_GOTPCREL[ ]+xtrn\+0xf+c ++.*[ ]+R_X86_64_GOTPCREL[ ]+xtrn-0x0*4 + .*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_\+0x0*2 +-.*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_\+0xf+c +-.*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_\+0xf+c ++.*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_-0x0*4 ++.*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_-0x0*4 + .*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_\+0x0*2 + .*[ ]+R_X86_64_PLT32[ ]+xtrn + .*[ ]+R_X86_64_PLT32[ ]+xtrn + .*[ ]+R_X86_64_PLT32[ ]+xtrn + .*[ ]+R_X86_64_PLT32[ ]+xtrn +-.*[ ]+R_X86_64_PLT32[ ]+xtrn\+0xf+c ++.*[ ]+R_X86_64_PLT32[ ]+xtrn-0x0*4 + .*[ ]+R_X86_64_TLSGD[ ]+xtrn + .*[ ]+R_X86_64_TLSGD[ ]+xtrn + .*[ ]+R_X86_64_TLSGD[ ]+xtrn + .*[ ]+R_X86_64_TLSGD[ ]+xtrn +-.*[ ]+R_X86_64_TLSGD[ ]+xtrn\+0xf+c ++.*[ ]+R_X86_64_TLSGD[ ]+xtrn-0x0*4 + .*[ ]+R_X86_64_GOTTPOFF[ ]+xtrn + .*[ ]+R_X86_64_GOTTPOFF[ ]+xtrn + .*[ ]+R_X86_64_GOTTPOFF[ ]+xtrn + .*[ ]+R_X86_64_GOTTPOFF[ ]+xtrn +-.*[ ]+R_X86_64_GOTTPOFF[ ]+xtrn\+0xf+c ++.*[ ]+R_X86_64_GOTTPOFF[ ]+xtrn-0x0*4 + .*[ ]+R_X86_64_TLSLD[ ]+xtrn + .*[ ]+R_X86_64_TLSLD[ ]+xtrn + .*[ ]+R_X86_64_TLSLD[ ]+xtrn + .*[ ]+R_X86_64_TLSLD[ ]+xtrn +-.*[ ]+R_X86_64_TLSLD[ ]+xtrn\+0xf+c ++.*[ ]+R_X86_64_TLSLD[ ]+xtrn-0x0*4 + .*[ ]+R_X86_64_DTPOFF32[ ]+xtrn + .*[ ]+R_X86_64_DTPOFF32[ ]+xtrn + .*[ ]+R_X86_64_DTPOFF32[ ]+xtrn +diff --git a/gas/testsuite/gas/i386/mixed-mode-reloc64.d b/gas/testsuite/gas/i386/mixed-mode-reloc64.d +index dc50e43..9b82cb5 100644 +--- a/gas/testsuite/gas/i386/mixed-mode-reloc64.d ++++ b/gas/testsuite/gas/i386/mixed-mode-reloc64.d +@@ -7,8 +7,8 @@ + RELOCATION RECORDS FOR \[.text\]: + OFFSET[ ]+TYPE[ ]+VALUE[ ]* + [0-9a-f]+[ ]+R_X86_64_GOT32[ ]+xtrn[ ]* +-[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn\+0xf+c[ ]* ++[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn-0x0*4[ ]* + [0-9a-f]+[ ]+R_X86_64_GOT32[ ]+xtrn[ ]* +-[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn\+0xf+c[ ]* ++[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn-0x0*4[ ]* + [0-9a-f]+[ ]+R_X86_64_GOT32[ ]+xtrn[ ]* +-[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn\+0xf+c[ ]* ++[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+xtrn-0x0*4[ ]* +diff --git a/gas/testsuite/gas/i386/reloc64.d b/gas/testsuite/gas/i386/reloc64.d +index 5c14019..b4780d4 100644 +--- a/gas/testsuite/gas/i386/reloc64.d ++++ b/gas/testsuite/gas/i386/reloc64.d +@@ -16,33 +16,33 @@ Disassembly of section \.text: + .*[ ]+R_X86_64_PC32[ ]+xtrn\+0x0*2 + .*[ ]+R_X86_64_PC16[ ]+xtrn\+0x0*2 + .*[ ]+R_X86_64_PC8[ ]+xtrn\+0x0*1 +-.*[ ]+R_X86_64_PC32[ ]+xtrn\+0xf+c +-.*[ ]+R_X86_64_PC32[ ]+xtrn\+0xf+c +-.*[ ]+R_X86_64_PC32[ ]+xtrn\+0xf+c +-.*[ ]+R_X86_64_PC8[ ]+xtrn\+0xf+f ++.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4 ++.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4 ++.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4 ++.*[ ]+R_X86_64_PC8[ ]+xtrn-0x0*1 + .*[ ]+R_X86_64_GOT64[ ]+xtrn + .*[ ]+R_X86_64_GOT32[ ]+xtrn + .*[ ]+R_X86_64_GOT32[ ]+xtrn + .*[ ]+R_X86_64_GOTOFF64[ ]+xtrn + .*[ ]+R_X86_64_GOTPCREL[ ]+xtrn + .*[ ]+R_X86_64_GOTPCREL[ ]+xtrn +-.*[ ]+R_X86_64_GOTPCREL[ ]+xtrn\+0xf+c ++.*[ ]+R_X86_64_GOTPCREL[ ]+xtrn-0x0*4 + .*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_\+0x0*2 +-.*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_\+0xf+c +-.*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_\+0xf+c ++.*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_-0x0*4 ++.*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_-0x0*4 + .*[ ]+R_X86_64_GOTPC32[ ]+_GLOBAL_OFFSET_TABLE_\+0x0*2 + .*[ ]+R_X86_64_PLT32[ ]+xtrn + .*[ ]+R_X86_64_PLT32[ ]+xtrn +-.*[ ]+R_X86_64_PLT32[ ]+xtrn\+0xf+c ++.*[ ]+R_X86_64_PLT32[ ]+xtrn-0x0*4 + .*[ ]+R_X86_64_TLSGD[ ]+xtrn + .*[ ]+R_X86_64_TLSGD[ ]+xtrn +-.*[ ]+R_X86_64_TLSGD[ ]+xtrn\+0xf+c ++.*[ ]+R_X86_64_TLSGD[ ]+xtrn-0x0*4 + .*[ ]+R_X86_64_GOTTPOFF[ ]+xtrn + .*[ ]+R_X86_64_GOTTPOFF[ ]+xtrn +-.*[ ]+R_X86_64_GOTTPOFF[ ]+xtrn\+0xf+c ++.*[ ]+R_X86_64_GOTTPOFF[ ]+xtrn-0x0*4 + .*[ ]+R_X86_64_TLSLD[ ]+xtrn + .*[ ]+R_X86_64_TLSLD[ ]+xtrn +-.*[ ]+R_X86_64_TLSLD[ ]+xtrn\+0xf+c ++.*[ ]+R_X86_64_TLSLD[ ]+xtrn-0x0*4 + .*[ ]+R_X86_64_DTPOFF64[ ]+xtrn + .*[ ]+R_X86_64_DTPOFF32[ ]+xtrn + .*[ ]+R_X86_64_DTPOFF32[ ]+xtrn +diff --git a/gas/testsuite/gas/ia64/pcrel.d b/gas/testsuite/gas/ia64/pcrel.d +index 674060d..a01c006 100644 +--- a/gas/testsuite/gas/ia64/pcrel.d ++++ b/gas/testsuite/gas/ia64/pcrel.d +@@ -9,28 +9,28 @@ OFFSET[[:space:]]+TYPE[[:space:]]+VALUE[[:space:]]* + 0+10[[:space:]]+PCREL22[[:space:]]+esym + 0+20[[:space:]]+PCREL22[[:space:]]+esym\+0x0+20 + 0+30[[:space:]]+PCREL22[[:space:]]+esym +-0+40[[:space:]]+PCREL22[[:space:]]+esym\+0xf+e0 ++0+40[[:space:]]+PCREL22[[:space:]]+esym-0x0+20 + + RELOCATION RECORDS FOR \[\.movl\]: + OFFSET[[:space:]]+TYPE[[:space:]]+VALUE[[:space:]]* + 0+12[[:space:]]+PCREL64I[[:space:]]+esym + 0+22[[:space:]]+PCREL64I[[:space:]]+esym\+0x0+20 + 0+32[[:space:]]+PCREL64I[[:space:]]+esym +-0+42[[:space:]]+PCREL64I[[:space:]]+esym\+0xf+e0 ++0+42[[:space:]]+PCREL64I[[:space:]]+esym-0x0+20 + + RELOCATION RECORDS FOR \[\.data8\]: + OFFSET[[:space:]]+TYPE[[:space:]]+VALUE[[:space:]]* + 0+10[[:space:]]+PCREL64[LM]SB[[:space:]]+esym + 0+20[[:space:]]+PCREL64[LM]SB[[:space:]]+esym\+0x0+20 + 0+30[[:space:]]+PCREL64[LM]SB[[:space:]]+esym +-0+40[[:space:]]+PCREL64[LM]SB[[:space:]]+esym\+0xf+e0 ++0+40[[:space:]]+PCREL64[LM]SB[[:space:]]+esym-0x0+20 + + RELOCATION RECORDS FOR \[\.data4\]: + OFFSET[[:space:]]+TYPE[[:space:]]+VALUE[[:space:]]* + 0+10[[:space:]]+PCREL32[LM]SB[[:space:]]+esym + 0+20[[:space:]]+PCREL32[LM]SB[[:space:]]+esym\+0x0+20 + 0+30[[:space:]]+PCREL32[LM]SB[[:space:]]+esym +-0+40[[:space:]]+PCREL32[LM]SB[[:space:]]+esym\+0xf+e0 ++0+40[[:space:]]+PCREL32[LM]SB[[:space:]]+esym-0x0+20 + + + Contents of section \.mov: +diff --git a/gas/testsuite/gas/mips/branch-misc-2-64.d b/gas/testsuite/gas/mips/branch-misc-2-64.d +index 064c42f..b540b8a 100644 +--- a/gas/testsuite/gas/mips/branch-misc-2-64.d ++++ b/gas/testsuite/gas/mips/branch-misc-2-64.d +@@ -13,51 +13,51 @@ Disassembly of section .text: + \.\.\. + \.\.\. + 0+003c <[^>]*> 04110000 bal 0000000000000040 +-[ ]*3c: R_MIPS_PC16 g1\+0xfffffffffffffffc +-[ ]*3c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*3c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*3c: R_MIPS_PC16 g1-0x4 ++[ ]*3c: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*3c: R_MIPS_NONE \*ABS\*-0x4 + 0+0040 <[^>]*> 00000000 nop + 0+0044 <[^>]*> 04110000 bal 0000000000000048 +-[ ]*44: R_MIPS_PC16 g2\+0xfffffffffffffffc +-[ ]*44: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*44: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*44: R_MIPS_PC16 g2-0x4 ++[ ]*44: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*44: R_MIPS_NONE \*ABS\*-0x4 + 0+0048 <[^>]*> 00000000 nop + 0+004c <[^>]*> 04110000 bal 0000000000000050 +-[ ]*4c: R_MIPS_PC16 g3\+0xfffffffffffffffc +-[ ]*4c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*4c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*4c: R_MIPS_PC16 g3-0x4 ++[ ]*4c: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*4c: R_MIPS_NONE \*ABS\*-0x4 + 0+0050 <[^>]*> 00000000 nop + 0+0054 <[^>]*> 04110000 bal 0000000000000058 +-[ ]*54: R_MIPS_PC16 g4\+0xfffffffffffffffc +-[ ]*54: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*54: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*54: R_MIPS_PC16 g4-0x4 ++[ ]*54: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*54: R_MIPS_NONE \*ABS\*-0x4 + 0+0058 <[^>]*> 00000000 nop + 0+005c <[^>]*> 04110000 bal 0000000000000060 +-[ ]*5c: R_MIPS_PC16 g5\+0xfffffffffffffffc +-[ ]*5c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*5c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*5c: R_MIPS_PC16 g5-0x4 ++[ ]*5c: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*5c: R_MIPS_NONE \*ABS\*-0x4 + 0+0060 <[^>]*> 00000000 nop + 0+0064 <[^>]*> 04110000 bal 0000000000000068 +-[ ]*64: R_MIPS_PC16 g6\+0xfffffffffffffffc +-[ ]*64: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*64: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*64: R_MIPS_PC16 g6-0x4 ++[ ]*64: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*64: R_MIPS_NONE \*ABS\*-0x4 + 0+0068 <[^>]*> 00000000 nop + \.\.\. + \.\.\. + \.\.\. + 0+00a8 <[^>]*> 10000000 b 00000000000000ac +-[ ]*a8: R_MIPS_PC16 x1\+0xfffffffffffffffc +-[ ]*a8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*a8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*a8: R_MIPS_PC16 x1-0x4 ++[ ]*a8: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*a8: R_MIPS_NONE \*ABS\*-0x4 + 0+00ac <[^>]*> 00000000 nop + 0+00b0 <[^>]*> 10000000 b 00000000000000b4 +-[ ]*b0: R_MIPS_PC16 x2\+0xfffffffffffffffc +-[ ]*b0: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*b0: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*b0: R_MIPS_PC16 x2-0x4 ++[ ]*b0: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*b0: R_MIPS_NONE \*ABS\*-0x4 + 0+00b4 <[^>]*> 00000000 nop + 0+00b8 <[^>]*> 10000000 b 00000000000000bc +-[ ]*b8: R_MIPS_PC16 \.data\+0xfffffffffffffffc +-[ ]*b8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*b8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*b8: R_MIPS_PC16 \.data-0x4 ++[ ]*b8: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*b8: R_MIPS_NONE \*ABS\*-0x4 + 0+00bc <[^>]*> 00000000 nop + \.\.\. +diff --git a/gas/testsuite/gas/mips/branch-misc-2pic-64.d b/gas/testsuite/gas/mips/branch-misc-2pic-64.d +index 6b8720d..3cb292d 100644 +--- a/gas/testsuite/gas/mips/branch-misc-2pic-64.d ++++ b/gas/testsuite/gas/mips/branch-misc-2pic-64.d +@@ -13,51 +13,51 @@ Disassembly of section .text: + \.\.\. + \.\.\. + 0+003c <[^>]*> 04110000 bal 0000000000000040 +-[ ]*3c: R_MIPS_PC16 g1\+0xfffffffffffffffc +-[ ]*3c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*3c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*3c: R_MIPS_PC16 g1-0x4 ++[ ]*3c: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*3c: R_MIPS_NONE \*ABS\*-0x4 + 0+0040 <[^>]*> 00000000 nop + 0+0044 <[^>]*> 04110000 bal 0000000000000048 +-[ ]*44: R_MIPS_PC16 g2\+0xfffffffffffffffc +-[ ]*44: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*44: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*44: R_MIPS_PC16 g2-0x4 ++[ ]*44: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*44: R_MIPS_NONE \*ABS\*-0x4 + 0+0048 <[^>]*> 00000000 nop + 0+004c <[^>]*> 04110000 bal 0000000000000050 +-[ ]*4c: R_MIPS_PC16 g3\+0xfffffffffffffffc +-[ ]*4c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*4c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*4c: R_MIPS_PC16 g3-0x4 ++[ ]*4c: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*4c: R_MIPS_NONE \*ABS\*-0x4 + 0+0050 <[^>]*> 00000000 nop + 0+0054 <[^>]*> 04110000 bal 0000000000000058 +-[ ]*54: R_MIPS_PC16 g4\+0xfffffffffffffffc +-[ ]*54: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*54: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*54: R_MIPS_PC16 g4-0x4 ++[ ]*54: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*54: R_MIPS_NONE \*ABS\*-0x4 + 0+0058 <[^>]*> 00000000 nop + 0+005c <[^>]*> 04110000 bal 0000000000000060 +-[ ]*5c: R_MIPS_PC16 g5\+0xfffffffffffffffc +-[ ]*5c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*5c: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*5c: R_MIPS_PC16 g5-0x4 ++[ ]*5c: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*5c: R_MIPS_NONE \*ABS\*-0x4 + 0+0060 <[^>]*> 00000000 nop + 0+0064 <[^>]*> 04110000 bal 0000000000000068 +-[ ]*64: R_MIPS_PC16 g6\+0xfffffffffffffffc +-[ ]*64: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*64: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*64: R_MIPS_PC16 g6-0x4 ++[ ]*64: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*64: R_MIPS_NONE \*ABS\*-0x4 + 0+0068 <[^>]*> 00000000 nop + \.\.\. + \.\.\. + \.\.\. + 0+00a8 <[^>]*> 10000000 b 00000000000000ac +-[ ]*a8: R_MIPS_PC16 x1\+0xfffffffffffffffc +-[ ]*a8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*a8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*a8: R_MIPS_PC16 x1-0x4 ++[ ]*a8: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*a8: R_MIPS_NONE \*ABS\*-0x4 + 0+00ac <[^>]*> 00000000 nop + 0+00b0 <[^>]*> 10000000 b 00000000000000b4 +-[ ]*b0: R_MIPS_PC16 x2\+0xfffffffffffffffc +-[ ]*b0: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*b0: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*b0: R_MIPS_PC16 x2-0x4 ++[ ]*b0: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*b0: R_MIPS_NONE \*ABS\*-0x4 + 0+00b4 <[^>]*> 00000000 nop + 0+00b8 <[^>]*> 10000000 b 00000000000000bc +-[ ]*b8: R_MIPS_PC16 \.data\+0xfffffffffffffffc +-[ ]*b8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc +-[ ]*b8: R_MIPS_NONE \*ABS\*\+0xfffffffffffffffc ++[ ]*b8: R_MIPS_PC16 \.data-0x4 ++[ ]*b8: R_MIPS_NONE \*ABS\*-0x4 ++[ ]*b8: R_MIPS_NONE \*ABS\*-0x4 + 0+00bc <[^>]*> 00000000 nop + \.\.\. +diff --git a/gas/testsuite/gas/mips/ldstla-n64-sym32.d b/gas/testsuite/gas/mips/ldstla-n64-sym32.d +index 8d30cfb..066d749 100644 +--- a/gas/testsuite/gas/mips/ldstla-n64-sym32.d ++++ b/gas/testsuite/gas/mips/ldstla-n64-sym32.d +@@ -196,19 +196,19 @@ Disassembly .*: + .*: R_MIPS_NONE .* + .* daddu a0,a0,v1 + .* lui a0,0x0 +-.*: R_MIPS_HI16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_HI16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* d?addiu a0,a0,0 +-.*: R_MIPS_LO16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_LO16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* lui a0,0x0 +-.*: R_MIPS_HI16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_HI16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* d?addiu a0,a0,0 +-.*: R_MIPS_LO16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_LO16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* daddu a0,a0,v1 +@@ -406,20 +406,20 @@ Disassembly .*: + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* lui a0,0x0 +-.*: R_MIPS_HI16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_HI16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* lw a0,0\(a0\) +-.*: R_MIPS_LO16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_LO16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* lui a0,0x0 +-.*: R_MIPS_HI16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_HI16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* daddu a0,a0,v1 + .* lw a0,0\(a0\) +-.*: R_MIPS_LO16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_LO16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + # +@@ -616,20 +616,20 @@ Disassembly .*: + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* lui at,0x0 +-.*: R_MIPS_HI16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_HI16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* sw a0,0\(at\) +-.*: R_MIPS_LO16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_LO16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* lui at,0x0 +-.*: R_MIPS_HI16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_HI16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* daddu at,at,v1 + .* sw a0,0\(at\) +-.*: R_MIPS_LO16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_LO16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + # +@@ -880,21 +880,21 @@ Disassembly .*: + .* swl a0,0\(at\) + .* swr a0,3\(at\) + .* lui at,0x0 +-.*: R_MIPS_HI16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_HI16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* d?addiu at,at,0 +-.*: R_MIPS_LO16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_LO16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* swl a0,0\(at\) + .* swr a0,3\(at\) + .* lui at,0x0 +-.*: R_MIPS_HI16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_HI16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* d?addiu at,at,0 +-.*: R_MIPS_LO16 extern\+0xfffffffffffcc000 ++.*: R_MIPS_LO16 extern-0x34000 + .*: R_MIPS_NONE .* + .*: R_MIPS_NONE .* + .* daddu at,at,v1 +diff --git a/gas/testsuite/gas/mips/mips16-hilo-n32.d b/gas/testsuite/gas/mips/mips16-hilo-n32.d +index 2e3c8a1..5ac680d 100644 +--- a/gas/testsuite/gas/mips/mips16-hilo-n32.d ++++ b/gas/testsuite/gas/mips/mips16-hilo-n32.d +@@ -141,45 +141,45 @@ Disassembly of section \.text: + 13c: f400 3480 sll a0,16 + 140: f010 4c00 addiu a0,-32768 + 144: f000 6c00 li a0,0 +- 144: R_MIPS16_HI16 \.data\+0xffff8000 ++ 144: R_MIPS16_HI16 \.data-0x8000 + 148: f400 3480 sll a0,16 + 14c: f000 4c00 addiu a0,0 +- 14c: R_MIPS16_LO16 \.data\+0xffff8000 ++ 14c: R_MIPS16_LO16 \.data-0x8000 + 150: f000 6c00 li a0,0 +- 150: R_MIPS16_HI16 \.data\+0xffff8004 ++ 150: R_MIPS16_HI16 \.data-0x7ffc + 154: f400 3480 sll a0,16 + 158: f000 4c00 addiu a0,0 +- 158: R_MIPS16_LO16 \.data\+0xffff8004 ++ 158: R_MIPS16_LO16 \.data-0x7ffc + 15c: f000 6c00 li a0,0 +- 15c: R_MIPS16_HI16 big_external_data_label\+0xffff8000 ++ 15c: R_MIPS16_HI16 big_external_data_label-0x8000 + 160: f400 3480 sll a0,16 + 164: f000 4c00 addiu a0,0 +- 164: R_MIPS16_LO16 big_external_data_label\+0xffff8000 ++ 164: R_MIPS16_LO16 big_external_data_label-0x8000 + 168: f000 6c00 li a0,0 +- 168: R_MIPS16_HI16 small_external_data_label\+0xffff8000 ++ 168: R_MIPS16_HI16 small_external_data_label-0x8000 + 16c: f400 3480 sll a0,16 + 170: f000 4c00 addiu a0,0 +- 170: R_MIPS16_LO16 small_external_data_label\+0xffff8000 ++ 170: R_MIPS16_LO16 small_external_data_label-0x8000 + 174: f000 6c00 li a0,0 +- 174: R_MIPS16_HI16 big_external_common\+0xffff8000 ++ 174: R_MIPS16_HI16 big_external_common-0x8000 + 178: f400 3480 sll a0,16 + 17c: f000 4c00 addiu a0,0 +- 17c: R_MIPS16_LO16 big_external_common\+0xffff8000 ++ 17c: R_MIPS16_LO16 big_external_common-0x8000 + 180: f000 6c00 li a0,0 +- 180: R_MIPS16_HI16 small_external_common\+0xffff8000 ++ 180: R_MIPS16_HI16 small_external_common-0x8000 + 184: f400 3480 sll a0,16 + 188: f000 4c00 addiu a0,0 +- 188: R_MIPS16_LO16 small_external_common\+0xffff8000 ++ 188: R_MIPS16_LO16 small_external_common-0x8000 + 18c: f000 6c00 li a0,0 +- 18c: R_MIPS16_HI16 \.bss\+0xffff8000 ++ 18c: R_MIPS16_HI16 \.bss-0x8000 + 190: f400 3480 sll a0,16 + 194: f000 4c00 addiu a0,0 +- 194: R_MIPS16_LO16 \.bss\+0xffff8000 ++ 194: R_MIPS16_LO16 \.bss-0x8000 + 198: f000 6c00 li a0,0 +- 198: R_MIPS16_HI16 \.sbss\+0xffff8000 ++ 198: R_MIPS16_HI16 \.sbss-0x8000 + 19c: f400 3480 sll a0,16 + 1a0: f000 4c00 addiu a0,0 +- 1a0: R_MIPS16_LO16 \.sbss\+0xffff8000 ++ 1a0: R_MIPS16_LO16 \.sbss-0x8000 + 1a4: 6c01 li a0,1 + 1a6: f400 3480 sll a0,16 + 1aa: 4c00 addiu a0,0 +@@ -399,45 +399,45 @@ Disassembly of section \.text: + 3b4: f400 35a0 sll a1,16 + 3b8: f010 9d80 lw a0,-32768\(a1\) + 3bc: f000 6d00 li a1,0 +- 3bc: R_MIPS16_HI16 \.data\+0xffff8000 ++ 3bc: R_MIPS16_HI16 \.data-0x8000 + 3c0: f400 35a0 sll a1,16 + 3c4: f000 9d80 lw a0,0\(a1\) +- 3c4: R_MIPS16_LO16 \.data\+0xffff8000 ++ 3c4: R_MIPS16_LO16 \.data-0x8000 + 3c8: f000 6d00 li a1,0 +- 3c8: R_MIPS16_HI16 \.data\+0xffff8004 ++ 3c8: R_MIPS16_HI16 \.data-0x7ffc + 3cc: f400 35a0 sll a1,16 + 3d0: f000 9d80 lw a0,0\(a1\) +- 3d0: R_MIPS16_LO16 \.data\+0xffff8004 ++ 3d0: R_MIPS16_LO16 \.data-0x7ffc + 3d4: f000 6d00 li a1,0 +- 3d4: R_MIPS16_HI16 big_external_data_label\+0xffff8000 ++ 3d4: R_MIPS16_HI16 big_external_data_label-0x8000 + 3d8: f400 35a0 sll a1,16 + 3dc: f000 9d80 lw a0,0\(a1\) +- 3dc: R_MIPS16_LO16 big_external_data_label\+0xffff8000 ++ 3dc: R_MIPS16_LO16 big_external_data_label-0x8000 + 3e0: f000 6d00 li a1,0 +- 3e0: R_MIPS16_HI16 small_external_data_label\+0xffff8000 ++ 3e0: R_MIPS16_HI16 small_external_data_label-0x8000 + 3e4: f400 35a0 sll a1,16 + 3e8: f000 9d80 lw a0,0\(a1\) +- 3e8: R_MIPS16_LO16 small_external_data_label\+0xffff8000 ++ 3e8: R_MIPS16_LO16 small_external_data_label-0x8000 + 3ec: f000 6d00 li a1,0 +- 3ec: R_MIPS16_HI16 big_external_common\+0xffff8000 ++ 3ec: R_MIPS16_HI16 big_external_common-0x8000 + 3f0: f400 35a0 sll a1,16 + 3f4: f000 9d80 lw a0,0\(a1\) +- 3f4: R_MIPS16_LO16 big_external_common\+0xffff8000 ++ 3f4: R_MIPS16_LO16 big_external_common-0x8000 + 3f8: f000 6d00 li a1,0 +- 3f8: R_MIPS16_HI16 small_external_common\+0xffff8000 ++ 3f8: R_MIPS16_HI16 small_external_common-0x8000 + 3fc: f400 35a0 sll a1,16 + 400: f000 9d80 lw a0,0\(a1\) +- 400: R_MIPS16_LO16 small_external_common\+0xffff8000 ++ 400: R_MIPS16_LO16 small_external_common-0x8000 + 404: f000 6d00 li a1,0 +- 404: R_MIPS16_HI16 \.bss\+0xffff8000 ++ 404: R_MIPS16_HI16 \.bss-0x8000 + 408: f400 35a0 sll a1,16 + 40c: f000 9d80 lw a0,0\(a1\) +- 40c: R_MIPS16_LO16 \.bss\+0xffff8000 ++ 40c: R_MIPS16_LO16 \.bss-0x8000 + 410: f000 6d00 li a1,0 +- 410: R_MIPS16_HI16 \.sbss\+0xffff8000 ++ 410: R_MIPS16_HI16 \.sbss-0x8000 + 414: f400 35a0 sll a1,16 + 418: f000 9d80 lw a0,0\(a1\) +- 418: R_MIPS16_LO16 \.sbss\+0xffff8000 ++ 418: R_MIPS16_LO16 \.sbss-0x8000 + 41c: 6d01 li a1,1 + 41e: f400 35a0 sll a1,16 + 422: 9d80 lw a0,0\(a1\) +diff --git a/gas/testsuite/gas/ppc/astest.d b/gas/testsuite/gas/ppc/astest.d +index 715bc4e..aebc745 100644 +--- a/gas/testsuite/gas/ppc/astest.d ++++ b/gas/testsuite/gas/ppc/astest.d +@@ -52,11 +52,11 @@ Disassembly of section \.text: + 60: 00 00 00 00 \.long 0x0 + 60: R_PPC_ADDR32 z + 64: ff ff ff fc fnmsub f31,f31,f31,f31 +- 64: R_PPC_ADDR32 x\+0xf+ffffffc ++ 64: R_PPC_ADDR32 x-0x4 + 68: 00 00 00 00 \.long 0x0 + 68: R_PPC_ADDR32 \.data + 6c: ff ff ff fc fnmsub f31,f31,f31,f31 +- 6c: R_PPC_ADDR32 z\+0xf+ffffffc ++ 6c: R_PPC_ADDR32 z-0x4 + 70: ff ff ff 9c \.long 0xffffff9c + 74: ff ff ff 9c \.long 0xffffff9c + 78: 00 00 00 00 \.long 0x0 +diff --git a/gas/testsuite/gas/ppc/astest2.d b/gas/testsuite/gas/ppc/astest2.d +index e0e1943..030e985 100644 +--- a/gas/testsuite/gas/ppc/astest2.d ++++ b/gas/testsuite/gas/ppc/astest2.d +@@ -48,11 +48,11 @@ Disassembly of section \.text: + 60: 00 00 00 00 \.long 0x0 + 60: R_PPC_ADDR32 z + 64: ff ff ff fc fnmsub f31,f31,f31,f31 +- 64: R_PPC_ADDR32 x\+0xf+ffffffc ++ 64: R_PPC_ADDR32 x-0x4 + 68: 00 00 00 00 \.long 0x0 + 68: R_PPC_ADDR32 \.data + 6c: ff ff ff fc fnmsub f31,f31,f31,f31 +- 6c: R_PPC_ADDR32 z\+0xf+ffffffc ++ 6c: R_PPC_ADDR32 z-0x4 + 70: 00 00 00 08 \.long 0x8 + 74: 00 00 00 08 \.long 0x8 + +diff --git a/gas/testsuite/gas/ppc/astest2_64.d b/gas/testsuite/gas/ppc/astest2_64.d +index 356db54..901d425 100644 +--- a/gas/testsuite/gas/ppc/astest2_64.d ++++ b/gas/testsuite/gas/ppc/astest2_64.d +@@ -45,11 +45,11 @@ Disassembly of section \.text: + 58: 00 00 00 00 \.long 0x0 + 58: R_PPC64_ADDR32 z + 5c: ff ff ff fc fnmsub f31,f31,f31,f31 +- 5c: R_PPC64_ADDR32 x\+0xfffffffffffffffc ++ 5c: R_PPC64_ADDR32 x-0x4 + 60: 00 00 00 00 \.long 0x0 + 60: R_PPC64_ADDR32 \.data + 64: ff ff ff fc fnmsub f31,f31,f31,f31 +- 64: R_PPC64_ADDR32 z\+0xfffffffffffffffc ++ 64: R_PPC64_ADDR32 z-0x4 + 68: 00 00 00 08 \.long 0x8 + 6c: 00 00 00 08 \.long 0x8 + +diff --git a/gas/testsuite/gas/ppc/astest64.d b/gas/testsuite/gas/ppc/astest64.d +index d8edf05..a1a39cc 100644 +--- a/gas/testsuite/gas/ppc/astest64.d ++++ b/gas/testsuite/gas/ppc/astest64.d +@@ -49,11 +49,11 @@ Disassembly of section \.text: + 58: 00 00 00 00 \.long 0x0 + 58: R_PPC64_ADDR32 z + 5c: ff ff ff fc fnmsub f31,f31,f31,f31 +- 5c: R_PPC64_ADDR32 x\+0xfffffffffffffffc ++ 5c: R_PPC64_ADDR32 x-0x4 + 60: 00 00 00 00 \.long 0x0 + 60: R_PPC64_ADDR32 \.data + 64: ff ff ff fc fnmsub f31,f31,f31,f31 +- 64: R_PPC64_ADDR32 z\+0xfffffffffffffffc ++ 64: R_PPC64_ADDR32 z-0x4 + 68: ff ff ff a4 \.long 0xffffffa4 + 6c: ff ff ff a4 \.long 0xffffffa4 + 70: 00 00 00 00 \.long 0x0 +diff --git a/gas/testsuite/gas/ppc/test1elf32.d b/gas/testsuite/gas/ppc/test1elf32.d +index 2e76061..80cc667 100644 +--- a/gas/testsuite/gas/ppc/test1elf32.d ++++ b/gas/testsuite/gas/ppc/test1elf32.d +@@ -79,7 +79,7 @@ Disassembly of section \.data: + + 0+000c : + c: ff ff ff fc fnmsub f31,f31,f31,f31 +- c: R_PPC_REL32 jk\+0xf+fffc ++ c: R_PPC_REL32 jk-0x4 + + 0+0010 : + 10: 00 00 00 00 \.long 0x0 +diff --git a/gas/testsuite/gas/ppc/test1elf64.d b/gas/testsuite/gas/ppc/test1elf64.d +index 8ea8230..33fb6db 100644 +--- a/gas/testsuite/gas/ppc/test1elf64.d ++++ b/gas/testsuite/gas/ppc/test1elf64.d +@@ -114,7 +114,7 @@ Disassembly of section \.data: + + 0000000000000014 : + 14: ff ff ff fc fnmsub f31,f31,f31,f31 +- 14: R_PPC64_REL32 jk\+0xfffffffffffffffc ++ 14: R_PPC64_REL32 jk-0x4 + + 0000000000000018 : + 18: 00 00 00 00 \.long 0x0 +diff --git a/gas/testsuite/gas/sparc/reloc64.d b/gas/testsuite/gas/sparc/reloc64.d +index da40d0c..70bc99d 100644 +--- a/gas/testsuite/gas/sparc/reloc64.d ++++ b/gas/testsuite/gas/sparc/reloc64.d +@@ -35,13 +35,13 @@ Disassembly of section .text: + 44: R_SPARC_LO10 .text + 48: 01 00 00 00 nop + 4c: 03 00 00 00 sethi %hi\((0x|)0\), %g1 +- 4c: R_SPARC_HH22 .text\+0xfedcba9876543210 ++ 4c: R_SPARC_HH22 .text\-0x123456789abcdf0 + 50: 82 10 60 00 mov %g1, %g1 ! 0 +- 50: R_SPARC_HM10 .text\+0xfedcba9876543210 ++ 50: R_SPARC_HM10 .text\-0x123456789abcdf0 + 54: 05 00 00 00 sethi %hi\((0x|)0\), %g2 +- 54: R_SPARC_LM22 .text\+0xfedcba9876543210 ++ 54: R_SPARC_LM22 .text\-0x123456789abcdf0 + 58: 84 10 60 00 mov %g1, %g2 +- 58: R_SPARC_LO10 .text\+0xfedcba9876543210 ++ 58: R_SPARC_LO10 .text\-0x123456789abcdf0 + 5c: 01 00 00 00 nop + 60: 03 2a 61 d9 sethi %hi\(0xa9876400\), %g1 + 64: 82 10 61 43 or %g1, 0x143, %g1.* +@@ -70,7 +70,7 @@ Disassembly of section .text: + a0: R_SPARC_LOX10 .text + a4: 01 00 00 00 nop + a8: 03 00 00 00 sethi %hi\((0x|)0\), %g1 +- a8: R_SPARC_HIX22 .text\+0xffffffff76543210 ++ a8: R_SPARC_HIX22 .text-0x89abcdf0 + ac: 82 18 60 00 xor %g1, 0, %g1 +- ac: R_SPARC_LOX10 .text\+0xffffffff76543210 ++ ac: R_SPARC_LOX10 .text-0x89abcdf0 + b0: 01 00 00 00 nop --- binutils-2.22.orig/debian/patches/135_bfd_version.patch +++ binutils-2.22/debian/patches/135_bfd_version.patch @@ -0,0 +1,47 @@ +Author: +Description: Description: Fix bfd version handling for extra builds + +Index: binutils-2.21.0.20110216/bfd/Makefile.am +=================================================================== +--- binutils-2.21.0.20110216.orig/bfd/Makefile.am 2011-02-01 12:25:32.000000000 +0000 ++++ binutils-2.21.0.20110216/bfd/Makefile.am 2011-02-16 18:28:14.568229030 +0000 +@@ -948,14 +948,14 @@ + + bfdver.h: $(srcdir)/version.h $(srcdir)/Makefile.in + @echo "creating $@" +- @bfd_version=`echo "$(VERSION)" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ +- bfd_version_string="\"$(VERSION)\"" ;\ ++ @bfd_version=`echo "$(VERSION)" | sed -e 's/-.*$$//' | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ ++ bfd_version_string="\"`echo $(VERSION) | sed -e 's/-.*$$//'`\"" ;\ + bfd_soversion="$(VERSION)" ;\ + bfd_version_package="\"$(PKGVERSION)\"" ;\ + report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\ + if test "x$(RELEASE)" = x ; then \ + bfd_version_date=`sed -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ +- bfd_version_string="\"$(VERSION).$${bfd_version_date}\"" ;\ ++ bfd_version_string="\"`echo $(VERSION) | sed -e 's/-.*$$//'`.$${bfd_version_date}\"" ;\ + bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ + fi ;\ + sed -e "s,@bfd_version@,$$bfd_version," \ +Index: binutils-2.21.0.20110216/bfd/Makefile.in +=================================================================== +--- binutils-2.21.0.20110216.orig/bfd/Makefile.in 2011-02-01 12:25:32.000000000 +0000 ++++ binutils-2.21.0.20110216/bfd/Makefile.in 2011-02-16 18:28:34.248228995 +0000 +@@ -1980,14 +1980,14 @@ + + bfdver.h: $(srcdir)/version.h $(srcdir)/Makefile.in + @echo "creating $@" +- @bfd_version=`echo "$(VERSION)" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ +- bfd_version_string="\"$(VERSION)\"" ;\ ++ @bfd_version=`echo "$(VERSION)" | sed -e 's/-.*$$//' | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ ++ bfd_version_string="\"`echo $(VERSION) | sed -e 's/-.*$$//'`\"" ;\ + bfd_soversion="$(VERSION)" ;\ + bfd_version_package="\"$(PKGVERSION)\"" ;\ + report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\ + if test "x$(RELEASE)" = x ; then \ + bfd_version_date=`sed -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ +- bfd_version_string="\"$(VERSION).$${bfd_version_date}\"" ;\ ++ bfd_version_string="\"`echo $(VERSION) | sed -e 's/-.*$$//'`.$${bfd_version_date}\"" ;\ + bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ + fi ;\ + sed -e "s,@bfd_version@,$$bfd_version," \ --- binutils-2.22.orig/debian/patches/pr13449.diff +++ binutils-2.22/debian/patches/pr13449.diff @@ -0,0 +1,20 @@ +2011-12-21 Nick Clifton + + PR gas/13449 + * config/tc-arm.c (create_unwind_entry): Zero allocated table + entries. + + +diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c +index 865f430..02a63a6 100644 +--- a/gas/config/tc-arm.c ++++ b/gas/config/tc-arm.c +@@ -19944,6 +19944,8 @@ create_unwind_entry (int have_data) + + /* Allocate the table entry. */ + ptr = frag_more ((size << 2) + 4); ++ /* PR 13449: Zero the table entries in case some of them are not used. */ ++ memset (ptr, 0, (size << 2) + 4); + where = frag_now_fix () - ((size << 2) + 4); + + switch (unwind.personality_index) --- binutils-2.22.orig/debian/patches/binutils-CVE-2014-8502.patch +++ binutils-2.22/debian/patches/binutils-CVE-2014-8502.patch @@ -0,0 +1,610 @@ +From b69c87280595b7ce4e956cb2a62278412f0722f7 Mon Sep 17 00:00:00 2001 +From: Jon Turney +Date: Thu, 3 Apr 2014 12:26:27 +0100 +Subject: [PATCH] * peXXigen.c (pe_print_edata): Verify edt.name lies inside + section before dereferencing. + (pe_print_idata, pe_print_edata, pe_print_reloc) + (rsrc_print_section): Don't bother interpreting the contents + of sections which have no contents. + +From b2f93c5011cab00f31669363577b938697752e43 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Tue, 28 Oct 2014 10:50:17 +0000 +Subject: [PATCH] Import patches from the master branch which prevent seg-faults when parsing + corrupt binaries. + + 2014-10-27 Nick Clifton + PR binutils/17512 + * elf.c (bfd_section_from_shdr): Detect and warn about ELF + binaries with a group of sections linked by the string table + indicies. + * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Handle corrupt binaries + with an invalid value for NumberOfRvaAndSizes. + (pe_print_edata): Detect out of range rvas and entry counts for + the Export Address table, Name Pointer table and Ordinal table. + + PR binutils/17510 + * elf.c (setup_group): Improve handling of corrupt group + sections. + +From 5a4b0ccc20ba30caef53b01bee2c0aaa5b855339 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Tue, 28 Oct 2014 15:42:56 +0000 +Subject: [PATCH] More fixes for corrupt binaries crashing the binutils. + + PR binutils/17512 + * elf.c (bfd_section_from_shdr): Allocate and free the recursion + detection table on a per-bfd basis. + * peXXigen.c (pe_print_edata): Handle binaries with a truncated + export table. + +From e5b470e24ce448a56230137a37d3b17299593041 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Wed, 29 Oct 2014 20:58:13 +0000 +Subject: [PATCH] Fixes another memory corruption bug introduced by patches for PR 17512. + + * elf.c (bfd_section_from_shdr): Fix heap use after free memory + leak. + +[Ubuntu note: patch differs from upstream commits in that it drops +the changelog entry to reduce patch conflicts, the first patches +fix to rsrc_print_section as it doesn't exist yet, and the second +commit's fixes to handle srec, as that's already covered by the +binutils-CVE-2014-8504.patch. -- sbeattie] + +Third commit fixes CVE-2014-8502, but first two commits are needed as +prerequisites, and the last one fixes a use-after-free introduced by +earlier patches. + +--- + bfd/elf.c | 204 ++++++++++++++++++++++++++++++++++++++------------------- + bfd/peXXigen.c | 55 ++++++++++++--- + 2 files changed, 185 insertions(+), 74 deletions(-) + +Index: b/bfd/peXXigen.c +=================================================================== +--- a/bfd/peXXigen.c ++++ b/bfd/peXXigen.c +@@ -1115,6 +1115,13 @@ pe_print_idata (bfd * abfd, void * vfile + _("\nThere is an import table, but the section containing it could not be found\n")); + return TRUE; + } ++ else if (!(section->flags & SEC_HAS_CONTENTS)) ++ { ++ fprintf (file, ++ _("\nThere is an import table in %s, but that section has no contents\n"), ++ section->name); ++ return TRUE; ++ } + } + + fprintf (file, _("\nThere is an import table in %s at 0x%lx\n"), +@@ -1376,7 +1383,7 @@ pe_print_edata (bfd * abfd, void * vfile + bfd_size_type datasize = 0; + bfd_size_type dataoff; + bfd_size_type i; +- bfd_signed_vma adj; ++ bfd_vma adj; + struct EDT_type + { + long export_flags; /* Reserved - should be zero. */ +@@ -1426,6 +1433,13 @@ pe_print_edata (bfd * abfd, void * vfile + _("\nThere is an export table, but the section containing it could not be found\n")); + return TRUE; + } ++ else if (!(section->flags & SEC_HAS_CONTENTS)) ++ { ++ fprintf (file, ++ _("\nThere is an export table in %s, but that section has no contents\n"), ++ section->name); ++ return TRUE; ++ } + + dataoff = addr - section->vma; + datasize = extra->DataDirectory[PE_EXPORT_TABLE].Size; +@@ -1438,6 +1452,15 @@ pe_print_edata (bfd * abfd, void * vfile + } + } + ++ /* PR 17512: Handle corrupt PE binaries. */ ++ if (datasize < 36) ++ { ++ fprintf (file, ++ _("\nThere is an export table in %s, but it is too small (%d)\n"), ++ section->name, (int) datasize); ++ return TRUE; ++ } ++ + fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"), + section->name, (unsigned long) addr); + +@@ -1481,8 +1504,11 @@ pe_print_edata (bfd * abfd, void * vfile + fprintf (file, + _("Name \t\t\t\t")); + bfd_fprintf_vma (abfd, file, edt.name); +- fprintf (file, +- " %s\n", data + edt.name - adj); ++ ++ if ((edt.name >= adj) && (edt.name < adj + datasize)) ++ fprintf (file, " %s\n", data + edt.name - adj); ++ else ++ fprintf (file, "(outside .edata section)\n"); + + fprintf (file, + _("Ordinal Base \t\t\t%ld\n"), edt.base); +@@ -1528,7 +1554,12 @@ pe_print_edata (bfd * abfd, void * vfile + _("\nExport Address Table -- Ordinal Base %ld\n"), + edt.base); + +- for (i = 0; i < edt.num_functions; ++i) ++ /* PR 17512: Handle corrupt PE binaries. */ ++ if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize) ++ fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"), ++ (long) edt.eat_addr, ++ (long) edt.num_functions); ++ else for (i = 0; i < edt.num_functions; ++i) + { + bfd_vma eat_member = bfd_get_32 (abfd, + data + edt.eat_addr + (i * 4) - adj); +@@ -1564,7 +1595,16 @@ pe_print_edata (bfd * abfd, void * vfile + fprintf (file, + _("\n[Ordinal/Name Pointer] Table\n")); + +- for (i = 0; i < edt.num_names; ++i) ++ /* PR 17512: Handle corrupt PE binaries. */ ++ if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize) ++ fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"), ++ (long) edt.npt_addr, ++ (long) edt.num_names); ++ else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize) ++ fprintf (file, _("\tInvalid Ordinal Table rva (0x%lx) or entry count (0x%lx)\n"), ++ (long) edt.ot_addr, ++ (long) edt.num_names); ++ else for (i = 0; i < edt.num_names; ++i) + { + bfd_vma name_ptr = bfd_get_32 (abfd, + data + +@@ -1930,10 +1970,7 @@ pe_print_reloc (bfd * abfd, void * vfile + bfd_size_type i; + bfd_size_type start, stop; + +- if (section == NULL) +- return TRUE; +- +- if (section->size == 0) ++ if (section == NULL || section->size == 0 || !(section->flags & SEC_HAS_CONTENTS)) + return TRUE; + + fprintf (file, +Index: b/bfd/elf.c +=================================================================== +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -1574,38 +1574,74 @@ bfd_section_from_shdr (bfd *abfd, unsign + Elf_Internal_Ehdr *ehdr; + const struct elf_backend_data *bed; + const char *name; ++ bfd_boolean ret = TRUE; ++ static bfd_boolean * sections_being_created = NULL; ++ static bfd * sections_being_created_abfd = NULL; ++ static unsigned int nesting = 0; + + if (shindex >= elf_numsections (abfd)) + return FALSE; + ++ if (++ nesting > 3) ++ { ++ /* PR17512: A corrupt ELF binary might contain a recursive group of ++ sections, each the string indicies pointing to the next in the ++ loop. Detect this here, by refusing to load a section that we are ++ already in the process of loading. We only trigger this test if ++ we have nested at least three sections deep as normal ELF binaries ++ can expect to recurse at least once. ++ ++ FIXME: It would be better if this array was attached to the bfd, ++ rather than being held in a static pointer. */ ++ ++ if (sections_being_created_abfd != abfd) ++ sections_being_created = NULL; ++ if (sections_being_created == NULL) ++ { ++ /* FIXME: It would be more efficient to attach this array to the bfd somehow. */ ++ sections_being_created = (bfd_boolean *) ++ bfd_zalloc (abfd, elf_numsections (abfd) * sizeof (bfd_boolean)); ++ sections_being_created_abfd = abfd; ++ } ++ if (sections_being_created [shindex]) ++ { ++ (*_bfd_error_handler) ++ (_("%B: warning: loop in section dependencies detected"), abfd); ++ return FALSE; ++ } ++ sections_being_created [shindex] = TRUE; ++ } ++ + hdr = elf_elfsections (abfd)[shindex]; + ehdr = elf_elfheader (abfd); + name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx, + hdr->sh_name); + if (name == NULL) +- return FALSE; ++ goto fail; + + bed = get_elf_backend_data (abfd); + switch (hdr->sh_type) + { + case SHT_NULL: + /* Inactive section. Throw it away. */ +- return TRUE; ++ goto success; + +- case SHT_PROGBITS: /* Normal section with contents. */ +- case SHT_NOBITS: /* .bss section. */ +- case SHT_HASH: /* .hash section. */ +- case SHT_NOTE: /* .note section. */ ++ case SHT_PROGBITS: /* Normal section with contents. */ ++ case SHT_NOBITS: /* .bss section. */ ++ case SHT_HASH: /* .hash section. */ ++ case SHT_NOTE: /* .note section. */ + case SHT_INIT_ARRAY: /* .init_array section. */ + case SHT_FINI_ARRAY: /* .fini_array section. */ + case SHT_PREINIT_ARRAY: /* .preinit_array section. */ + case SHT_GNU_LIBLIST: /* .gnu.liblist section. */ + case SHT_GNU_HASH: /* .gnu.hash section. */ +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + + case SHT_DYNAMIC: /* Dynamic linking information. */ + if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) +- return FALSE; ++ goto fail; ++ + if (hdr->sh_link > elf_numsections (abfd)) + { + /* PR 10478: Accept Solaris binaries with a sh_link +@@ -1619,11 +1655,11 @@ bfd_section_from_shdr (bfd *abfd, unsign + break; + /* Otherwise fall through. */ + default: +- return FALSE; ++ goto fail; + } + } + else if (elf_elfsections (abfd)[hdr->sh_link] == NULL) +- return FALSE; ++ goto fail; + else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB) + { + Elf_Internal_Shdr *dynsymhdr; +@@ -1652,16 +1688,18 @@ bfd_section_from_shdr (bfd *abfd, unsign + } + } + } +- break; ++ goto success; + +- case SHT_SYMTAB: /* A symbol table */ ++ case SHT_SYMTAB: /* A symbol table. */ + if (elf_onesymtab (abfd) == shindex) +- return TRUE; ++ goto success; + + if (hdr->sh_entsize != bed->s->sizeof_sym) +- return FALSE; ++ goto fail; ++ + if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) +- return FALSE; ++ goto fail; ++ + BFD_ASSERT (elf_onesymtab (abfd) == 0); + elf_onesymtab (abfd) = shindex; + elf_tdata (abfd)->symtab_hdr = *hdr; +@@ -1686,7 +1724,7 @@ bfd_section_from_shdr (bfd *abfd, unsign + && (abfd->flags & DYNAMIC) != 0 + && ! _bfd_elf_make_section_from_shdr (abfd, hdr, name, + shindex)) +- return FALSE; ++ goto fail; + + /* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we + can't read symbols without that section loaded as well. It +@@ -1712,16 +1750,20 @@ bfd_section_from_shdr (bfd *abfd, unsign + break; + } + if (i != shindex) +- return bfd_section_from_shdr (abfd, i); ++ ret = bfd_section_from_shdr (abfd, i); + } +- return TRUE; ++ goto success; + +- case SHT_DYNSYM: /* A dynamic symbol table */ ++ case SHT_DYNSYM: /* A dynamic symbol table. */ + if (elf_dynsymtab (abfd) == shindex) +- return TRUE; ++ goto success; + + if (hdr->sh_entsize != bed->s->sizeof_sym) +- return FALSE; ++ goto fail; ++ ++ if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size) ++ goto fail; ++ + BFD_ASSERT (elf_dynsymtab (abfd) == 0); + elf_dynsymtab (abfd) = shindex; + elf_tdata (abfd)->dynsymtab_hdr = *hdr; +@@ -1740,34 +1781,38 @@ bfd_section_from_shdr (bfd *abfd, unsign + + /* Besides being a symbol table, we also treat this as a regular + section, so that objcopy can handle it. */ +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + +- case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections */ ++ case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections. */ + if (elf_symtab_shndx (abfd) == shindex) +- return TRUE; ++ goto success; + + BFD_ASSERT (elf_symtab_shndx (abfd) == 0); + elf_symtab_shndx (abfd) = shindex; + elf_tdata (abfd)->symtab_shndx_hdr = *hdr; + elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr; +- return TRUE; ++ goto success; + +- case SHT_STRTAB: /* A string table */ ++ case SHT_STRTAB: /* A string table. */ + if (hdr->bfd_section != NULL) +- return TRUE; ++ goto success; ++ + if (ehdr->e_shstrndx == shindex) + { + elf_tdata (abfd)->shstrtab_hdr = *hdr; + elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr; +- return TRUE; ++ goto success; + } ++ + if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex) + { + symtab_strtab: + elf_tdata (abfd)->strtab_hdr = *hdr; + elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr; +- return TRUE; ++ goto success; + } ++ + if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex) + { + dynsymtab_strtab: +@@ -1776,8 +1821,9 @@ bfd_section_from_shdr (bfd *abfd, unsign + elf_elfsections (abfd)[shindex] = hdr; + /* We also treat this as a regular section, so that objcopy + can handle it. */ +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, +- shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, ++ shindex); ++ goto success; + } + + /* If the string table isn't one of the above, then treat it as a +@@ -1795,9 +1841,9 @@ bfd_section_from_shdr (bfd *abfd, unsign + { + /* Prevent endless recursion on broken objects. */ + if (i == shindex) +- return FALSE; ++ goto fail; + if (! bfd_section_from_shdr (abfd, i)) +- return FALSE; ++ goto fail; + if (elf_onesymtab (abfd) == i) + goto symtab_strtab; + if (elf_dynsymtab (abfd) == i) +@@ -1805,7 +1851,8 @@ bfd_section_from_shdr (bfd *abfd, unsign + } + } + } +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + + case SHT_REL: + case SHT_RELA: +@@ -1820,7 +1867,7 @@ bfd_section_from_shdr (bfd *abfd, unsign + if (hdr->sh_entsize + != (bfd_size_type) (hdr->sh_type == SHT_REL + ? bed->s->sizeof_rel : bed->s->sizeof_rela)) +- return FALSE; ++ goto fail; + + /* Check for a bogus link to avoid crashing. */ + if (hdr->sh_link >= num_sec) +@@ -1828,8 +1875,9 @@ bfd_section_from_shdr (bfd *abfd, unsign + ((*_bfd_error_handler) + (_("%B: invalid link %lu for reloc section %s (index %u)"), + abfd, hdr->sh_link, name, shindex)); +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, +- shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, ++ shindex); ++ goto success; + } + + /* For some incomprehensible reason Oracle distributes +@@ -1870,7 +1918,7 @@ bfd_section_from_shdr (bfd *abfd, unsign + if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB + || elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM) + && ! bfd_section_from_shdr (abfd, hdr->sh_link)) +- return FALSE; ++ goto fail; + + /* If this reloc section does not use the main symbol table we + don't treat it as a reloc section. BFD can't adequately +@@ -1885,14 +1933,18 @@ bfd_section_from_shdr (bfd *abfd, unsign + || hdr->sh_info >= num_sec + || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL + || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA) +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, +- shindex); ++ { ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, ++ shindex); ++ goto success; ++ } + + if (! bfd_section_from_shdr (abfd, hdr->sh_info)) +- return FALSE; ++ goto fail; ++ + target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info); + if (target_sect == NULL) +- return FALSE; ++ goto fail; + + esdt = elf_section_data (target_sect); + if (hdr->sh_type == SHT_RELA) +@@ -1904,7 +1956,7 @@ bfd_section_from_shdr (bfd *abfd, unsign + amt = sizeof (*hdr2); + hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt); + if (hdr2 == NULL) +- return FALSE; ++ goto fail; + *hdr2 = *hdr; + *p_hdr = hdr2; + elf_elfsections (abfd)[shindex] = hdr2; +@@ -1920,34 +1972,40 @@ bfd_section_from_shdr (bfd *abfd, unsign + target_sect->use_rela_p = 1; + } + abfd->flags |= HAS_RELOC; +- return TRUE; ++ goto success; + } + + case SHT_GNU_verdef: + elf_dynverdef (abfd) = shindex; + elf_tdata (abfd)->dynverdef_hdr = *hdr; +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + + case SHT_GNU_versym: + if (hdr->sh_entsize != sizeof (Elf_External_Versym)) +- return FALSE; ++ goto fail; ++ + elf_dynversym (abfd) = shindex; + elf_tdata (abfd)->dynversym_hdr = *hdr; +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + + case SHT_GNU_verneed: + elf_dynverref (abfd) = shindex; + elf_tdata (abfd)->dynverref_hdr = *hdr; +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; + + case SHT_SHLIB: +- return TRUE; ++ goto success; + + case SHT_GROUP: + if (! IS_VALID_GROUP_SECTION_HEADER (hdr)) +- return FALSE; ++ goto fail; ++ + if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) +- return FALSE; ++ goto fail; ++ + if (hdr->contents != NULL) + { + Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents; +@@ -1973,7 +2031,7 @@ bfd_section_from_shdr (bfd *abfd, unsign + } + } + } +- break; ++ goto success; + + default: + /* Possibly an attributes section. */ +@@ -1981,14 +2039,14 @@ bfd_section_from_shdr (bfd *abfd, unsign + || hdr->sh_type == bed->obj_attrs_section_type) + { + if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) +- return FALSE; ++ goto fail; + _bfd_elf_parse_attributes (abfd, hdr); +- return TRUE; ++ goto success; + } + + /* Check for any processor-specific section types. */ + if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex)) +- return TRUE; ++ goto success; + + if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER) + { +@@ -2000,9 +2058,12 @@ bfd_section_from_shdr (bfd *abfd, unsign + "specific section `%s' [0x%8x]"), + abfd, name, hdr->sh_type); + else +- /* Allow sections reserved for applications. */ +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, +- shindex); ++ { ++ /* Allow sections reserved for applications. */ ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, ++ shindex); ++ goto success; ++ } + } + else if (hdr->sh_type >= SHT_LOPROC + && hdr->sh_type <= SHT_HIPROC) +@@ -2023,8 +2084,11 @@ bfd_section_from_shdr (bfd *abfd, unsign + "`%s' [0x%8x]"), + abfd, name, hdr->sh_type); + else +- /* Otherwise it should be processed. */ +- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ { ++ /* Otherwise it should be processed. */ ++ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex); ++ goto success; ++ } + } + else + /* FIXME: We should handle this section. */ +@@ -2032,10 +2096,20 @@ bfd_section_from_shdr (bfd *abfd, unsign + (_("%B: don't know how to handle section `%s' [0x%8x]"), + abfd, name, hdr->sh_type); + +- return FALSE; ++ goto fail; + } + +- return TRUE; ++ fail: ++ ret = FALSE; ++ success: ++ if (sections_being_created && sections_being_created_abfd == abfd) ++ sections_being_created [shindex] = FALSE; ++ if (-- nesting == 0) ++ { ++ sections_being_created = NULL; ++ sections_being_created_abfd = abfd; ++ } ++ return ret; + } + + /* Return the local symbol specified by ABFD, R_SYMNDX. */ --- binutils-2.22.orig/debian/patches/157_ar_scripts_with_tilde.patch +++ binutils-2.22/debian/patches/157_ar_scripts_with_tilde.patch @@ -0,0 +1,11 @@ +--- a/binutils/arlex.l ++++ b/binutils/arlex.l +@@ -77,7 +77,7 @@ + "(" { return '('; } + ")" { return ')'; } + "," { return ','; } +-[A-Za-z0-9/\\$:.\-\_]+ { ++[A-Za-z0-9/\\$:.\-\_~]+ { + yylval.name = xstrdup (yytext); + return FILENAME; + } --- binutils-2.22.orig/debian/patches/014_hash_style-both.patch +++ binutils-2.22/debian/patches/014_hash_style-both.patch @@ -0,0 +1,30 @@ +# DP: Default to --hash-style=both in ld.bfd and ld.gold. + +--- a/ld/ldmain.c ++++ b/ld/ldmain.c +@@ -287,6 +288,14 @@ + emulation = get_emulation (argc, argv); + ldemul_choose_mode (emulation); + default_target = ldemul_choose_target (argc, argv); ++ ++ /* Default to --hash-style=gnu */ ++ if (strcmp (default_target, "elf32-tradbigmips") != 0 ++ && strcmp (default_target, "elf32-tradlittlemips") != 0) ++ { ++ link_info.emit_gnu_hash = TRUE; ++ } ++ + config.maxpagesize = bfd_emul_get_maxpagesize (default_target); + config.commonpagesize = bfd_emul_get_commonpagesize (default_target); + lang_init (); +--- a/gold/options.h ++++ b/gold/options.h +@@ -794,7 +794,7 @@ + N_("Min fraction of empty buckets in dynamic hash"), + N_("FRACTION")); + +- DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "sysv", ++ DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "both", + N_("Dynamic hash style"), N_("[sysv,gnu,both]"), + {"sysv", "gnu", "both"}); + --- binutils-2.22.orig/debian/patches/129_ld_mulitarch_dirs.patch +++ binutils-2.22/debian/patches/129_ld_mulitarch_dirs.patch @@ -0,0 +1,72 @@ +# DP: Add multiarch directories to linker search path. + +Index: binutils-2.21.0.20110322/ld/genscripts.sh +=================================================================== +--- binutils-2.21.0.20110322.orig/ld/genscripts.sh 2011-03-27 18:45:12.283057003 +0000 ++++ binutils-2.21.0.20110322/ld/genscripts.sh 2011-03-27 18:51:20.623057182 +0000 +@@ -240,6 +240,65 @@ + fi + + LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'` ++if [ -n "$DEB_HOST_MULTIARCH" ]; then ++ temp_dirs=' ' ++ for dir in `echo ${LIB_PATH} | sed -e 's/:/ /g'`; do ++ case "$dir" in ++ ${tool_lib}*|*/${target_alias}/*) ++ ;; ++ */lib) ++ if [ -n "$DEB_HOST_MULTIARCH32" ]; then ++ case $EMULATION_NAME in ++ elf_i386|elf32*) ++ temp_dirs="${temp_dirs}${dir}/$DEB_HOST_MULTIARCH32 ";; ++ *) ++ temp_dirs="${temp_dirs}${dir}/$DEB_HOST_MULTIARCH " ++ esac ++ elif [ -n "$DEB_HOST_MULTIARCH64" ]; then ++ case $EMULATION_NAME in ++ elf*_64|elf64*) ++ temp_dirs="${temp_dirs}${dir}/$DEB_HOST_MULTIARCH64 ";; ++ *) ++ temp_dirs="${temp_dirs}${dir}/$DEB_HOST_MULTIARCH " ++ esac ++ else ++ temp_dirs="${temp_dirs}${dir}/$DEB_HOST_MULTIARCH " ++ fi ++ ;; ++ */lib32) ++ if [ -n "$DEB_HOST_MULTIARCH32" ]; then ++ dir2=$(echo $dir | sed "s,32$,,") ++ temp_dirs="${temp_dirs}${dir2}/$DEB_HOST_MULTIARCH32 " ++ fi ++ ;; ++ */lib64) ++ case "${target}" in ++ powerpc64-*-*|s390x-*-*|sparc64-*-*|x86_64-*-linux*) ++ #dir=$(echo $dir | sed "s,64$,,") ++ dir2=$(echo $dir | sed "s,64$,,") ++ temp_dirs="${temp_dirs}${dir2}/$DEB_HOST_MULTIARCH " ++ ;; ++ *) ++ if [ -n "$DEB_HOST_MULTIARCH64" ]; then ++ dir2=$(echo $dir | sed "s,64$,,") ++ temp_dirs="${temp_dirs}${dir2}/$DEB_HOST_MULTIARCH64 " ++ fi ++ ;; ++ esac ++ ;; ++ *) ++ ;; ++ esac ++ temp_dirs="${temp_dirs}${dir} " ++ done ++ LIB_SEARCH_DIRS= ++ for dir in $temp_dirs; do ++ if echo "$LIB_SEARCH_DIRS" | fgrep -q "\"$dir\""; then ++ continue ++ fi ++ LIB_SEARCH_DIRS="${LIB_SEARCH_DIRS}SEARCH_DIR(\"$dir\"); " ++ done ++fi + + # We need it for testsuite. + set $EMULATION_LIBPATH --- binutils-2.22.orig/debian/patches/168_readelf_go.patch +++ binutils-2.22/debian/patches/168_readelf_go.patch @@ -0,0 +1,13 @@ +# DP: Recognize DW_LANG_Go in readelf (backport from trunk) + +--- a/binutils/dwarf.c ++++ b/binutils/dwarf.c +@@ -1599,6 +1599,8 @@ read_and_display_attr_value (unsigned lo + case DW_LANG_D: printf ("(D)"); break; + /* DWARF 4 values. */ + case DW_LANG_Python: printf ("(Python)"); break; ++ /* DWARF 5 values. */ ++ case DW_LANG_Go: printf ("(Go)"); break; + /* MIPS extension. */ + case DW_LANG_Mips_Assembler: printf ("(MIPS assembler)"); break; + /* UPC extension. */ --- binutils-2.22.orig/debian/patches/pr13534-03.diff +++ binutils-2.22/debian/patches/pr13534-03.diff @@ -0,0 +1,29 @@ +commit 23a979dc1779ac63cd799bfa2f6c2aed1f1bff66 +Author: Francois Gouget +Date: Tue Dec 20 18:41:35 2011 +0100 + + bfd: Fix parsing the size of archive elements larger than 2GB. + +diff --git a/bfd/archive.c b/bfd/archive.c +index 05aba6c..01acf98 100644 +--- a/bfd/archive.c ++++ b/bfd/archive.c +@@ -446,7 +446,7 @@ _bfd_generic_read_ar_hdr_mag (bfd *abfd, const char *mag) + { + struct ar_hdr hdr; + char *hdrp = (char *) &hdr; +- size_t parsed_size; ++ bfd_size_type parsed_size; + struct areltdata *ared; + char *filename = NULL; + bfd_size_type namelen = 0; +@@ -470,8 +470,7 @@ _bfd_generic_read_ar_hdr_mag (bfd *abfd, const char *mag) + } + + errno = 0; +- parsed_size = strtol (hdr.ar_size, NULL, 10); +- if (errno != 0) ++ if (sscanf(hdr.ar_size, "%" BFD_VMA_FMT "u", &parsed_size) != 1) + { + bfd_set_error (bfd_error_malformed_archive); + return NULL; --- binutils-2.22.orig/debian/patches/series +++ binutils-2.22/debian/patches/series @@ -0,0 +1,63 @@ +branch-updates.diff +#branch-version.diff +001_ld_makefile_patch.patch +002_gprof_profile_arcs.patch +003_gprof_see_also_monitor.patch +006_better_file_error.patch +012_check_ldrunpath_length.patch +013_bash_in_ld_testsuite.patch +#014_hash_style-both.patch +127_x86_64_i386_biarch.patch +128_ppc64_powerpc_biarch.patch +128_build_id.patch +129_ld_mulitarch_dirs.patch +130_gold_disable_testsuite_build.patch +131_ld_bootstrap_testsuite.patch +134_gold_no_spu.patch +135_bfd_version.patch +140_pr10340.patch +156_pr10144.patch +157_ar_scripts_with_tilde.patch +158_ld_system_root.patch +160_gas_pr12698.diff +162_fpic_s390x.diff +161_gold_dummy_zoption.diff +163_multiarch_search_path.patch +167_pr13302.diff +pr13534-01.diff +pr13534-02.diff +pr13534-03.diff +pr13534-04.diff +pr13534-05.diff +168_readelf_go.patch +pr13449.diff + +# not applied for Ubuntu: +#200-hjl-ld-env.patch +#201-hjl-ld-needed.patch + +# not applied for Ubuntu, ia64 only +#203-hjl-binutils-indirect.patch + +# not applied for Ubuntu: +#206-hjl-binutils-shr.patch + +#209-hjl-binutils-error.patch +210-hjl-binutils-signed.patch +211-hjl-binutils-weakdef.patch +212-hjl-bfd-64k.patch +213-hjl-binutils-sec64k.patch +213-gold-arm-pie-fix.patch +binutils-CVE-2012-3509.patch +binutils-CVE-2014-8484.patch +binutils-CVE-2014-8485.patch +binutils-CVE-2014-8501.patch +binutils-CVE-2014-8502.patch +binutils-CVE-2014-8503.patch +binutils-CVE-2014-8504.patch +binutils-CVE-2014-8737.patch +binutils-CVE-2014-8738.patch +binutils-bz17512_prereqs.patch +binutils-bz17512-misc.patch +binutils-harden_strings.patch +gold-fuse-ld.diff --- binutils-2.22.orig/debian/patches/binutils-CVE-2014-8484.patch +++ binutils-2.22/debian/patches/binutils-CVE-2014-8484.patch @@ -0,0 +1,52 @@ +From bd25671c6f202c4a5108883caa2adb24ff6f361f Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Fri, 29 Aug 2014 10:36:29 +0930 +Subject: [PATCH] Report an error for S-records with less than the miniumum size + + * srec.c (srec_scan): Revert last change. Report an error for + S-records with less than the miniumum byte count. + +[Ubuntu note: patch differs from upstream by removing the changelog +update, and the reversion of the previous svn commit. -- sbeattie] + +CVE-2014-8484 +--- + bfd/srec.c | 18 +++++++++++++++--- + 2 files changed, 20 insertions(+), 3 deletions(-) + +diff --git a/bfd/srec.c b/bfd/srec.c +index d979bf5..42143c7 100644 +--- a/bfd/srec.c ++++ b/bfd/srec.c +@@ -453,7 +453,7 @@ srec_scan (bfd *abfd) + { + file_ptr pos; + char hdr[3]; +- unsigned int bytes; ++ unsigned int bytes, min_bytes; + bfd_vma address; + bfd_byte *data; + unsigned char check_sum; +@@ -476,6 +476,19 @@ srec_scan (bfd *abfd) + } + + check_sum = bytes = HEX (hdr + 1); ++ min_bytes = 3; ++ if (hdr[0] == '2' || hdr[0] == '8') ++ min_bytes = 4; ++ else if (hdr[0] == '3' || hdr[0] == '7') ++ min_bytes = 5; ++ if (bytes < min_bytes) ++ { ++ (*_bfd_error_handler) (_("%B:%d: byte count %d too small\n"), ++ abfd, lineno, bytes); ++ bfd_set_error (bfd_error_bad_value); ++ goto error_return; ++ } ++ + if (bytes * 2 > bufsize) + { + if (buf != NULL) +-- +1.7.1 + --- binutils-2.22.orig/debian/patches/158_ld_system_root.patch +++ binutils-2.22/debian/patches/158_ld_system_root.patch @@ -0,0 +1,36 @@ +--- a/ld/configure.in ++++ b/ld/configure.in +@@ -38,7 +38,9 @@ + *) TARGET_SYSTEM_ROOT=$with_sysroot ;; + esac + ++ if test "x$TARGET_SYSTEM_ROOT" != x/; then + TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"' ++ fi + use_sysroot=yes + + if test "x$prefix" = xNONE; then +--- a/ld/configure ++++ b/ld/configure +@@ -4139,7 +4139,9 @@ + *) TARGET_SYSTEM_ROOT=$with_sysroot ;; + esac + ++ if test "x$TARGET_SYSTEM_ROOT" != x/; then + TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"' ++ fi + use_sysroot=yes + + if test "x$prefix" = xNONE; then +--- a/ld/ldmain.c ++++ b/ld/ldmain.c +@@ -214,8 +214,8 @@ + { + if (*TARGET_SYSTEM_ROOT == 0) + { +- einfo ("%P%F: this linker was not configured to use sysroots\n"); + ld_sysroot = ""; ++ ld_canon_sysroot = ""; + } + else + ld_canon_sysroot = lrealpath (ld_sysroot); --- binutils-2.22.orig/debian/patches/006_better_file_error.patch +++ binutils-2.22/debian/patches/006_better_file_error.patch @@ -0,0 +1,19 @@ +Author: David Kimdon +Description: Specify which filename is causing an error if the filename is a +directory. (#45832) +--- a/bfd/opncls.c ++++ b/bfd/opncls.c +@@ -183,6 +183,13 @@ + { + bfd *nbfd; + const bfd_target *target_vec; ++ struct stat s; ++ ++ if (stat (filename, &s) == 0) ++ if (S_ISDIR(s.st_mode)) { ++ bfd_set_error (bfd_error_file_not_recognized); ++ return NULL; ++ } + + nbfd = _bfd_new_bfd (); + if (nbfd == NULL) --- binutils-2.22.orig/debian/patches/134_gold_no_spu.patch +++ binutils-2.22/debian/patches/134_gold_no_spu.patch @@ -0,0 +1,13 @@ +Author: +Description: Description: Don't configure gold for spu target. +--- a/Makefile.in ++++ b/Makefile.in +@@ -21929,7 +21929,7 @@ + srcdiroption="--srcdir=$${topdir}/gold"; \ + libsrcdir="$$s/gold"; \ + $(SHELL) $${libsrcdir}/configure \ +- $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \ ++ $$(echo $(HOST_CONFIGARGS) |sed 's/,spu//') --build=${build_alias} --host=${host_alias} \ + --target=${target_alias} $${srcdiroption} \ + || exit 1 + @endif gold --- binutils-2.22.orig/debian/patches/203-hjl-binutils-indirect.patch +++ binutils-2.22/debian/patches/203-hjl-binutils-indirect.patch @@ -0,0 +1,581 @@ +Description: PR ld/3351; avoid linker crash on ia64 +Author: H.J. Lu +Upstream status: hjl 2.21.51.0.6 +Original patch: binutils-indirect-4.patch + +bfd/ + +2006-10-17 H.J. Lu + + PR ld/3351 + * elflink.c (_bfd_elf_update_dynamic_flags): New. + (_bfd_elf_merge_symbol): Update both real and indirect symbol + dynamic flags. + (_bfd_elf_add_default_symbol): Make the real symbol dynamic if + the indirect symbol is defined in a shared library. + (elf_link_add_object_symbols): Likewise. If the indirect + symbol has been forced local, don't make the real symbol + dynamic. + (elf_link_check_versioned_symbol): Check indirect symbol. + (elf_link_output_extsym): Use real symbol definition when + reporting indirect symbol error. Check version info for + dynamic versioned symbol. + +ld/testsuite/ + +2006-10-17 H.J. Lu + + PR ld/3351 + * ld-elf/indirect.exp: New file. + * ld-elf/indirect1a.c: Likewise. + * ld-elf/indirect1b.c: Likewise. + * ld-elf/indirect1c.c: Likewise. + * ld-elf/indirect2.c: Likewise. + * ld-elf/indirect3.out: Likewise. + * ld-elf/indirect3a.c: Likewise. + * ld-elf/indirect3b.c: Likewise. + * ld-elf/indirect3c.c: Likewise. + * ld-elf/indirect4.out: Likewise. + * ld-elf/indirect4a.c: Likewise. + * ld-elf/indirect4b.c: Likewise. + * ld-elf/indirect4c.c: Likewise. + +diff --git a/bfd/elflink.c b/bfd/elflink.c +index 32575d9..f6f2740 100644 +--- a/bfd/elflink.c ++++ b/bfd/elflink.c +@@ -899,6 +899,33 @@ elf_merge_st_other (bfd *abfd, struct elf_link_hash_entry *h, + } + } + ++/* Mark if a symbol has a definition in a dynamic object or is ++ weak in all dynamic objects. */ ++ ++static void ++_bfd_elf_mark_dynamic_def_weak (struct elf_link_hash_entry *h, ++ asection *sec, int bind) ++{ ++ if (!h->dynamic_def) ++ { ++ if (!bfd_is_und_section (sec)) ++ h->dynamic_def = 1; ++ else ++ { ++ /* Check if this symbol is weak in all dynamic objects. If it ++ is the first time we see it in a dynamic object, we mark ++ if it is weak. Otherwise, we clear it. */ ++ if (!h->ref_dynamic) ++ { ++ if (bind == STB_WEAK) ++ h->dynamic_weak = 1; ++ } ++ else if (bind != STB_WEAK) ++ h->dynamic_weak = 0; ++ } ++ } ++} ++ + /* This function is called when we want to define a new symbol. It + handles the various cases which arise when we find a definition in + a dynamic object, or when there is already a definition in a +@@ -927,6 +954,7 @@ _bfd_elf_merge_symbol (bfd *abfd, + { + asection *sec, *oldsec; + struct elf_link_hash_entry *h; ++ struct elf_link_hash_entry *hi; + struct elf_link_hash_entry *flip; + int bind; + bfd *oldbfd; +@@ -965,8 +993,9 @@ _bfd_elf_merge_symbol (bfd *abfd, + if (!(*bed->relocs_compatible) (abfd->xvec, info->output_bfd->xvec)) + return TRUE; + +- /* For merging, we only care about real symbols. */ +- ++ /* For merging, we only care about real symbols. But we need to make ++ sure that indirect symbol dynamic flags are updated. */ ++ hi = h; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; +@@ -1138,23 +1167,11 @@ _bfd_elf_merge_symbol (bfd *abfd, + /* We need to remember if a symbol has a definition in a dynamic + object or is weak in all dynamic objects. Internal and hidden + visibility will make it unavailable to dynamic objects. */ +- if (newdyn && !h->dynamic_def) ++ if (newdyn) + { +- if (!bfd_is_und_section (sec)) +- h->dynamic_def = 1; +- else +- { +- /* Check if this symbol is weak in all dynamic objects. If it +- is the first time we see it in a dynamic object, we mark +- if it is weak. Otherwise, we clear it. */ +- if (!h->ref_dynamic) +- { +- if (bind == STB_WEAK) +- h->dynamic_weak = 1; +- } +- else if (bind != STB_WEAK) +- h->dynamic_weak = 0; +- } ++ _bfd_elf_mark_dynamic_def_weak (h, sec, bind); ++ if (h != hi) ++ _bfd_elf_mark_dynamic_def_weak (hi, sec, bind); + } + + /* If the old symbol has non-default visibility, we ignore the new +@@ -1166,6 +1183,7 @@ _bfd_elf_merge_symbol (bfd *abfd, + *skip = TRUE; + /* Make sure this symbol is dynamic. */ + h->ref_dynamic = 1; ++ hi->ref_dynamic = 1; + /* A protected symbol has external availability. Make sure it is + recorded as dynamic. + +@@ -1718,6 +1736,7 @@ _bfd_elf_add_default_symbol (bfd *abfd, + if (! dynamic) + { + if (! info->executable ++ || hi->def_dynamic + || hi->ref_dynamic) + *dynsym = TRUE; + } +@@ -3860,6 +3879,7 @@ error_free_dyn: + flagword flags; + const char *name; + struct elf_link_hash_entry *h; ++ struct elf_link_hash_entry *hi; + bfd_boolean definition; + bfd_boolean size_change_ok; + bfd_boolean type_change_ok; +@@ -4179,6 +4199,9 @@ error_free_dyn: + goto error_free_vers; + + h = *sym_hash; ++ /* We need to make sure that indirect symbol dynamic flags are ++ updated. */ ++ hi = h; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; +@@ -4371,22 +4394,36 @@ error_free_dyn: + h->dynamic_def = 1; + } + } +- if (! info->executable +- || h->def_dynamic +- || h->ref_dynamic) ++ ++ /* If the indirect symbol has been forced local, don't ++ make the real symbol dynamic. */ ++ if ((h == hi || !hi->forced_local) ++ && (! info->executable ++ || h->def_dynamic ++ || h->ref_dynamic)) + dynsym = TRUE; + } + else + { + if (! definition) +- h->ref_dynamic = 1; ++ { ++ h->ref_dynamic = 1; ++ hi->ref_dynamic = 1; ++ } + else +- h->def_dynamic = 1; +- if (h->def_regular +- || h->ref_regular +- || (h->u.weakdef != NULL +- && ! new_weakdef +- && h->u.weakdef->dynindx != -1)) ++ { ++ h->def_dynamic = 1; ++ hi->def_dynamic = 1; ++ } ++ ++ /* If the indirect symbol has been forced local, don't ++ make the real symbol dynamic. */ ++ if ((h == hi || !hi->forced_local) ++ && (h->def_regular ++ || h->ref_regular ++ || (h->u.weakdef != NULL ++ && ! new_weakdef ++ && h->u.weakdef->dynindx != -1))) + dynsym = TRUE; + } + +@@ -8442,6 +8479,10 @@ elf_link_check_versioned_symbol (struct bfd_link_info *info, + if (!is_elf_hash_table (info->hash)) + return FALSE; + ++ /* Check indirect symbol. */ ++ while (h->root.type == bfd_link_hash_indirect) ++ h = (struct elf_link_hash_entry *) h->root.u.i.link; ++ + switch (h->root.type) + { + default: +@@ -8662,6 +8703,11 @@ elf_link_output_extsym (struct elf_link_hash_entry *h, void *data) + { + bfd *def_bfd; + const char *msg; ++ struct elf_link_hash_entry *hi = h; ++ ++ /* Check indirect symbol. */ ++ while (hi->root.type == bfd_link_hash_indirect) ++ hi = (struct elf_link_hash_entry *) hi->root.u.i.link; + + if (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL) + msg = _("%B: internal symbol `%s' in %B is referenced by DSO"); +@@ -8670,8 +8716,8 @@ elf_link_output_extsym (struct elf_link_hash_entry *h, void *data) + else + msg = _("%B: local symbol `%s' in %B is referenced by DSO"); + def_bfd = finfo->output_bfd; +- if (h->root.u.def.section != bfd_abs_section_ptr) +- def_bfd = h->root.u.def.section->owner; ++ if (hi->root.u.def.section != bfd_abs_section_ptr) ++ def_bfd = hi->root.u.def.section->owner; + (*_bfd_error_handler) (msg, finfo->output_bfd, def_bfd, + h->root.root.string); + bfd_set_error (bfd_error_bad_value); +@@ -8899,6 +8945,23 @@ elf_link_output_extsym (struct elf_link_hash_entry *h, void *data) + { + bfd_byte *esym; + ++ /* Since there is no version information in the dynamic string, ++ if there is no version info in symbol version section, we will ++ have a run-time problem. */ ++ if (h->verinfo.verdef == NULL) ++ { ++ char *p = strrchr (h->root.root.string, ELF_VER_CHR); ++ ++ if (p && p [1] != '\0') ++ { ++ (*_bfd_error_handler) ++ (_("%B: No symbol version section for versioned symbol `%s'"), ++ finfo->output_bfd, h->root.root.string); ++ eoinfo->failed = TRUE; ++ return FALSE; ++ } ++ } ++ + sym.st_name = h->dynstr_index; + esym = finfo->dynsym_sec->contents + h->dynindx * bed->s->sizeof_sym; + if (! check_dynsym (finfo->output_bfd, &sym)) +diff --git a/ld/testsuite/ld-elf/indirect.exp b/ld/testsuite/ld-elf/indirect.exp +new file mode 100644 +index 0000000..603179a +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect.exp +@@ -0,0 +1,126 @@ ++# Expect script for various indirect symbol tests. ++# Copyright 2006 Free Software Foundation, Inc. ++# ++# This file 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. ++# ++ ++# ++# Written by H.J. Lu (hongjiu.lu@intel.com) ++# ++ ++# Exclude non-ELF targets. ++ ++if ![is_elf_format] { ++ return ++} ++ ++# Check if compiler works ++if { [which $CC] == 0 } { ++ return ++} ++ ++proc check_link_message { cmd string testname } { ++ send_log "$cmd\n" ++ verbose "$cmd" ++ catch "exec $cmd" exec_output ++ send_log "$exec_output\n" ++ verbose "$exec_output" ++ ++ foreach str $string { ++ if [string match "*$str*" $exec_output] { ++ pass "$testname: $str" ++ } else { ++ fail "$testname: $str" ++ } ++ } ++} ++ ++if { ![ld_compile $CC $srcdir/$subdir/indirect1a.c tmpdir/indirect1a.o] ++ || ![ld_compile $CC $srcdir/$subdir/indirect1b.c tmpdir/indirect1b.o] ++ || ![ld_compile "$CC -fPIC" $srcdir/$subdir/indirect2.c tmpdir/indirect2.o] ++ || ![ld_compile $CC $srcdir/$subdir/indirect3a.c tmpdir/indirect3a.o] ++ || ![ld_compile $CC $srcdir/$subdir/indirect3b.c tmpdir/indirect3b.o] ++ || ![ld_compile $CC $srcdir/$subdir/indirect4a.c tmpdir/indirect4a.o] ++ || ![ld_compile $CC $srcdir/$subdir/indirect4b.c tmpdir/indirect4b.o] } { ++ unresolved "Indirect symbol tests" ++ return ++} ++ ++set build_tests { ++ {"Build libindirect1c.so" ++ "-shared" "-fPIC" ++ {indirect1c.c} {} "libindirect1c.so"} ++ {"Build libindirect3c.so" ++ "-shared" "-fPIC" ++ {indirect3c.c} {} "libindirect3c.so"} ++ {"Build libindirect4c.so" ++ "-shared" "-fPIC" ++ {indirect4c.c} {} "libindirect4c.so"} ++} ++ ++run_cc_link_tests $build_tests ++ ++global ld ++ ++set string ": final link failed: Bad value" ++set string1 ": local symbol \`foo\' in tmpdir/indirect1b.o is referenced by DSO" ++ ++set testname "Indirect symbol 1a" ++set cmd "$ld -e start -o tmpdir/indirect1 tmpdir/indirect1a.o tmpdir/indirect1b.o tmpdir/libindirect1c.so" ++check_link_message "$cmd" [list $string1 $string] "$testname" ++ ++set testname "Indirect symbol 1b" ++set cmd "$ld -e start -o tmpdir/indirect1 tmpdir/indirect1a.o tmpdir/libindirect1c.so tmpdir/indirect1b.o" ++check_link_message "$cmd" [list $string1 $string] "$testname" ++ ++set string ": final link failed: Nonrepresentable section on output" ++set string2 ": No symbol version section for versioned symbol \`foo@FOO\'" ++set testname "Indirect symbol 2" ++set cmd "$ld -shared -o tmpdir/indirect2.so tmpdir/indirect2.o" ++check_link_message "$cmd" [list $string2 $string] "$testname" ++ ++# The following tests require running the executable generated by ld. ++if ![isnative] { ++ return ++} ++ ++set run_tests { ++ {"Run with libindirect3c.so 1" ++ "tmpdir/indirect3a.o tmpdir/indirect3b.o tmpdir/libindirect3c.so" "" ++ {dummy.c} "indirect3a" "indirect3.out"} ++ {"Run with libindirect3c.so 2" ++ "tmpdir/indirect3a.o tmpdir/libindirect3c.so tmpdir/indirect3b.o" "" ++ {dummy.c} "indirect3b" "indirect3.out"} ++ {"Run with libindirect3c.so 3" ++ "tmpdir/indirect3b.o tmpdir/libindirect3c.so tmpdir/indirect3a.o" "" ++ {dummy.c} "indirect3c" "indirect3.out"} ++ {"Run with libindirect3c.so 4" ++ "tmpdir/libindirect3c.so tmpdir/indirect3b.o tmpdir/indirect3a.o" "" ++ {dummy.c} "indirect3d" "indirect3.out"} ++ {"Run with libindirect4c.so 1" ++ "tmpdir/indirect4a.o tmpdir/indirect4b.o tmpdir/libindirect4c.so" "" ++ {dummy.c} "indirect4a" "indirect4.out"} ++ {"Run with libindirect4c.so 2" ++ "tmpdir/indirect4a.o tmpdir/libindirect4c.so tmpdir/indirect4b.o" "" ++ {dummy.c} "indirect4b" "indirect4.out"} ++ {"Run with libindirect4c.so 3" ++ "tmpdir/indirect4b.o tmpdir/libindirect4c.so tmpdir/indirect4a.o" "" ++ {dummy.c} "indirect4c" "indirect4.out"} ++ {"Run with libindirect4c.so 4" ++ "tmpdir/libindirect4c.so tmpdir/indirect4b.o tmpdir/indirect4a.o" "" ++ {dummy.c} "indirect4d" "indirect4.out"} ++} ++ ++run_ld_link_exec_tests [] $run_tests +diff --git a/ld/testsuite/ld-elf/indirect1a.c b/ld/testsuite/ld-elf/indirect1a.c +new file mode 100644 +index 0000000..6931542 +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect1a.c +@@ -0,0 +1,8 @@ ++extern void bar (void); ++ ++int ++start (void) ++{ ++ bar (); ++ return 0; ++} +diff --git a/ld/testsuite/ld-elf/indirect1b.c b/ld/testsuite/ld-elf/indirect1b.c +new file mode 100644 +index 0000000..51740f9 +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect1b.c +@@ -0,0 +1,6 @@ ++void ++foo (void) ++{ ++} ++ ++asm (".symver foo,foo@FOO"); +diff --git a/ld/testsuite/ld-elf/indirect1c.c b/ld/testsuite/ld-elf/indirect1c.c +new file mode 100644 +index 0000000..eae278d +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect1c.c +@@ -0,0 +1,7 @@ ++extern void foo (void); ++ ++void ++bar (void) ++{ ++ foo (); ++} +diff --git a/ld/testsuite/ld-elf/indirect2.c b/ld/testsuite/ld-elf/indirect2.c +new file mode 100644 +index 0000000..6df29be +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect2.c +@@ -0,0 +1,9 @@ ++extern void foo (void); ++ ++asm (".symver foo,foo@@@FOO"); ++ ++void ++bar (void) ++{ ++ foo (); ++} +diff --git a/ld/testsuite/ld-elf/indirect3.out b/ld/testsuite/ld-elf/indirect3.out +new file mode 100644 +index 0000000..482e981 +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect3.out +@@ -0,0 +1,2 @@ ++MAIN ++DSO +diff --git a/ld/testsuite/ld-elf/indirect3a.c b/ld/testsuite/ld-elf/indirect3a.c +new file mode 100644 +index 0000000..0f6ddc8 +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect3a.c +@@ -0,0 +1,10 @@ ++extern void bar (void); ++extern void foo (void); ++ ++int ++main (void) ++{ ++ foo (); ++ bar (); ++ return 0; ++} +diff --git a/ld/testsuite/ld-elf/indirect3b.c b/ld/testsuite/ld-elf/indirect3b.c +new file mode 100644 +index 0000000..dbb37c3 +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect3b.c +@@ -0,0 +1,9 @@ ++#include ++ ++void ++foo (void) ++{ ++ printf ("MAIN\n"); ++} ++ ++asm (".symver foo,foo@FOO"); +diff --git a/ld/testsuite/ld-elf/indirect3c.c b/ld/testsuite/ld-elf/indirect3c.c +new file mode 100644 +index 0000000..b52cb95 +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect3c.c +@@ -0,0 +1,15 @@ ++#include ++ ++extern void foo (void); ++ ++void ++foo (void) ++{ ++ printf ("DSO\n"); ++} ++ ++void ++bar (void) ++{ ++ foo (); ++} +diff --git a/ld/testsuite/ld-elf/indirect4.out b/ld/testsuite/ld-elf/indirect4.out +new file mode 100644 +index 0000000..3b34ee4 +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect4.out +@@ -0,0 +1,2 @@ ++MAIN2 ++MAIN2 +diff --git a/ld/testsuite/ld-elf/indirect4a.c b/ld/testsuite/ld-elf/indirect4a.c +new file mode 100644 +index 0000000..0f6ddc8 +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect4a.c +@@ -0,0 +1,10 @@ ++extern void bar (void); ++extern void foo (void); ++ ++int ++main (void) ++{ ++ foo (); ++ bar (); ++ return 0; ++} +diff --git a/ld/testsuite/ld-elf/indirect4b.c b/ld/testsuite/ld-elf/indirect4b.c +new file mode 100644 +index 0000000..b8db9d0 +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect4b.c +@@ -0,0 +1,17 @@ ++#include ++ ++void ++foo2 (void) ++{ ++ printf ("MAIN2\n"); ++} ++ ++asm (".symver foo2,foo@@FOO2"); ++ ++void ++foo1 (void) ++{ ++ printf ("MAIN1\n"); ++} ++ ++asm (".symver foo1,foo@FOO1"); +diff --git a/ld/testsuite/ld-elf/indirect4c.c b/ld/testsuite/ld-elf/indirect4c.c +new file mode 100644 +index 0000000..b52cb95 +--- /dev/null ++++ b/ld/testsuite/ld-elf/indirect4c.c +@@ -0,0 +1,15 @@ ++#include ++ ++extern void foo (void); ++ ++void ++foo (void) ++{ ++ printf ("DSO\n"); ++} ++ ++void ++bar (void) ++{ ++ foo (); ++} --- binutils-2.22.orig/debian/patches/213-hjl-binutils-sec64k.patch +++ binutils-2.22/debian/patches/213-hjl-binutils-sec64k.patch @@ -0,0 +1,503 @@ +Description: Proposed patch for PR binutils/6412 +Author: H.J. Lu +Upstream status: hjl 2.20.51.0.8 +Original patch: binutils-sec64k-7.patch + +bfd/ + +2008-04-21 H.J. Lu + + PR binutils/6412 + * bfd.c (bfd): Add has_gap_in_elf_shndx. + * bfd-in2.h: Regenerated. + + * bfd-in.h (bfd_has_gap_in_elf_shndx): New. + + * elf.c (setup_group): Handle gap in section indices. + * elfcode.h (elf_swap_symbol_in): Likewise. + (elf_object_p): Likewise. Use %B where reporting corrupt + string table index. + +include/elf/ + +2008-04-21 H.J. Lu + + PR binutils/6412 + * internal.h (ELF_SECTION_HEADER_INDEX_GAP): New. + +binutils/ + +2008-04-21 H.J. Lu + + PR binutils/6412 + * readelf.c (hole_in_shndx): New. + (original_shndx_info): Likewise. + (original_shndx): Likewise. + (process_file_header): Move ELF magic bytes check to ... + (get_file_header): Here. + (get_32bit_section_headers): Set hole_in_shndx if sh_link + >= number of sections. + (get_64bit_section_headers): Likewise. + (get_32bit_elf_symbols): Adjust st_shndx if hole_in_shndx + isn't 0. + (get_64bit_elf_symbols): Likewise. + (process_section_headers): Adjust elf_header.e_shstrndx, + sh_link and sh_info, save original sh_link and sh_info, + display adjustment for sh_link and sh_info if hole_in_shndx + isn't 0. + (process_section_groups): Adjust member section index if + hole_in_shndx isn't 0. + (process_object): Free original_shndx if needed. + +--- a/bfd/bfd-in.h ++++ b/bfd/bfd-in.h +@@ -497,6 +497,7 @@ + #define bfd_my_archive(abfd) ((abfd)->my_archive) + #define bfd_has_map(abfd) ((abfd)->has_armap) + #define bfd_is_thin_archive(abfd) ((abfd)->is_thin_archive) ++#define bfd_has_gap_in_elf_shndx(abfd) ((abfd)->has_gap_in_elf_shndx) + + #define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types) + #define bfd_usrdata(abfd) ((abfd)->usrdata) +--- a/bfd/bfd-in2.h ++++ b/bfd/bfd-in2.h +@@ -504,6 +504,7 @@ + #define bfd_my_archive(abfd) ((abfd)->my_archive) + #define bfd_has_map(abfd) ((abfd)->has_armap) + #define bfd_is_thin_archive(abfd) ((abfd)->is_thin_archive) ++#define bfd_has_gap_in_elf_shndx(abfd) ((abfd)->has_gap_in_elf_shndx) + + #define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types) + #define bfd_usrdata(abfd) ((abfd)->usrdata) +@@ -5196,6 +5197,9 @@ + /* Set if only required symbols should be added in the link hash table for + this object. Used by VMS linkers. */ + unsigned int selective_search : 1; ++ ++ /* Set if there is a gap in ELF section index. */ ++ unsigned int has_gap_in_elf_shndx : 1; + }; + + typedef enum bfd_error +--- a/bfd/bfd.c ++++ b/bfd/bfd.c +@@ -290,6 +290,9 @@ + . {* Set if only required symbols should be added in the link hash table for + . this object. Used by VMS linkers. *} + . unsigned int selective_search : 1; ++. ++. {* Set if there is a gap in ELF section index. *} ++. unsigned int has_gap_in_elf_shndx : 1; + .}; + . + */ +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -632,6 +632,12 @@ + |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; + break; + } ++ ++ /* Handle gap in section indices. */ ++ if (bfd_has_gap_in_elf_shndx (abfd) ++ && idx > (SHN_HIRESERVE & 0xffff)) ++ idx -= ELF_SECTION_HEADER_INDEX_GAP; ++ + if (idx >= shnum) + { + ((*_bfd_error_handler) +--- a/bfd/elfcode.h ++++ b/bfd/elfcode.h +@@ -195,6 +195,10 @@ + if (shndx == NULL) + return FALSE; + dst->st_shndx = H_GET_32 (abfd, shndx->est_shndx); ++ /* Handle gap in section indices. */ ++ if (bfd_has_gap_in_elf_shndx (abfd) ++ && dst->st_shndx > (SHN_HIRESERVE & 0xffff)) ++ dst->st_shndx -= ELF_SECTION_HEADER_INDEX_GAP; + } + else if (dst->st_shndx >= (SHN_LORESERVE & 0xffff)) + dst->st_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff); +@@ -815,6 +819,28 @@ + != 0)) + abfd->flags &= ~D_PAGED; + } ++ ++ /* To support files generated by the older linker, we adjust ++ section indices if there is a gap. */ ++ if (bfd_has_gap_in_elf_shndx (abfd)) ++ { ++ BFD_ASSERT (i_ehdrp->e_shstrndx == i_shdrp->sh_link); ++ ++ for (; num_sec > 0; num_sec--, i_shdrp++) ++ { ++ if (i_shdrp->sh_link > (SHN_HIRESERVE & 0xffff)) ++ i_shdrp->sh_link -= ELF_SECTION_HEADER_INDEX_GAP; ++ ++ if (i_shdrp->sh_info > (SHN_HIRESERVE & 0xffff) ++ && ((i_shdrp->sh_flags & SHF_INFO_LINK) ++ || i_shdrp->sh_type == SHT_RELA ++ || i_shdrp->sh_type == SHT_REL)) ++ i_shdrp->sh_info -= ELF_SECTION_HEADER_INDEX_GAP; ++ } ++ ++ if (i_ehdrp->e_shstrndx > (SHN_HIRESERVE & 0xffff)) ++ i_ehdrp->e_shstrndx -= ELF_SECTION_HEADER_INDEX_GAP; ++ } + } + + /* A further sanity check. */ +@@ -829,7 +855,8 @@ + So we are kind, and reset the string index value to 0 + so that at least some processing can be done. */ + i_ehdrp->e_shstrndx = SHN_UNDEF; +- _bfd_error_handler (_("warning: %s has a corrupt string table index - ignoring"), abfd->filename); ++ _bfd_error_handler (_("warning: %B has a corrupt string table index - ignoring"), ++ abfd); + } + } + else if (i_ehdrp->e_shstrndx != SHN_UNDEF) +--- a/binutils/readelf.c ++++ b/binutils/readelf.c +@@ -198,6 +198,15 @@ + static int do_archive_index; + static int is_32bit_elf; + ++struct original_shndx_info ++{ ++ unsigned int sh_link; ++ unsigned int sh_info; ++}; ++static struct original_shndx_info *original_shndx; ++/* The largest section index in sh_link if it isn't 0. */ ++static unsigned int hole_in_shndx; ++ + struct group_list + { + struct group_list * next; +@@ -3485,16 +3494,6 @@ + static int + process_file_header (void) + { +- if ( elf_header.e_ident[EI_MAG0] != ELFMAG0 +- || elf_header.e_ident[EI_MAG1] != ELFMAG1 +- || elf_header.e_ident[EI_MAG2] != ELFMAG2 +- || elf_header.e_ident[EI_MAG3] != ELFMAG3) +- { +- error +- (_("Not an ELF file - it has the wrong magic bytes at the start\n")); +- return 0; +- } +- + init_dwarf_regnames (elf_header.e_machine); + + if (do_header) +@@ -3993,6 +3992,10 @@ + internal->sh_info = BYTE_GET (shdrs[i].sh_info); + internal->sh_addralign = BYTE_GET (shdrs[i].sh_addralign); + internal->sh_entsize = BYTE_GET (shdrs[i].sh_entsize); ++ /* The older linker generates section header indices with ++ hole. */ ++ if (i > 0 && internal->sh_link >= elf_header.e_shnum) ++ hole_in_shndx = internal->sh_link; + } + + free (shdrs); +@@ -4036,6 +4039,10 @@ + internal->sh_info = BYTE_GET (shdrs[i].sh_info); + internal->sh_offset = BYTE_GET (shdrs[i].sh_offset); + internal->sh_addralign = BYTE_GET (shdrs[i].sh_addralign); ++ /* The older linker generates section header indices with ++ hole. */ ++ if (i > 0 && internal->sh_link >= elf_header.e_shnum) ++ hole_in_shndx = internal->sh_link; + } + + free (shdrs); +@@ -4101,8 +4108,12 @@ + psym->st_size = BYTE_GET (esyms[j].st_size); + psym->st_shndx = BYTE_GET (esyms[j].st_shndx); + if (psym->st_shndx == (SHN_XINDEX & 0xffff) && shndx != NULL) +- psym->st_shndx +- = byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j])); ++ { ++ psym->st_shndx ++ = byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j])); ++ if (hole_in_shndx && psym->st_shndx > (SHN_HIRESERVE & 0xffff)) ++ psym->st_shndx -= ELF_SECTION_HEADER_INDEX_GAP; ++ } + else if (psym->st_shndx >= (SHN_LORESERVE & 0xffff)) + psym->st_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff); + psym->st_info = BYTE_GET (esyms[j].st_info); +@@ -4184,8 +4195,12 @@ + psym->st_other = BYTE_GET (esyms[j].st_other); + psym->st_shndx = BYTE_GET (esyms[j].st_shndx); + if (psym->st_shndx == (SHN_XINDEX & 0xffff) && shndx != NULL) +- psym->st_shndx +- = byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j])); ++ { ++ psym->st_shndx ++ = byte_get ((unsigned char *) &shndx[j], sizeof (shndx[j])); ++ if (hole_in_shndx && psym->st_shndx > (SHN_HIRESERVE & 0xffff)) ++ psym->st_shndx -= ELF_SECTION_HEADER_INDEX_GAP; ++ } + else if (psym->st_shndx >= (SHN_LORESERVE & 0xffff)) + psym->st_shndx += SHN_LORESERVE - (SHN_LORESERVE & 0xffff); + psym->st_value = BYTE_GET (esyms[j].st_value); +@@ -4433,6 +4448,7 @@ + unsigned int i; + + section_headers = NULL; ++ original_shndx = NULL; + + if (elf_header.e_shnum == 0) + { +@@ -4454,6 +4470,44 @@ + else if (! get_64bit_section_headers (file, elf_header.e_shnum)) + return 0; + ++ if (hole_in_shndx ++ && ((hole_in_shndx - ELF_SECTION_HEADER_INDEX_GAP) ++ < elf_header.e_shnum)) ++ { ++ Elf_Internal_Shdr *internal; ++ struct original_shndx_info *p; ++ ++ if (elf_header.e_shstrndx > (SHN_HIRESERVE & 0xffff)) ++ elf_header.e_shstrndx -= ELF_SECTION_HEADER_INDEX_GAP; ++ ++ original_shndx = cmalloc (elf_header.e_shnum, ++ sizeof (*original_shndx)); ++ if (original_shndx == NULL) ++ { ++ error (_("Out of memory\n")); ++ return 0; ++ } ++ ++ internal = section_headers; ++ p = original_shndx; ++ for (i = elf_header.e_shnum; ++ i > 0; ++ i--, internal++, p++) ++ { ++ p->sh_link = internal->sh_link; ++ p->sh_info = internal->sh_info; ++ ++ if (internal->sh_link > (SHN_HIRESERVE & 0xffff)) ++ internal->sh_link -= ELF_SECTION_HEADER_INDEX_GAP; ++ ++ if (internal->sh_info > (SHN_HIRESERVE & 0xffff) ++ && (internal->sh_flags & SHF_INFO_LINK ++ || internal->sh_type == SHT_REL ++ || internal->sh_type == SHT_RELA)) ++ internal->sh_info -= ELF_SECTION_HEADER_INDEX_GAP; ++ } ++ } ++ + /* Read in the string table, so that we have names to display. */ + if (elf_header.e_shstrndx != SHN_UNDEF + && elf_header.e_shstrndx < elf_header.e_shnum) +@@ -4750,7 +4804,23 @@ + } + } + +- if (do_section_details) ++ if (hole_in_shndx && original_shndx) ++ { ++ if (original_shndx[i].sh_link != section->sh_link) ++ printf ("%2u/-%3u ", ++ original_shndx[i].sh_link, ++ ELF_SECTION_HEADER_INDEX_GAP); ++ else ++ printf ("%2u ", section->sh_link); ++ if (original_shndx[i].sh_info != section->sh_info) ++ printf ("%3u/-%3u ", ++ original_shndx[i].sh_info, ++ ELF_SECTION_HEADER_INDEX_GAP); ++ else ++ printf ("%3u ", section->sh_info); ++ printf ("%2lu\n", (unsigned long) section->sh_addralign); ++ } ++ else if (do_section_details) + { + if (link_too_big != NULL && * link_too_big) + printf ("<%s> ", link_too_big); +@@ -4802,7 +4872,23 @@ + else + printf (" %3s ", get_elf_section_flags (section->sh_flags)); + +- printf ("%2u %3u ", section->sh_link, section->sh_info); ++ if (hole_in_shndx) ++ { ++ if (original_shndx[i].sh_link != section->sh_link) ++ printf ("%2u/-%3u ", ++ original_shndx[i].sh_link, ++ ELF_SECTION_HEADER_INDEX_GAP); ++ else ++ printf ("%2u ", section->sh_link); ++ if (original_shndx[i].sh_info != section->sh_info) ++ printf ("%3u/-%3u ", ++ original_shndx[i].sh_info, ++ ELF_SECTION_HEADER_INDEX_GAP); ++ else ++ printf ("%3u ", section->sh_info); ++ } ++ else ++ printf ("%2u %3u ", section->sh_link, section->sh_info); + + if ((unsigned long) section->sh_addralign == section->sh_addralign) + printf ("%2lu\n", (unsigned long) section->sh_addralign); +@@ -4824,14 +4910,35 @@ + printf (" "); + print_vma (section->sh_offset, LONG_HEX); + } +- printf (" %u\n ", section->sh_link); ++ if (hole_in_shndx) ++ { ++ if (original_shndx[i].sh_link != section->sh_link) ++ printf (" %u/-%3u\n ", ++ original_shndx[i].sh_link, ++ ELF_SECTION_HEADER_INDEX_GAP); ++ else ++ printf (" %u\n ", section->sh_link); ++ } ++ else ++ printf (" %u\n ", section->sh_link); + print_vma (section->sh_size, LONG_HEX); + putchar (' '); + print_vma (section->sh_entsize, LONG_HEX); + +- printf (" %-16u %lu\n", +- section->sh_info, +- (unsigned long) section->sh_addralign); ++ if (hole_in_shndx) ++ { ++ if (original_shndx[i].sh_info != section->sh_info) ++ printf (" %-11u/-%3u", ++ original_shndx[i].sh_info, ++ ELF_SECTION_HEADER_INDEX_GAP); ++ else ++ printf (" %-16u", section->sh_info); ++ printf (" %lu\n", (unsigned long) section->sh_addralign); ++ } ++ else ++ printf (" %-16u %lu\n", ++ section->sh_info, ++ (unsigned long) section->sh_addralign); + } + else + { +@@ -4851,10 +4958,28 @@ + + printf (" %3s ", get_elf_section_flags (section->sh_flags)); + +- printf (" %2u %3u %lu\n", +- section->sh_link, +- section->sh_info, +- (unsigned long) section->sh_addralign); ++ if (hole_in_shndx) ++ { ++ if (original_shndx[i].sh_link != section->sh_link) ++ printf (" %2u/-%3u", ++ original_shndx[i].sh_link, ++ ELF_SECTION_HEADER_INDEX_GAP); ++ else ++ printf (" %2u", section->sh_link); ++ if (original_shndx[i].sh_info != section->sh_info) ++ printf (" %3u/-%3u", ++ original_shndx[i].sh_info, ++ ELF_SECTION_HEADER_INDEX_GAP); ++ else ++ printf (" %3u", section->sh_info); ++ printf (" %lu\n", ++ (unsigned long) section->sh_addralign); ++ } ++ else ++ printf (" %2u %3u %lu\n", ++ section->sh_link, ++ section->sh_info, ++ (unsigned long) section->sh_addralign); + } + + if (do_section_details) +@@ -5069,10 +5194,15 @@ + for (j = 0; j < size; j++) + { + struct group_list * g; ++ unsigned int orig; + + entry = byte_get (indices, 4); + indices += 4; + ++ orig = entry; ++ if (hole_in_shndx && entry > (SHN_HIRESERVE & 0xffff)) ++ entry -= ELF_SECTION_HEADER_INDEX_GAP; ++ + if (entry >= elf_header.e_shnum) + { + error (_("section [%5u] in group section [%5u] > maximum section [%5u]\n"), +@@ -5109,7 +5239,13 @@ + if (do_section_groups) + { + sec = section_headers + entry; +- printf (" [%5u] %s\n", entry, SECTION_NAME (sec)); ++ if (orig != entry) ++ printf (" [%5u/-%3u] %s\n", ++ orig, ELF_SECTION_HEADER_INDEX_GAP, ++ SECTION_NAME (sec)); ++ else ++ printf (" [%5u] %s\n", ++ entry, SECTION_NAME (sec)); + } + + g = (struct group_list *) xmalloc (sizeof (struct group_list)); +@@ -12086,6 +12222,15 @@ + if (fread (elf_header.e_ident, EI_NIDENT, 1, file) != 1) + return 0; + ++ if (elf_header.e_ident[EI_MAG0] != ELFMAG0 ++ || elf_header.e_ident[EI_MAG1] != ELFMAG1 ++ || elf_header.e_ident[EI_MAG2] != ELFMAG2 ++ || elf_header.e_ident[EI_MAG3] != ELFMAG3) ++ { ++ error (_("Not an ELF file - it has the wrong magic bytes at the start\n")); ++ return 0; ++ } ++ + /* Determine how to read the rest of the header. */ + switch (elf_header.e_ident[EI_DATA]) + { +@@ -12181,6 +12326,8 @@ + { + unsigned int i; + ++ hole_in_shndx = 0; ++ + if (! get_file_header (file)) + { + error (_("%s: Failed to read file header\n"), file_name); +@@ -12268,6 +12415,12 @@ + section_headers = NULL; + } + ++ if (original_shndx) ++ { ++ free (original_shndx); ++ original_shndx = NULL; ++ } ++ + if (string_table) + { + free (string_table); +--- a/include/elf/internal.h ++++ b/include/elf/internal.h +@@ -342,4 +342,8 @@ + #define ELF_SECTION_IN_SEGMENT_STRICT(sec_hdr, segment) \ + (ELF_SECTION_IN_SEGMENT_1 (sec_hdr, segment, 1, 1)) + ++/* The gap in section indices created by the older linker before ++ bug fix for PR ld/5900. */ ++#define ELF_SECTION_HEADER_INDEX_GAP (SHN_HIRESERVE + 1 - SHN_LORESERVE) ++ + #endif /* _ELF_INTERNAL_H */ --- binutils-2.22.orig/debian/patches/pr13534-04.diff +++ binutils-2.22/debian/patches/pr13534-04.diff @@ -0,0 +1,82 @@ +commit 70ed6152e1e163b9ca240fe8b91aa3feb942ac84 +Author: Francois Gouget +Date: Tue Dec 20 18:45:18 2011 +0100 + + bfd: Always use bfd_size_type to manipulate the size of an archive element. + + Other types may not be able to deal with archive elements larger than 2GB. + +diff --git a/bfd/archive.c b/bfd/archive.c +index 01acf98..c1438ef 100644 +--- a/bfd/archive.c ++++ b/bfd/archive.c +@@ -748,7 +748,7 @@ bfd_generic_openr_next_archived_file (bfd *archive, bfd *last_file) + filestart = bfd_ardata (archive)->first_file_filepos; + else + { +- unsigned int size = arelt_size (last_file); ++ bfd_size_type size = arelt_size (last_file); + + filestart = last_file->proxy_origin; + if (! bfd_is_thin_archive (archive)) +@@ -946,7 +946,7 @@ do_slurp_coff_armap (bfd *abfd) + struct artdata *ardata = bfd_ardata (abfd); + char *stringbase; + bfd_size_type stringsize; +- unsigned int parsed_size; ++ bfd_size_type parsed_size; + carsym *carsyms; + bfd_size_type nsymz; /* Number of symbols in armap. */ + bfd_vma (*swap) (const void *); +@@ -2174,7 +2174,7 @@ _bfd_write_archive_contents (bfd *arch) + current = current->archive_next) + { + char buffer[DEFAULT_BUFFERSIZE]; +- unsigned int remaining = arelt_size (current); ++ bfd_size_type remaining = arelt_size (current); + + /* Write ar header. */ + if (!_bfd_write_ar_hdr (arch, current)) +diff --git a/bfd/bfdio.c b/bfd/bfdio.c +index 841c781..5bc8061 100644 +--- a/bfd/bfdio.c ++++ b/bfd/bfdio.c +@@ -185,7 +185,7 @@ bfd_bread (void *ptr, bfd_size_type size, bfd *abfd) + this element. */ + if (abfd->arelt_data != NULL) + { +- size_t maxbytes = ((struct areltdata *) abfd->arelt_data)->parsed_size; ++ bfd_size_type maxbytes = arelt_size (abfd); + if (abfd->where + size > maxbytes) + { + if (abfd->where >= maxbytes) +diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h +index a4ba4b6..683c1cc 100644 +--- a/bfd/libbfd-in.h ++++ b/bfd/libbfd-in.h +@@ -90,8 +90,8 @@ struct artdata { + /* Goes in bfd's arelt_data slot */ + struct areltdata { + char * arch_header; /* it's actually a string */ +- unsigned int parsed_size; /* octets of filesize not including ar_hdr */ +- unsigned int extra_size; /* BSD4.4: extra bytes after the header. */ ++ bfd_size_type parsed_size; /* octets of filesize not including ar_hdr */ ++ bfd_size_type extra_size; /* BSD4.4: extra bytes after the header. */ + char *filename; /* null-terminated */ + file_ptr origin; /* for element of a thin archive */ + }; +diff --git a/bfd/libbfd.h b/bfd/libbfd.h +index 7f142d0..6d27901 100644 +--- a/bfd/libbfd.h ++++ b/bfd/libbfd.h +@@ -95,8 +95,8 @@ struct artdata { + /* Goes in bfd's arelt_data slot */ + struct areltdata { + char * arch_header; /* it's actually a string */ +- unsigned int parsed_size; /* octets of filesize not including ar_hdr */ +- unsigned int extra_size; /* BSD4.4: extra bytes after the header. */ ++ bfd_size_type parsed_size; /* octets of filesize not including ar_hdr */ ++ bfd_size_type extra_size; /* BSD4.4: extra bytes after the header. */ + char *filename; /* null-terminated */ + file_ptr origin; /* for element of a thin archive */ + }; --- binutils-2.22.orig/debian/patches/128_ppc64_powerpc_biarch.patch +++ binutils-2.22/debian/patches/128_ppc64_powerpc_biarch.patch @@ -0,0 +1,15 @@ +--- a/ld/emulparams/elf32ppccommon.sh 2011-03-01 21:36:22.239025005 +0000 ++++ b/ld/emulparams/elf32ppccommon.sh 2011-03-01 21:38:13.187024999 +0000 +@@ -48,3 +48,12 @@ + case "$EMULATION_NAME" in + *64*) LIBPATH_SUFFIX=64 ;; + esac ++ ++# On 64bit, look for 32 bit target libraries in /lib32, /usr/lib32 etc., first. ++case "$target" in ++ powerpc64-*-linux* | ppc64-*-linux*) ++ case "$EMULATION_NAME" in ++ *32*) LIBPATH_SUFFIX=32 ;; ++ esac ++ ;; ++esac --- binutils-2.22.orig/debian/patches/200-hjl-ld-env.patch +++ binutils-2.22/debian/patches/200-hjl-ld-env.patch @@ -0,0 +1,65 @@ +Description: Handle LD_SYMBOLIC and LD_SYMBOLIC_FUNCTIONS env vars +Author: H.J. Lu +Upstream status: hjl 2.20.51.0.7 +Original patch: ld-env-11.patch + +2007-01-24 H.J. Lu + + * NEWS: Mention LD_SYMBOLIC and LD_SYMBOLIC_FUNCTIONS. + + * ld.texinfo: Document LD_SYMBOLIC and LD_SYMBOLIC_FUNCTIONS. + + * ldmain.c (main): Handle LD_SYMBOLIC and + LD_SYMBOLIC_FUNCTIONS. + +--- ./ld/NEWS.env 2008-09-08 09:34:53.000000000 -0700 ++++ ./ld/NEWS 2008-09-08 09:36:43.000000000 -0700 +@@ -1,5 +1,8 @@ + -*- text -*- + ++* ELF: Support environment variables, LD_SYMBOLIC for -Bsymbolic and ++ LD_SYMBOLIC_FUNCTIONS for -Bsymbolic-functions. ++ + Changes in 2.19: + + * Linker scripts support a new INSERT command that makes it easier to +--- ./ld/ld.texinfo.env 2008-07-22 07:19:39.000000000 -0700 ++++ ./ld/ld.texinfo 2008-09-08 09:35:29.000000000 -0700 +@@ -1147,14 +1147,21 @@ When creating a shared library, bind ref + definition within the shared library, if any. Normally, it is possible + for a program linked against a shared library to override the definition + within the shared library. This option is only meaningful on ELF +-platforms which support shared libraries. ++platforms which support shared libraries. If @option{-Bsymbolic} is not ++used when linking a shared library, the linker will also turn on this ++option if the environment variable @code{LD_SYMBOLIC} is set. + + @kindex -Bsymbolic-functions + @item -Bsymbolic-functions + When creating a shared library, bind references to global function + symbols to the definition within the shared library, if any. + This option is only meaningful on ELF platforms which support shared +-libraries. ++libraries. If @option{-Bsymbolic-functions} is not used when linking a ++shared library, the linker will also turn on this option if the ++environment variable @code{LD_SYMBOLIC_FUNCTIONS} is set. When ++both environment variables @code{LD_SYMBOLIC} and ++@code{LD_SYMBOLIC_FUNCTIONS} are set, @code{LD_SYMBOLIC} will take ++precedent. + + @kindex --dynamic-list=@var{dynamic-list-file} + @item --dynamic-list=@var{dynamic-list-file} +--- ./ld/ldmain.c.env 2008-09-08 09:35:29.000000000 -0700 ++++ ./ld/ldmain.c 2008-09-08 09:35:29.000000000 -0700 +@@ -253,6 +253,11 @@ main (int argc, char **argv) + command_line.warn_search_mismatch = TRUE; + command_line.check_section_addresses = TRUE; + ++ if (getenv ("LD_SYMBOLIC") != NULL) ++ command_line.symbolic = symbolic; ++ else if (getenv ("LD_SYMBOLIC_FUNCTIONS") != NULL) ++ command_line.symbolic = symbolic_functions; ++ + /* We initialize DEMANGLING based on the environment variable + COLLECT_NO_DEMANGLE. The gcc collect2 program will demangle the + output of the linker, unless COLLECT_NO_DEMANGLE is set in the --- binutils-2.22.orig/debian/patches/212-hjl-bfd-64k.patch +++ binutils-2.22/debian/patches/212-hjl-bfd-64k.patch @@ -0,0 +1,48 @@ +Description: elf.c (assign_section_numbers): Check if number of sections +Description: >= SHN_LORESERVE. +Description: elfcode.h (elf_object_p): Likewise. +Author: H.J. Lu +Upstream status: hjl 2.18.50.0.5 +Original patch: bfd-64k-2.patch + +2008-03-12 H.J. Lu + + * elf.c (assign_section_numbers): Check if number of sections + >= SHN_LORESERVE. + * elfcode.h (elf_object_p): Likewise. + +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -2919,6 +2919,13 @@ + _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->strtab_hdr.sh_name); + } + ++ if (section_number >= SHN_LORESERVE) ++ { ++ _bfd_error_handler (_("%B: too many sections: %u"), ++ abfd, section_number); ++ return FALSE; ++ } ++ + _bfd_elf_strtab_finalize (elf_shstrtab (abfd)); + t->shstrtab_hdr.sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd)); + +--- a/bfd/elfcode.h ++++ b/bfd/elfcode.h +@@ -692,8 +692,14 @@ + if (i_ehdrp->e_shnum == SHN_UNDEF) + { + i_ehdrp->e_shnum = i_shdr.sh_size; +- if (i_ehdrp->e_shnum != i_shdr.sh_size +- || i_ehdrp->e_shnum == 0) ++ if (i_ehdrp->e_shnum >= SHN_LORESERVE) ++ { ++ _bfd_error_handler (_("%B: too many sections: %u"), ++ abfd, i_ehdrp->e_shnum); ++ abort (); ++ } ++ else if (i_ehdrp->e_shnum != i_shdr.sh_size ++ || i_ehdrp->e_shnum == 0) + goto got_wrong_format_error; + } + --- binutils-2.22.orig/debian/patches/binutils-bz17512-misc.patch +++ binutils-2.22/debian/patches/binutils-bz17512-misc.patch @@ -0,0 +1,5203 @@ +From 32a9d621c3c480aa093a089a36e36c35f68a4010 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Mon, 17 Nov 2014 16:59:09 +0000 +Subject: [PATCH] Applies a series of patches for PR 17512 and 17533 which fix invalid memory accesses. +Origin: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=32a9d621c3c480aa093a089a36e36c35f68a4010 +Bug-Upstream: https://sourceware.org/bugzilla/show_bug.cgi?id=17512#c95 + + 2014-11-13 Nick Clifton + + PR binutils/17512 + * config/obj-coff.c (coff_obj_symbol_new_hook): Set the is_sym + field. + + 2014-11-14 Nick Clifton + + PR binutils/17512 + * dwarf.c (get_encoded_value): Add an 'end' parameter. Change the + 'data' parameter to a double pointer and return the updated value. + (decode_location_expression): Update call to get_encoded_value. + (frame_need_space): Handle the case where one or both of the + mallocs fails. + (read_cie): Initialise the cie pointer, even if the read fails. + (display_debug_frames): Warn if the calculated block_end is before + the start of the block. Break the loop if the CIE could not be + read. Update call to get_encoded_value. Warn if the read CFA + expressions are too big. + + 2014-11-13 Nick Clifton + + PR binutils/17531 + * readelf.c (process_version_sections): If the read of the version + def information fails, make sure that the external verdef data is + not used. + (get_dynamic_data): Do not attempt to allocate memory for more + dynamic data than there is in the file. If the read fails, free + the allocated buffer. + (process_symbol_table): Do not print dynamic information if we + were unable to read the dynamic symbol table. + (print_gnu_note): Do not print the note if the descsz is too + small. + + 2014-11-12 Nick Clifton + + PR binutils/17512 + * dwarf.c (read_and_display_attr_value): Check that we do not read + past end. + (display_debug_pubnames_worker): Add range checks. + (process_debug_info): Check for invalid pointer sizes. + (display_loc_list): Likewise. + (display_loc_list_dwo): Likewise. + (display_debug_ranges): Likewise. + (display_debug_aranges): Check for invalid address size. + (read_cie): Add range checks. Replace call strchr with while loop. + * objdump.c (dump_dwarf): Replace abort with a warning message. + (print_section_stabs): Improve range checks. + * rdcoff.c (coff_get_slot): Use long for indx parameter type. + Add check for an excesively large index. + * rddbg.c (read_section_stabs_debugging_info): Zero terminate the + string table. Avoid walking off the end of the stabs data. + * stabs.c (parse_stab_string): Add check for a NULL name. + + 2014-11-11 Nick Clifton + + PR binutils/17531 + * binutils/readelf.c (dynamic_nent): Change type to size_t. + (slurp_rela_relocs): Use size_t type for nrelas. + (slurp_rel_relocs): Likewise. + (get_program_headers): Improve out of memory error message. + (get_32bit_section_headers): Likewise. + (get_32bit_section_headers): Likewise. + (get_64bit_section_headers): Likewise. + (get_32bit_elf_symbols): Likewise. + (get_64bit_elf_symbols): Likewise. + (process_section_groups): Likewise. + (get_32bit_dynamic_section): Likewise. + (get_64bit_dynamic_section): Likewise. + (process_dynamic_section): Likewise. + (process_version_sections): Likewise. + (get_symbol_index_type): Likewise. + (process_mips_specific): Likewise. + (process_corefile_note_segment): Likewise. + (process_version_sections): Use size_t type for total. + (get_dynamic_data): Change type of number parameter to size_t. + Improve out of memory error messages. + (process_symbol_table): Change type of nbuckets and nchains to + size_t. Skip processing of sections headers if there are none. + Improve out of memory error messages. + + 2014-11-11 Nick Clifton + + PR binutils/17531 + * readelf.c (display_arm_attribute): Avoid reading off the end of + the buffer when processing a Tag_nodefaults. + + 2014-11-10 Nick Clifton + + PR binutils/17531 + * readelf.c (ia64_process_unwind): Replace assertion with an error + message. Add range checking for group section indicies. + (hppa_process_unwind): Replace assertion with an error message. + (process_syminfo): Likewise. + (decode_arm_unwind_bytecode): Add range checking. + (dump_section_as_strings): Add more string range checking. + (display_tag_value): Likewise. + (display_arm_attribute): Likewise. + (display_gnu_attribute): Likewise. + (display_tic6x_attribute): Likewise. + (display_msp430x_attribute): Likewise. + + 2014-11-10 Nick Clifton + + PR binutils/17552 + * objcopy.c (copy_archive): Clean up temporary files even if an + error occurs. + + 2014-11-07 Nick Clifton + + PR binutils/17531 + * readelf.c (get_data): Avoid allocating memory when we know that + the read will fail. + (find_section_by_type): New function. + (get_unwind_section_word): Check for invalid symbol indicies. + Check for invalid reloc types. + (get_32bit_dynamic_section): Add range checks. + (get_64bit_dynamic_section): Add range checks. + (process_dynamic_section): Check for a corrupt time value. + (process_symbol_table): Add range checks. + (dump_section_as_strings): Add string length range checks. + (display_tag_value): Likewise. + (display_arm_attribute): Likewise. + (display_gnu_attribute): Likewise. + (display_tic6x_attribute): Likewise. + (display_msp430x_attribute): Likewise. + (process_mips_specific): Add range check. + + 2014-11-06 Nick Clifton + + PR binutils/17552, binutils/17533 + * bucomm.c (is_valid_archive_path): New function. Returns false + for absolute pathnames and pathnames that include /../. + * bucomm.h (is_valid_archive_path): Add prototype. + * ar.c (extract_file): Use new function to check for valid + pathnames when extracting files from an archive. + * objcopy.c (copy_archive): Likewise. + * doc/binutils.texi: Update documentation to mention the + limitation on pathname of archive members. + + 2014-11-05 Nick Clifton + + PR binutils/17531 + * readelf.c (printable_section_name): New function. + (printable_section_name_from_index): New function. + (dump_relocations): Use new function. + (process_program_headers, get_32bit_elf_symbols, + (get_64bit_elf_symbols, process_section_headers, + (process_section_groups, process_relocs, ia64_process_unwind, + (hppa_process_unwind, get_unwind_section_word, decode_arm_unwind, + (arm_process_unwind, process_version_sections, + (process_symbol_table, apply_relocations, get_section_contents, + (dump_section_as_strings, dump_section_as_bytes, + (display_debug_section, process_attributes, process_mips_specific, + (process_mips_specific process_gnu_liblist): Likewise. + (get_unwind_section_word): Check for a missing symbol table. + Replace aborts with error messages. + (arm_process_unwind): Check for a missing string table. + (process_attributes): Check for an attribute length that is too + small. + (process_mips_specific): Check for a corrupt GOT symbol offset. + + 2014-11-05 Nick Clifton + + PR binutils/17533 + * bucomm.c (is_valid_archive_path): New function. + * bucomm.h (is_valid_archive_path): Prototype it. + * ar.c (extract_file): Call is_valid_archive_path to verify a + member filename before extracting it. + * objcopy.c (copy_archive): Likewise. + + 2014-11-04 Nick Clifton + + PR binutils/17531 + * readelf.c (get_data): If the reason parameter is null, do not + print any error messages. + (get_32bit_section_headers): Verify section header entry size + before reading in the section headers. + (get_64bit_section_headers): Likewise. + (process_section_headers): Pass FALSE to get_section_headers. + (get_file_header): Pass TRUE to get_section_headers. + (process_dynamic_section): Change an assert to an error message. + (process_symbol_table): Handle corrupt histograms. + (get_32bit_program_headers): Verify program header entry size + before reading in the program headers. + (get_64bit_program_headers): Likewise. + (get_unwind_section_word): Do nothing if no section was provided. + Fail if the offset is outside of the section. + (print_dynamic_symbol): Catch out of range symbol indicies. + (process_mips_specific): Likewise. + (process_attributes): Make sure that there is enough space left in + the section before attempting to read the length of the next + attribute. + + 2014-11-03 Nick Clifton + + PR binutils/17512 + * objdump.c (slurp_symtab): Fail gracefully if the table could not + be read. + (dump_relocs_in_section): Likewise. + + 2014-11-14 Nick Clifton + + PR binutils/17597 + * opncls.c (bfd_get_debug_link_info): Avoid reading off the end of + the section. + (bfd_get_alt_debug_link_info): Likewise. + + 2014-11-14 Nick Clifton + + PR binutils/17512 + * ieee.c (ieee_archive_p) Skip processing if no bytes are read at + all. + (ieee_object_p): Likewise. + + 2014-11-13 H.J. Lu + + * coffcode.h (coff_slurp_line_table): Add cast to unsigned int. + + 2014-11-13 H.J. Lu + + * coffcode.h (coff_pointerize_aux_hook): Fix a typo. + + 2014-11-13 Nick Clifton + + PR binutils/17512 + * coffcode.h (coff_ptr_struct): Add is_sym field. + (coff_new_section_hook): Set the is_sym field. + (coff_pointerize_aux_hook): Check the is_sym field. + (coff_print_aux): Likewise. + (coff_compute_section_file_positions): Likewise. + (coff_write_object_contents): Likewise. + (coff_slurp_line_table): Likewise. + (coff_slurp_symbol_table): Likewise. + (CALC_ADDEND): Likewise. + * coffgen.c (coff_renumber_symbols): Likewise. + (coff_mangle_symbols): Likewise. + (coff_fix_symbol_name): Likewise. + (coff_write_symbol): Likewise. + (coff_write_alien_symbol): Likewise. + (coff_write_native_symbol): Likewise. + (coff_write_symbols): Likewise. + (coff_write_linenumbers): Likewise. + (coff_pointerize_aux): Likewise. + (coff_get_normalized_symtab): Likewise. + (coff_get_symbol_info): Likewise. + (bfd_coff_get_syment): Likewise. + (bfd_coff_get_auxent): Likewise. + (coff_print_symbol): Likewise. + (coff_find_nearest_line_with_names): Likewise. + (bfd_coff_set_symbol_class): Likewise. + (coff_make_empty_symbol): Set the is_sym field. + (coff_bfd_make_debug_symbol): Likewise. + * peicode.h (pe_ILF_make_a_symbol): Likewise. + * libcoff.h: Regenerate. + * libcoff-in.h: Regenerate. + + 2014-11-12 Nick Clifton + + PR binutils/17512 + * coffcode.h (coff_slurp_line_table): Set the line number of + corrupt entries to -1. + (coff_slurp_symbol_table): Alway initialise the value of the + symbol. + * coffgen.c (coff_print_symbol): Check that the combined pointer + is valid. + (coff_print_symbol): Do not print negative line numbers. + * peXXigen.c (pe_print_idata): Add range checking displaying + member names. + + 2014-11-12 Alan Modra + + PR binutils/17512 + * coffcode.h (coff_slurp_line_table): Drop line number info + not preceded by a valid function entry. Revert last change. + + 2014-11-11 Nick Clifton + + PR binutils/17512 + * coffcode.h (coff_slurp_line_table): Initialise the parts of the + line number cache that would not be initialised by the copy from + the new line number table. + (coff_classify_symbol): Allow for _bfd_coff_internal_syment_name + returning NULL. + * coffgen.c (coff_get_normalized_symbols): Get the external + symbols before allocating space for the internal symbols, in case + the get fails. + * elf.c (_bfd_elf_slurp_version_tables): Only allocate a verref + array if one is needed. Likewise with the verdef array. + * peXXigen.c (_bfd_XXi_swap_sym_in): Replace abort()'s with error + messages. + (_bfd_XXi_swap_aux_in): Make sure that all fields of the aux + structure are initialised. + (pe_print_edata): Avoid reading off the end of the data buffer. + + 2014-11-11 Alan Modra + + PR binutils/17512 + * coffcode.h (coff_slurp_line_table): Use updated lineno_count + when building func_table. + + 2014-11-11 Alan Modra + + PR binutils/17512 + * coffcode.h (coff_slurp_line_table): Don't bfd_zalloc, just + memset the particular bits we need. Update src after hitting loop + "continue". Don't count lineno omitted due to invalid symbols in + nbr_func, and update lineno_count. Init entire terminating + lineno. Don't both allocating terminator in n_lineno_cache. + Redirect sym->lineno pointer to where n_lineno_cache will be + copied, and free n_lineno_cache. + * pe-mips.c (NUM_HOWTOS): Typo fix. + + 2014-11-10 Nick Clifton + + PR binutils/17521 + * coff-i386.c (NUM_HOWTOS): New define. + (RTYPE2HOWTO): Use it. + (coff_i386_rtype_to_howto): Likewise. + (coff_i386_reloc_name_lookup): Likewise. + (CALC_ADDEND): Check that reloc r_type field is valid. + * coff-x86_64.c (NUM_HOWTOS): New define. + (RTYPE2HOWTO): Use it. + (coff_amd64_rtype_to_howto): Likewise. + (coff_amd64_reloc_name_lookup): Likewise. + (CALC_ADDEND): Check that reloc r_type field is valid. + * coffcode.h (coff_slurp_line_table): Check for symbol table + indexing underflow. + (coff_slurp_symbol_table): Use zalloc to ensure that all table + entries are initialised. + * coffgen.c (_bfd_coff_read_string_table): Initialise unused bits + in the string table. Also ensure that the table is 0 terminated. + (coff_get_normalized_symtab): Check for symbol table indexing + underflow. + * opncls.c (bfd_alloc): Catch the case where a small negative size + can result in only 1 byte being allocated. + (bfd_alloc2): Use bfd_alloc. + * pe-mips.c (NUM_HOWTOS): New define. + (coff_mips_reloc_name_lookup): Use it. + (CALC_ADDEND): Check that reloc r_type field is valid. + * peXXigen.c (_bfd_XXi_swap_aouthdr_in): Initialise unused entries + in the DataDirectory. + (pe_print_idata): Avoid reading beyond the end of the data block + wen printing strings. + (pe_print_edata): Likewise. + Check for table indexing underflow. + * peicode.h (pe_mkobject): Initialise the pe_opthdr field. + (pe_bfd_object_p): Allocate and initialize enough space to hold a + PEAOUTHDR, even if the opt_hdr field specified less. + + 2014-11-08 Alan Modra + + * peXXigen.c (pe_print_idata): Revert last patch, cast lhs instead. + + 2014-11-07 H.J. Lu + + * peXXigen.c (pe_print_idata): Cast to unsigned long in range + checks. + + 2014-11-07 Alan Modra + + * tekhex.c (tekhex_set_arch_mach): Ignore unknown arch errors. + + 2014-11-07 Alan Modra + + * tekhex.c (CHUNK_SPAN): Define. + (struct data_struct ): Use one byte per span, update + all code accessing this field. + (find_chunk): Add create param, don't create new entry unless set. + (insert_byte): Don't save zeros. + (first_phase): Set section SEC_CODE or SEC_DATA flag depending + on symbol type. Create an alternate section if both types of + symbol are given. Attach type '2' and '6' symbols to absolute + section. + (move_section_contents): Fix caching of chunk. Don't create chunk + when reading, or for writing zeros. + (tekhex_set_section_contents): Don't create initial chunks. + (tekhex_write_object_contents): Use CHUNK_SPAN. + + 2014-11-07 Alan Modra + + * aoutx.h (aout_get_external_symbols): Tidy allocation of symbol buffer. + + 2014-11-07 Alan Modra + + * archive.c (_bfd_slurp_extended_name_table): Revert bfd_get_size check. + * coffcode.h (coff_set_alignment_hook): Likewise. + (coff_slurp_line_table): Likewise. + * coffgen.c (coff_get_normalized_symtab): Likewise. + (_bfd_coff_get_external_symbols): Likewise. + * elf.c (bfd_elf_get_str_section): Likewise. + * tekhex.c (first_phase): Likewise. + + 2014-11-06 Nick Clifton + + * aoutx.h (slurp_symbol_table): Revert previous delta. + (slurp_reloc_table): Likewise. + * compress.c (bfd_get_full_section_contents): Remove file size + test. + * coffgen.c (coff_get_normalized_symtab): Allow zero-sized symtabs + and do not complain about linker generated files. + + 2014-11-04 Nick Clifton + + PR binutils/17512 + * coffcode.h (handle_COMDAT): Replace abort with BFD_ASSERT. + Replace another abort with an error message. + (coff_slurp_line_table): Add more range checking. + * peXXigen.c (pe_print_debugdata): Add range checking. + + 2014-11-05 Nick Clifton + + PR binutils/17512 + * coffcode.h (coff_set_alignment_hook): Warn if the file lies + about the number of relocations it contains. + (coff_sort_func_alent): Return 0 if the pointers are NULL. + (coff_slurp_line_table): Add more range checks. Do not free new + tables created when sorting line numbers. + * peXXigen.c (pe_print_idata): Add range checks. + (pe_print_edata): Likewise. + (rsrc_print_resource_entries): Likewise. Avoid printing control + characters. Terminate priniting if corruption is detected. + (rsrc_print_resource_directory): Terminate printing if an unknown + directory type is encountered. + (pe_print_debugdata): Fix off-by-one error. + (rsrc_count_entries): Add range checking. + (rsrc_parse_entry): Likewise. + + 2014-11-04 Nick Clifton + + PR binutils/17512 + * compress.c (bfd_get_full_section_contents): Improve test for + linker created objects. + + PR binutils/17533 + * archive.c (_bfd_slurp_extended_name_table): Handle archives with + corrupt extended name tables. + + 2014-11-03 Nick Clifton + + PR binutils/17512 + * aoutx.h (slurp_symbol_table): Check that computed table size is + not bigger than the file from which is it being read. + (slurp_reloc_table): Likewise. + * coffcode.h (coff_slurp_line_table): Remove unneeded local + 'warned'. Do not try to print the details of a symbol with an + invalid index. + * coffgen.c (make_a_sectiobn_from_file): Check computed string + index against length of string table. + (bfd_coff_internal_syment_name): Check read in string offset + against length of string table. + (build_debug_section): Return a pointer to the section used. + (_bfd_coff_read_string_table): Store the length of the string + table in the coff_tdata structure. + (bfd_coff_free_symbols): Set the length of the string table to + zero when it is freed. + (coff_get_normalized_symtab): Check offsets against string table + or data table lengths as appropriate. + * cofflink.c (_bfd_coff_link_input_bfd): Check offset against + length of string table. + * compress.c (bfd_get_full_section_contents): Check computed size + against the size of the file. + * libcoff-in.h (obj_coff_strings_len): Define. + (struct coff_tdata): Add strings_len field. + * libcoff.h: Regenerate. + * peXXigen.c (pe_print_debugdata): Do not attempt to print the + data if the debug section is too small. + * xcofflink.c (xcoff_link_input_bfd): Check offset against + length of string table. + + 2014-10-31 Nick Clifton + + PR binutils/17512 + * coffgen.c (_bfd_coff_get_external_symbols): Do not try to load a + symbol table bigger than the file. + * elf.c (bfd_elf_get_str_section): Do not try to load a string + table bigger than the file. + * tekhex.c (first_phase): Check that the section range is sane. + +From: Cary Coutant +Date: Tue, 11 Feb 2014 19:33:49 +0000 (-0800) +Subject: Fix readelf so it doesn't complain about corrupt attribute. +X-Git-Tag: gdb-7.8-release~1356 +X-Git-Url: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff_plain;h=503a609192b5d13905b40969ea82c62a72b576e0 + +Fix readelf so it doesn't complain about corrupt attribute. + +When a DW_FORM_flag_present attribute comes at the very end of a +debug section, readelf complains about a corrupt attribute +because it's checking to make sure there's at least one byte of +data remaining. This patch suppresses the check when the form +is DW_FORM_flag_present. + +From 513ea82edf8533e3483073561c06be97de035c83 Mon Sep 17 00:00:00 2001 +From: Alan Modra +Date: Thu, 14 Aug 2014 15:53:19 +0930 +Subject: [PATCH] Fix for objdump segfault on broken PE executable + + * peXXigen.c (pe_print_reloc): Protect against access past end + of .reloc section. + +[Ubuntu note: this patch fixes multiple issues that did not get CVEs +assigned. The patch differs from upstream commits in that the changelog +entries have been dropped to reduce patch conflicts, as well as the +following changes: + + * bfd/archive.c: already applied in patch binutils-CVE-2014-8738.patch + * bfd/coffcode.h: remove comment change (chunk 25) that was causing a + patch conflict + * bfd/opncls.c: drop last 2 chunks that deal with BuildIds, which are + not relevant to current code. + * bfd/peXXigen.c: drop changes to code printing resource and debug + section data, as these functions had not been added yet. + * bfd/peicode.h: drop changes to optional headers (2 chunks) + * binutils/ar.c, binutils/bucomm.c, binutils/bucomm.h, + binutils/doc/binutils.texi, binutils/objcopy.c: already applied + in patch binutils-CVE-2104-8737.patch + * binutils/dwarf.c: backport change to display_debug_pubnames + * binutils/readelf.c: + - remove comment change (chunk 27) that was causing + a patch conflict + - add missing frees to fix memory leaks, were preventing patch + from applying (chunk 78, 81) + - drop four whitespace-only changes to display_sparc_hwcaps{,2} that + did not apply cleanly + * bfs/coffgen.c: drop write to native[1] as this + version of binutils does not have upstream commit + e7ebb214834628b2b0d9d3233febc9fef2912515, which converted + dummy/native from a single struct into a two element struct array. + See LP: #1477350 for the problems this caused. + + -- sbeattie] + +--- + bfd/aoutx.h | 24 - + bfd/coff-i386.c | 17 + bfd/coff-x86_64.c | 11 + bfd/coffcode.h | 168 +++++--- + bfd/coffgen.c | 164 ++++++-- + bfd/cofflink.c | 5 + bfd/elf.c | 24 - + bfd/ieee.c | 6 + bfd/libcoff-in.h | 3 + bfd/libcoff.h | 16 + bfd/opncls.c | 35 - + bfd/pe-mips.c | 9 + bfd/peXXigen.c | 156 +++++-- + bfd/peicode.h | 2 + bfd/tekhex.c | 112 +++-- + bfd/xcofflink.c | 5 + binutils/dwarf.c | 141 +++++-- + binutils/objdump.c | 27 + + binutils/rdcoff.c | 9 + binutils/rddbg.c | 40 +- + binutils/readelf.c | 986 ++++++++++++++++++++++++++++++++++++-------------- + binutils/stabs.c | 30 - + gas/config/obj-coff.c | 1 + 23 files changed, 1404 insertions(+), 587 deletions(-) + +Index: b/bfd/aoutx.h +=================================================================== +--- a/bfd/aoutx.h ++++ b/bfd/aoutx.h +@@ -1296,14 +1296,14 @@ aout_get_external_symbols (bfd *abfd) + { + bfd_size_type count; + struct external_nlist *syms; ++ bfd_size_type amt = exec_hdr (abfd)->a_syms; + +- count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE; ++ count = amt / EXTERNAL_NLIST_SIZE; + if (count == 0) + return TRUE; /* Nothing to do. */ + + #ifdef USE_MMAP +- if (! bfd_get_file_window (abfd, obj_sym_filepos (abfd), +- exec_hdr (abfd)->a_syms, ++ if (! bfd_get_file_window (abfd, obj_sym_filepos (abfd), amt, + &obj_aout_sym_window (abfd), TRUE)) + return FALSE; + syms = (struct external_nlist *) obj_aout_sym_window (abfd).data; +@@ -1311,20 +1311,16 @@ aout_get_external_symbols (bfd *abfd) + /* We allocate using malloc to make the values easy to free + later on. If we put them on the objalloc it might not be + possible to free them. */ +- syms = (struct external_nlist *) bfd_malloc (count * EXTERNAL_NLIST_SIZE); ++ syms = (struct external_nlist *) bfd_malloc (amt); + if (syms == NULL) + return FALSE; + +- { +- bfd_size_type amt; +- amt = exec_hdr (abfd)->a_syms; +- if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 +- || bfd_bread (syms, amt, abfd) != amt) +- { +- free (syms); +- return FALSE; +- } +- } ++ if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 ++ || bfd_bread (syms, amt, abfd) != amt) ++ { ++ free (syms); ++ return FALSE; ++ } + #endif + + obj_aout_external_syms (abfd) = syms; +Index: b/bfd/coff-i386.c +=================================================================== +--- a/bfd/coff-i386.c ++++ b/bfd/coff-i386.c +@@ -349,16 +349,18 @@ static reloc_howto_type howto_table[] = + PCRELOFFSET) /* pcrel_offset */ + }; + ++#define NUM_HOWTOS (sizeof (howto_table) / sizeof (howto_table[0])) ++ + /* Turn a howto into a reloc nunmber */ + + #define SELECT_RELOC(x,howto) { x.r_type = howto->type; } + #define BADMAG(x) I386BADMAG(x) + #define I386 1 /* Customize coffcode.h */ + +-#define RTYPE2HOWTO(cache_ptr, dst) \ +- ((cache_ptr)->howto = \ +- ((dst)->r_type < sizeof (howto_table) / sizeof (howto_table[0]) \ +- ? howto_table + (dst)->r_type \ ++#define RTYPE2HOWTO(cache_ptr, dst) \ ++ ((cache_ptr)->howto = \ ++ ((dst)->r_type < NUM_HOWTOS \ ++ ? howto_table + (dst)->r_type \ + : NULL)) + + /* For 386 COFF a STYP_NOLOAD | STYP_BSS section is part of a shared +@@ -395,7 +397,8 @@ static reloc_howto_type howto_table[] = + cache_ptr->addend = - (ptr->section->vma + ptr->value); \ + else \ + cache_ptr->addend = 0; \ +- if (ptr && howto_table[reloc.r_type].pc_relative) \ ++ if (ptr && reloc.r_type < NUM_HOWTOS \ ++ && howto_table[reloc.r_type].pc_relative) \ + cache_ptr->addend += asect->vma; \ + } + +@@ -455,7 +458,7 @@ coff_i386_rtype_to_howto (abfd, sec, rel + { + reloc_howto_type *howto; + +- if (rel->r_type >= sizeof (howto_table) / sizeof (howto_table[0])) ++ if (rel->r_type >= NUM_HOWTOS) + { + bfd_set_error (bfd_error_bad_value); + return NULL; +@@ -592,7 +595,7 @@ coff_i386_reloc_name_lookup (bfd *abfd A + { + unsigned int i; + +- for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++) ++ for (i = 0; i < NUM_HOWTOS; i++) + if (howto_table[i].name != NULL + && strcasecmp (howto_table[i].name, r_name) == 0) + return &howto_table[i]; +Index: b/bfd/coff-x86_64.c +=================================================================== +--- a/bfd/coff-x86_64.c ++++ b/bfd/coff-x86_64.c +@@ -449,6 +449,8 @@ static reloc_howto_type howto_table[] = + PCRELOFFSET) /* pcrel_offset */ + }; + ++#define NUM_HOWTOS ARRAY_SIZE (howto_table) ++ + /* Turn a howto into a reloc nunmber */ + + #define SELECT_RELOC(x,howto) { x.r_type = howto->type; } +@@ -457,7 +459,7 @@ static reloc_howto_type howto_table[] = + + #define RTYPE2HOWTO(cache_ptr, dst) \ + ((cache_ptr)->howto = \ +- ((dst)->r_type < ARRAY_SIZE (howto_table)) \ ++ ((dst)->r_type < NUM_HOWTOS) \ + ? howto_table + (dst)->r_type \ + : NULL) + +@@ -497,7 +499,8 @@ static reloc_howto_type howto_table[] = + cache_ptr->addend = - (ptr->section->vma + ptr->value); \ + else \ + cache_ptr->addend = 0; \ +- if (ptr && howto_table[reloc.r_type].pc_relative) \ ++ if (ptr && reloc.r_type < NUM_HOWTOS \ ++ && howto_table[reloc.r_type].pc_relative) \ + cache_ptr->addend += asect->vma; \ + } + +@@ -547,7 +550,7 @@ coff_amd64_rtype_to_howto (bfd *abfd ATT + { + reloc_howto_type *howto; + +- if (rel->r_type >= ARRAY_SIZE (howto_table)) ++ if (rel->r_type >= NUM_HOWTOS) + { + bfd_set_error (bfd_error_bad_value); + return NULL; +@@ -689,7 +692,7 @@ coff_amd64_reloc_name_lookup (bfd *abfd + { + unsigned int i; + +- for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++) ++ for (i = 0; i < NUM_HOWTOS; i++) + if (howto_table[i].name != NULL + && strcasecmp (howto_table[i].name, r_name) == 0) + return &howto_table[i]; +Index: b/bfd/coffcode.h +=================================================================== +--- a/bfd/coffcode.h ++++ b/bfd/coffcode.h +@@ -309,7 +309,7 @@ CODE_FRAGMENT + .typedef struct coff_ptr_struct + .{ + . {* Remembers the offset from the first symbol in the file for +-. this symbol. Generated by coff_renumber_symbols. *} ++. this symbol. Generated by coff_renumber_symbols. *} + . unsigned int offset; + . + . {* Should the value of this symbol be renumbered. Used for +@@ -317,15 +317,15 @@ CODE_FRAGMENT + . unsigned int fix_value : 1; + . + . {* Should the tag field of this symbol be renumbered. +-. Created by coff_pointerize_aux. *} ++. Created by coff_pointerize_aux. *} + . unsigned int fix_tag : 1; + . + . {* Should the endidx field of this symbol be renumbered. +-. Created by coff_pointerize_aux. *} ++. Created by coff_pointerize_aux. *} + . unsigned int fix_end : 1; + . + . {* Should the x_csect.x_scnlen field be renumbered. +-. Created by coff_pointerize_aux. *} ++. Created by coff_pointerize_aux. *} + . unsigned int fix_scnlen : 1; + . + . {* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the +@@ -333,12 +333,15 @@ CODE_FRAGMENT + . unsigned int fix_line : 1; + . + . {* The container for the symbol structure as read and translated +-. from the file. *} ++. from the file. *} + . union + . { + . union internal_auxent auxent; + . struct internal_syment syment; + . } u; ++. ++. {* Selector for the union above. *} ++. bfd_boolean is_sym; + .} combined_entry_type; + . + . +@@ -914,12 +917,7 @@ handle_COMDAT (bfd * abfd, + + bfd_coff_swap_sym_in (abfd, esym, & isym); + +- if (sizeof (internal_s->s_name) > SYMNMLEN) +- { +- /* This case implies that the matching +- symbol name will be in the string table. */ +- abort (); +- } ++ BFD_ASSERT (sizeof (internal_s->s_name) <= SYMNMLEN); + + if (isym.n_scnum == section->target_index) + { +@@ -950,8 +948,12 @@ handle_COMDAT (bfd * abfd, + /* All 3 branches use this. */ + symname = _bfd_coff_internal_syment_name (abfd, &isym, buf); + ++ /* PR 17512 file: 078-11867-0.004 */ + if (symname == NULL) +- abort (); ++ { ++ _bfd_error_handler (_("%B: unable to load COMDAT section name"), abfd); ++ break; ++ } + + switch (seen_state) + { +@@ -1778,6 +1780,7 @@ coff_new_section_hook (bfd * abfd, asect + in case this symbol winds up getting written out. The value 0 + for n_numaux is already correct. */ + ++ native->is_sym = TRUE; + native->u.syment.n_type = T_NULL; + native->u.syment.n_sclass = sclass; + +@@ -2485,11 +2488,13 @@ coff_pointerize_aux_hook (bfd *abfd ATTR + unsigned int indaux, + combined_entry_type *aux) + { ++ BFD_ASSERT (symbol->is_sym); + int n_sclass = symbol->u.syment.n_sclass; + + if (CSECT_SYM_P (n_sclass) + && indaux + 1 == symbol->u.syment.n_numaux) + { ++ BFD_ASSERT (! aux->is_sym); + if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) == XTY_LD) + { + aux->u.auxent.x_csect.x_scnlen.p = +@@ -2522,6 +2527,7 @@ coff_pointerize_aux_hook (bfd *abfd ATTR + /* Return TRUE if we don't want to pointerize this aux entry, which + is the case for the lastfirst aux entry for a C_LEAFPROC symbol. */ + return (indaux == 1 ++ && symbol->is_sym + && (symbol->u.syment.n_sclass == C_LEAFPROC + || symbol->u.syment.n_sclass == C_LEAFSTAT + || symbol->u.syment.n_sclass == C_LEAFEXT)); +@@ -2544,6 +2550,8 @@ coff_print_aux (bfd *abfd ATTRIBUTE_UNUS + combined_entry_type *aux ATTRIBUTE_UNUSED, + unsigned int indaux ATTRIBUTE_UNUSED) + { ++ BFD_ASSERT (symbol->is_sym); ++ BFD_ASSERT (! aux->is_sym); + #ifdef RS6000COFF_C + if (CSECT_SYM_P (symbol->u.syment.n_sclass) + && indaux + 1 == symbol->u.syment.n_numaux) +@@ -3164,6 +3172,7 @@ coff_compute_section_file_positions (bfd + cf = coff_symbol_from (abfd, *symp); + if (cf != NULL + && cf->native != NULL ++ && cf->native->is_sym + && SYMNAME_IN_DEBUG (&cf->native->u.syment)) + { + size_t len; +@@ -3859,6 +3868,7 @@ coff_write_object_contents (bfd * abfd) + csym = coff_symbol_from (abfd, *psym); + if (csym == NULL + || csym->native == NULL ++ || ! csym->native->is_sym + || csym->native->u.syment.n_numaux < 1 + || csym->native->u.syment.n_sclass != C_STAT + || csym->native->u.syment.n_type != T_NULL) +@@ -3881,6 +3891,7 @@ coff_write_object_contents (bfd * abfd) + x_associated field is not currently supported. */ + + aux = csym->native + 1; ++ BFD_ASSERT (! aux->is_sym); + switch (current->flags & SEC_LINK_DUPLICATES) + { + case SEC_LINK_DUPLICATES_DISCARD: +@@ -4026,8 +4037,6 @@ coff_write_object_contents (bfd * abfd) + internal_f.f_flags |= F_DYNLOAD; + #endif + +- memset (&internal_a, 0, sizeof internal_a); +- + /* Set up architecture-dependent stuff. */ + { + unsigned int magic = 0; +@@ -4443,11 +4452,11 @@ buy_and_read (bfd *abfd, file_ptr where, + void * area = bfd_alloc (abfd, size); + + if (!area) +- return (NULL); ++ return NULL; + if (bfd_seek (abfd, where, SEEK_SET) != 0 + || bfd_bread (area, size, abfd) != size) +- return (NULL); +- return (area); ++ return NULL; ++ return area; + } + + /* +@@ -4481,6 +4490,8 @@ coff_sort_func_alent (const void * arg1, + const coff_symbol_type *s1 = (const coff_symbol_type *) (al1->u.sym); + const coff_symbol_type *s2 = (const coff_symbol_type *) (al2->u.sym); + ++ if (s1 == NULL || s2 == NULL) ++ return 0; + if (s1->symbol.value < s2->symbol.value) + return -1; + else if (s1->symbol.value > s2->symbol.value) +@@ -4498,9 +4509,10 @@ coff_slurp_line_table (bfd *abfd, asecti + unsigned int counter; + alent *cache_ptr; + bfd_vma prev_offset = 0; +- int ordered = 1; ++ bfd_boolean ordered = TRUE; + unsigned int nbr_func; + LINENO *src; ++ bfd_boolean have_func; + + BFD_ASSERT (asect->lineno == NULL); + +@@ -4523,57 +4535,85 @@ coff_slurp_line_table (bfd *abfd, asecti + asect->lineno = lineno_cache; + src = native_lineno; + nbr_func = 0; ++ have_func = FALSE; + +- for (counter = 0; counter < asect->lineno_count; counter++) ++ for (counter = 0; counter < asect->lineno_count; counter++, src++) + { + struct internal_lineno dst; + + bfd_coff_swap_lineno_in (abfd, src, &dst); + cache_ptr->line_number = dst.l_lnno; ++ /* Appease memory checkers that get all excited about ++ uninitialised memory when copying alents if u.offset is ++ larger than u.sym. (64-bit BFD on 32-bit host.) */ ++ memset (&cache_ptr->u, 0, sizeof (cache_ptr->u)); + + if (cache_ptr->line_number == 0) + { +- bfd_boolean warned; +- bfd_signed_vma symndx; ++ combined_entry_type * ent; ++ bfd_vma symndx; + coff_symbol_type *sym; + +- nbr_func++; +- warned = FALSE; ++ have_func = FALSE; + symndx = dst.l_addr.l_symndx; +- if (symndx < 0 +- || (bfd_vma) symndx >= obj_raw_syment_count (abfd)) ++ if (symndx >= obj_raw_syment_count (abfd)) + { + (*_bfd_error_handler) +- (_("%B: warning: illegal symbol index %ld in line numbers"), +- abfd, (long) symndx); +- symndx = 0; +- warned = TRUE; ++ (_("%B: warning: illegal symbol index 0x%lx in line number entry %d"), ++ abfd, (long) symndx, counter); ++ cache_ptr->line_number = -1; ++ continue; + } + ++ ent = obj_raw_syments (abfd) + symndx; + /* FIXME: We should not be casting between ints and + pointers like this. */ +- sym = ((coff_symbol_type *) +- ((symndx + obj_raw_syments (abfd)) +- ->u.syment._n._n_n._n_zeroes)); ++ if (! ent->is_sym) ++ { ++ (*_bfd_error_handler) ++ (_("%B: warning: illegal symbol index 0x%lx in line number entry %d"), ++ abfd, (long) symndx, counter); ++ cache_ptr->line_number = -1; ++ continue; ++ } ++ sym = (coff_symbol_type *) (ent->u.syment._n._n_n._n_zeroes); ++ ++ /* PR 17512 file: 078-10659-0.004 */ ++ if (sym < obj_symbols (abfd) ++ || sym >= obj_symbols (abfd) + bfd_get_symcount (abfd)) ++ { ++ (*_bfd_error_handler) ++ (_("%B: warning: illegal symbol in line number entry %d"), ++ abfd, counter); ++ cache_ptr->line_number = -1; ++ continue; ++ } ++ ++ have_func = TRUE; ++ nbr_func++; + cache_ptr->u.sym = (asymbol *) sym; +- if (sym->lineno != NULL && ! warned) ++ if (sym->lineno != NULL) + (*_bfd_error_handler) + (_("%B: warning: duplicate line number information for `%s'"), + abfd, bfd_asymbol_name (&sym->symbol)); + + sym->lineno = cache_ptr; + if (sym->symbol.value < prev_offset) +- ordered = 0; ++ ordered = FALSE; + prev_offset = sym->symbol.value; + } ++ else if (!have_func) ++ /* Drop line information that has no associated function. ++ PR 17521: file: 078-10659-0.004. */ ++ continue; + else +- cache_ptr->u.offset = dst.l_addr.l_paddr +- - bfd_section_vma (abfd, asect); +- ++ cache_ptr->u.offset = (dst.l_addr.l_paddr ++ - bfd_section_vma (abfd, asect)); + cache_ptr++; +- src++; + } +- cache_ptr->line_number = 0; ++ ++ asect->lineno_count = cache_ptr - lineno_cache; ++ memset (cache_ptr, 0, sizeof (*cache_ptr)); + bfd_release (abfd, native_lineno); + + /* On some systems (eg AIX5.3) the lineno table may not be sorted. */ +@@ -4590,15 +4630,17 @@ coff_slurp_line_table (bfd *abfd, asecti + alent **p = func_table; + unsigned int i; + +- for (i = 0; i < counter; i++) ++ for (i = 0; i < asect->lineno_count; i++) + if (lineno_cache[i].line_number == 0) + *p++ = &lineno_cache[i]; + ++ BFD_ASSERT ((unsigned int) (p - func_table) == nbr_func); ++ + /* Sort by functions. */ + qsort (func_table, nbr_func, sizeof (alent *), coff_sort_func_alent); + + /* Create the new sorted table. */ +- amt = ((bfd_size_type) asect->lineno_count + 1) * sizeof (alent); ++ amt = (bfd_size_type) asect->lineno_count * sizeof (alent); + n_lineno_cache = (alent *) bfd_alloc (abfd, amt); + if (n_lineno_cache != NULL) + { +@@ -4609,18 +4651,18 @@ coff_slurp_line_table (bfd *abfd, asecti + coff_symbol_type *sym; + alent *old_ptr = func_table[i]; + +- /* Copy the function entry and update it. */ +- *n_cache_ptr = *old_ptr; +- sym = (coff_symbol_type *)n_cache_ptr->u.sym; +- sym->lineno = n_cache_ptr; +- n_cache_ptr++; +- old_ptr++; +- +- /* Copy the line number entries. */ +- while (old_ptr->line_number != 0) ++ /* Update the function entry. */ ++ sym = (coff_symbol_type *) old_ptr->u.sym; ++ /* PR binutils/17512: Point the lineno to where ++ this entry will be after the memcpy below. */ ++ sym->lineno = lineno_cache + (n_cache_ptr - n_lineno_cache); ++ /* Copy the function and line number entries. */ ++ do + *n_cache_ptr++ = *old_ptr++; ++ while (old_ptr->line_number != 0); + } +- n_cache_ptr->line_number = 0; ++ BFD_ASSERT ((bfd_size_type) (n_cache_ptr - n_lineno_cache) == (amt / sizeof (alent))); ++ + memcpy (lineno_cache, n_lineno_cache, amt); + } + bfd_release (abfd, func_table); +@@ -4659,7 +4701,7 @@ coff_slurp_symbol_table (bfd * abfd) + + amt = obj_raw_syment_count (abfd); + amt *= sizeof (unsigned int); +- table_ptr = (unsigned int *) bfd_alloc (abfd, amt); ++ table_ptr = (unsigned int *) bfd_zalloc (abfd, amt); + + if (table_ptr == NULL) + return FALSE; +@@ -4673,14 +4715,17 @@ coff_slurp_symbol_table (bfd * abfd) + { + combined_entry_type *src = native_symbols + this_index; + table_ptr[this_index] = number_of_symbols; +- dst->symbol.the_bfd = abfd; + ++ dst->symbol.the_bfd = abfd; ++ BFD_ASSERT (src->is_sym); + dst->symbol.name = (char *) (src->u.syment._n._n_n._n_offset); + /* We use the native name field to point to the cached field. */ + src->u.syment._n._n_n._n_zeroes = (bfd_hostptr_t) dst; + dst->symbol.section = coff_section_from_bfd_index (abfd, + src->u.syment.n_scnum); + dst->symbol.flags = 0; ++ /* PR 17512: file: 079-7098-0.001:0.1. */ ++ dst->symbol.value = 0; + dst->done_lineno = FALSE; + + switch (src->u.syment.n_sclass) +@@ -4967,9 +5012,9 @@ coff_slurp_symbol_table (bfd * abfd) + } + + dst->native = src; +- + dst->symbol.udata.i = 0; + dst->lineno = NULL; ++ + this_index += (src->u.syment.n_numaux) + 1; + dst++; + number_of_symbols++; +@@ -5052,13 +5097,13 @@ coff_classify_symbol (bfd *abfd, + if (syment->n_value == 0) + { + asection *sec; +- char buf[SYMNMLEN + 1]; +- +- sec = coff_section_from_bfd_index (abfd, syment->n_scnum); +- if (sec != NULL +- && (strcmp (bfd_get_section_name (abfd, sec), +- _bfd_coff_internal_syment_name (abfd, syment, buf)) +- == 0)) ++ char * name; ++ char buf[SYMNMLEN + 1]; ++ ++ name = _bfd_coff_internal_syment_name (abfd, syment, buf) ++ sec = coff_section_from_bfd_index (abfd, syment->n_scnum); ++ if (sec != NULL && name != NULL ++ && (strcmp (bfd_get_section_name (abfd, sec), name) == 0)) + return COFF_SYMBOL_PE_SECTION; + } + #endif +@@ -5129,6 +5174,7 @@ SUBSUBSECTION + else if (ptr) \ + coffsym = coff_symbol_from (abfd, ptr); \ + if (coffsym != NULL \ ++ && coffsym->native->is_sym \ + && coffsym->native->u.syment.n_scnum == 0) \ + cache_ptr->addend = 0; \ + else if (ptr && bfd_asymbol_bfd (ptr) == abfd \ +Index: b/bfd/coffgen.c +=================================================================== +--- a/bfd/coffgen.c ++++ b/bfd/coffgen.c +@@ -86,9 +86,8 @@ make_a_section_from_file (bfd *abfd, + strings = _bfd_coff_read_string_table (abfd); + if (strings == NULL) + return FALSE; +- /* FIXME: For extra safety, we should make sure that +- strindex does not run us past the end, but right now we +- don't know the length of the string table. */ ++ if ((bfd_size_type)(strindex + 2) >= obj_coff_strings_len (abfd)) ++ return FALSE; + strings += strindex; + name = (char *) bfd_alloc (abfd, + (bfd_size_type) strlen (strings) + 1); +@@ -392,6 +391,8 @@ _bfd_coff_internal_syment_name (bfd *abf + if (strings == NULL) + return NULL; + } ++ if (sym->_n._n_n._n_offset >= obj_coff_strings_len (abfd)) ++ return NULL; + return strings + sym->_n._n_n._n_offset; + } + } +@@ -688,12 +689,14 @@ coff_renumber_symbols (bfd *bfd_ptr, int + for (symbol_index = 0; symbol_index < symbol_count; symbol_index++) + { + coff_symbol_type *coff_symbol_ptr = coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]); ++ + symbol_ptr_ptr[symbol_index]->udata.i = symbol_index; + if (coff_symbol_ptr && coff_symbol_ptr->native) + { + combined_entry_type *s = coff_symbol_ptr->native; + int i; + ++ BFD_ASSERT (s->is_sym); + if (s->u.syment.n_sclass == C_FILE) + { + if (last_file != NULL) +@@ -738,6 +741,7 @@ coff_mangle_symbols (bfd *bfd_ptr) + int i; + combined_entry_type *s = coff_symbol_ptr->native; + ++ BFD_ASSERT (s->is_sym); + if (s->fix_value) + { + /* FIXME: We should use a union here. */ +@@ -761,6 +765,8 @@ coff_mangle_symbols (bfd *bfd_ptr) + for (i = 0; i < s->u.syment.n_numaux; i++) + { + combined_entry_type *a = s + i + 1; ++ ++ BFD_ASSERT (! a->is_sym); + if (a->fix_tag) + { + a->u.auxent.x_sym.x_tagndx.l = +@@ -804,6 +810,7 @@ coff_fix_symbol_name (bfd *abfd, + } + name_length = strlen (name); + ++ BFD_ASSERT (native->is_sym); + if (native->u.syment.n_sclass == C_FILE + && native->u.syment.n_numaux > 0) + { +@@ -819,6 +826,7 @@ coff_fix_symbol_name (bfd *abfd, + else + strncpy (native->u.syment._n._n_name, ".file", SYMNMLEN); + ++ BFD_ASSERT (! (native + 1)->is_sym); + auxent = &(native + 1)->u.auxent; + + filnmlen = bfd_coff_filnmlen (abfd); +@@ -921,6 +929,8 @@ coff_write_symbol (bfd *abfd, + void * buf; + bfd_size_type symesz; + ++ BFD_ASSERT (native->is_sym); ++ + if (native->u.syment.n_sclass == C_FILE) + symbol->flags |= BSF_DEBUGGING; + +@@ -961,6 +971,7 @@ coff_write_symbol (bfd *abfd, + return FALSE; + for (j = 0; j < native->u.syment.n_numaux; j++) + { ++ BFD_ASSERT (! (native + j + 1)->is_sym); + bfd_coff_swap_aux_out (abfd, + &((native + j + 1)->u.auxent), + type, n_sclass, (int) j, +@@ -998,6 +1009,8 @@ coff_write_alien_symbol (bfd *abfd, + : symbol->section; + + native = &dummy; ++ native->is_sym = TRUE; ++ /* native[1].is_sym = FALSE; // need e7ebb214834628b2b0d9d3233febc9fef2912515 */ + native->u.syment.n_type = T_NULL; + native->u.syment.n_flags = 0; + if (bfd_is_und_section (symbol->section)) +@@ -1062,6 +1075,7 @@ coff_write_native_symbol (bfd *abfd, + combined_entry_type *native = symbol->native; + alent *lineno = symbol->lineno; + ++ BFD_ASSERT (native->is_sym); + /* If this symbol has an associated line number, we must store the + symbol index in the line number field. We also tag the auxent to + point to the right place in the lineno table. */ +@@ -1171,8 +1185,9 @@ coff_write_symbols (bfd *abfd) + symbol which has no associated section and we do not have to + worry about this, all we need to know is that it is local. */ + current_error_handler = bfd_set_error_handler (null_error_handler); ++ BFD_ASSERT (c_symbol->native->is_sym); + sym_class = bfd_coff_classify_symbol (abfd, +- &c_symbol->native->u.syment); ++ &c_symbol->native->u.syment); + (void) bfd_set_error_handler (current_error_handler); + + n_sclass = &c_symbol->native->u.syment.n_sclass; +@@ -1263,6 +1278,9 @@ coff_write_symbols (bfd *abfd) + file name, nor does it go in the .debug section. */ + maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN; + ++ else if (! c_symbol->native->is_sym) ++ maxlen = bfd_coff_force_symnames_in_strings (abfd) ? 0 : SYMNMLEN; ++ + else if (bfd_coff_symname_in_debug (abfd, + &c_symbol->native->u.syment)) + /* This symbol name is in the XCOFF .debug section. +@@ -1353,6 +1371,7 @@ coff_write_linenumbers (bfd *abfd) + { + /* Found a linenumber entry, output. */ + struct internal_lineno out; ++ + memset ((void *) & out, 0, sizeof (out)); + out.l_lnno = 0; + out.l_addr.l_symndx = l->u.offset; +@@ -1400,6 +1419,7 @@ coff_pointerize_aux (bfd *abfd, + unsigned int type = symbol->u.syment.n_type; + unsigned int n_sclass = symbol->u.syment.n_sclass; + ++ BFD_ASSERT (symbol->is_sym); + if (coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook) + { + if ((*coff_backend_info (abfd)->_bfd_coff_pointerize_aux_hook) +@@ -1413,6 +1433,7 @@ coff_pointerize_aux (bfd *abfd, + if (n_sclass == C_FILE) + return; + ++ BFD_ASSERT (! auxent->is_sym); + /* Otherwise patch up. */ + #define N_TMASK coff_data (abfd)->local_n_tmask + #define N_BTSHFT coff_data (abfd)->local_n_btshft +@@ -1440,7 +1461,7 @@ coff_pointerize_aux (bfd *abfd, + we didn't want to go to the trouble until someone needed it. */ + + static char * +-build_debug_section (bfd *abfd) ++build_debug_section (bfd *abfd, asection ** sect_return) + { + char *debug_section; + file_ptr position; +@@ -1468,6 +1489,8 @@ build_debug_section (bfd *abfd) + || bfd_bread (debug_section, sec_size, abfd) != sec_size + || bfd_seek (abfd, position, SEEK_SET) != 0) + return NULL; ++ ++ * sect_return = sect; + return debug_section; + } + +@@ -1530,7 +1553,9 @@ _bfd_coff_get_external_symbols (bfd *abf + + /* Read in the external strings. The strings are not loaded until + they are needed. This is because we have no simple way of +- detecting a missing string table in an archive. */ ++ detecting a missing string table in an archive. If the strings ++ are loaded then the STRINGS and STRINGS_LEN fields in the ++ coff_tdata structure will be set. */ + + const char * + _bfd_coff_read_string_table (bfd *abfd) +@@ -1580,7 +1605,13 @@ _bfd_coff_read_string_table (bfd *abfd) + return NULL; + } + +- strings = (char *) bfd_malloc (strsize); ++ strings = (char *) bfd_malloc (strsize + 1); ++ /* PR 17521 file: 079-54929-0.004. ++ A corrupt file could contain an index that points into the first ++ STRING_SIZE_SIZE bytes of the string table, so make sure that ++ they are zero. */ ++ memset (strings, 0, STRING_SIZE_SIZE); ++ + if (strings == NULL) + return NULL; + +@@ -1592,7 +1623,9 @@ _bfd_coff_read_string_table (bfd *abfd) + } + + obj_coff_strings (abfd) = strings; +- ++ obj_coff_strings_len (abfd) = strsize; ++ /* Terminate the string table, just in case. */ ++ strings[strsize] = 0; + return strings; + } + +@@ -1612,6 +1645,7 @@ _bfd_coff_free_symbols (bfd *abfd) + { + free (obj_coff_strings (abfd)); + obj_coff_strings (abfd) = NULL; ++ obj_coff_strings_len (abfd) = 0; + } + return TRUE; + } +@@ -1632,21 +1666,22 @@ coff_get_normalized_symtab (bfd *abfd) + char *raw_src; + char *raw_end; + const char *string_table = NULL; +- char *debug_section = NULL; ++ asection * debug_sec = NULL; ++ char *debug_sec_data = NULL; + bfd_size_type size; + + if (obj_raw_syments (abfd) != NULL) + return obj_raw_syments (abfd); + ++ if (! _bfd_coff_get_external_symbols (abfd)) ++ return NULL; ++ + size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type); + internal = (combined_entry_type *) bfd_zalloc (abfd, size); + if (internal == NULL && size != 0) + return NULL; + internal_end = internal + obj_raw_syment_count (abfd); +- +- if (! _bfd_coff_get_external_symbols (abfd)) +- return NULL; +- ++ + raw_src = (char *) obj_coff_external_syms (abfd); + + /* Mark the end of the symbols. */ +@@ -1661,23 +1696,29 @@ coff_get_normalized_symtab (bfd *abfd) + raw_src < raw_end; + raw_src += symesz, internal_ptr++) + { +- + unsigned int i; ++ + bfd_coff_swap_sym_in (abfd, (void *) raw_src, + (void *) & internal_ptr->u.syment); + symbol_ptr = internal_ptr; ++ internal_ptr->is_sym = TRUE; + + for (i = 0; + i < symbol_ptr->u.syment.n_numaux; + i++) + { + internal_ptr++; ++ /* PR 17512: Prevent buffer overrun. */ ++ if (internal_ptr >= internal_end) ++ return NULL; ++ + raw_src += symesz; + bfd_coff_swap_aux_in (abfd, (void *) raw_src, + symbol_ptr->u.syment.n_type, + symbol_ptr->u.syment.n_sclass, + (int) i, symbol_ptr->u.syment.n_numaux, + &(internal_ptr->u.auxent)); ++ internal_ptr->is_sym = FALSE; + coff_pointerize_aux (abfd, internal, symbol_ptr, i, + internal_ptr); + } +@@ -1691,12 +1732,18 @@ coff_get_normalized_symtab (bfd *abfd) + for (internal_ptr = internal; internal_ptr < internal_end; + internal_ptr++) + { ++ BFD_ASSERT (internal_ptr->is_sym); ++ + if (internal_ptr->u.syment.n_sclass == C_FILE + && internal_ptr->u.syment.n_numaux > 0) + { ++ combined_entry_type * aux = internal_ptr + 1; ++ + /* Make a file symbol point to the name in the auxent, since + the text ".file" is redundant. */ +- if ((internal_ptr + 1)->u.auxent.x_file.x_n.x_zeroes == 0) ++ BFD_ASSERT (! aux->is_sym); ++ ++ if (aux->u.auxent.x_file.x_n.x_zeroes == 0) + { + /* The filename is a long one, point into the string table. */ + if (string_table == NULL) +@@ -1706,10 +1753,12 @@ coff_get_normalized_symtab (bfd *abfd) + return NULL; + } + +- internal_ptr->u.syment._n._n_n._n_offset = +- ((bfd_hostptr_t) +- (string_table +- + (internal_ptr + 1)->u.auxent.x_file.x_n.x_offset)); ++ if ((bfd_size_type)(aux->u.auxent.x_file.x_n.x_offset) ++ >= obj_coff_strings_len (abfd)) ++ internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _(""); ++ else ++ internal_ptr->u.syment._n._n_n._n_offset = ++ (bfd_hostptr_t) (string_table + (aux->u.auxent.x_file.x_n.x_offset)); + } + else + { +@@ -1719,15 +1768,15 @@ coff_get_normalized_symtab (bfd *abfd) + if (internal_ptr->u.syment.n_numaux > 1 + && coff_data (abfd)->pe) + internal_ptr->u.syment._n._n_n._n_offset = +- ((bfd_hostptr_t) +- copy_name (abfd, +- (internal_ptr + 1)->u.auxent.x_file.x_fname, +- internal_ptr->u.syment.n_numaux * symesz)); ++ (bfd_hostptr_t) ++ copy_name (abfd, ++ aux->u.auxent.x_file.x_fname, ++ internal_ptr->u.syment.n_numaux * symesz); + else + internal_ptr->u.syment._n._n_n._n_offset = + ((bfd_hostptr_t) + copy_name (abfd, +- (internal_ptr + 1)->u.auxent.x_file.x_fname, ++ aux->u.auxent.x_file.x_fname, + (size_t) bfd_coff_filnmlen (abfd))); + } + } +@@ -1764,18 +1813,33 @@ coff_get_normalized_symtab (bfd *abfd) + if (string_table == NULL) + return NULL; + } +- internal_ptr->u.syment._n._n_n._n_offset = +- ((bfd_hostptr_t) +- (string_table +- + internal_ptr->u.syment._n._n_n._n_offset)); ++ if (internal_ptr->u.syment._n._n_n._n_offset >= obj_coff_strings_len (abfd) ++ || string_table + internal_ptr->u.syment._n._n_n._n_offset < string_table) ++ internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _(""); ++ else ++ internal_ptr->u.syment._n._n_n._n_offset = ++ ((bfd_hostptr_t) ++ (string_table ++ + internal_ptr->u.syment._n._n_n._n_offset)); + } + else + { + /* Long name in debug section. Very similar. */ +- if (debug_section == NULL) +- debug_section = build_debug_section (abfd); +- internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) +- (debug_section + internal_ptr->u.syment._n._n_n._n_offset); ++ if (debug_sec_data == NULL) ++ debug_sec_data = build_debug_section (abfd, & debug_sec); ++ if (debug_sec_data != NULL) ++ { ++ BFD_ASSERT (debug_sec != NULL); ++ /* PR binutils/17512: Catch out of range offsets into the debug data. */ ++ if (internal_ptr->u.syment._n._n_n._n_offset > debug_sec->size ++ || debug_sec_data + internal_ptr->u.syment._n._n_n._n_offset < debug_sec_data) ++ internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) _(""); ++ else ++ internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) ++ (debug_sec_data + internal_ptr->u.syment._n._n_n._n_offset); ++ } ++ else ++ internal_ptr->u.syment._n._n_n._n_offset = (bfd_hostptr_t) ""; + } + } + internal_ptr += internal_ptr->u.syment.n_numaux; +@@ -1808,7 +1872,7 @@ coff_make_empty_symbol (bfd *abfd) + if (new_symbol == NULL) + return NULL; + new_symbol->symbol.section = 0; +- new_symbol->native = 0; ++ new_symbol->native = NULL; + new_symbol->lineno = NULL; + new_symbol->done_lineno = FALSE; + new_symbol->symbol.the_bfd = abfd; +@@ -1834,6 +1898,7 @@ coff_bfd_make_debug_symbol (bfd *abfd, + new_symbol->native = (combined_entry_type *) bfd_zalloc (abfd, amt); + if (!new_symbol->native) + return NULL; ++ new_symbol->native->is_sym = TRUE; + new_symbol->symbol.section = bfd_abs_section_ptr; + new_symbol->symbol.flags = BSF_DEBUGGING; + new_symbol->lineno = NULL; +@@ -1849,7 +1914,8 @@ coff_get_symbol_info (bfd *abfd, asymbol + bfd_symbol_info (symbol, ret); + + if (coffsymbol (symbol)->native != NULL +- && coffsymbol (symbol)->native->fix_value) ++ && coffsymbol (symbol)->native->fix_value ++ && coffsymbol (symbol)->native->is_sym) + ret->value = coffsymbol (symbol)->native->u.syment.n_value - + (bfd_hostptr_t) obj_raw_syments (abfd); + } +@@ -1864,7 +1930,8 @@ bfd_coff_get_syment (bfd *abfd, + coff_symbol_type *csym; + + csym = coff_symbol_from (abfd, symbol); +- if (csym == NULL || csym->native == NULL) ++ if (csym == NULL || csym->native == NULL ++ || ! csym->native->is_sym) + { + bfd_set_error (bfd_error_invalid_operation); + return FALSE; +@@ -1896,6 +1963,7 @@ bfd_coff_get_auxent (bfd *abfd, + + if (csym == NULL + || csym->native == NULL ++ || ! csym->native->is_sym + || indx >= csym->native->u.syment.n_numaux) + { + bfd_set_error (bfd_error_invalid_operation); +@@ -1904,6 +1972,7 @@ bfd_coff_get_auxent (bfd *abfd, + + ent = csym->native + indx + 1; + ++ BFD_ASSERT (! ent->is_sym); + *pauxent = ent->u.auxent; + + if (ent->fix_tag) +@@ -1957,6 +2026,15 @@ coff_print_symbol (bfd *abfd, + + fprintf (file, "[%3ld]", (long) (combined - root)); + ++ /* PR 17512: file: 079-33786-0.001:0.1. */ ++ if (combined < obj_raw_syments (abfd) ++ || combined >= obj_raw_syments (abfd) + obj_raw_syment_count (abfd)) ++ { ++ fprintf (file, _(" %s"), symbol->name); ++ break; ++ } ++ ++ BFD_ASSERT (combined->is_sym); + if (! combined->fix_value) + val = (bfd_vma) combined->u.syment.n_value; + else +@@ -1976,6 +2054,7 @@ coff_print_symbol (bfd *abfd, + combined_entry_type *auxp = combined + aux + 1; + long tagndx; + ++ BFD_ASSERT (! auxp->is_sym); + if (auxp->fix_tag) + tagndx = auxp->u.auxent.x_sym.x_tagndx.p - root; + else +@@ -2050,8 +2129,11 @@ coff_print_symbol (bfd *abfd, + l++; + while (l->line_number) + { +- fprintf (file, "\n%4d : ", l->line_number); +- bfd_fprintf_vma (abfd, file, l->u.offset + symbol->section->vma); ++ if (l->line_number > 0) ++ { ++ fprintf (file, "\n%4d : ", l->line_number); ++ bfd_fprintf_vma (abfd, file, l->u.offset + symbol->section->vma); ++ } + l++; + } + } +@@ -2141,6 +2223,7 @@ coff_find_nearest_line (bfd *abfd, + pend = p + cof->raw_syment_count; + while (p < pend) + { ++ BFD_ASSERT (p->is_sym); + if (p->u.syment.n_sclass == C_FILE) + break; + p += 1 + p->u.syment.n_numaux; +@@ -2164,6 +2247,7 @@ coff_find_nearest_line (bfd *abfd, + p2 < pend; + p2 += 1 + p2->u.syment.n_numaux) + { ++ BFD_ASSERT (p2->is_sym); + if (p2->u.syment.n_scnum > 0 + && (section + == coff_section_from_bfd_index (abfd, +@@ -2175,6 +2259,8 @@ coff_find_nearest_line (bfd *abfd, + break; + } + } ++ if (p2 >= pend) ++ break; + + file_addr = (bfd_vma) p2->u.syment.n_value; + /* PR 11512: Include the section address of the function name symbol. */ +@@ -2239,6 +2325,8 @@ coff_find_nearest_line (bfd *abfd, + if (coff->native) + { + combined_entry_type *s = coff->native; ++ ++ BFD_ASSERT (s->is_sym); + s = s + 1 + s->u.syment.n_numaux; + + /* In XCOFF a debugging symbol can follow the +@@ -2251,6 +2339,7 @@ coff_find_nearest_line (bfd *abfd, + { + /* The linenumber is stored in the auxent. */ + union internal_auxent *a = &((s + 1)->u.auxent); ++ + line_base = a->x_sym.x_misc.x_lnsz.x_lnno; + *line_ptr = line_base; + } +@@ -2355,6 +2444,7 @@ bfd_coff_set_symbol_class (bfd * + if (native == NULL) + return FALSE; + ++ native->is_sym = TRUE; + native->u.syment.n_type = T_NULL; + native->u.syment.n_sclass = symbol_class; + +Index: b/bfd/cofflink.c +=================================================================== +--- a/bfd/cofflink.c ++++ b/bfd/cofflink.c +@@ -2001,7 +2001,10 @@ _bfd_coff_link_input_bfd (struct coff_fi + if (strings == NULL) + return FALSE; + } +- filename = strings + auxp->x_file.x_n.x_offset; ++ if ((bfd_size_type) auxp->x_file.x_n.x_offset >= obj_coff_strings_len (input_bfd)) ++ filename = _(""); ++ else ++ filename = strings + auxp->x_file.x_n.x_offset; + indx = _bfd_stringtab_add (finfo->strtab, filename, + hash, copy); + if (indx == (bfd_size_type) -1) +Index: b/bfd/elf.c +=================================================================== +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -7106,8 +7106,12 @@ _bfd_elf_slurp_version_tables (bfd *abfd + + hdr = &elf_tdata (abfd)->dynverref_hdr; + +- elf_tdata (abfd)->verref = (Elf_Internal_Verneed *) ++ if (hdr->sh_info) ++ elf_tdata (abfd)->verref = (Elf_Internal_Verneed *) + bfd_zalloc2 (abfd, hdr->sh_info, sizeof (Elf_Internal_Verneed)); ++ else ++ elf_tdata (abfd)->verref = NULL; ++ + if (elf_tdata (abfd)->verref == NULL) + goto error_return; + +@@ -7267,8 +7271,12 @@ error_return_verref: + else + freeidx = ++maxidx; + } +- elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) ++ if (maxidx) ++ elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) + bfd_zalloc2 (abfd, maxidx, sizeof (Elf_Internal_Verdef)); ++ else ++ elf_tdata (abfd)->verdef = NULL; ++ + if (elf_tdata (abfd)->verdef == NULL) + goto error_return; + +@@ -7409,16 +7417,12 @@ asymbol * + _bfd_elf_make_empty_symbol (bfd *abfd) + { + elf_symbol_type *newsym; +- bfd_size_type amt = sizeof (elf_symbol_type); + +- newsym = (elf_symbol_type *) bfd_zalloc (abfd, amt); ++ newsym = (elf_symbol_type *) bfd_zalloc (abfd, sizeof * newsym); + if (!newsym) + return NULL; +- else +- { +- newsym->symbol.the_bfd = abfd; +- return &newsym->symbol; +- } ++ newsym->symbol.the_bfd = abfd; ++ return &newsym->symbol; + } + + void +@@ -9098,7 +9102,7 @@ elfcore_write_lwpstatus (bfd *abfd, + lwpstat.pr_lwpid = pid >> 16; + lwpstat.pr_cursig = cursig; + #if defined (HAVE_LWPSTATUS_T_PR_REG) +- memcpy (lwpstat.pr_reg, gregs, sizeof (lwpstat.pr_reg)); ++ memcpy (&lwpstat.pr_reg, gregs, sizeof (lwpstat.pr_reg)); + #elif defined (HAVE_LWPSTATUS_T_PR_CONTEXT) + #if !defined(gregs) + memcpy (lwpstat.pr_context.uc_mcontext.gregs, +Index: b/bfd/ieee.c +=================================================================== +--- a/bfd/ieee.c ++++ b/bfd/ieee.c +@@ -1313,7 +1313,8 @@ ieee_archive_p (bfd *abfd) + + /* Ignore the return value here. It doesn't matter if we don't read + the entire buffer. We might have a very small ieee file. */ +- bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd); ++ if (bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd) <= 0) ++ goto got_wrong_format_error; + + ieee->h.first_byte = buffer; + ieee->h.input_p = buffer; +@@ -1802,7 +1803,8 @@ ieee_object_p (bfd *abfd) + goto fail; + /* Read the first few bytes in to see if it makes sense. Ignore + bfd_bread return value; The file might be very small. */ +- bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd); ++ if (bfd_bread ((void *) buffer, (bfd_size_type) sizeof (buffer), abfd) <= 0) ++ goto got_wrong_format; + + ieee->h.input_p = buffer; + if (this_byte_and_next (&(ieee->h)) != Module_Beginning) +Index: b/bfd/libcoff-in.h +=================================================================== +--- a/bfd/libcoff-in.h ++++ b/bfd/libcoff-in.h +@@ -37,6 +37,7 @@ + #define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms) + #define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms) + #define obj_coff_strings(bfd) (coff_data (bfd)->strings) ++#define obj_coff_strings_len(bfd) (coff_data (bfd)->strings_len) + #define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings) + #define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes) + #define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written) +@@ -77,6 +78,8 @@ typedef struct coff_tdata + /* The string table. May be NULL. Read by + _bfd_coff_read_string_table. */ + char *strings; ++ /* The length of the strings table. For error checking. */ ++ bfd_size_type strings_len; + /* If this is TRUE, the strings may not be freed. */ + bfd_boolean keep_strings; + /* If this is TRUE, the strings have been written out already. */ +Index: b/bfd/libcoff.h +=================================================================== +--- a/bfd/libcoff.h ++++ b/bfd/libcoff.h +@@ -41,6 +41,7 @@ + #define obj_coff_external_syms(bfd) (coff_data (bfd)->external_syms) + #define obj_coff_keep_syms(bfd) (coff_data (bfd)->keep_syms) + #define obj_coff_strings(bfd) (coff_data (bfd)->strings) ++#define obj_coff_strings_len(bfd) (coff_data (bfd)->strings_len) + #define obj_coff_keep_strings(bfd) (coff_data (bfd)->keep_strings) + #define obj_coff_sym_hashes(bfd) (coff_data (bfd)->sym_hashes) + #define obj_coff_strings_written(bfd) (coff_data (bfd)->strings_written) +@@ -81,6 +82,8 @@ typedef struct coff_tdata + /* The string table. May be NULL. Read by + _bfd_coff_read_string_table. */ + char *strings; ++ /* The length of the strings table. For error checking. */ ++ bfd_size_type strings_len; + /* If this is TRUE, the strings may not be freed. */ + bfd_boolean keep_strings; + /* If this is TRUE, the strings have been written out already. */ +@@ -613,7 +616,7 @@ extern bfd_boolean ppc_process_before_al + typedef struct coff_ptr_struct + { + /* Remembers the offset from the first symbol in the file for +- this symbol. Generated by coff_renumber_symbols. */ ++ this symbol. Generated by coff_renumber_symbols. */ + unsigned int offset; + + /* Should the value of this symbol be renumbered. Used for +@@ -621,15 +624,15 @@ typedef struct coff_ptr_struct + unsigned int fix_value : 1; + + /* Should the tag field of this symbol be renumbered. +- Created by coff_pointerize_aux. */ ++ Created by coff_pointerize_aux. */ + unsigned int fix_tag : 1; + + /* Should the endidx field of this symbol be renumbered. +- Created by coff_pointerize_aux. */ ++ Created by coff_pointerize_aux. */ + unsigned int fix_end : 1; + + /* Should the x_csect.x_scnlen field be renumbered. +- Created by coff_pointerize_aux. */ ++ Created by coff_pointerize_aux. */ + unsigned int fix_scnlen : 1; + + /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the +@@ -637,12 +640,15 @@ typedef struct coff_ptr_struct + unsigned int fix_line : 1; + + /* The container for the symbol structure as read and translated +- from the file. */ ++ from the file. */ + union + { + union internal_auxent auxent; + struct internal_syment syment; + } u; ++ ++ /* Selector for the union above. */ ++ bfd_boolean is_sym; + } combined_entry_type; + + +Index: b/bfd/opncls.c +=================================================================== +--- a/bfd/opncls.c ++++ b/bfd/opncls.c +@@ -916,14 +916,19 @@ void * + bfd_alloc (bfd *abfd, bfd_size_type size) + { + void *ret; ++ unsigned long ul_size = (unsigned long) size; + +- if (size != (unsigned long) size) ++ if (size != ul_size ++ /* A small negative size can result in objalloc_alloc allocating just ++ 1 byte of memory, but the caller will be expecting more. So catch ++ this case here. */ ++ || (size != 0 && (((ul_size + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1)) == 0))) + { + bfd_set_error (bfd_error_no_memory); + return NULL; + } +- +- ret = objalloc_alloc ((struct objalloc *) abfd->memory, (unsigned long) size); ++ ++ ret = objalloc_alloc ((struct objalloc *) abfd->memory, ul_size); + if (ret == NULL) + bfd_set_error (bfd_error_no_memory); + return ret; +@@ -944,8 +949,6 @@ DESCRIPTION + void * + bfd_alloc2 (bfd *abfd, bfd_size_type nmemb, bfd_size_type size) + { +- void *ret; +- + if ((nmemb | size) >= HALF_BFD_SIZE_TYPE + && size != 0 + && nmemb > ~(bfd_size_type) 0 / size) +@@ -954,18 +957,7 @@ bfd_alloc2 (bfd *abfd, bfd_size_type nme + return NULL; + } + +- size *= nmemb; +- +- if (size != (unsigned long) size) +- { +- bfd_set_error (bfd_error_no_memory); +- return NULL; +- } +- +- ret = objalloc_alloc ((struct objalloc *) abfd->memory, (unsigned long) size); +- if (ret == NULL) +- bfd_set_error (bfd_error_no_memory); +- return ret; ++ return bfd_alloc (abfd, size * nmemb); + } + + /* +@@ -1154,7 +1146,7 @@ get_debug_link_info (bfd *abfd, unsigned + asection *sect; + unsigned long crc32; + bfd_byte *contents; +- int crc_offset; ++ unsigned int crc_offset; + char *name; + + BFD_ASSERT (abfd); +@@ -1172,10 +1164,13 @@ get_debug_link_info (bfd *abfd, unsigned + return NULL; + } + +- /* Crc value is stored after the filename, aligned up to 4 bytes. */ ++ /* CRC value is stored after the filename, aligned up to 4 bytes. */ + name = (char *) contents; +- crc_offset = strlen (name) + 1; ++ /* PR 17597: avoid reading off the end of the buffer. */ ++ crc_offset = strnlen (name, bfd_get_section_size (sect)) + 1; + crc_offset = (crc_offset + 3) & ~3; ++ if (crc_offset >= bfd_get_section_size (sect)) ++ return NULL; + + crc32 = bfd_get_32 (abfd, contents + crc_offset); + +Index: b/bfd/pe-mips.c +=================================================================== +--- a/bfd/pe-mips.c ++++ b/bfd/pe-mips.c +@@ -341,6 +341,8 @@ static reloc_howto_type howto_table[] = + FALSE), /* Pcrel_offset. */ + }; + ++#define NUM_HOWTOS (sizeof (howto_table) / sizeof (howto_table[0])) ++ + /* Turn a howto into a reloc nunmber. */ + + #define SELECT_RELOC(x, howto) { x.r_type = howto->type; } +@@ -381,7 +383,8 @@ static reloc_howto_type howto_table[] = + cache_ptr->addend = - (ptr->section->vma + ptr->value); \ + else \ + cache_ptr->addend = 0; \ +- if (ptr && howto_table[reloc.r_type].pc_relative) \ ++ if (ptr && reloc.r_type < NUM_HOWTOS \ ++ && howto_table[reloc.r_type].pc_relative) \ + cache_ptr->addend += asect->vma; \ + } + +@@ -511,9 +514,7 @@ coff_mips_reloc_name_lookup (bfd *abfd A + { + unsigned int i; + +- for (i = 0; +- i < sizeof (howto_table) / sizeof (howto_table[0]); +- i++) ++ for (i = 0; i < NUM_HOWTOS; i++) + if (howto_table[i].name != NULL + && strcasecmp (howto_table[i].name, r_name) == 0) + return &howto_table[i]; +Index: b/bfd/peXXigen.c +=================================================================== +--- a/bfd/peXXigen.c ++++ b/bfd/peXXigen.c +@@ -142,8 +142,13 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void * + + name = _bfd_coff_internal_syment_name (abfd, in, namebuf); + if (name == NULL) +- /* FIXME: Return error. */ +- abort (); ++ { ++ _bfd_error_handler (_("%B: unable to find name for empty section"), ++ abfd); ++ bfd_set_error (bfd_error_invalid_target); ++ return; ++ } ++ + sec = bfd_get_section_by_name (abfd, name); + if (sec != NULL) + in->n_scnum = sec->target_index; +@@ -163,15 +168,22 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void * + { + name = (const char *) bfd_alloc (abfd, strlen (namebuf) + 1); + if (name == NULL) +- /* FIXME: Return error. */ +- abort (); ++ { ++ _bfd_error_handler (_("%B: out of memory creating name for empty section"), ++ abfd); ++ return; ++ } + strcpy ((char *) name, namebuf); + } ++ + flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD; + sec = bfd_make_section_anyway_with_flags (abfd, name, flags); + if (sec == NULL) +- /* FIXME: Return error. */ +- abort (); ++ { ++ _bfd_error_handler (_("%B: unable to create fake empty section"), ++ abfd); ++ return; ++ } + + sec->vma = 0; + sec->lma = 0; +@@ -240,6 +252,9 @@ _bfd_XXi_swap_aux_in (bfd * abfd, + AUXENT *ext = (AUXENT *) ext1; + union internal_auxent *in = (union internal_auxent *) in1; + ++ /* PR 17521: Make sure that all fields in the aux structure ++ are initialised. */ ++ memset (in, 0, sizeof * in); + switch (in_class) + { + case C_FILE: +@@ -415,6 +430,7 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, + aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry); + aouthdr_int->text_start = + GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start); ++ + #if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) + /* PE32+ does not have data_start member! */ + aouthdr_int->data_start = +@@ -462,7 +478,7 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, + int idx; + + /* PR 17512: Corrupt PE binaries can cause seg-faults. */ +- if (a->NumberOfRvaAndSizes > 16) ++ if (a->NumberOfRvaAndSizes > IMAGE_NUMBEROF_DIRECTORY_ENTRIES) + { + (*_bfd_error_handler) + (_("%B: aout header specifies an invalid number of data-directory entries: %d"), +@@ -486,6 +502,13 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, + else + a->DataDirectory[idx].VirtualAddress = 0; + } ++ ++ while (idx < IMAGE_NUMBEROF_DIRECTORY_ENTRIES) ++ { ++ a->DataDirectory[idx].Size = 0; ++ a->DataDirectory[idx].VirtualAddress = 0; ++ idx ++; ++ } + } + + if (aouthdr_int->entry) +@@ -732,7 +755,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, v + { + int idx; + +- for (idx = 0; idx < 16; idx++) ++ for (idx = 0; idx < IMAGE_NUMBEROF_DIRECTORY_ENTRIES; idx++) + { + H_PUT_32 (abfd, extra->DataDirectory[idx].VirtualAddress, + aouthdr_out->DataDirectory[idx][0]); +@@ -1233,7 +1256,9 @@ pe_print_idata (bfd * abfd, void * vfile + break; + + dll = (char *) data + dll_name - adj; +- fprintf (file, _("\n\tDLL Name: %s\n"), dll); ++ /* PR 17512 file: 078-12277-0.004. */ ++ bfd_size_type maxlen = (char *)(data + datasize) - dll - 1; ++ fprintf (file, _("\n\tDLL Name: %.*s\n"), (int) maxlen, dll); + + if (hint_addr != 0) + { +@@ -1298,23 +1323,30 @@ pe_print_idata (bfd * abfd, void * vfile + #ifdef COFF_WITH_pex64 + for (j = 0; idx + j + 8 <= datasize; j += 8) + { ++ bfd_size_type amt; + unsigned long member = bfd_get_32 (abfd, data + idx + j); + unsigned long member_high = bfd_get_32 (abfd, data + idx + j + 4); + + if (!member && !member_high) + break; + ++ amt = member - adj; ++ + if (member_high & 0x80000000) + fprintf (file, "\t%lx%08lx\t %4lx%08lx ", + member_high,member, member_high & 0x7fffffff, member); ++ /* PR binutils/17512: Handle corrupt PE data. */ ++ else if (amt + 2 >= datasize) ++ fprintf (file, _("\t"), member); + else + { + int ordinal; + char *member_name; + +- ordinal = bfd_get_16 (abfd, data + member - adj); +- member_name = (char *) data + member - adj + 2; +- fprintf (file, "\t%04lx\t %4d %s",member, ordinal, member_name); ++ ordinal = bfd_get_16 (abfd, data + amt); ++ member_name = (char *) data + amt + 2; ++ fprintf (file, "\t%04lx\t %4d %.*s",member, ordinal, ++ (int) (datasize - (amt + 2)), member_name); + } + + /* If the time stamp is not zero, the import address +@@ -1330,24 +1362,30 @@ pe_print_idata (bfd * abfd, void * vfile + #else + for (j = 0; idx + j + 4 <= datasize; j += 4) + { ++ bfd_size_type amt; + unsigned long member = bfd_get_32 (abfd, data + idx + j); + + /* Print single IMAGE_IMPORT_BY_NAME vector. */ + if (member == 0) + break; + ++ amt = member - adj; + if (member & 0x80000000) + fprintf (file, "\t%04lx\t %4lu ", + member, member & 0x7fffffff); ++ /* PR binutils/17512: Handle corrupt PE data. */ ++ else if (amt + 2 >= datasize) ++ fprintf (file, _("\t"), member); + else + { + int ordinal; + char *member_name; + +- ordinal = bfd_get_16 (abfd, data + member - adj); +- member_name = (char *) data + member - adj + 2; +- fprintf (file, "\t%04lx\t %4d %s", +- member, ordinal, member_name); ++ ordinal = bfd_get_16 (abfd, data + amt); ++ member_name = (char *) data + amt + 2; ++ fprintf (file, "\t%04lx\t %4d %.*s", ++ member, ordinal, ++ (int) (datasize - (amt + 2)), member_name); + } + + /* If the time stamp is not zero, the import address +@@ -1506,7 +1544,9 @@ pe_print_edata (bfd * abfd, void * vfile + bfd_fprintf_vma (abfd, file, edt.name); + + if ((edt.name >= adj) && (edt.name < adj + datasize)) +- fprintf (file, " %s\n", data + edt.name - adj); ++ fprintf (file, " %.*s\n", ++ (int) (datasize - (edt.name - adj)), ++ data + edt.name - adj); + else + fprintf (file, "(outside .edata section)\n"); + +@@ -1555,7 +1595,9 @@ pe_print_edata (bfd * abfd, void * vfile + edt.base); + + /* PR 17512: Handle corrupt PE binaries. */ +- if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize) ++ if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize ++ /* PR 17512 file: 140-165018-0.004. */ ++ || data + edt.eat_addr - adj < data) + fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"), + (long) edt.eat_addr, + (long) edt.num_functions); +@@ -1571,11 +1613,12 @@ pe_print_edata (bfd * abfd, void * vfile + /* This rva is to a name (forwarding function) in our section. */ + /* Should locate a function descriptor. */ + fprintf (file, +- "\t[%4ld] +base[%4ld] %04lx %s -- %s\n", ++ "\t[%4ld] +base[%4ld] %04lx %s -- %.*s\n", + (long) i, + (long) (i + edt.base), + (unsigned long) eat_member, + _("Forwarder RVA"), ++ (int)(datasize - (eat_member - adj)), + data + eat_member - adj); + } + else +@@ -1596,29 +1639,37 @@ pe_print_edata (bfd * abfd, void * vfile + _("\n[Ordinal/Name Pointer] Table\n")); + + /* PR 17512: Handle corrupt PE binaries. */ +- if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize) ++ if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize ++ || (data + edt.npt_addr - adj) < data) + fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"), + (long) edt.npt_addr, + (long) edt.num_names); +- else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize) ++ /* PR 17512: file: 140-147171-0.004. */ ++ else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize ++ || data + edt.ot_addr - adj < data) + fprintf (file, _("\tInvalid Ordinal Table rva (0x%lx) or entry count (0x%lx)\n"), + (long) edt.ot_addr, + (long) edt.num_names); + else for (i = 0; i < edt.num_names; ++i) + { +- bfd_vma name_ptr = bfd_get_32 (abfd, +- data + +- edt.npt_addr +- + (i*4) - adj); +- +- char *name = (char *) data + name_ptr - adj; +- +- bfd_vma ord = bfd_get_16 (abfd, +- data + +- edt.ot_addr +- + (i*2) - adj); +- fprintf (file, +- "\t[%4ld] %s\n", (long) ord, name); ++ bfd_vma name_ptr; ++ bfd_vma ord; ++ ++ ord = bfd_get_16 (abfd, data + edt.ot_addr + (i * 2) - adj); ++ name_ptr = bfd_get_32 (abfd, data + edt.npt_addr + (i * 4) - adj); ++ ++ if ((name_ptr - adj) >= datasize) ++ { ++ fprintf (file, _("\t[%4ld] \n"), ++ (long) ord, (long) name_ptr); ++ } ++ else ++ { ++ char * name = (char *) data + name_ptr - adj; ++ ++ fprintf (file, "\t[%4ld] %.*s\n", (long) ord, ++ (int)((char *)(data + datasize) - name), name); ++ } + } + + free (data); +@@ -1967,8 +2018,7 @@ pe_print_reloc (bfd * abfd, void * vfile + FILE *file = (FILE *) vfile; + bfd_byte *data = 0; + asection *section = bfd_get_section_by_name (abfd, ".reloc"); +- bfd_size_type i; +- bfd_size_type start, stop; ++ bfd_byte *p, *end; + + if (section == NULL || section->size == 0 || !(section->flags & SEC_HAS_CONTENTS)) + return TRUE; +@@ -1983,20 +2033,20 @@ pe_print_reloc (bfd * abfd, void * vfile + return FALSE; + } + +- start = 0; +- +- stop = section->size; +- +- for (i = start; i < stop;) ++ p = data; ++ end = data + section->size; ++ while (p + 8 <= end) + { + int j; + bfd_vma virtual_address; + long number, size; ++ bfd_byte *chunk_end; + + /* The .reloc section is a sequence of blocks, with a header consisting + of two 32 bit quantities, followed by a number of 16 bit entries. */ +- virtual_address = bfd_get_32 (abfd, data+i); +- size = bfd_get_32 (abfd, data+i+4); ++ virtual_address = bfd_get_32 (abfd, p); ++ size = bfd_get_32 (abfd, p + 4); ++ p += 8; + number = (size - 8) / 2; + + if (size == 0) +@@ -2006,9 +2056,13 @@ pe_print_reloc (bfd * abfd, void * vfile + _("\nVirtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n"), + (unsigned long) virtual_address, size, (unsigned long) size, number); + +- for (j = 0; j < number; ++j) ++ chunk_end = p + size; ++ if (chunk_end > end) ++ chunk_end = end; ++ j = 0; ++ while (p + 2 <= chunk_end) + { +- unsigned short e = bfd_get_16 (abfd, data + i + 8 + j * 2); ++ unsigned short e = bfd_get_16 (abfd, p); + unsigned int t = (e & 0xF000) >> 12; + int off = e & 0x0FFF; + +@@ -2019,20 +2073,20 @@ pe_print_reloc (bfd * abfd, void * vfile + _("\treloc %4d offset %4x [%4lx] %s"), + j, off, (unsigned long) (off + virtual_address), tbl[t]); + ++ p += 2; ++ j++; ++ + /* HIGHADJ takes an argument, - the next record *is* the + low 16 bits of addend. */ +- if (t == IMAGE_REL_BASED_HIGHADJ) ++ if (t == IMAGE_REL_BASED_HIGHADJ && p + 2 <= chunk_end) + { +- fprintf (file, " (%4x)", +- ((unsigned int) +- bfd_get_16 (abfd, data + i + 8 + j * 2 + 2))); ++ fprintf (file, " (%4x)", (unsigned int) bfd_get_16 (abfd, p)); ++ p += 2; + j++; + } + + fprintf (file, "\n"); + } +- +- i += size; + } + + free (data); +Index: b/bfd/peicode.h +=================================================================== +--- a/bfd/peicode.h ++++ b/bfd/peicode.h +@@ -264,6 +264,7 @@ pe_mkobject (bfd * abfd) + /* in_reloc_p is architecture dependent. */ + pe->in_reloc_p = in_reloc_p; + ++ memset (& pe->pe_opthdr, 0, sizeof pe->pe_opthdr); + return TRUE; + } + +@@ -560,6 +561,7 @@ pe_ILF_make_a_symbol (pe_ILF_vars * var + ent->u.syment.n_sclass = sclass; + ent->u.syment.n_scnum = section->target_index; + ent->u.syment._n._n_n._n_offset = (bfd_hostptr_t) sym; ++ ent->is_sym = TRUE; + + sym->symbol.the_bfd = vars->abfd; + sym->symbol.name = vars->string_ptr; +Index: b/bfd/tekhex.c +=================================================================== +--- a/bfd/tekhex.c ++++ b/bfd/tekhex.c +@@ -247,11 +247,12 @@ struct tekhex_data_list_struct + typedef struct tekhex_data_list_struct tekhex_data_list_type; + + #define CHUNK_MASK 0x1fff ++#define CHUNK_SPAN 32 + + struct data_struct + { +- char chunk_data[CHUNK_MASK + 1]; +- char chunk_init[CHUNK_MASK + 1]; ++ unsigned char chunk_data[CHUNK_MASK + 1]; ++ unsigned char chunk_init[(CHUNK_MASK + 1 + CHUNK_SPAN - 1) / CHUNK_SPAN]; + bfd_vma vma; + struct data_struct *next; + }; +@@ -313,7 +314,7 @@ getsym (char *dstp, char **srcp, unsigne + } + + static struct data_struct * +-find_chunk (bfd *abfd, bfd_vma vma) ++find_chunk (bfd *abfd, bfd_vma vma, bfd_boolean create) + { + struct data_struct *d = abfd->tdata.tekhex_data->data; + +@@ -321,7 +322,7 @@ find_chunk (bfd *abfd, bfd_vma vma) + while (d && (d->vma) != vma) + d = d->next; + +- if (!d) ++ if (!d && create) + { + /* No chunk for this address, so make one up. */ + d = (struct data_struct *) +@@ -340,11 +341,14 @@ find_chunk (bfd *abfd, bfd_vma vma) + static void + insert_byte (bfd *abfd, int value, bfd_vma addr) + { +- /* Find the chunk that this byte needs and put it in. */ +- struct data_struct *d = find_chunk (abfd, addr); ++ if (value != 0) ++ { ++ /* Find the chunk that this byte needs and put it in. */ ++ struct data_struct *d = find_chunk (abfd, addr, TRUE); + +- d->chunk_data[addr & CHUNK_MASK] = value; +- d->chunk_init[addr & CHUNK_MASK] = 1; ++ d->chunk_data[addr & CHUNK_MASK] = value; ++ d->chunk_init[(addr & CHUNK_MASK) / CHUNK_SPAN] = 1; ++ } + } + + /* The first pass is to find the names of all the sections, and see +@@ -353,7 +357,7 @@ insert_byte (bfd *abfd, int value, bfd_v + static bfd_boolean + first_phase (bfd *abfd, int type, char *src) + { +- asection *section = bfd_abs_section_ptr; ++ asection *section, *alt_section; + unsigned int len; + bfd_vma val; + char sym[17]; /* A symbol can only be 16chars long. */ +@@ -393,6 +397,7 @@ first_phase (bfd *abfd, int type, char * + if (section == NULL) + return FALSE; + } ++ alt_section = NULL; + while (*src) + { + switch (*src) +@@ -440,6 +445,42 @@ first_phase (bfd *abfd, int type, char * + new_symbol->symbol.flags = (BSF_GLOBAL | BSF_EXPORT); + else + new_symbol->symbol.flags = BSF_LOCAL; ++ if (stype == '2' || stype == '6') ++ new_symbol->symbol.section = bfd_abs_section_ptr; ++ else if (stype == '3' || stype == '7') ++ { ++ if ((section->flags & SEC_DATA) == 0) ++ section->flags |= SEC_CODE; ++ else ++ { ++ if (alt_section == NULL) ++ alt_section = bfd_get_next_section_by_name (section); ++ if (alt_section == NULL) ++ alt_section = bfd_make_section_anyway_with_flags ++ (abfd, section->name, ++ (section->flags & ~SEC_DATA) | SEC_CODE); ++ if (alt_section == NULL) ++ return FALSE; ++ new_symbol->symbol.section = alt_section; ++ } ++ } ++ else if (stype == '4' || stype == '8') ++ { ++ if ((section->flags & SEC_CODE) == 0) ++ section->flags |= SEC_DATA; ++ else ++ { ++ if (alt_section == NULL) ++ alt_section = bfd_get_next_section_by_name (section); ++ if (alt_section == NULL) ++ alt_section = bfd_make_section_anyway_with_flags ++ (abfd, section->name, ++ (section->flags & ~SEC_CODE) | SEC_DATA); ++ if (alt_section == NULL) ++ return FALSE; ++ new_symbol->symbol.section = alt_section; ++ } ++ } + if (!getvalue (&src, &val)) + return FALSE; + new_symbol->symbol.value = val - section->vma; +@@ -590,22 +631,26 @@ move_section_contents (bfd *abfd, + /* Get high bits of address. */ + bfd_vma chunk_number = addr & ~(bfd_vma) CHUNK_MASK; + bfd_vma low_bits = addr & CHUNK_MASK; ++ bfd_boolean must_write = !get && *location != 0; + +- if (chunk_number != prev_number) +- /* Different chunk, so move pointer. */ +- d = find_chunk (abfd, chunk_number); ++ if (chunk_number != prev_number || (!d && must_write)) ++ { ++ /* Different chunk, so move pointer. */ ++ d = find_chunk (abfd, chunk_number, must_write); ++ prev_number = chunk_number; ++ } + + if (get) + { +- if (d->chunk_init[low_bits]) ++ if (d) + *location = d->chunk_data[low_bits]; + else + *location = 0; + } +- else ++ else if (must_write) + { + d->chunk_data[low_bits] = *location; +- d->chunk_init[low_bits] = (*location != 0); ++ d->chunk_init[low_bits / CHUNK_SPAN] = 1; + } + + location++; +@@ -633,7 +678,9 @@ tekhex_set_arch_mach (bfd *abfd, + enum bfd_architecture arch, + unsigned long machine) + { +- return bfd_default_set_arch_mach (abfd, arch, machine); ++ /* Ignore errors about unknown architecture. */ ++ return (bfd_default_set_arch_mach (abfd, arch, machine) ++ || arch == bfd_arch_unknown); + } + + /* We have to save up all the Tekhexords for a splurge before output. */ +@@ -645,24 +692,6 @@ tekhex_set_section_contents (bfd *abfd, + file_ptr offset, + bfd_size_type bytes_to_do) + { +- if (! abfd->output_has_begun) +- { +- /* The first time around, allocate enough sections to hold all the chunks. */ +- asection *s = abfd->sections; +- bfd_vma vma; +- +- for (s = abfd->sections; s; s = s->next) +- { +- if (s->flags & SEC_LOAD) +- { +- for (vma = s->vma & ~(bfd_vma) CHUNK_MASK; +- vma < s->vma + s->size; +- vma += CHUNK_MASK) +- find_chunk (abfd, vma); +- } +- } +- } +- + if (section->flags & (SEC_LOAD | SEC_ALLOC)) + { + move_section_contents (abfd, section, locationp, offset, bytes_to_do, +@@ -773,26 +802,17 @@ tekhex_write_object_contents (bfd *abfd) + d = d->next) + { + int low; +- +- const int span = 32; + int addr; + + /* Write it in blocks of 32 bytes. */ +- for (addr = 0; addr < CHUNK_MASK + 1; addr += span) ++ for (addr = 0; addr < CHUNK_MASK + 1; addr += CHUNK_SPAN) + { +- int need = 0; +- +- /* Check to see if necessary. */ +- for (low = 0; !need && low < span; low++) +- if (d->chunk_init[addr + low]) +- need = 1; +- +- if (need) ++ if (d->chunk_init[addr / CHUNK_SPAN]) + { + char *dst = buffer; + + writevalue (&dst, addr + d->vma); +- for (low = 0; low < span; low++) ++ for (low = 0; low < CHUNK_SPAN; low++) + { + TOHEX (dst, d->chunk_data[addr + low]); + dst += 2; +Index: b/bfd/xcofflink.c +=================================================================== +--- a/bfd/xcofflink.c ++++ b/bfd/xcofflink.c +@@ -4496,7 +4496,10 @@ xcoff_link_input_bfd (struct xcoff_final + if (strings == NULL) + return FALSE; + } +- filename = strings + aux.x_file.x_n.x_offset; ++ if ((bfd_size_type) aux.x_file.x_n.x_offset >= obj_coff_strings_len (input_bfd)) ++ filename = _(""); ++ else ++ filename = strings + aux.x_file.x_n.x_offset; + indx = _bfd_stringtab_add (flinfo->strtab, filename, + hash, copy); + if (indx == (bfd_size_type) -1) +Index: b/binutils/dwarf.c +=================================================================== +--- a/binutils/dwarf.c ++++ b/binutils/dwarf.c +@@ -84,13 +84,22 @@ size_of_encoded_value (int encoding) + } + + static dwarf_vma +-get_encoded_value (unsigned char *data, ++get_encoded_value (unsigned char **pdata, + int encoding, +- struct dwarf_section *section) ++ struct dwarf_section *section, ++ unsigned char * end) + { ++ unsigned char * data = * pdata; + int size = size_of_encoded_value (encoding); + dwarf_vma val; + ++ if (data + size >= end) ++ { ++ warn (_("Encoded value extends past end of section\n")); ++ * pdata = end; ++ return 0; ++ } ++ + if (encoding & DW_EH_PE_signed) + val = byte_get_signed (data, size); + else +@@ -98,6 +107,8 @@ get_encoded_value (unsigned char *data, + + if ((encoding & 0x70) == DW_EH_PE_pcrel) + val += section->address + (data - section->start); ++ ++ * pdata = data + size; + return val; + } + +@@ -341,7 +352,7 @@ process_extended_line_op (unsigned char + + if (len == 0 || data == end) + { +- warn (_("badly formed extended line op encountered!\n")); ++ warn (_("Badly formed extended line op encountered!\n")); + return bytes_read; + } + +@@ -1215,8 +1226,7 @@ decode_location_expression (unsigned cha + dwarf_vma addr; + + encoding = *data++; +- addr = get_encoded_value (data, encoding, section); +- data += size_of_encoded_value (encoding); ++ addr = get_encoded_value (&data, encoding, section, end); + + printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding); + print_dwarf_vma (addr, pointer_size); +@@ -1370,9 +1380,9 @@ read_and_display_attr_value (unsigned lo + unsigned char * orig_data = data; + unsigned int bytes_read; + +- if (data == end) ++ if (data > end || (data == end && form != DW_FORM_flag_present)) + { +- warn (_("corrupt attribute\n")); ++ warn (_("Corrupt attribute\n")); + return data; + } + +@@ -1507,6 +1517,12 @@ read_and_display_attr_value (unsigned lo + case DW_FORM_exprloc: + uvalue = read_uleb128 (data, & bytes_read, end); + block_start = data + bytes_read; ++ /* PR 17512: file: 008-103549-0.001:0.1. */ ++ if (block_start + uvalue > end) ++ { ++ warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); ++ uvalue = end - block_start; ++ } + if (do_loc) + data = block_start + uvalue; + else +@@ -1516,6 +1532,11 @@ read_and_display_attr_value (unsigned lo + case DW_FORM_block1: + SAFE_BYTE_GET (uvalue, data, 1, end); + block_start = data + 1; ++ if (block_start + uvalue > end) ++ { ++ warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); ++ uvalue = end - block_start; ++ } + if (do_loc) + data = block_start + uvalue; + else +@@ -1525,6 +1546,11 @@ read_and_display_attr_value (unsigned lo + case DW_FORM_block2: + SAFE_BYTE_GET (uvalue, data, 2, end); + block_start = data + 2; ++ if (block_start + uvalue > end) ++ { ++ warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); ++ uvalue = end - block_start; ++ } + if (do_loc) + data = block_start + uvalue; + else +@@ -1534,6 +1560,11 @@ read_and_display_attr_value (unsigned lo + case DW_FORM_block4: + SAFE_BYTE_GET (uvalue, data, 4, end); + block_start = data + 4; ++ if (block_start + uvalue > end) ++ { ++ warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue); ++ uvalue = end - block_start; ++ } + if (do_loc) + data = block_start + uvalue; + else +@@ -2174,7 +2205,7 @@ process_debug_info (struct dwarf_section + + if (num_units == 0) + { +- error (_("No comp units in %s section ?"), section->name); ++ error (_("No comp units in %s section ?\n"), section->name); + return 0; + } + +@@ -2183,7 +2214,7 @@ process_debug_info (struct dwarf_section + sizeof (* debug_information)); + if (debug_information == NULL) + { +- error (_("Not enough memory for a debug info array of %u entries"), ++ error (_("Not enough memory for a debug info array of %u entries\n"), + num_units); + return 0; + } +@@ -2240,6 +2271,13 @@ process_debug_info (struct dwarf_section + SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end); + + SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end); ++ /* PR 17512: file: 001-108546-0.001:0.1. */ ++ if (compunit.cu_pointer_size < 2 || compunit.cu_pointer_size > 8) ++ { ++ warn (_("Invalid pointer size (%d) in compunit header, using %d instead\n"), ++ compunit.cu_pointer_size, offset_size); ++ compunit.cu_pointer_size = offset_size; ++ } + + if (do_types) + { +@@ -3458,6 +3496,8 @@ display_debug_pubnames (struct dwarf_sec + if (offset != 0) + { + data += offset_size; ++ if (data >= end) ++ break; + printf (" %-6lx\t%s\n", offset, data); + data += strnlen ((char *) data, end - data) + 1; + } +@@ -4072,6 +4112,13 @@ display_debug_loc (struct dwarf_section + continue; + } + ++ if (pointer_size < 2 || pointer_size > 8) ++ { ++ warn (_("Invalid pointer size (%d) in debug info for entry %d\n"), ++ pointer_size, i); ++ continue; ++ } ++ + while (1) + { + if (start + 2 * pointer_size > section_end) +@@ -4302,7 +4349,8 @@ display_debug_aranges (struct dwarf_sect + + address_size = arange.ar_pointer_size + arange.ar_segment_size; + +- if (address_size == 0) ++ /* PR 17512: file: 001-108546-0.001:0.1. */ ++ if (address_size == 0 || address_size > 8) + { + error (_("Invalid address size in %s section!\n"), + section->name); +@@ -4443,12 +4491,19 @@ display_debug_ranges (struct dwarf_secti + unsigned long base_address; + + pointer_size = debug_info_p->pointer_size; +- + /* DWARF sections under Mach-O have non-zero addresses. */ + offset = range_entry->ranges_offset - section->address; + next = section_begin + offset; + base_address = debug_info_p->base_address; + ++ /* PR 17512: file: 001-101485-0.001:0.1. */ ++ if (pointer_size < 2 || pointer_size > 8) ++ { ++ warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"), ++ pointer_size, offset); ++ continue; ++ } ++ + if (i > 0) + { + if (start < next) +@@ -4562,6 +4617,14 @@ frame_need_space (Frame_Chunk *fc, unsig + fc->col_type = (short int *) xcrealloc (fc->col_type, fc->ncols, + sizeof (short int)); + fc->col_offset = (int *) xcrealloc (fc->col_offset, fc->ncols, sizeof (int)); ++ /* PR 17512: file:002-10025-0.005. */ ++ if (fc->col_type == NULL || fc->col_offset == NULL) ++ { ++ error (_("Out of memory allocating %u columns in dwarf frame arrays\n"), ++ fc->ncols); ++ fc->ncols = 0; ++ return -1; ++ } + + while (prev < fc->ncols) + { +@@ -4752,6 +4815,11 @@ read_cie (unsigned char *start, unsigned + unsigned char *augmentation_data = NULL; + unsigned long augmentation_data_len = 0; + ++ * p_cie = NULL; ++ /* PR 17512: file: 001-228113-0.004. */ ++ if (start >= end) ++ return end; ++ + fc = (Frame_Chunk *) xmalloc (sizeof (Frame_Chunk)); + memset (fc, 0, sizeof (Frame_Chunk)); + +@@ -4761,7 +4829,16 @@ read_cie (unsigned char *start, unsigned + version = *start++; + + fc->augmentation = (char *) start; +- start = (unsigned char *) strchr ((char *) start, '\0') + 1; ++ /* PR 17512: file: 001-228113-0.004. ++ Skip past augmentation name, but avoid running off the end of the data. */ ++ while (start < end) ++ if (* start ++ == '\0') ++ break; ++ if (start == end) ++ { ++ warn (_("No terminator for augmentation name\n")); ++ return start; ++ } + + if (strcmp (fc->augmentation, "eh") == 0) + start += eh_addr_size; +@@ -4864,6 +4941,7 @@ display_debug_frames (struct dwarf_secti + saved_start = start; + + SAFE_BYTE_GET_AND_INC (length, start, 4, end); ++ + if (length == 0) + { + printf ("\n%08lx ZERO terminator\n\n", +@@ -4884,7 +4962,7 @@ display_debug_frames (struct dwarf_secti + } + + block_end = saved_start + length + initial_length_size; +- if (block_end > end) ++ if (block_end > end || block_end < start) + { + warn ("Invalid length %#08lx in FDE at %#08lx\n", + length, (unsigned long)(saved_start - section_start)); +@@ -4900,6 +4978,9 @@ display_debug_frames (struct dwarf_secti + + start = read_cie (start, end, &cie, &version, + &augmentation_data_len, &augmentation_data); ++ /* PR 17512: file: 027-135133-0.005. */ ++ if (cie == NULL) ++ break; + fc = cie; + fc->next = chunks; + chunks = fc; +@@ -5052,11 +5133,9 @@ display_debug_frames (struct dwarf_secti + + segment_selector = 0; + if (fc->segment_size) +- { +- SAFE_BYTE_GET_AND_INC (segment_selector, start, fc->segment_size, end); +- } +- fc->pc_begin = get_encoded_value (start, fc->fde_encoding, section); +- start += encoded_ptr_size; ++ SAFE_BYTE_GET_AND_INC (segment_selector, start, fc->segment_size, end); ++ ++ fc->pc_begin = get_encoded_value (&start, fc->fde_encoding, section, end); + + /* FIXME: It appears that sometimes the final pc_range value is + encoded in less than encoded_ptr_size bytes. See the x86_64 +@@ -5104,8 +5183,8 @@ display_debug_frames (struct dwarf_secti + + while (start < block_end) + { +- unsigned op, opa; +- unsigned long reg, temp; ++ unsigned int reg, op, opa; ++ unsigned long temp; + + op = *start++; + opa = op & 0x3f; +@@ -5177,13 +5256,26 @@ display_debug_frames (struct dwarf_secti + break; + case DW_CFA_def_cfa_expression: + temp = LEB (); +- start += temp; ++ if (start + temp < start) ++ { ++ warn (_("Corrupt CFA_def expression value: %lu\n"), temp); ++ start = block_end; ++ } ++ else ++ start += temp; + break; + case DW_CFA_expression: + case DW_CFA_val_expression: + reg = LEB (); + temp = LEB (); +- start += temp; ++ if (start + temp < start) ++ { ++ /* PR 17512: file:306-192417-0.005. */ ++ warn (_("Corrupt CFA expression value: %lu\n"), temp); ++ start = block_end; ++ } ++ else ++ start += temp; + if (frame_need_space (fc, reg) >= 0) + fc->col_type[reg] = DW_CFA_undefined; + break; +@@ -5277,8 +5369,7 @@ display_debug_frames (struct dwarf_secti + break; + + case DW_CFA_set_loc: +- vma = get_encoded_value (start, fc->fde_encoding, section); +- start += encoded_ptr_size; ++ vma = get_encoded_value (&start, fc->fde_encoding, section, end); + if (do_debug_frames_interp) + frame_display_row (fc, &need_col_headers, &max_regs); + else +@@ -5613,7 +5704,7 @@ display_debug_frames (struct dwarf_secti + if (op >= DW_CFA_lo_user && op <= DW_CFA_hi_user) + printf (_(" DW_CFA_??? (User defined call frame op: %#x)\n"), op); + else +- warn (_("unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op); ++ warn (_("Unsupported or unknown Dwarf Call Frame Instruction number: %#x\n"), op); + start = block_end; + } + } +Index: b/binutils/objdump.c +=================================================================== +--- a/binutils/objdump.c ++++ b/binutils/objdump.c +@@ -560,7 +560,10 @@ slurp_symtab (bfd *abfd) + + storage = bfd_get_symtab_upper_bound (abfd); + if (storage < 0) +- bfd_fatal (bfd_get_filename (abfd)); ++ { ++ non_fatal (_("failed to read symbol table from: %s"), bfd_get_filename (abfd)); ++ bfd_fatal (_("error message was")); ++ } + if (storage) + sy = (asymbol **) xmalloc (storage); + +@@ -2370,7 +2373,12 @@ dump_dwarf (bfd *abfd) + else if (bfd_little_endian (abfd)) + byte_get = byte_get_little_endian; + else +- abort (); ++ /* PR 17512: file: objdump-s-endless-loop.tekhex. */ ++ { ++ warn (_("File %s does not contain any dwarf debug information\n"), ++ bfd_get_filename (abfd)); ++ return; ++ } + + switch (bfd_get_arch (abfd)) + { +@@ -2470,7 +2478,7 @@ print_section_stabs (bfd *abfd, + + We start the index at -1 because there is a dummy symbol on + the front of stabs-in-{coff,elf} sections that supplies sizes. */ +- for (i = -1; stabp < stabs_end; stabp += STABSIZE, i++) ++ for (i = -1; stabp <= stabs_end - STABSIZE; stabp += STABSIZE, i++) + { + const char *name; + unsigned long strx; +@@ -2508,10 +2516,13 @@ print_section_stabs (bfd *abfd, + } + else + { ++ bfd_size_type amt = strx + file_string_table_offset; ++ + /* Using the (possibly updated) string table offset, print the + string (if any) associated with this symbol. */ +- if ((strx + file_string_table_offset) < stabstr_size) +- printf (" %s", &strtab[strx + file_string_table_offset]); ++ if (amt < stabstr_size) ++ /* PR 17512: file: 079-79389-0.001:0.1. */ ++ printf (" %.*s", (int)(stabstr_size - amt), strtab + amt); + else + printf (" *"); + } +@@ -3076,7 +3087,11 @@ dump_relocs_in_section (bfd *abfd, + relcount = bfd_canonicalize_reloc (abfd, section, relpp, syms); + + if (relcount < 0) +- bfd_fatal (bfd_get_filename (abfd)); ++ { ++ printf ("\n"); ++ non_fatal (_("failed to read relocs in: %s"), bfd_get_filename (abfd)); ++ bfd_fatal (_("error message was")); ++ } + else if (relcount == 0) + printf (" (none)\n\n"); + else +Index: b/binutils/rdcoff.c +=================================================================== +--- a/binutils/rdcoff.c ++++ b/binutils/rdcoff.c +@@ -84,7 +84,7 @@ struct coff_types + debug_type basic[T_MAX + 1]; + }; + +-static debug_type *coff_get_slot (struct coff_types *, int); ++static debug_type *coff_get_slot (struct coff_types *, long); + static debug_type parse_coff_type + (bfd *, struct coff_symbols *, struct coff_types *, long, int, + union internal_auxent *, bfd_boolean, void *); +@@ -105,12 +105,17 @@ static bfd_boolean external_coff_symbol_ + /* Return the slot for a type. */ + + static debug_type * +-coff_get_slot (struct coff_types *types, int indx) ++coff_get_slot (struct coff_types *types, long indx) + { + struct coff_slots **pps; + + pps = &types->slots; + ++ /* PR 17512: file: 078-18333-0.001:0.1. ++ FIXME: The value of 1000 is a guess. Maybe a better heuristic is needed. */ ++ if (indx / COFF_SLOTS > 1000) ++ fatal (_("Excessively large slot index: %lx"), indx); ++ + while (indx >= COFF_SLOTS) + { + if (*pps == NULL) +Index: b/binutils/rddbg.c +=================================================================== +--- a/binutils/rddbg.c ++++ b/binutils/rddbg.c +@@ -140,7 +140,7 @@ read_section_stabs_debugging_info (bfd * + } + + strsize = bfd_section_size (abfd, strsec); +- strings = (bfd_byte *) xmalloc (strsize); ++ strings = (bfd_byte *) xmalloc (strsize + 1); + if (! bfd_get_section_contents (abfd, strsec, strings, 0, strsize)) + { + fprintf (stderr, "%s: %s: %s\n", +@@ -148,7 +148,8 @@ read_section_stabs_debugging_info (bfd * + bfd_errmsg (bfd_get_error ())); + return FALSE; + } +- ++ /* Zero terminate the strings table, just in case. */ ++ strings [strsize] = 0; + if (shandle == NULL) + { + shandle = start_stab (dhandle, abfd, TRUE, syms, symcount); +@@ -160,7 +161,8 @@ read_section_stabs_debugging_info (bfd * + + stroff = 0; + next_stroff = 0; +- for (stab = stabs; stab < stabs + stabsize; stab += 12) ++ /* PR 17512: file: 078-60391-0.001:0.1. */ ++ for (stab = stabs; stab <= (stabs + stabsize) - 12; stab += 12) + { + unsigned int strx; + int type; +@@ -185,33 +187,43 @@ read_section_stabs_debugging_info (bfd * + } + else + { ++ size_t len; + char *f, *s; + +- f = NULL; +- +- if (stroff + strx > strsize) ++ if (stroff + strx >= strsize) + { +- fprintf (stderr, "%s: %s: stab entry %ld is corrupt, strx = 0x%x, type = %d\n", ++ fprintf (stderr, _("%s: %s: stab entry %ld is corrupt, strx = 0x%x, type = %d\n"), + bfd_get_filename (abfd), names[i].secname, + (long) (stab - stabs) / 12, strx, type); + continue; + } + + s = (char *) strings + stroff + strx; ++ f = NULL; + +- while (s[strlen (s) - 1] == '\\' ++ /* PR 17512: file: 002-87578-0.001:0.1. ++ It is possible to craft a file where, without the 'strlen (s) > 0', ++ an attempt to read the byte before 'strings' would occur. */ ++ while ((len = strlen (s)) > 0 ++ && s[len - 1] == '\\' + && stab + 12 < stabs + stabsize) + { + char *p; + + stab += 12; +- p = s + strlen (s) - 1; ++ p = s + len - 1; + *p = '\0'; +- s = concat (s, +- ((char *) strings +- + stroff +- + bfd_get_32 (abfd, stab)), +- (const char *) NULL); ++ strx = stroff + bfd_get_32 (abfd, stab); ++ if (strx >= strsize) ++ { ++ fprintf (stderr, _("%s: %s: stab entry %ld is corrupt\n"), ++ bfd_get_filename (abfd), names[i].secname, ++ (long) (stab - stabs) / 12); ++ break; ++ } ++ else ++ s = concat (s, (char *) strings + strx, ++ (const char *) NULL); + + /* We have to restore the backslash, because, if + the linker is hashing stabs strings, we may +Index: b/binutils/readelf.c +=================================================================== +--- a/binutils/readelf.c ++++ b/binutils/readelf.c +@@ -157,9 +157,10 @@ + char * program_name = "readelf"; + static long archive_file_offset; + static unsigned long archive_file_size; ++static bfd_size_type current_file_size; + static unsigned long dynamic_addr; + static bfd_size_type dynamic_size; +-static unsigned int dynamic_nent; ++static size_t dynamic_nent; + static char * dynamic_strings; + static unsigned long dynamic_strings_length; + static char * string_table; +@@ -314,8 +315,19 @@ get_data (void * var, FILE * file, long + + if (fseek (file, archive_file_offset + offset, SEEK_SET)) + { +- error (_("Unable to seek to 0x%lx for %s\n"), +- (unsigned long) archive_file_offset + offset, reason); ++ if (reason) ++ error (_("Unable to seek to 0x%lx for %s\n"), ++ (unsigned long) archive_file_offset + offset, reason); ++ return NULL; ++ } ++ ++ /* Be kind to memory chekers (eg valgrind, address sanitizer) by not ++ attempting to allocate memory when the read is bound to fail. */ ++ if (offset + archive_file_offset + size * nmemb > current_file_size) ++ { ++ if (reason) ++ error (_("Reading 0x%lx bytes extends past end of file for %s\n"), ++ (unsigned long) (size * nmemb), reason); + return NULL; + } + +@@ -329,8 +341,9 @@ get_data (void * var, FILE * file, long + + if (mvar == NULL) + { +- error (_("Out of memory allocating 0x%lx bytes for %s\n"), +- (unsigned long)(size * nmemb), reason); ++ if (reason) ++ error (_("Out of memory allocating 0x%lx bytes for %s\n"), ++ (unsigned long)(size * nmemb), reason); + return NULL; + } + +@@ -339,8 +352,9 @@ get_data (void * var, FILE * file, long + + if (fread (mvar, size, nmemb, file) != nmemb) + { +- error (_("Unable to read in 0x%lx bytes of %s\n"), +- (unsigned long)(size * nmemb), reason); ++ if (reason) ++ error (_("Unable to read in 0x%lx bytes of %s\n"), ++ (unsigned long)(size * nmemb), reason); + if (mvar != var) + free (mvar); + return NULL; +@@ -418,6 +432,7 @@ print_symbol (int width, const char *sym + width = - width; + extra_padding = TRUE; + } ++ assert (width != 0); + + while (width) + { +@@ -483,6 +498,66 @@ print_symbol (int width, const char *sym + return num_printed; + } + ++/* Returns a pointer to a static buffer containing a printable version of ++ the given section's name. Like print_symbol, except that it does not try ++ to print multibyte characters, it just interprets them as hex values. */ ++ ++static const char * ++printable_section_name (Elf_Internal_Shdr * sec) ++{ ++#define MAX_PRINT_SEC_NAME_LEN 128 ++ static char sec_name_buf [MAX_PRINT_SEC_NAME_LEN + 1]; ++ const char * name = SECTION_NAME (sec); ++ char * buf = sec_name_buf; ++ char c; ++ unsigned int remaining = MAX_PRINT_SEC_NAME_LEN; ++ ++ while ((c = * name ++) != 0) ++ { ++ if (ISCNTRL (c)) ++ { ++ if (remaining < 2) ++ break; ++ ++ * buf ++ = '^'; ++ * buf ++ = c + 0x40; ++ remaining -= 2; ++ } ++ else if (ISPRINT (c)) ++ { ++ * buf ++ = c; ++ remaining -= 1; ++ } ++ else ++ { ++ static char hex[17] = "0123456789ABCDEF"; ++ ++ if (remaining < 4) ++ break; ++ * buf ++ = '<'; ++ * buf ++ = hex[(c & 0xf0) >> 4]; ++ * buf ++ = hex[c & 0x0f]; ++ * buf ++ = '>'; ++ remaining -= 4; ++ } ++ ++ if (remaining == 0) ++ break; ++ } ++ ++ * buf = 0; ++ return sec_name_buf; ++} ++ ++static const char * ++printable_section_name_from_index (unsigned long ndx) ++{ ++ if (ndx >= elf_header.e_shnum) ++ return _(""); ++ ++ return printable_section_name (section_headers + ndx); ++} ++ + /* Return a pointer to section NAME, or NULL if no such section exists. */ + + static Elf_Internal_Shdr * +@@ -515,6 +590,21 @@ find_section_by_address (bfd_vma addr) + return NULL; + } + ++static Elf_Internal_Shdr * ++find_section_by_type (unsigned int type) ++{ ++ unsigned int i; ++ ++ for (i = 0; i < elf_header.e_shnum; i++) ++ { ++ Elf_Internal_Shdr *sec = section_headers + i; ++ if (sec->sh_type == type) ++ return sec; ++ } ++ ++ return NULL; ++} ++ + /* Read an unsigned LEB128 encoded value from p. Set *PLEN to the number of + bytes read. */ + +@@ -657,7 +747,7 @@ slurp_rela_relocs (FILE * file, + unsigned long * nrelasp) + { + Elf_Internal_Rela * relas; +- unsigned long nrelas; ++ size_t nrelas; + unsigned int i; + + if (is_32bit_elf) +@@ -755,7 +845,7 @@ slurp_rel_relocs (FILE * file, + unsigned long * nrelsp) + { + Elf_Internal_Rela * rels; +- unsigned long nrels; ++ size_t nrels; + unsigned int i; + + if (is_32bit_elf) +@@ -1329,8 +1419,7 @@ dump_relocations (FILE * file, + if (ELF_ST_TYPE (psym->st_info) == STT_SECTION) + { + if (psym->st_shndx < elf_header.e_shnum) +- sec_name +- = SECTION_NAME (section_headers + psym->st_shndx); ++ sec_name = SECTION_NAME (section_headers + psym->st_shndx); + else if (psym->st_shndx == SHN_ABS) + sec_name = "ABS"; + else if (psym->st_shndx == SHN_COMMON) +@@ -3584,21 +3673,31 @@ process_file_header (void) + return 1; + } + +- +-static int ++static bfd_boolean + get_32bit_program_headers (FILE * file, Elf_Internal_Phdr * pheaders) + { + Elf32_External_Phdr * phdrs; + Elf32_External_Phdr * external; + Elf_Internal_Phdr * internal; + unsigned int i; ++ unsigned int size = elf_header.e_phentsize; ++ unsigned int num = elf_header.e_phnum; ++ ++ /* PR binutils/17531: Cope with unexpected section header sizes. */ ++ if (size == 0 || num == 0) ++ return FALSE; ++ if (size < sizeof * phdrs) ++ { ++ error (_("The e_phentsize field in the ELF header is less than the size of an ELF program header\n")); ++ return FALSE; ++ } ++ if (size > sizeof * phdrs) ++ warn (_("The e_phentsize field in the ELF header is larger than the size of an ELF program header\n")); + + phdrs = (Elf32_External_Phdr *) get_data (NULL, file, elf_header.e_phoff, +- elf_header.e_phentsize, +- elf_header.e_phnum, +- _("program headers")); +- if (!phdrs) +- return 0; ++ size, num, _("program headers")); ++ if (phdrs == NULL) ++ return FALSE; + + for (i = 0, internal = pheaders, external = phdrs; + i < elf_header.e_phnum; +@@ -3615,24 +3714,34 @@ get_32bit_program_headers (FILE * file, + } + + free (phdrs); +- +- return 1; ++ return TRUE; + } + +-static int ++static bfd_boolean + get_64bit_program_headers (FILE * file, Elf_Internal_Phdr * pheaders) + { + Elf64_External_Phdr * phdrs; + Elf64_External_Phdr * external; + Elf_Internal_Phdr * internal; + unsigned int i; ++ unsigned int size = elf_header.e_phentsize; ++ unsigned int num = elf_header.e_phnum; ++ ++ /* PR binutils/17531: Cope with unexpected section header sizes. */ ++ if (size == 0 || num == 0) ++ return FALSE; ++ if (size < sizeof * phdrs) ++ { ++ error (_("The e_phentsize field in the ELF header is less than the size of an ELF program header\n")); ++ return FALSE; ++ } ++ if (size > sizeof * phdrs) ++ warn (_("The e_phentsize field in the ELF header is larger than the size of an ELF program header\n")); + + phdrs = (Elf64_External_Phdr *) get_data (NULL, file, elf_header.e_phoff, +- elf_header.e_phentsize, +- elf_header.e_phnum, +- _("program headers")); ++ size, num, _("program headers")); + if (!phdrs) +- return 0; ++ return FALSE; + + for (i = 0, internal = pheaders, external = phdrs; + i < elf_header.e_phnum; +@@ -3649,8 +3758,7 @@ get_64bit_program_headers (FILE * file, + } + + free (phdrs); +- +- return 1; ++ return TRUE; + } + + /* Returns 1 if the program headers were read into `program_headers'. */ +@@ -3669,7 +3777,8 @@ get_program_headers (FILE * file) + + if (phdrs == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory reading %u program headers\n"), ++ elf_header.e_phnum); + return 0; + } + +@@ -3825,6 +3934,9 @@ process_program_headers (FILE * file) + } + } + ++ if (do_segments) ++ putc ('\n', stdout); ++ + switch (segment->p_type) + { + case PT_DYNAMIC: +@@ -3835,6 +3947,12 @@ process_program_headers (FILE * file) + section in the DYNAMIC segment. */ + dynamic_addr = segment->p_offset; + dynamic_size = segment->p_filesz; ++ /* PR binutils/17512: Avoid corrupt dynamic section info in the segment. */ ++ if (dynamic_addr + dynamic_size >= current_file_size) ++ { ++ error (_("the dynamic segment offset + size exceeds the size of the file\n")); ++ dynamic_addr = dynamic_size = 0; ++ } + + /* Try to locate the .dynamic section. If there is + a section header table, we can easily locate it. */ +@@ -3888,14 +4006,11 @@ process_program_headers (FILE * file) + error (_("Unable to read program interpreter name\n")); + + if (do_segments) +- printf (_("\n [Requesting program interpreter: %s]"), ++ printf (_(" [Requesting program interpreter: %s]\n"), + program_interpreter); + } + break; + } +- +- if (do_segments) +- putc ('\n', stdout); + } + + if (do_segments && section_headers != NULL && string_table != NULL) +@@ -3917,7 +4032,7 @@ process_program_headers (FILE * file) + { + if (!ELF_TBSS_SPECIAL (section, segment) + && ELF_SECTION_IN_SEGMENT_STRICT (section, segment)) +- printf ("%s ", SECTION_NAME (section)); ++ printf ("%s ", printable_section_name (section)); + } + + putc ('\n',stdout); +@@ -3959,26 +4074,46 @@ offset_from_vma (FILE * file, bfd_vma vm + } + + +-static int +-get_32bit_section_headers (FILE * file, unsigned int num) ++/* Allocate memory and load the sections headers into the global pointer ++ SECTION_HEADERS. If PROBE is true, this is just a probe and we do not ++ generate any error messages if the load fails. */ ++ ++static bfd_boolean ++get_32bit_section_headers (FILE * file, bfd_boolean probe) + { + Elf32_External_Shdr * shdrs; + Elf_Internal_Shdr * internal; + unsigned int i; ++ unsigned int size = elf_header.e_shentsize; ++ unsigned int num = probe ? 1 : elf_header.e_shnum; ++ ++ /* PR binutils/17531: Cope with unexpected section header sizes. */ ++ if (size == 0 || num == 0) ++ return FALSE; ++ if (size < sizeof * shdrs) ++ { ++ if (! probe) ++ error (_("The e_shentsize field in the ELF header is less than the size of an ELF section header\n")); ++ return FALSE; ++ } ++ if (!probe && size > sizeof * shdrs) ++ warn (_("The e_shentsize field in the ELF header is larger than the size of an ELF section header\n")); + + shdrs = (Elf32_External_Shdr *) get_data (NULL, file, elf_header.e_shoff, +- elf_header.e_shentsize, num, +- _("section headers")); +- if (!shdrs) +- return 0; ++ size, num, ++ probe ? NULL : _("section headers")); ++ if (shdrs == NULL) ++ return FALSE; + ++ if (section_headers != NULL) ++ free (section_headers); + section_headers = (Elf_Internal_Shdr *) cmalloc (num, + sizeof (Elf_Internal_Shdr)); +- + if (section_headers == NULL) + { +- error (_("Out of memory\n")); +- return 0; ++ if (!probe) ++ error (_("Out of memory reading %u section headers\n"), num); ++ return FALSE; + } + + for (i = 0, internal = section_headers; +@@ -4002,30 +4137,45 @@ get_32bit_section_headers (FILE * file, + } + + free (shdrs); +- +- return 1; ++ return TRUE; + } + +-static int +-get_64bit_section_headers (FILE * file, unsigned int num) ++static bfd_boolean ++get_64bit_section_headers (FILE * file, bfd_boolean probe) + { + Elf64_External_Shdr * shdrs; + Elf_Internal_Shdr * internal; + unsigned int i; ++ unsigned int size = elf_header.e_shentsize; ++ unsigned int num = probe ? 1 : elf_header.e_shnum; ++ ++ /* PR binutils/17531: Cope with unexpected section header sizes. */ ++ if (size == 0 || num == 0) ++ return FALSE; ++ if (size < sizeof * shdrs) ++ { ++ if (! probe) ++ error (_("The e_shentsize field in the ELF header is less than the size of an ELF section header\n")); ++ return FALSE; ++ } ++ if (! probe && size > sizeof * shdrs) ++ warn (_("The e_shentsize field in the ELF header is larger than the size of an ELF section header\n")); + + shdrs = (Elf64_External_Shdr *) get_data (NULL, file, elf_header.e_shoff, +- elf_header.e_shentsize, num, +- _("section headers")); +- if (!shdrs) +- return 0; ++ size, num, ++ probe ? NULL : _("section headers")); ++ if (shdrs == NULL) ++ return FALSE; + ++ if (section_headers != NULL) ++ free (section_headers); + section_headers = (Elf_Internal_Shdr *) cmalloc (num, + sizeof (Elf_Internal_Shdr)); +- + if (section_headers == NULL) + { +- error (_("Out of memory\n")); +- return 0; ++ if (! probe) ++ error (_("Out of memory reading %u section headers\n"), num); ++ return FALSE; + } + + for (i = 0, internal = section_headers; +@@ -4049,8 +4199,7 @@ get_64bit_section_headers (FILE * file, + } + + free (shdrs); +- +- return 1; ++ return TRUE; + } + + static Elf_Internal_Sym * +@@ -4058,7 +4207,7 @@ get_32bit_elf_symbols (FILE * file, Elf_ + { + unsigned long number; + Elf32_External_Sym * esyms = NULL; +- Elf_External_Sym_Shndx * shndx; ++ Elf_External_Sym_Shndx * shndx = NULL; + Elf_Internal_Sym * isyms = NULL; + Elf_Internal_Sym * psym; + unsigned int j; +@@ -4070,6 +4219,13 @@ get_32bit_elf_symbols (FILE * file, Elf_ + return NULL; + } + ++ if (section->sh_size > current_file_size) ++ { ++ error (_("Section %s has an invalid sh_size of 0x%lx\n"), ++ printable_section_name (section), (unsigned long) section->sh_size); ++ goto exit_point; ++ } ++ + number = section->sh_size / section->sh_entsize; + + if (number * sizeof (Elf32_External_Sym) > section->sh_size + 1) +@@ -4100,7 +4256,8 @@ get_32bit_elf_symbols (FILE * file, Elf_ + + if (isyms == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory reading %lu symbols\n"), ++ (unsigned long) number); + goto exit_point; + } + +@@ -4149,6 +4306,13 @@ get_64bit_elf_symbols (FILE * file, Elf_ + return NULL; + } + ++ if (section->sh_size > current_file_size) ++ { ++ error (_("Section %s has an invalid sh_size of 0x%lx\n"), ++ printable_section_name (section), (unsigned long) section->sh_size); ++ return NULL; ++ } ++ + number = section->sh_size / section->sh_entsize; + + if (number * sizeof (Elf64_External_Sym) > section->sh_size + 1) +@@ -4182,7 +4346,8 @@ get_64bit_elf_symbols (FILE * file, Elf_ + + if (isyms == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory reading %lu symbols\n"), ++ (unsigned long) number); + if (shndx) + free (shndx); + free (esyms); +@@ -4473,10 +4638,10 @@ process_section_headers (FILE * file) + + if (is_32bit_elf) + { +- if (! get_32bit_section_headers (file, elf_header.e_shnum)) ++ if (! get_32bit_section_headers (file, FALSE)) + return 0; + } +- else if (! get_64bit_section_headers (file, elf_header.e_shnum)) ++ else if (! get_64bit_section_headers (file, FALSE)) + return 0; + + if (hole_in_shndx +@@ -4704,7 +4869,6 @@ process_section_headers (FILE * file) + ) + request_dump_bynumber (i, DEBUG_DUMP); + } +- + } + + if (! do_sections) +@@ -5073,7 +5237,8 @@ process_section_groups (FILE * file) + + if (section_headers_groups == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory reading %u section group headers\n"), ++ elf_header.e_shnum); + return 0; + } + +@@ -5097,7 +5262,8 @@ process_section_groups (FILE * file) + + if (section_groups == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory reading %lu groups\n"), ++ (unsigned long) group_count); + return 0; + } + +@@ -5112,8 +5278,8 @@ process_section_groups (FILE * file) + { + if (section->sh_type == SHT_GROUP) + { +- char * name = SECTION_NAME (section); +- char * group_name; ++ const char * name = printable_section_name (section); ++ const char * group_name; + unsigned char * start; + unsigned char * indices; + unsigned int entry, j, size; +@@ -5178,9 +5344,10 @@ process_section_groups (FILE * file) + strtab_sec = sec; + if (strtab) + free (strtab); ++ + strtab = (char *) get_data (NULL, file, strtab_sec->sh_offset, +- 1, strtab_sec->sh_size, +- _("string table")); ++ 1, strtab_sec->sh_size, ++ _("string table")); + strtab_size = strtab != NULL ? strtab_sec->sh_size : 0; + } + group_name = sym->st_name < strtab_size +@@ -5259,10 +5426,10 @@ process_section_groups (FILE * file) + if (orig != entry) + printf (" [%5u/-%3u] %s\n", + orig, ELF_SECTION_HEADER_INDEX_GAP, +- SECTION_NAME (sec)); ++ printable_section_name (sec)); + else + printf (" [%5u] %s\n", +- entry, SECTION_NAME (sec)); ++ entry, printable_section_name (sec)); + } + + g = (struct group_list *) xmalloc (sizeof (struct group_list)); +@@ -5570,7 +5737,7 @@ process_relocs (FILE * file) + if (string_table == NULL) + printf ("%d", section->sh_name); + else +- printf (_("'%s'"), SECTION_NAME (section)); ++ printf ("'%s'", printable_section_name (section)); + + printf (_(" at offset 0x%lx contains %lu entries:\n"), + rel_offset, (unsigned long) (rel_size / section->sh_entsize)); +@@ -5603,8 +5770,8 @@ process_relocs (FILE * file) + strsec = section_headers + symsec->sh_link; + + strtab = (char *) get_data (NULL, file, strsec->sh_offset, +- 1, strsec->sh_size, +- _("string table")); ++ 1, strsec->sh_size, ++ _("string table")); + strtablen = strtab == NULL ? 0 : strsec->sh_size; + } + +@@ -5908,7 +6075,11 @@ ia64_process_unwind (FILE * file) + aux.symtab = GET_ELF_SYMBOLS (file, sec); + + strsec = section_headers + sec->sh_link; +- assert (aux.strtab == NULL); ++ if (aux.strtab != NULL) ++ { ++ error (_("Multiple auxillary string tables encountered\n")); ++ free (aux.strtab); ++ } + aux.strtab = (char *) get_data (NULL, file, strsec->sh_offset, + 1, strsec->sh_size, + _("string table")); +@@ -5926,13 +6097,16 @@ ia64_process_unwind (FILE * file) + char * suffix; + size_t len, len2; + +- for (i = unwstart, sec = section_headers + unwstart; ++ for (i = unwstart, sec = section_headers + unwstart, unwsec = NULL; + i < elf_header.e_shnum; ++i, ++sec) + if (sec->sh_type == SHT_IA_64_UNWIND) + { + unwsec = sec; + break; + } ++ /* We have already counted the number of SHT_IA64_UNWIND ++ sections so the loop above should never fail. */ ++ assert (unwsec != NULL); + + unwstart = i + 1; + len = sizeof (ELF_STRING_ia64_unwind_once) - 1; +@@ -5940,18 +6114,26 @@ ia64_process_unwind (FILE * file) + if ((unwsec->sh_flags & SHF_GROUP) != 0) + { + /* We need to find which section group it is in. */ +- struct group_list * g = section_headers_groups [i]->root; ++ struct group_list * g; + +- for (; g != NULL; g = g->next) ++ if (section_headers_groups == NULL ++ || section_headers_groups [i] == NULL) ++ i = elf_header.e_shnum; ++ else + { +- sec = section_headers + g->section_index; ++ g = section_headers_groups [i]->root; + +- if (streq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info)) +- break; +- } ++ for (; g != NULL; g = g->next) ++ { ++ sec = section_headers + g->section_index; + +- if (g == NULL) +- i = elf_header.e_shnum; ++ if (streq (SECTION_NAME (sec), ELF_STRING_ia64_unwind_info)) ++ break; ++ } ++ ++ if (g == NULL) ++ i = elf_header.e_shnum; ++ } + } + else if (strneq (SECTION_NAME (unwsec), ELF_STRING_ia64_unwind_once, len)) + { +@@ -5987,14 +6169,14 @@ ia64_process_unwind (FILE * file) + if (string_table == NULL) + printf ("%d", unwsec->sh_name); + else +- printf (_("'%s'"), SECTION_NAME (unwsec)); ++ printf ("'%s'", printable_section_name (unwsec)); + } + else + { + aux.info_addr = sec->sh_addr; + aux.info = (unsigned char *) get_data (NULL, file, sec->sh_offset, 1, +- sec->sh_size, +- _("unwind info")); ++ sec->sh_size, ++ _("unwind info")); + aux.info_size = aux.info == NULL ? 0 : sec->sh_size; + + printf (_("\nUnwind section ")); +@@ -6002,7 +6184,7 @@ ia64_process_unwind (FILE * file) + if (string_table == NULL) + printf ("%d", unwsec->sh_name); + else +- printf (_("'%s'"), SECTION_NAME (unwsec)); ++ printf ("'%s'", printable_section_name (unwsec)); + + printf (_(" at offset 0x%lx contains %lu entries:\n"), + (unsigned long) unwsec->sh_offset, +@@ -6322,7 +6504,11 @@ hppa_process_unwind (FILE * file) + aux.symtab = GET_ELF_SYMBOLS (file, sec); + + strsec = section_headers + sec->sh_link; +- assert (aux.strtab == NULL); ++ if (aux.strtab != NULL) ++ { ++ error (_("Multiple auxillary string tables encountered\n")); ++ free (aux.strtab); ++ } + aux.strtab = (char *) get_data (NULL, file, strsec->sh_offset, + 1, strsec->sh_size, + _("string table")); +@@ -6339,10 +6525,8 @@ hppa_process_unwind (FILE * file) + { + if (streq (SECTION_NAME (sec), ".PARISC.unwind")) + { +- printf (_("\nUnwind section ")); +- printf (_("'%s'"), SECTION_NAME (sec)); +- +- printf (_(" at offset 0x%lx contains %lu entries:\n"), ++ printf (_("\nUnwind section '%s' at offset 0x%lx contains %lu entries:\n"), ++ printable_section_name (sec), + (unsigned long) sec->sh_offset, + (unsigned long) (sec->sh_size / (2 * eh_addr_size + 8))); + +@@ -6437,6 +6621,9 @@ arm_section_get_word (struct arm_unw_aux + unsigned int word; + bfd_boolean wrapped; + ++ if (sec == NULL || arm_sec == NULL) ++ return FALSE; ++ + addr->section = SHN_UNDEF; + addr->offset = 0; + +@@ -6484,6 +6671,10 @@ arm_section_get_word (struct arm_unw_aux + if (arm_sec->data == NULL) + return 0; + ++ /* If the offset is invalid then fail. */ ++ if (word_offset > sec->sh_size - 4) ++ return FALSE; ++ + word = byte_get (arm_sec->data + word_offset, 4); + + wrapped = FALSE; +@@ -6513,10 +6704,22 @@ arm_section_get_word (struct arm_unw_aux + { + case EM_ARM: + relname = elf_arm_reloc_type (ELF32_R_TYPE (rp->r_info)); ++ if (relname == NULL) ++ { ++ warn (_("Skipping unknown ARM relocation type: %d\n"), ++ (int) ELF32_R_TYPE (rp->r_info)); ++ continue; ++ } + break; + + case EM_TI_C6000: + relname = elf_tic6x_reloc_type (ELF32_R_TYPE (rp->r_info)); ++ if (relname == NULL) ++ { ++ warn (_("Skipping unknown C6000 relocation type: %d\n"), ++ (int) ELF32_R_TYPE (rp->r_info)); ++ continue; ++ } + break; + + default: +@@ -6534,7 +6737,9 @@ arm_section_get_word (struct arm_unw_aux + continue; + } + +- sym = aux->symtab + ELF32_R_SYM (rp->r_info); ++ /* PR 17531: file: 027-161405-0.004 */ ++ if (aux->symtab == NULL) ++ continue; + + if (arm_sec->rel_type == SHT_REL) + { +@@ -6545,6 +6750,15 @@ arm_section_get_word (struct arm_unw_aux + else + offset = rp->r_addend; + ++ /* PR 17531 file: 027-1241568-0.004. */ ++ if (ELF32_R_SYM (rp->r_info) >= aux->nsyms) ++ { ++ error (_("Bad symbol index in unwind relocation (%lu > %lu)\n"), ++ (unsigned long) ELF32_R_SYM (rp->r_info), aux->nsyms); ++ break; ++ } ++ ++ sym = aux->symtab + ELF32_R_SYM (rp->r_info); + offset += sym->st_value; + prelval = offset - (arm_sec->sec->sh_addr + rp->r_offset); + +@@ -6737,11 +6951,15 @@ decode_arm_unwind_bytecode (struct arm_u + if ((buf[i] & 0x80) == 0) + break; + } +- assert (i < sizeof (buf)); +- offset = read_uleb128 (buf, &len, buf + i + 1); +- assert (len == i + 1); +- offset = offset * 4 + 0x204; +- printf ("vsp = vsp + %ld", offset); ++ if (i == sizeof (buf)) ++ printf (_("corrupt change to vsp")); ++ else ++ { ++ offset = read_uleb128 (buf, &len, buf + i + 1); ++ assert (len == i + 1); ++ offset = offset * 4 + 0x204; ++ printf ("vsp = vsp + %ld", offset); ++ } + } + else if (op == 0xb3 || op == 0xc8 || op == 0xc9) + { +@@ -7207,7 +7425,13 @@ arm_process_unwind (FILE *file) + aux.symtab = GET_ELF_SYMBOLS (file, sec); + + strsec = section_headers + sec->sh_link; +- assert (aux.strtab == NULL); ++ ++ /* PR binutils/17531 file: 011-12666-0.004. */ ++ if (aux.strtab != NULL) ++ { ++ error (_("Multiple string tables found in file.\n")); ++ free (aux.strtab); ++ } + aux.strtab = get_data (NULL, file, strsec->sh_offset, + 1, strsec->sh_size, _("string table")); + aux.strtab_size = aux.strtab != NULL ? strsec->sh_size : 0; +@@ -7224,7 +7448,7 @@ arm_process_unwind (FILE *file) + if (sec->sh_type == sec_type) + { + printf (_("\nUnwind table index '%s' at offset 0x%lx contains %lu entries:\n"), +- SECTION_NAME (sec), ++ printable_section_name (sec), + (unsigned long) sec->sh_offset, + (unsigned long) (sec->sh_size / (2 * eh_addr_size))); + +@@ -7497,11 +7721,11 @@ get_32bit_dynamic_section (FILE * file) + if (!edyn) + return 0; + +-/* SGI's ELF has more than one section in the DYNAMIC segment, and we +- might not have the luxury of section headers. Look for the DT_NULL +- terminator to determine the number of entries. */ ++ /* SGI's ELF has more than one section in the DYNAMIC segment, and we ++ might not have the luxury of section headers. Look for the DT_NULL ++ terminator to determine the number of entries. */ + for (ext = edyn, dynamic_nent = 0; +- (char *) ext < (char *) edyn + dynamic_size; ++ (char *) ext < (char *) edyn + dynamic_size - sizeof (* entry); + ext++) + { + dynamic_nent++; +@@ -7513,7 +7737,8 @@ get_32bit_dynamic_section (FILE * file) + sizeof (* entry)); + if (dynamic_section == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory allocating space for %lu dynamic entries\n"), ++ (unsigned long) dynamic_nent); + free (edyn); + return 0; + } +@@ -7538,16 +7763,18 @@ get_64bit_dynamic_section (FILE * file) + Elf64_External_Dyn * ext; + Elf_Internal_Dyn * entry; + ++ /* Read in the data. */ + edyn = (Elf64_External_Dyn *) get_data (NULL, file, dynamic_addr, 1, + dynamic_size, _("dynamic section")); + if (!edyn) + return 0; + +-/* SGI's ELF has more than one section in the DYNAMIC segment, and we +- might not have the luxury of section headers. Look for the DT_NULL +- terminator to determine the number of entries. */ ++ /* SGI's ELF has more than one section in the DYNAMIC segment, and we ++ might not have the luxury of section headers. Look for the DT_NULL ++ terminator to determine the number of entries. */ + for (ext = edyn, dynamic_nent = 0; +- (char *) ext < (char *) edyn + dynamic_size; ++ /* PR 17533 file: 033-67080-0.004 - do not read off the end of the buffer. */ ++ (char *) ext < ((char *) edyn) + dynamic_size - sizeof (* ext); + ext++) + { + dynamic_nent++; +@@ -7559,11 +7786,13 @@ get_64bit_dynamic_section (FILE * file) + sizeof (* entry)); + if (dynamic_section == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory allocating space for %lu dynamic entries\n"), ++ (unsigned long) dynamic_nent); + free (edyn); + return 0; + } + ++ /* Convert from external to internal formats. */ + for (ext = edyn, entry = dynamic_section; + entry < dynamic_section + dynamic_nent; + ext++, entry++) +@@ -7664,6 +7893,7 @@ process_dynamic_section (FILE * file) + section.sh_entsize = sizeof (Elf32_External_Sym); + else + section.sh_entsize = sizeof (Elf64_External_Sym); ++ section.sh_name = string_table_length; + + num_dynamic_syms = section.sh_size / section.sh_entsize; + if (num_dynamic_syms < 1) +@@ -7735,7 +7965,11 @@ process_dynamic_section (FILE * file) + { + /* Note: these braces are necessary to avoid a syntax + error from the SunOS4 C compiler. */ +- assert (sizeof (Elf_External_Syminfo) == entry->d_un.d_val); ++ /* PR binutils/17531: A corrupt file can trigger this test. ++ So do not use an assert, instead generate an error message. */ ++ if (sizeof (Elf_External_Syminfo) != entry->d_un.d_val) ++ error (_("Bad value (%d) for SYMINENT entry\n"), ++ (int) entry->d_un.d_val); + } + else if (entry->d_tag == DT_SYMINSZ) + syminsz = entry->d_un.d_val; +@@ -7760,7 +7994,8 @@ process_dynamic_section (FILE * file) + dynamic_syminfo = (Elf_Internal_Syminfo *) malloc (syminsz); + if (dynamic_syminfo == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory allocating %lu byte for dynamic symbol info\n"), ++ (unsigned long) syminsz); + return 0; + } + +@@ -7778,8 +8013,8 @@ process_dynamic_section (FILE * file) + } + + if (do_dynamic && dynamic_addr) +- printf (_("\nDynamic section at offset 0x%lx contains %u entries:\n"), +- dynamic_addr, dynamic_nent); ++ printf (_("\nDynamic section at offset 0x%lx contains %lu entries:\n"), ++ dynamic_addr, (unsigned long) dynamic_nent); + if (do_dynamic) + printf (_(" Tag Type Name/Value\n")); + +@@ -8131,9 +8366,14 @@ process_dynamic_section (FILE * file) + time_t atime = entry->d_un.d_val; + + tmp = gmtime (&atime); +- printf ("%04u-%02u-%02uT%02u:%02u:%02u\n", +- tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, +- tmp->tm_hour, tmp->tm_min, tmp->tm_sec); ++ /* PR 17533 file: 041-1244816-0.004. */ ++ if (tmp == NULL) ++ printf (_("tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday, ++ tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + + } + break; +@@ -8240,17 +8480,15 @@ process_version_sections (FILE * file) + + found = 1; + +- printf +- (_("\nVersion definition section '%s' contains %u entries:\n"), +- SECTION_NAME (section), section->sh_info); ++ printf (_("\nVersion definition section '%s' contains %u entries:\n"), ++ printable_section_name (section), ++ section->sh_info); + + printf (_(" Addr: 0x")); + printf_vma (section->sh_addr); +- printf (_(" Offset: %#08lx Link: %u (%s)\n"), ++ printf (_(" Offset: %#08lx Link: %u (%s)"), + (unsigned long) section->sh_offset, section->sh_link, +- section->sh_link < elf_header.e_shnum +- ? SECTION_NAME (section_headers + section->sh_link) +- : _("")); ++ printable_section_name_from_index (section->sh_link)); + + edefs = (Elf_External_Verdef *) + get_data (NULL, file, section->sh_offset, 1,section->sh_size, +@@ -8360,15 +8598,13 @@ process_version_sections (FILE * file) + found = 1; + + printf (_("\nVersion needs section '%s' contains %u entries:\n"), +- SECTION_NAME (section), section->sh_info); ++ printable_section_name (section), section->sh_info); + + printf (_(" Addr: 0x")); + printf_vma (section->sh_addr); + printf (_(" Offset: %#08lx Link: %u (%s)\n"), + (unsigned long) section->sh_offset, section->sh_link, +- section->sh_link < elf_header.e_shnum +- ? SECTION_NAME (section_headers + section->sh_link) +- : _("")); ++ printable_section_name_from_index (section->sh_link)); + + eneed = (Elf_External_Verneed *) get_data (NULL, file, + section->sh_offset, 1, +@@ -8465,8 +8701,8 @@ process_version_sections (FILE * file) + case SHT_GNU_versym: + { + Elf_Internal_Shdr * link_section; +- int total; +- int cnt; ++ size_t total; ++ unsigned int cnt; + unsigned char * edata; + unsigned short * data; + char * strtab; +@@ -8500,14 +8736,14 @@ process_version_sections (FILE * file) + break; + } + +- printf (_("\nVersion symbols section '%s' contains %d entries:\n"), +- SECTION_NAME (section), total); ++ printf (_("\nVersion symbols section '%s' contains %lu entries:\n"), ++ printable_section_name (section), (unsigned long) total); + + printf (_(" Addr: ")); + printf_vma (section->sh_addr); + printf (_(" Offset: %#08lx Link: %u (%s)\n"), + (unsigned long) section->sh_offset, section->sh_link, +- SECTION_NAME (link_section)); ++ printable_section_name (link_section)); + + off = offset_from_vma (file, + version_info[DT_VERSIONTAGIDX (DT_VERSYM)], +@@ -8658,7 +8894,9 @@ process_version_sections (FILE * file) + _("version def")) == NULL) + { + ivd.vd_next = 0; +- ivd.vd_ndx = 0; ++ /* PR 17531: file: 046-1082287-0.004. */ ++ ivd.vd_ndx = (data[cnt + j] & VERSYM_VERSION) + 1; ++ break; + } + else + { +@@ -8971,30 +9209,41 @@ get_symbol_index_type (unsigned int type + } + + static bfd_vma * +-get_dynamic_data (FILE * file, unsigned int number, unsigned int ent_size) ++get_dynamic_data (FILE * file, size_t number, unsigned int ent_size) + { + unsigned char * e_data; + bfd_vma * i_data; + +- e_data = (unsigned char *) cmalloc (number, ent_size); ++ /* Be kind to memory chekers (eg valgrind, address sanitizer) by not ++ attempting to allocate memory when the read is bound to fail. */ ++ if (ent_size * number > current_file_size) ++ { ++ error (_("Invalid number of dynamic entries: %lu\n"), ++ (unsigned long) number); ++ return NULL; ++ } + ++ e_data = (unsigned char *) cmalloc (number, ent_size); + if (e_data == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory reading %lu dynamic entries\n"), ++ (unsigned long) number); + return NULL; + } + + if (fread (e_data, ent_size, number, file) != number) + { +- error (_("Unable to read in dynamic data\n")); ++ error (_("Unable to read in %lu bytes of dynamic data\n"), ++ (unsigned long) (number * ent_size)); ++ free (e_data); + return NULL; + } + + i_data = (bfd_vma *) cmalloc (number, sizeof (*i_data)); +- + if (i_data == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory allocating space for %lu dynamic entries\n"), ++ (unsigned long) number); + free (e_data); + return NULL; + } +@@ -9013,12 +9262,19 @@ print_dynamic_symbol (bfd_vma si, unsign + Elf_Internal_Sym * psym; + int n; + +- psym = dynamic_symbols + si; +- + n = print_vma (si, DEC_5); + if (n < 5) + fputs (" " + n, stdout); + printf (" %3lu: ", hn); ++ ++ if (dynamic_symbols == NULL || si >= num_dynamic_syms) ++ { ++ printf (_("\n"), ++ (unsigned long) si); ++ return; ++ } ++ ++ psym = dynamic_symbols + si; + print_vma (psym->st_value, LONG_HEX); + putchar (' '); + print_vma (psym->st_size, DEC_5); +@@ -9045,14 +9301,15 @@ static int + process_symbol_table (FILE * file) + { + Elf_Internal_Shdr * section; +- bfd_vma nbuckets = 0; +- bfd_vma nchains = 0; ++ bfd_size_type nbuckets = 0; ++ bfd_size_type nchains = 0; + bfd_vma * buckets = NULL; + bfd_vma * chains = NULL; + bfd_vma ngnubuckets = 0; + bfd_vma * gnubuckets = NULL; + bfd_vma * gnuchains = NULL; + bfd_vma gnusymidx = 0; ++ bfd_size_type ngnuchains = 0; + + if (!do_syms && !do_dyn_syms && !do_histogram) + return 1; +@@ -9065,7 +9322,7 @@ process_symbol_table (FILE * file) + { + unsigned char nb[8]; + unsigned char nc[8]; +- int hash_ent_size = 4; ++ unsigned int hash_ent_size = 4; + + if ((elf_header.e_machine == EM_ALPHA + || elf_header.e_machine == EM_S390 +@@ -9214,6 +9471,7 @@ process_symbol_table (FILE * file) + } + + gnuchains = get_dynamic_data (file, maxchain, 4); ++ ngnuchains = maxchain; + + no_gnu_hash: + if (gnuchains == NULL) +@@ -9229,7 +9487,8 @@ process_symbol_table (FILE * file) + if ((dynamic_info[DT_HASH] || dynamic_info_DT_GNU_HASH) + && do_syms + && do_using_dynamic +- && dynamic_strings != NULL) ++ && dynamic_strings != NULL ++ && dynamic_symbols != NULL) + { + unsigned long hn; + +@@ -9272,11 +9531,12 @@ process_symbol_table (FILE * file) + print_dynamic_symbol (si, hn); + si++; + } +- while ((gnuchains[off++] & 1) == 0); ++ while (off < ngnuchains && (gnuchains[off++] & 1) == 0); + } + } + } +- else if (do_dyn_syms || (do_syms && !do_using_dynamic)) ++ else if ((do_dyn_syms || (do_syms && !do_using_dynamic)) ++ && section_headers != NULL) + { + unsigned int i; + +@@ -9299,12 +9559,12 @@ process_symbol_table (FILE * file) + if (section->sh_entsize == 0) + { + printf (_("\nSymbol table '%s' has a sh_entsize of zero!\n"), +- SECTION_NAME (section)); ++ printable_section_name (section)); + continue; + } + + printf (_("\nSymbol table '%s' contains %lu entries:\n"), +- SECTION_NAME (section), ++ printable_section_name (section), + (unsigned long) (section->sh_size / section->sh_entsize)); + + if (is_32bit_elf) +@@ -9536,14 +9796,15 @@ process_symbol_table (FILE * file) + + printf (_("\nHistogram for bucket list length (total of %lu buckets):\n"), + (unsigned long) nbuckets); +- printf (_(" Length Number %% of total Coverage\n")); + + lengths = (unsigned long *) calloc (nbuckets, sizeof (*lengths)); + if (lengths == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory allocating space for histogram buckets\n")); + return 0; + } ++ ++ printf (_(" Length Number %% of total Coverage\n")); + for (hn = 0; hn < nbuckets; ++hn) + { + for (si = buckets[hn]; si > 0 && si < nchains; si = chains[si]) +@@ -9551,13 +9812,23 @@ process_symbol_table (FILE * file) + ++nsyms; + if (maxlength < ++lengths[hn]) + ++maxlength; ++ ++ /* PR binutils/17531: A corrupt binary could contain broken ++ histogram data. Do not go into an infinite loop trying ++ to process it. */ ++ if (chains[si] == si) ++ { ++ error (_("histogram chain links to itself\n")); ++ break; ++ } + } + } + + counts = (unsigned long *) calloc (maxlength + 1, sizeof (*counts)); + if (counts == NULL) + { +- error (_("Out of memory\n")); ++ free (lengths); ++ error (_("Out of memory allocating space for histogram counts\n")); + return 0; + } + +@@ -9597,15 +9868,16 @@ process_symbol_table (FILE * file) + unsigned long nzero_counts = 0; + unsigned long nsyms = 0; + ++ printf (_("\nHistogram for `.gnu.hash' bucket list length (total of %lu buckets):\n"), ++ (unsigned long) ngnubuckets); ++ + lengths = (unsigned long *) calloc (ngnubuckets, sizeof (*lengths)); + if (lengths == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory allocating space for gnu histogram buckets\n")); + return 0; + } + +- printf (_("\nHistogram for `.gnu.hash' bucket list length (total of %lu buckets):\n"), +- (unsigned long) ngnubuckets); + printf (_(" Length Number %% of total Coverage\n")); + + for (hn = 0; hn < ngnubuckets; ++hn) +@@ -9614,7 +9886,9 @@ process_symbol_table (FILE * file) + bfd_vma off, length = 1; + + for (off = gnubuckets[hn] - gnusymidx; +- (gnuchains[off] & 1) == 0; ++off) ++ /* PR 17531 file: 010-77222-0.004. */ ++ off < ngnuchains && (gnuchains[off] & 1) == 0; ++ ++off) + ++length; + lengths[hn] = length; + if (length > maxlength) +@@ -9625,7 +9899,8 @@ process_symbol_table (FILE * file) + counts = (unsigned long *) calloc (maxlength + 1, sizeof (*counts)); + if (counts == NULL) + { +- error (_("Out of memory\n")); ++ free (lengths); ++ error (_("Out of memory allocating space for gnu histogram counts\n")); + return 0; + } + +@@ -9679,7 +9954,9 @@ process_syminfo (FILE * file ATTRIBUTE_U + unsigned short int flags = dynamic_syminfo[i].si_flags; + + printf ("%4d: ", i); +- if (VALID_DYNAMIC_NAME (dynamic_symbols[i].st_name)) ++ if (i >= num_dynamic_syms) ++ printf (_("")); ++ else if (VALID_DYNAMIC_NAME (dynamic_symbols[i].st_name)) + print_symbol (30, GET_DYNAMIC_NAME (dynamic_symbols[i].st_name)); + else + printf (_(""), dynamic_symbols[i].st_name); +@@ -9764,7 +10041,7 @@ target_specific_reloc_handling (Elf_Inte + break; + default: + if (saved_sym != NULL) +- error (_("Unhandled MN10300 reloc type found after SYM_DIFF reloc")); ++ error (_("Unhandled MN10300 reloc type found after SYM_DIFF reloc\n")); + break; + } + break; +@@ -10248,7 +10525,7 @@ apply_relocations (void * file, + else + { + warn (_("unable to apply unsupported reloc type %d to section %s\n"), +- reloc_type, SECTION_NAME (section)); ++ reloc_type, printable_section_name (section)); + continue; + } + +@@ -10257,7 +10534,7 @@ apply_relocations (void * file, + { + warn (_("skipping invalid relocation offset 0x%lx in section %s\n"), + (unsigned long) rp->r_offset, +- SECTION_NAME (section)); ++ printable_section_name (section)); + continue; + } + +@@ -10282,7 +10559,7 @@ apply_relocations (void * file, + warn (_("skipping unexpected symbol type %s in %ld'th relocation in section %s\n"), + get_symbol_type (ELF_ST_TYPE (sym->st_info)), + (long int)(rp - relocs), +- SECTION_NAME (relsec)); ++ printable_section_name (relsec)); + continue; + } + +@@ -10325,10 +10602,9 @@ apply_relocations (void * file, + static int + disassemble_section (Elf_Internal_Shdr * section, FILE * file) + { +- printf (_("\nAssembly dump of section %s\n"), +- SECTION_NAME (section)); ++ printf (_("\nAssembly dump of section %s\n"), printable_section_name (section)); + +- /* XXX -- to be done --- XXX */ ++ /* FIXME: XXX -- to be done --- XXX */ + + return 1; + } +@@ -10347,7 +10623,7 @@ get_section_contents (Elf_Internal_Shdr + if (num_bytes == 0 || section->sh_type == SHT_NOBITS) + { + printf (_("\nSection '%s' has no data to dump.\n"), +- SECTION_NAME (section)); ++ printable_section_name (section)); + return NULL; + } + +@@ -10364,14 +10640,13 @@ dump_section_as_strings (Elf_Internal_Sh + char * data; + char * end; + char * start; +- char * name = SECTION_NAME (section); + bfd_boolean some_strings_shown; + + start = get_section_contents (section, file); + if (start == NULL) + return; + +- printf (_("\nString dump of section '%s':\n"), name); ++ printf (_("\nString dump of section '%s':\n"), printable_section_name (section)); + + /* If the section being dumped has relocations against it the user might + be expecting these relocations to have been applied. Check for this +@@ -10406,15 +10681,26 @@ dump_section_as_strings (Elf_Internal_Sh + + if (data < end) + { ++ size_t maxlen = end - data; ++ + #ifndef __MSVCRT__ + /* PR 11128: Use two separate invocations in order to work + around bugs in the Solaris 8 implementation of printf. */ + printf (" [%6tx] ", data - start); +- printf ("%s\n", data); + #else +- printf (" [%6Ix] %s\n", (size_t) (data - start), data); ++ printf (" [%6Ix] ", (size_t) (data - start)); + #endif +- data += strlen (data); ++ if (maxlen > 0) ++ { ++ print_symbol ((int) maxlen, data); ++ putchar ('\n'); ++ data += strnlen (data, maxlen); ++ } ++ else ++ { ++ printf (_("\n")); ++ data = end; ++ } + some_strings_shown = TRUE; + } + } +@@ -10442,7 +10728,7 @@ dump_section_as_bytes (Elf_Internal_Shdr + if (start == NULL) + return; + +- printf (_("\nHex dump of section '%s':\n"), SECTION_NAME (section)); ++ printf (_("\nHex dump of section '%s':\n"), printable_section_name (section)); + + if (relocate) + { +@@ -10663,6 +10949,7 @@ static int + display_debug_section (Elf_Internal_Shdr * section, FILE * file) + { + char * name = SECTION_NAME (section); ++ const char * print_name = printable_section_name (section); + bfd_size_type length; + int result = 1; + int i; +@@ -10670,7 +10957,7 @@ display_debug_section (Elf_Internal_Shdr + length = section->sh_size; + if (length == 0) + { +- printf (_("\nSection '%s' has no debugging data.\n"), name); ++ printf (_("\nSection '%s' has no debugging data.\n"), print_name); + return 0; + } + if (section->sh_type == SHT_NOBITS) +@@ -10679,7 +10966,8 @@ display_debug_section (Elf_Internal_Shdr + which has the NOBITS type - the bits in the file will be random. + This can happen when a file containing a .eh_frame section is + stripped with the --only-keep-debug command line option. */ +- printf (_("section '%s' has the NOBITS type - its contents are unreliable.\n"), name); ++ printf (_("section '%s' has the NOBITS type - its contents are unreliable.\n"), ++ print_name); + return 0; + } + +@@ -10715,7 +11003,7 @@ display_debug_section (Elf_Internal_Shdr + + if (i == max) + { +- printf (_("Unrecognized debug section: %s\n"), name); ++ printf (_("Unrecognized debug section: %s\n"), print_name); + result = 0; + } + +@@ -10834,13 +11122,25 @@ display_tag_value (int tag, + + if (p >= end) + { +- warn (_("corrupt tag\n")); ++ warn (_("\n")); + } + else if (tag & 1) + { +- /* FIXME: we could read beyond END here. */ +- printf ("\"%s\"\n", p); +- p += strlen ((char *) p) + 1; ++ /* PR 17531 file: 027-19978-0.004. */ ++ size_t maxlen = (end - p) - 1; ++ ++ putchar ('"'); ++ if (maxlen > 0) ++ { ++ print_symbol ((int) maxlen, (const char *) p); ++ p += strnlen ((char *) p, maxlen) + 1; ++ } ++ else ++ { ++ printf (_("")); ++ p = (unsigned char *) end; ++ } ++ printf ("\"\n"); + } + else + { +@@ -10851,6 +11151,7 @@ display_tag_value (int tag, + printf ("%ld (0x%lx)\n", val, val); + } + ++ assert (p <= end); + return p; + } + +@@ -11057,14 +11358,30 @@ display_arm_attribute (unsigned char * p + break; + + case 32: /* Tag_compatibility. */ +- val = read_uleb128 (p, &len, end); +- p += len; +- printf (_("flag = %d, vendor = %s\n"), val, p); +- p += strlen ((char *) p) + 1; ++ { ++ val = read_uleb128 (p, &len, end); ++ p += len; ++ printf (_("flag = %d, vendor = "), val); ++ if (p < end - 1) ++ { ++ size_t maxlen = (end - p) - 1; ++ ++ print_symbol ((int) maxlen, (const char *) p); ++ p += strnlen ((char *) p, maxlen) + 1; ++ } ++ else ++ { ++ printf (_("")); ++ p = (unsigned char *) end; ++ } ++ putchar ('\n'); ++ } + break; + + case 64: /* Tag_nodefaults. */ +- p++; ++ /* PR 17531: file: 001-505008-0.01. */ ++ if (p < end) ++ p++; + printf (_("True\n")); + break; + +@@ -11075,14 +11392,15 @@ display_arm_attribute (unsigned char * p + { + val = read_uleb128 (p, &len, end); + p += len; +- if ((unsigned int)val >= ARRAY_SIZE (arm_attr_tag_CPU_arch)) ++ if ((unsigned int) val >= ARRAY_SIZE (arm_attr_tag_CPU_arch)) + printf ("??? (%d)\n", val); + else + printf ("%s\n", arm_attr_tag_CPU_arch[val]); + } + else + printf ("???\n"); +- while (*(p++) != '\0' /* NUL terminator. */); ++ while (p < end && *(p++) != '\0' /* NUL terminator. */) ++ ; + break; + + default: +@@ -11129,15 +11447,28 @@ display_gnu_attribute (unsigned char * p + { + val = read_uleb128 (p, &len, end); + p += len; ++ ++ printf (_("flag = %d, vendor = "), val); + if (p == end) + { +- printf (_("flag = %d, vendor = \n"), val); ++ printf (_("\n")); + warn (_("corrupt vendor attribute\n")); + } + else + { +- printf (_("flag = %d, vendor = %s\n"), val, p); +- p += strlen ((char *) p) + 1; ++ if (p < end - 1) ++ { ++ size_t maxlen = (end - p) - 1; ++ ++ print_symbol ((int) maxlen, (const char *) p); ++ p += strnlen ((char *) p, maxlen) + 1; ++ } ++ else ++ { ++ printf (_("")); ++ p = (unsigned char *) end; ++ } ++ putchar ('\n'); + } + return p; + } +@@ -11213,7 +11544,7 @@ display_power_gnu_attribute (unsigned ch + { + if (p == end) + { +- warn (_("corrupt Tag_GNU_Power_ABI_Struct_Return")); ++ warn (_("corrupt Tag_GNU_Power_ABI_Struct_Return\n")); + return p; + } + +@@ -11550,18 +11881,45 @@ display_tic6x_attribute (unsigned char * + return p; + + case Tag_ABI_compatibility: +- val = read_uleb128 (p, &len, end); +- p += len; +- printf (" Tag_ABI_compatibility: "); +- printf (_("flag = %d, vendor = %s\n"), val, p); +- p += strlen ((char *) p) + 1; +- return p; ++ { ++ val = read_uleb128 (p, &len, end); ++ p += len; ++ printf (" Tag_ABI_compatibility: "); ++ printf (_("flag = %d, vendor = "), val); ++ if (p < end - 1) ++ { ++ size_t maxlen = (end - p) - 1; ++ ++ print_symbol ((int) maxlen, (const char *) p); ++ p += strnlen ((char *) p, maxlen) + 1; ++ } ++ else ++ { ++ printf (_("")); ++ p = (unsigned char *) end; ++ } ++ putchar ('\n'); ++ return p; ++ } + + case Tag_ABI_conformance: +- printf (" Tag_ABI_conformance: "); +- printf ("\"%s\"\n", p); +- p += strlen ((char *) p) + 1; +- return p; ++ { ++ printf (" Tag_ABI_conformance: \""); ++ if (p < end - 1) ++ { ++ size_t maxlen = (end - p) - 1; ++ ++ print_symbol ((int) maxlen, (const char *) p); ++ p += strnlen ((char *) p, maxlen) + 1; ++ } ++ else ++ { ++ printf (_("")); ++ p = (unsigned char *) end; ++ } ++ printf ("\"\n"); ++ return p; ++ } + } + + return display_tag_value (tag, p, end); +@@ -11573,6 +11931,7 @@ display_raw_attribute (unsigned char * p + unsigned long addr = 0; + size_t bytes = end - p; + ++ assert (end > p); + while (bytes) + { + int j; +@@ -11619,11 +11978,6 @@ process_attributes (FILE * file, + unsigned char * (* display_proc_gnu_attribute) (unsigned char *, int, const unsigned char * const)) + { + Elf_Internal_Shdr * sect; +- unsigned char * contents; +- unsigned char * p; +- unsigned char * end; +- bfd_vma section_len; +- bfd_vma len; + unsigned i; + + /* Find the section header so that we get the size. */ +@@ -11631,6 +11985,9 @@ process_attributes (FILE * file, + i < elf_header.e_shnum; + i++, sect++) + { ++ unsigned char * contents; ++ unsigned char * p; ++ + if (sect->sh_type != proc_type && sect->sh_type != SHT_GNU_ATTRIBUTES) + continue; + +@@ -11642,27 +11999,52 @@ process_attributes (FILE * file, + p = contents; + if (*p == 'A') + { +- len = sect->sh_size - 1; ++ bfd_vma section_len; ++ ++ section_len = sect->sh_size - 1; + p++; + +- while (len > 0) ++ while (section_len > 0) + { +- int namelen; ++ bfd_vma attr_len; ++ unsigned int namelen; + bfd_boolean public_section; + bfd_boolean gnu_section; + +- section_len = byte_get (p, 4); ++ if (section_len <= 4) ++ { ++ error (_("Tag section ends prematurely\n")); ++ break; ++ } ++ attr_len = byte_get (p, 4); + p += 4; + +- if (section_len > len) ++ if (attr_len > section_len) ++ { ++ error (_("Bad attribute length (%u > %u)\n"), ++ (unsigned) attr_len, (unsigned) section_len); ++ attr_len = section_len; ++ } ++ /* PR 17531: file: 001-101425-0.004 */ ++ else if (attr_len < 5) ++ { ++ error (_("Attribute length of %u is too small\n"), (unsigned) attr_len); ++ break; ++ } ++ ++ section_len -= attr_len; ++ attr_len -= 4; ++ ++ namelen = strnlen ((char *) p, attr_len) + 1; ++ if (namelen == 0 || namelen >= attr_len) + { +- printf (_("ERROR: Bad section length (%d > %d)\n"), +- (int) section_len, (int) len); +- section_len = len; ++ error (_("Corrupt attribute section name\n")); ++ break; + } + +- len -= section_len; +- printf (_("Attribute Section: %s\n"), p); ++ printf (_("Attribute Section: ")); ++ print_symbol (INT_MAX, (const char *) p); ++ putchar ('\n'); + + if (public_name && streq ((char *) p, public_name)) + public_section = TRUE; +@@ -11674,26 +12056,44 @@ process_attributes (FILE * file, + else + gnu_section = FALSE; + +- namelen = strlen ((char *) p) + 1; + p += namelen; +- section_len -= namelen + 4; ++ attr_len -= namelen; + +- while (section_len > 0) ++ while (attr_len > 0 && p < contents + sect->sh_size) + { +- int tag = *(p++); ++ int tag; + int val; + bfd_vma size; ++ unsigned char * end; ++ ++ /* PR binutils/17531: Safe handling of corrupt files. */ ++ if (attr_len < 6) ++ { ++ error (_("Unused bytes at end of section\n")); ++ section_len = 0; ++ break; ++ } + ++ tag = *(p++); + size = byte_get (p, 4); +- if (size > section_len) ++ if (size > attr_len) ++ { ++ error (_("Bad subsection length (%u > %u)\n"), ++ (unsigned) size, (unsigned) attr_len); ++ size = attr_len; ++ } ++ /* PR binutils/17531: Safe handling of corrupt files. */ ++ if (size < 6) + { +- printf (_("ERROR: Bad subsection length (%d > %d)\n"), +- (int) size, (int) section_len); +- size = section_len; ++ error (_("Bad subsection length (%u < 6)\n"), ++ (unsigned) size); ++ section_len = 0; ++ break; + } + +- section_len -= size; ++ attr_len -= size; + end = p + size - 1; ++ assert (end <= contents + sect->sh_size); + p += 4; + + switch (tag) +@@ -11725,24 +12125,28 @@ process_attributes (FILE * file, + break; + } + +- if (public_section) ++ if (public_section && display_pub_attribute != NULL) + { + while (p < end) + p = display_pub_attribute (p, end); ++ assert (p <= end); + } +- else if (gnu_section) ++ else if (gnu_section && display_proc_gnu_attribute != NULL) + { + while (p < end) + p = display_gnu_attribute (p, + display_proc_gnu_attribute, + end); ++ assert (p <= end); + } +- else ++ else if (p < end) + { +- printf (_(" Unknown section contexts\n")); ++ printf (_(" Unknown attribute:\n")); + display_raw_attribute (p, end); + p = end; + } ++ else ++ attr_len = 0; + } + } + } +@@ -11857,7 +12261,10 @@ process_mips_specific (FILE * file) + /* No information available. */ + return 0; + +- for (entry = dynamic_section; entry->d_tag != DT_NULL; ++entry) ++ for (entry = dynamic_section; ++ /* PR 17531 file: 012-50589-0.004. */ ++ entry < dynamic_section + dynamic_nent && entry->d_tag != DT_NULL; ++ ++entry) + switch (entry->d_tag) + { + case DT_MIPS_LIBLIST: +@@ -11998,8 +12405,13 @@ process_mips_specific (FILE * file) + int cnt; + + /* Find the section header so that we get the size. */ +- while (sect->sh_type != SHT_MIPS_OPTIONS) +- ++sect; ++ sect = find_section_by_type (SHT_MIPS_OPTIONS); ++ /* PR 17533 file: 012-277276-0.004. */ ++ if (sect == NULL) ++ { ++ error (_("No MIPS_OPTIONS header found\n")); ++ return 0; ++ } + + eopt = (Elf_External_Options *) get_data (NULL, file, options_offset, 1, + sect->sh_size, _("options")); +@@ -12009,7 +12421,7 @@ process_mips_specific (FILE * file) + cmalloc ((sect->sh_size / sizeof (eopt)), sizeof (* iopt)); + if (iopt == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory allocatinf space for MIPS options\n")); + return 0; + } + +@@ -12034,7 +12446,7 @@ process_mips_specific (FILE * file) + } + + printf (_("\nSection '%s' contains %d entries:\n"), +- SECTION_NAME (sect), cnt); ++ printable_section_name (sect), cnt); + + option = iopt; + +@@ -12201,7 +12613,7 @@ process_mips_specific (FILE * file) + iconf = (Elf32_Conflict *) cmalloc (conflictsno, sizeof (* iconf)); + if (iconf == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory allocating space for dynamic conflicts\n")); + return 0; + } + +@@ -12242,15 +12654,22 @@ process_mips_specific (FILE * file) + + for (cnt = 0; cnt < conflictsno; ++cnt) + { +- Elf_Internal_Sym * psym = & dynamic_symbols[iconf[cnt]]; +- + printf ("%5lu: %8lu ", (unsigned long) cnt, iconf[cnt]); +- print_vma (psym->st_value, FULL_HEX); +- putchar (' '); +- if (VALID_DYNAMIC_NAME (psym->st_name)) +- print_symbol (25, GET_DYNAMIC_NAME (psym->st_name)); ++ ++ if (iconf[cnt] >= num_dynamic_syms) ++ printf (_("")); + else +- printf (_(""), psym->st_name); ++ { ++ Elf_Internal_Sym * psym; ++ ++ psym = & dynamic_symbols[iconf[cnt]]; ++ print_vma (psym->st_value, FULL_HEX); ++ putchar (' '); ++ if (VALID_DYNAMIC_NAME (psym->st_name)) ++ print_symbol (25, GET_DYNAMIC_NAME (psym->st_name)); ++ else ++ printf (_(""), psym->st_name); ++ } + putchar ('\n'); + } + +@@ -12267,8 +12686,17 @@ process_mips_specific (FILE * file) + ent = pltgot; + addr_size = (is_32bit_elf ? 4 : 8); + local_end = pltgot + local_gotno * addr_size; +- global_end = local_end + (symtabno - gotsym) * addr_size; + ++ /* PR binutils/17533 file: 012-111227-0.004 */ ++ if (symtabno < gotsym) ++ { ++ error (_("The GOT symbol offset (%lu) is greater than the symbol table size (%lu)\n"), ++ (long) gotsym, (long) symtabno); ++ return 0; ++ } ++ ++ global_end = local_end + (symtabno - gotsym) * addr_size; ++ assert (global_end >= local_end); + offset = offset_from_vma (file, pltgot, global_end - pltgot); + data = (unsigned char *) get_data (NULL, file, offset, + global_end - pltgot, 1, _("GOT")); +@@ -12319,21 +12747,32 @@ process_mips_specific (FILE * file) + addr_size * 2, _("Initial"), + addr_size * 2, _("Sym.Val."), _("Type"), _("Ndx"), _("Name")); + sym_width = (is_32bit_elf ? 80 : 160) - 28 - addr_size * 6 - 1; ++ + for (i = gotsym; i < symtabno; i++) + { +- Elf_Internal_Sym * psym; +- +- psym = dynamic_symbols + i; + ent = print_mips_got_entry (data, pltgot, ent); + printf (" "); +- print_vma (psym->st_value, LONG_HEX); +- printf (" %-7s %3s ", +- get_symbol_type (ELF_ST_TYPE (psym->st_info)), +- get_symbol_index_type (psym->st_shndx)); +- if (VALID_DYNAMIC_NAME (psym->st_name)) +- print_symbol (sym_width, GET_DYNAMIC_NAME (psym->st_name)); ++ ++ if (dynamic_symbols == NULL) ++ printf (_("")); ++ else if (i < num_dynamic_syms) ++ { ++ Elf_Internal_Sym * psym = dynamic_symbols + i; ++ ++ print_vma (psym->st_value, LONG_HEX); ++ printf (" %-7s %3s ", ++ get_symbol_type (ELF_ST_TYPE (psym->st_info)), ++ get_symbol_index_type (psym->st_shndx)); ++ ++ if (VALID_DYNAMIC_NAME (psym->st_name)) ++ print_symbol (sym_width, GET_DYNAMIC_NAME (psym->st_name)); ++ else ++ printf (_(""), psym->st_name); ++ } + else +- printf (_(""), psym->st_name); ++ printf (_(""), ++ (unsigned long) i); ++ + printf ("\n"); + } + printf ("\n"); +@@ -12392,19 +12831,26 @@ process_mips_specific (FILE * file) + sym_width = (is_32bit_elf ? 80 : 160) - 17 - addr_size * 6 - 1; + for (i = 0; i < count; i++) + { +- Elf_Internal_Sym * psym; ++ unsigned long idx = get_reloc_symindex (rels[i].r_info); + +- psym = dynamic_symbols + get_reloc_symindex (rels[i].r_info); + ent = print_mips_pltgot_entry (data, mips_pltgot, ent); + printf (" "); +- print_vma (psym->st_value, LONG_HEX); +- printf (" %-7s %3s ", +- get_symbol_type (ELF_ST_TYPE (psym->st_info)), +- get_symbol_index_type (psym->st_shndx)); +- if (VALID_DYNAMIC_NAME (psym->st_name)) +- print_symbol (sym_width, GET_DYNAMIC_NAME (psym->st_name)); ++ ++ if (idx >= num_dynamic_syms) ++ printf (_(""), idx); + else +- printf (_(""), psym->st_name); ++ { ++ Elf_Internal_Sym * psym = dynamic_symbols + idx; ++ ++ print_vma (psym->st_value, LONG_HEX); ++ printf (" %-7s %3s ", ++ get_symbol_type (ELF_ST_TYPE (psym->st_info)), ++ get_symbol_index_type (psym->st_shndx)); ++ if (VALID_DYNAMIC_NAME (psym->st_name)) ++ print_symbol (sym_width, GET_DYNAMIC_NAME (psym->st_name)); ++ else ++ printf (_(""), psym->st_name); ++ } + printf ("\n"); + } + printf ("\n"); +@@ -12462,7 +12908,7 @@ process_gnu_liblist (FILE * file) + strtab_size = string_sec->sh_size; + + printf (_("\nLibrary list section '%s' contains %lu entries:\n"), +- SECTION_NAME (section), ++ printable_section_name (section), + (unsigned long) (section->sh_size / sizeof (Elf32_External_Lib))); + + puts (_(" Library Time Stamp Checksum Version Flags")); +@@ -12620,6 +13066,13 @@ print_gnu_note (Elf_Internal_Note *pnote + unsigned long os, major, minor, subminor; + const char *osname; + ++ /* PR 17531: file: 030-599401-0.004. */ ++ if (pnote->descsz < 16) ++ { ++ printf (_(" \n")); ++ break; ++ } ++ + os = byte_get ((unsigned char *) pnote->descdata, 4); + major = byte_get ((unsigned char *) pnote->descdata + 4, 4); + minor = byte_get ((unsigned char *) pnote->descdata + 8, 4); +@@ -13027,7 +13480,7 @@ process_corefile_note_segment (FILE * fi + + if (temp == NULL) + { +- error (_("Out of memory\n")); ++ error (_("Out of memory allocating space for inote name\n")); + res = 0; + break; + } +@@ -13237,9 +13690,9 @@ get_file_header (FILE * file) + /* There may be some extensions in the first section header. Don't + bomb if we can't read it. */ + if (is_32bit_elf) +- get_32bit_section_headers (file, 1); ++ get_32bit_section_headers (file, TRUE); + else +- get_64bit_section_headers (file, 1); ++ get_64bit_section_headers (file, TRUE); + } + + return 1; +@@ -13675,6 +14128,8 @@ process_file (char * file_name) + return 1; + } + ++ current_file_size = (bfd_size_type) statbuf.st_size; ++ + if (memcmp (armag, ARMAG, SARMAG) == 0) + ret = process_archive (file_name, file, FALSE); + else if (memcmp (armag, ARMAGT, SARMAG) == 0) +@@ -13692,6 +14147,7 @@ process_file (char * file_name) + + fclose (file); + ++ current_file_size = 0; + return ret; + } + +Index: b/binutils/stabs.c +=================================================================== +--- a/binutils/stabs.c ++++ b/binutils/stabs.c +@@ -837,8 +837,6 @@ parse_stab_string (void *dhandle, struct + + case 'G': + { +- char leading; +- long c; + asymbol **ps; + + /* A global symbol. The value must be extracted from the +@@ -847,19 +845,27 @@ parse_stab_string (void *dhandle, struct + (debug_type **) NULL); + if (dtype == DEBUG_TYPE_NULL) + return FALSE; +- leading = bfd_get_symbol_leading_char (info->abfd); +- for (c = info->symcount, ps = info->syms; c > 0; --c, ++ps) ++ if (name != NULL) + { +- const char *n; ++ char leading; ++ long c; + +- n = bfd_asymbol_name (*ps); +- if (leading != '\0' && *n == leading) +- ++n; +- if (*n == *name && strcmp (n, name) == 0) +- break; ++ leading = bfd_get_symbol_leading_char (info->abfd); ++ for (c = info->symcount, ps = info->syms; c > 0; --c, ++ps) ++ { ++ const char *n; ++ ++ n = bfd_asymbol_name (*ps); ++ if (leading != '\0' && *n == leading) ++ ++n; ++ if (*n == *name && strcmp (n, name) == 0) ++ break; ++ } ++ ++ if (c > 0) ++ value = bfd_asymbol_value (*ps); + } +- if (c > 0) +- value = bfd_asymbol_value (*ps); ++ + if (! stab_record_variable (dhandle, info, name, dtype, DEBUG_GLOBAL, + value)) + return FALSE; +Index: b/gas/config/obj-coff.c +=================================================================== +--- a/gas/config/obj-coff.c ++++ b/gas/config/obj-coff.c +@@ -389,6 +389,7 @@ coff_obj_symbol_new_hook (symbolS *symbo + + memset (s, 0, sz); + coffsymbol (symbol_get_bfdsym (symbolP))->native = (combined_entry_type *) s; ++ coffsymbol (symbol_get_bfdsym (symbolP))->native->is_sym = TRUE; + + S_SET_DATA_TYPE (symbolP, T_NULL); + S_SET_STORAGE_CLASS (symbolP, 0); --- binutils-2.22.orig/debian/patches/160_gas_pr12698.diff +++ binutils-2.22/debian/patches/160_gas_pr12698.diff @@ -0,0 +1,54 @@ +# DP: Proposed patch for PR gas/12698 + +2011-04-15 Bernd Schmidt + + gas/ + * config/tc-arm.c (m_profile_p): New function. + (parse_psr, do_t_mrs, do_t_msr): Use m_profile_p. + + +--- a/gas/config/tc-arm.c ++++ b/gas/config/tc-arm.c +@@ -234,6 +234,15 @@ + static const arm_feature_set fpu_neon_ext_fma = ARM_FEATURE (0, FPU_NEON_EXT_FMA); + static const arm_feature_set fpu_vfp_ext_fma = ARM_FEATURE (0, FPU_VFP_EXT_FMA); + ++/* Return whether FEATURES indicates an M profile CPU, without getting ++ confused by ARM_ANY. */ ++static int ++m_profile_p (arm_feature_set features) ++{ ++ return (ARM_CPU_HAS_FEATURE (features, arm_ext_v6m) ++ && !ARM_CPU_HAS_FEATURE (features, arm_ext_v7a)); ++} ++ + static int mfloat_abi_opt = -1; + /* Record user cpu selection for object attributes. */ + static arm_feature_set selected_cpu = ARM_ARCH_NONE; +@@ -5354,7 +5363,7 @@ + const struct asm_psr *psr; + char *start; + bfd_boolean is_apsr = FALSE; +- bfd_boolean m_profile = ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m); ++ bfd_boolean m_profile = m_profile_p (selected_cpu); + + /* CPSR's and SPSR's can now be lowercase. This is just a convenience + feature for ease of use and backwards compatibility. */ +@@ -10947,7 +10956,7 @@ + { + int flags = inst.operands[1].imm & (PSR_c|PSR_x|PSR_s|PSR_f|SPSR_BIT); + +- if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m)) ++ if (m_profile_p (selected_cpu)) + constraint (flags != 0, _("selected processor does not support " + "requested special purpose register")); + else +@@ -10979,7 +10988,7 @@ + else + flags = inst.operands[0].imm; + +- if (ARM_CPU_HAS_FEATURE (selected_cpu, arm_ext_m)) ++ if (m_profile_p (selected_cpu)) + { + int bits = inst.operands[0].imm & (PSR_c|PSR_x|PSR_s|PSR_f|SPSR_BIT); + --- binutils-2.22.orig/debian/patches/130_gold_disable_testsuite_build.patch +++ binutils-2.22/debian/patches/130_gold_disable_testsuite_build.patch @@ -0,0 +1,26 @@ +Author: +Description: Description: Disable build of gold/testsuite +Author: Matthias Klose +Upstream status: local +--- a/gold/Makefile.am ++++ b/gold/Makefile.am +@@ -2,7 +2,7 @@ + + AUTOMAKE_OPTIONS = foreign + +-SUBDIRS = po testsuite ++SUBDIRS = po + + tooldir = $(exec_prefix)/$(target_alias) + +--- a/gold/Makefile.in ++++ b/gold/Makefile.in +@@ -355,7 +355,7 @@ + top_builddir = @top_builddir@ + top_srcdir = @top_srcdir@ + AUTOMAKE_OPTIONS = foreign +-SUBDIRS = po testsuite ++SUBDIRS = po + tooldir = $(exec_prefix)/$(target_alias) + ACLOCAL_AMFLAGS = -I ../bfd -I ../config + AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS)