]> oss.titaniummirror.com Git - msp430-binutils.git/commitdiff
Import 2.18.1~cvs20080103-0tinyos1 from old svn repo.
authorR. Steve McKown <rsmckown@gmail.com>
Wed, 9 Dec 2009 18:27:05 +0000 (11:27 -0700)
committerR. Steve McKown <rsmckown@gmail.com>
Wed, 9 Dec 2009 18:28:03 +0000 (11:28 -0700)
40 files changed:
debian/README.Debian [new file with mode: 0644]
debian/binutils.postinst [new file with mode: 0644]
debian/binutils.postrm [new file with mode: 0644]
debian/binutils.shlibs [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/patches/001_ld_makefile_patch.dpatch [new file with mode: 0644]
debian/patches/002_gprof_profile_arcs.dpatch [new file with mode: 0755]
debian/patches/003_gprof_see_also_monitor.dpatch [new file with mode: 0755]
debian/patches/006_better_file_error.dpatch [new file with mode: 0755]
debian/patches/00list [new file with mode: 0644]
debian/patches/012_check_ldrunpath_length.dpatch [new file with mode: 0755]
debian/patches/013_bash_in_ld_testsuite.dpatch [new file with mode: 0755]
debian/patches/127_x86_64_i386_biarch.dpatch [new file with mode: 0755]
debian/patches/128_powerpc64_biarch.dpatch [new file with mode: 0755]
debian/patches/200-hjl-ld-env.dpatch [new file with mode: 0644]
debian/patches/201-hjl-bfd-ref_addr.dpatch [new file with mode: 0755]
debian/patches/203-hjl-binutils-indirect.dpatch [new file with mode: 0755]
debian/patches/204-hjl-binutils-tls-relro.dpatch [new file with mode: 0755]
debian/patches/206-hjl-binutils-shr.dpatch [new file with mode: 0644]
debian/patches/208-hjl-libtool-relink.dpatch [new file with mode: 0644]
debian/patches/209-hjl-binutils-error.dpatch [new file with mode: 0755]
debian/patches/210-hjl-binutils-signed.dpatch [new file with mode: 0755]
debian/patches/211-hjl-binutils-weakdef.dpatch [new file with mode: 0755]
debian/patches/304_pr4476.dpatch [new file with mode: 0755]
debian/patches/305_arm-dis.dpatch [new file with mode: 0755]
debian/patches/311_pr5006.dpatch [new file with mode: 0755]
debian/patches/312_pr5011.dpatch [new file with mode: 0755]
debian/patches/313_pr5025.dpatch [new file with mode: 0755]
debian/patches/500-binutils-msp-new-cpus1.dpatch [new file with mode: 0755]
debian/patches/501-binutils-msp-new-cpus2.dpatch [new file with mode: 0755]
debian/patches/502-binutils-msp-ldscripts.dpatch [new file with mode: 0755]
debian/patches/503-binutils-msp-undef-LEX_DOLLAR.dpatch [new file with mode: 0755]
debian/rules [new file with mode: 0755]
debian/test-suite-compare.py [new file with mode: 0644]
gas/config/bfin-aux.h
ld/emultempl/spu_ovl.o [deleted file]
ld/testsuite/ld-auto-import/client.c
ld/testsuite/ld-auto-import/dll.c

diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644 (file)
index 0000000..3518b68
--- /dev/null
@@ -0,0 +1,3 @@
+This package is built from the standard ubuntu binutils distribution.  The
+patches/ directory includes patches maintained at mspgcc.sourceforge.net for
+the msp430 processor, plus a small patch for legacy TinyOS compatibility.
diff --git a/debian/binutils.postinst b/debian/binutils.postinst
new file mode 100644 (file)
index 0000000..9977c68
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+set -e
+
+if [ "$1" = "configure" ]; then
+       ldconfig
+fi
diff --git a/debian/binutils.postrm b/debian/binutils.postrm
new file mode 100644 (file)
index 0000000..33a236e
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+set -e
+
+if [ "$1" = "remove" ]; then
+       ldconfig
+fi
diff --git a/debian/binutils.shlibs b/debian/binutils.shlibs
new file mode 100644 (file)
index 0000000..92ea548
--- /dev/null
@@ -0,0 +1,2 @@
+libbfd 2.18.0.20080103 binutils
+libopcodes 2.18.0.20080103 binutils
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..b7301b3
--- /dev/null
@@ -0,0 +1,7 @@
+msp430-binutils (2.18.1~cvs20080103-0tinyos1) hardy; urgency=low
+
+  * Create msp430-binutils package from binutils 2.18.1~cvs20080103-0ubuntu1.
+    Includes patches derived from mspgcc.sourceforge.net cvs pulled from HEAD
+    on 2008-08-19.
+
+ -- R. Steve McKown <rsmckown@gmail.com>  Thu, 21 Aug 2008 16:00:00 +0007
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..fe128fa
--- /dev/null
@@ -0,0 +1,16 @@
+Source: msp430-binutils
+Section: devel
+Priority: optional
+Maintainer: R. Steve McKown <rsmckown@gmail.com>
+Standards-Version: 3.7.2.0
+Build-Depends: dpkg-dev (>= 1.13.9), autoconf (>= 2.13), bison, flex, gettext, texinfo, binutils (>= 2.9.5.0.12), gcc (>= 4:4.2.2), dejagnu (>= 1.4.2-1.1), dpatch, file, bzip2, lsb-release
+
+Package: msp430-binutils
+Architecture: any
+Depends: binutils, ${shlibs:Depends}
+Suggests:
+Priority: extra
+Description: The GNU binary utilities, for msp430 target
+ This package provides GNU assembler, linker and binary utilities for the
+ msp430 target, for use in a cross-compilation environment.  You don't need
+ this package unless you plan to cross-compile programs for msp430.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..9211d0f
--- /dev/null
@@ -0,0 +1,1101 @@
+This is the binutils package for use with the msp430 target.  It is a derivation
+of the standard binutils package, whose copyright contents are provided below
+intact.
+
+----
+
+This is the Debian GNU/Linux prepackaged version of the GNU assembler,
+linker, and binary utilities for the msp430 target.
+
+This package was put together by me, James Troup <james@nocrew.org>,
+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 <chris@debian.org>
+
+GNU Binutils is Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 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; version 2 dated June, 1991.
+
+GPL-3 UPDATE
+   [ files in CVS are currently converted to GPL-3 ]
+
+   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.
+END GPL-3 UPDATE
+
+   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 St, 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.1 or any later version published
+by the Free Software Foundation; with no Invariant Sections, with no
+Front-Cover Texts, and with no Back-Cover Texts. A copy of the license
+is shown below:
+
+GNU Free Documentation License
+******************************
+
+                        Version 1.1, March 2000
+     Copyright (C) 2000  Free Software Foundation, Inc.
+     51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+
+     Everyone is permitted to copy and distribute verbatim copies
+     of this license document, but changing it is not allowed.
+
+
+  0. PREAMBLE
+
+     The purpose of this License is to make a manual, textbook, or other
+     written document "free" in the sense of freedom: to assure everyone
+     the effective freedom to copy and redistribute it, with or without
+     modifying it, either commercially or noncommercially.  Secondarily,
+     this License preserves for the author and publisher a way to get
+     credit for their work, while not being considered responsible for
+     modifications made by others.
+
+     This License is a kind of "copyleft", which means that derivative
+     works of the document must themselves be free in the same sense.
+     It complements the GNU General Public License, which is a copyleft
+     license designed for free software.
+
+     We have designed this License in order to use it for manuals for
+     free software, because free software needs free documentation: a
+     free program should come with manuals providing the same freedoms
+     that the software does.  But this License is not limited to
+     software manuals; it can be used for any textual work, regardless
+     of subject matter or whether it is published as a printed book.
+     We recommend this License principally for works whose purpose is
+     instruction or reference.
+
+
+  1. APPLICABILITY AND DEFINITIONS
+
+     This License applies to any manual or other work that contains a
+     notice placed by the copyright holder saying it can be distributed
+     under the terms of this License.  The "Document", below, refers to
+     any such manual or work.  Any member of the public is a licensee,
+     and is addressed as "you."
+
+     A "Modified Version" of the Document means any work containing the
+     Document or a portion of it, either copied verbatim, or with
+     modifications and/or translated into another language.
+
+     A "Secondary Section" is a named appendix or a front-matter
+     section of the Document that deals exclusively with the
+     relationship of the publishers or authors of the Document to the
+     Document's overall subject (or to related matters) and contains
+     nothing that could fall directly within that overall subject.
+     (For example, if the Document is in part a textbook of
+     mathematics, a Secondary Section may not explain any mathematics.)
+     The relationship could be a matter of historical connection with
+     the subject or with related matters, or of legal, commercial,
+     philosophical, ethical or political position regarding them.
+
+     The "Invariant Sections" are certain Secondary Sections whose
+     titles are designated, as being those of Invariant Sections, in
+     the notice that says that the Document is released under this
+     License.
+
+     The "Cover Texts" are certain short passages of text that are
+     listed, as Front-Cover Texts or Back-Cover Texts, in the notice
+     that says that the Document is released under this License.
+
+     A "Transparent" copy of the Document means a machine-readable copy,
+     represented in a format whose specification is available to the
+     general public, whose contents can be viewed and edited directly
+     and straightforwardly with generic text editors or (for images
+     composed of pixels) generic paint programs or (for drawings) some
+     widely available drawing editor, and that is suitable for input to
+     text formatters or for automatic translation to a variety of
+     formats suitable for input to text formatters.  A copy made in an
+     otherwise Transparent file format whose markup has been designed
+     to thwart or discourage subsequent modification by readers is not
+     Transparent.  A copy that is not "Transparent" is called "Opaque."
+
+     Examples of suitable formats for Transparent copies include plain
+     ASCII without markup, Texinfo input format, LaTeX input format,
+     SGML or XML using a publicly available DTD, and
+     standard-conforming simple HTML designed for human modification.
+     Opaque formats include PostScript, PDF, proprietary formats that
+     can be read and edited only by proprietary word processors, SGML
+     or XML for which the DTD and/or processing tools are not generally
+     available, and the machine-generated HTML produced by some word
+     processors for output purposes only.
+
+     The "Title Page" means, for a printed book, the title page itself,
+     plus such following pages as are needed to hold, legibly, the
+     material this License requires to appear in the title page.  For
+     works in formats which do not have any title page as such, "Title
+     Page" means the text near the most prominent appearance of the
+     work's title, preceding the beginning of the body of the text.
+  
+  2. VERBATIM COPYING
+
+     You may copy and distribute the Document in any medium, either
+     commercially or noncommercially, provided that this License, the
+     copyright notices, and the license notice saying this License
+     applies to the Document are reproduced in all copies, and that you
+     add no other conditions whatsoever to those of this License.  You
+     may not use technical measures to obstruct or control the reading
+     or further copying of the copies you make or distribute.  However,
+     you may accept compensation in exchange for copies.  If you
+     distribute a large enough number of copies you must also follow
+     the conditions in section 3.
+
+     You may also lend copies, under the same conditions stated above,
+     and you may publicly display copies.
+  
+  3. COPYING IN QUANTITY
+
+     If you publish printed copies of the Document numbering more than
+     100, and the Document's license notice requires Cover Texts, you
+     must enclose the copies in covers that carry, clearly and legibly,
+     all these Cover Texts: Front-Cover Texts on the front cover, and
+     Back-Cover Texts on the back cover.  Both covers must also clearly
+     and legibly identify you as the publisher of these copies.  The
+     front cover must present the full title with all words of the
+     title equally prominent and visible.  You may add other material
+     on the covers in addition.  Copying with changes limited to the
+     covers, as long as they preserve the title of the Document and
+     satisfy these conditions, can be treated as verbatim copying in
+     other respects.
+
+     If the required texts for either cover are too voluminous to fit
+     legibly, you should put the first ones listed (as many as fit
+     reasonably) on the actual cover, and continue the rest onto
+     adjacent pages.
+
+     If you publish or distribute Opaque copies of the Document
+     numbering more than 100, you must either include a
+     machine-readable Transparent copy along with each Opaque copy, or
+     state in or with each Opaque copy a publicly-accessible
+     computer-network location containing a complete Transparent copy
+     of the Document, free of added material, which the general
+     network-using public has access to download anonymously at no
+     charge using public-standard network protocols.  If you use the
+     latter option, you must take reasonably prudent steps, when you
+     begin distribution of Opaque copies in quantity, to ensure that
+     this Transparent copy will remain thus accessible at the stated
+     location until at least one year after the last time you
+     distribute an Opaque copy (directly or through your agents or
+     retailers) of that edition to the public.
+
+     It is requested, but not required, that you contact the authors of
+     the Document well before redistributing any large number of
+     copies, to give them a chance to provide you with an updated
+     version of the Document.
+  
+  4. MODIFICATIONS
+
+     You may copy and distribute a Modified Version of the Document
+     under the conditions of sections 2 and 3 above, provided that you
+     release the Modified Version under precisely this License, with
+     the Modified Version filling the role of the Document, thus
+     licensing distribution and modification of the Modified Version to
+     whoever possesses a copy of it.  In addition, you must do these
+     things in the Modified Version:
+
+     A. Use in the Title Page (and on the covers, if any) a title
+     distinct    from that of the Document, and from those of previous
+     versions    (which should, if there were any, be listed in the
+     History section    of the Document).  You may use the same title
+     as a previous version    if the original publisher of that version
+     gives permission.
+     B. List on the Title Page, as authors, one or more persons or
+     entities    responsible for authorship of the modifications in the
+     Modified    Version, together with at least five of the principal
+     authors of the    Document (all of its principal authors, if it
+     has less than five).
+     C. State on the Title page the name of the publisher of the
+     Modified Version, as the publisher.
+     D. Preserve all the copyright notices of the Document.
+     E. Add an appropriate copyright notice for your modifications
+     adjacent to the other copyright notices.
+     F. Include, immediately after the copyright notices, a license
+     notice    giving the public permission to use the Modified Version
+     under the    terms of this License, in the form shown in the
+     Addendum below.
+     G. Preserve in that license notice the full lists of Invariant
+     Sections    and required Cover Texts given in the Document's
+     license notice.
+     H. Include an unaltered copy of this License.
+     I. Preserve the section entitled "History", and its title, and add
+     to    it an item stating at least the title, year, new authors, and
+       publisher of the Modified Version as given on the Title Page.
+     If    there is no section entitled "History" in the Document,
+     create one    stating the title, year, authors, and publisher of
+     the Document as    given on its Title Page, then add an item
+     describing the Modified    Version as stated in the previous
+     sentence.
+     J. Preserve the network location, if any, given in the Document for
+       public access to a Transparent copy of the Document, and
+     likewise    the network locations given in the Document for
+     previous versions    it was based on.  These may be placed in the
+     "History" section.     You may omit a network location for a work
+     that was published at    least four years before the Document
+     itself, or if the original    publisher of the version it refers
+     to gives permission.
+     K. In any section entitled "Acknowledgements" or "Dedications",
+     preserve the section's title, and preserve in the section all the
+      substance and tone of each of the contributor acknowledgements
+     and/or dedications given therein.
+     L. Preserve all the Invariant Sections of the Document,
+     unaltered in their text and in their titles.  Section numbers
+     or the equivalent are not considered part of the section titles.
+     M. Delete any section entitled "Endorsements."  Such a section
+     may not be included in the Modified Version.
+     N. Do not retitle any existing section as "Endorsements"    or to
+     conflict in title with any Invariant Section.
+
+     If the Modified Version includes new front-matter sections or
+     appendices that qualify as Secondary Sections and contain no
+     material copied from the Document, you may at your option
+     designate some or all of these sections as invariant.  To do this,
+     add their titles to the list of Invariant Sections in the Modified
+     Version's license notice.  These titles must be distinct from any
+     other section titles.
+
+     You may add a section entitled "Endorsements", provided it contains
+     nothing but endorsements of your Modified Version by various
+     parties-for example, statements of peer review or that the text has
+     been approved by an organization as the authoritative definition
+     of a standard.
+
+     You may add a passage of up to five words as a Front-Cover Text,
+     and a passage of up to 25 words as a Back-Cover Text, to the end
+     of the list of Cover Texts in the Modified Version.  Only one
+     passage of Front-Cover Text and one of Back-Cover Text may be
+     added by (or through arrangements made by) any one entity.  If the
+     Document already includes a cover text for the same cover,
+     previously added by you or by arrangement made by the same entity
+     you are acting on behalf of, you may not add another; but you may
+     replace the old one, on explicit permission from the previous
+     publisher that added the old one.
+
+     The author(s) and publisher(s) of the Document do not by this
+     License give permission to use their names for publicity for or to
+     assert or imply endorsement of any Modified Version.
+
+  5. COMBINING DOCUMENTS
+
+     You may combine the Document with other documents released under
+     this License, under the terms defined in section 4 above for
+     modified versions, provided that you include in the combination
+     all of the Invariant Sections of all of the original documents,
+     unmodified, and list them all as Invariant Sections of your
+     combined work in its license notice.
+
+     The combined work need only contain one copy of this License, and
+     multiple identical Invariant Sections may be replaced with a single
+     copy.  If there are multiple Invariant Sections with the same name
+     but different contents, make the title of each such section unique
+     by adding at the end of it, in parentheses, the name of the
+     original author or publisher of that section if known, or else a
+     unique number.  Make the same adjustment to the section titles in
+     the list of Invariant Sections in the license notice of the
+     combined work.
+
+     In the combination, you must combine any sections entitled
+     "History" in the various original documents, forming one section
+     entitled "History"; likewise combine any sections entitled
+     "Acknowledgements", and any sections entitled "Dedications."  You
+     must delete all sections entitled "Endorsements."
+  
+  6. COLLECTIONS OF DOCUMENTS
+
+     You may make a collection consisting of the Document and other
+     documents released under this License, and replace the individual
+     copies of this License in the various documents with a single copy
+     that is included in the collection, provided that you follow the
+     rules of this License for verbatim copying of each of the
+     documents in all other respects.
+
+     You may extract a single document from such a collection, and
+     distribute it individually under this License, provided you insert
+     a copy of this License into the extracted document, and follow
+     this License in all other respects regarding verbatim copying of
+     that document.
+  
+  7. AGGREGATION WITH INDEPENDENT WORKS
+
+     A compilation of the Document or its derivatives with other
+     separate and independent documents or works, in or on a volume of
+     a storage or distribution medium, does not as a whole count as a
+     Modified Version of the Document, provided no compilation
+     copyright is claimed for the compilation.  Such a compilation is
+     called an "aggregate", and this License does not apply to the
+     other self-contained works thus compiled with the Document, on
+     account of their being thus compiled, if they are not themselves
+     derivative works of the Document.
+
+     If the Cover Text requirement of section 3 is applicable to these
+     copies of the Document, then if the Document is less than one
+     quarter of the entire aggregate, the Document's Cover Texts may be
+     placed on covers that surround only the Document within the
+     aggregate.  Otherwise they must appear on covers around the whole
+     aggregate.
+
+  8. TRANSLATION
+
+     Translation is considered a kind of modification, so you may
+     distribute translations of the Document under the terms of section
+     4.  Replacing Invariant Sections with translations requires special
+     permission from their copyright holders, but you may include
+     translations of some or all Invariant Sections in addition to the
+     original versions of these Invariant Sections.  You may include a
+     translation of this License provided that you also include the
+     original English version of this License.  In case of a
+     disagreement between the translation and the original English
+     version of this License, the original English version will prevail.
+  
+  9. TERMINATION
+
+     You may not copy, modify, sublicense, or distribute the Document
+     except as expressly provided for under this License.  Any other
+     attempt to copy, modify, sublicense or distribute the Document is
+     void, and will automatically terminate your rights under this
+     License.  However, parties who have received copies, or rights,
+     from you under this License will not have their licenses
+     terminated so long as such parties remain in full compliance.
+ 10. FUTURE REVISIONS OF THIS LICENSE
+
+     The Free Software Foundation may publish new, revised versions of
+     the GNU Free Documentation License from time to time.  Such new
+     versions will be similar in spirit to the present version, but may
+     differ in detail to address new problems or concerns.  See
+     http://www.gnu.org/copyleft/.
+
+     Each version of the License is given a distinguishing version
+     number.  If the Document specifies that a particular numbered
+     version of this License "or any later version" applies to it, you
+     have the option of following the terms and conditions either of
+     that specified version or of any later version that has been
+     published (not as a draft) by the Free Software Foundation.  If
+     the Document does not specify a version number of this License,
+     you may choose any version ever published (not as a draft) by the
+     Free Software Foundation.
+
+
+ADDENDUM: How to use this License for your documents
+====================================================
+
+To use this License in a document you have written, include a copy of
+the License in the document and put the following copyright and license
+notices just after the title page:
+
+     Copyright (C)  YEAR  YOUR NAME.
+     Permission is granted to copy, distribute and/or modify this document
+     under the terms of the GNU Free Documentation License, Version 1.1
+     or any later version published by the Free Software Foundation;
+     with the Invariant Sections being LIST THEIR TITLES, with the
+     Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
+     A copy of the license is included in the section entitled "GNU
+     Free Documentation License."
+
+   If you have no Invariant Sections, write "with no Invariant Sections"
+instead of saying which ones are invariant.  If you have no Front-Cover
+Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
+LIST"; likewise for Back-Cover Texts.
+   
+   If your document contains nontrivial examples of program code, we
+recommend releasing these examples in parallel under your choice of
+free software license, such as the GNU General Public License, to
+permit their use in free software.
+
+
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/debian/patches/001_ld_makefile_patch.dpatch b/debian/patches/001_ld_makefile_patch.dpatch
new file mode 100644 (file)
index 0000000..823f6a0
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/sh -e
+## 001_ld_makefile_patch.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: correct where ld scripts are installed
+## DP: Author: Chris Chimelis <chris@debian.org>
+## DP: Upstream status: N/A
+## DP: Date: ??
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.am /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am
+--- ./ld/Makefile.am   2005-08-31 03:27:36.000000000 +0000
++++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am    2005-09-02 21:42:18.000000000 +0000
+@@ -20,7 +20,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@
+diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.in /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in
+--- ./ld/Makefile.in   2005-08-31 03:27:36.000000000 +0000
++++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in    2005-09-02 21:43:37.259127535 +0000
+@@ -268,7 +268,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
diff --git a/debian/patches/002_gprof_profile_arcs.dpatch b/debian/patches/002_gprof_profile_arcs.dpatch
new file mode 100755 (executable)
index 0000000..903852f
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/sh -e
+## 003_gmon_manpage_fix.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Add more documentation about profiling and -fprofile-arcs.
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad binutils-2.16/gprof/gprof.texi /tmp/dpep.NHuhql/binutils-2.16/gprof/gprof.texi
+--- binutils-2.16/gprof/gprof.texi     2005-03-03 13:05:12.000000000 +0100
++++ /tmp/dpep.NHuhql/binutils-2.16/gprof/gprof.texi    2005-05-06 19:14:10.038173569 +0200
+@@ -138,6 +138,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
+@@ -268,6 +272,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
diff --git a/debian/patches/003_gprof_see_also_monitor.dpatch b/debian/patches/003_gprof_see_also_monitor.dpatch
new file mode 100755 (executable)
index 0000000..b262fc3
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh -e
+## 014_gprof_manpage_fix.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Don't mention monitor(3) which doesn't exist in Debian. (#160654)
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/gprof/gprof.texi binutils-2.14.90.0.6/gprof/gprof.texi
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/gprof/gprof.texi 2002-08-02 01:49:32.000000000 +0100
++++ binutils-2.14.90.0.6/gprof/gprof.texi      2003-09-10 22:42:37.000000000 +0100
+@@ -181,7 +181,7 @@
+ @c man end
+ @c man begin SEEALSO
+-monitor(3), profil(2), cc(1), prof(1), and the Info entry for @file{gprof}.
++profil(2), cc(1), prof(1), and the Info entry for @file{gprof}.
+ ``An Execution Profiler for Modular Programs'',
+ by S. Graham, P. Kessler, M. McKusick;
diff --git a/debian/patches/006_better_file_error.dpatch b/debian/patches/006_better_file_error.dpatch
new file mode 100755 (executable)
index 0000000..f337611
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 006_better_file_error.dpatch by David Kimdon <dwhedon@gordian.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Specify which filename is causing an error if the filename is a
+## DP: directory. (#45832)
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c binutils-2.14.90.0.6/bfd/opncls.c
+--- /home/james/debian/packages/binutils/binutils-2.14.90.0.6/bfd/opncls.c     2003-07-23 16:08:09.000000000 +0100
++++ binutils-2.14.90.0.6/bfd/opncls.c  2003-09-10 22:35:00.000000000 +0100
+@@ -150,6 +150,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)
diff --git a/debian/patches/00list b/debian/patches/00list
new file mode 100644 (file)
index 0000000..b33eecd
--- /dev/null
@@ -0,0 +1,40 @@
+# not for the msp430 cross:
+#001_ld_makefile_patch
+
+002_gprof_profile_arcs
+003_gprof_see_also_monitor
+006_better_file_error
+012_check_ldrunpath_length
+013_bash_in_ld_testsuite
+127_x86_64_i386_biarch
+128_powerpc64_biarch
+
+# not applied for Ubuntu:
+#200-hjl-ld-env
+
+201-hjl-bfd-ref_addr
+203-hjl-binutils-indirect
+204-hjl-binutils-tls-relro
+
+# not applied for Ubuntu:
+#206-hjl-binutils-shr
+
+209-hjl-binutils-error
+210-hjl-binutils-signed
+211-hjl-binutils-weakdef
+
+# needs an update:
+#212-hjl-binutils-pe-align
+
+304_pr4476
+305_arm-dis
+
+311_pr5006
+312_pr5011
+313_pr5025
+
+# msp430 only, taken from mspgcc CVS 20080818
+500-binutils-msp-new-cpus1.dpatch
+501-binutils-msp-new-cpus2.dpatch
+502-binutils-msp-ldscripts.dpatch
+503-binutils-msp-undef-LEX_DOLLAR.dpatch
diff --git a/debian/patches/012_check_ldrunpath_length.dpatch b/debian/patches/012_check_ldrunpath_length.dpatch
new file mode 100755 (executable)
index 0000000..bf69da1
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh -e
+## 012_check_ldrunpath_length.dpatch by Chris Chimelis <chris@debian.org>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Only generate an RPATH entry if LD_RUN_PATH is not empty, for
+## DP: cases where -rpath isn't specified. (#151024)
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad binutils-2.16/ld/emultempl/elf32.em /tmp/dpep.u3SQkH/binutils-2.16/ld/emultempl/elf32.em
+--- binutils-2.16/ld/emultempl/elf32.em        2005-04-13 19:59:07.000000000 +0200
++++ /tmp/dpep.u3SQkH/binutils-2.16/ld/emultempl/elf32.em       2005-05-06 19:18:08.236669718 +0200
+@@ -885,6 +885,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;
+@@ -1059,6 +1061,8 @@
+   rpath = command_line.rpath;
+   if (rpath == NULL)
+     rpath = (const char *) getenv ("LD_RUN_PATH");
++  if ((rpath) && (strlen (rpath) == 0))
++      rpath = NULL;
+   if (! (bfd_elf_size_dynamic_sections
+        (output_bfd, command_line.soname, rpath,
+         command_line.filter_shlib,
diff --git a/debian/patches/013_bash_in_ld_testsuite.dpatch b/debian/patches/013_bash_in_ld_testsuite.dpatch
new file mode 100755 (executable)
index 0000000..8944013
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh -e
+## 007_bash_in_ld_testsuite.dpatch.dpatch by Matthias Klose <doko@ubuntu.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Explicitely use bash for the ld testsuite.
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- ./ld/testsuite/config/default.exp~ 2007-07-07 19:55:47.000000000 +0200
++++ ./ld/testsuite/config/default.exp  2007-07-07 20:20:45.000000000 +0200
+@@ -117,7 +117,7 @@
+     global srcdir
+     global CC
+     if ![info exists $varname] {
+-      set status [catch "exec sh -c \"host='$target_triplet' && CC='$CC' && . $srcdir/../configure.host && eval echo \\$$varname\"" result]
++      set status [catch "exec bash -c \"host='$target_triplet' && CC='$CC' && . $srcdir/../configure.host && eval echo \\$$varname\"" result]
+       if $status { error "Error getting native link files: $result" }
+       set $varname $result
+     }
+@@ -126,7 +126,7 @@
+ proc get_target_emul {} {
+     global target_triplet
+     global srcdir
+-    set status [catch "exec sh -c \"targ='$target_triplet' && . $srcdir/../configure.tgt && echo \\\$targ_emul\"" result]
++    set status [catch "exec bash -c \"targ='$target_triplet' && . $srcdir/../configure.tgt && echo \\\$targ_emul\"" result]
+     if $status { error "Error getting emulation name: $result" }
+     return $result
+ }
diff --git a/debian/patches/127_x86_64_i386_biarch.dpatch b/debian/patches/127_x86_64_i386_biarch.dpatch
new file mode 100755 (executable)
index 0000000..f08223a
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh -e
+## 127_x86_64_i386_biarch.dpatch
+##
+## DP: Description: Add (/usr)/lib32 to the search paths on x86_64.
+## DP: Author: Aurelien Jarno <aurel32.debian.org>
+## DP: Upstream status: Debian specific
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+--- binutils/ld/emulparams/elf_i386.sh
++++ binutils/ld/emulparams/elf_i386.sh
+@@ -12,3 +12,13 @@
+ GENERATE_PIE_SCRIPT=yes
+ NO_SMALL_DATA=yes
+ SEPARATE_GOTPLT=12
++
++# 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*)
++    case "$EMULATION_NAME" in
++      *i386*) LIBPATH_SUFFIX=32 ;;
++    esac
++    ;;
++esac
diff --git a/debian/patches/128_powerpc64_biarch.dpatch b/debian/patches/128_powerpc64_biarch.dpatch
new file mode 100755 (executable)
index 0000000..533e30f
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh -e
+## 128_powerpc64_biarch.dpatch
+##
+## DP: Description: Add (/usr)/lib32 to the search paths on powerpc64.
+## DP: Author: Andreas Jochens <aj@andaco.de>
+## DP: Upstream status: Debian specific
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
++++ binutils/ld/emulparams/elf32ppccommon.sh   2006-03-02 08:50:04.000000000 +0000
+--- binutils/ld/emulparams/elf32ppccommon.sh   2006-09-13 06:59:26.000000000 +0000
+@@ -45,5 +45,6 @@
+ # Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first.
+ case "$EMULATION_NAME" in
++  *32*) LIBPATH_SUFFIX=32 ;;
+   *64*) LIBPATH_SUFFIX=64 ;;
+ esac
diff --git a/debian/patches/200-hjl-ld-env.dpatch b/debian/patches/200-hjl-ld-env.dpatch
new file mode 100644 (file)
index 0000000..c4eac5d
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh -e
+## 200-hjl-ld-env.dpatch
+##
+## DP: Description: Handle LD_SYMBOLIC and LD_SYMBOLIC_FUNCTIONS env vars
+## DP: Author: H.J. Lu  <hongjiu.lu@intel.com>
+## DP: Upstream status: hjl 2.17.50.0.18
+## DP: Original patch: ld-env-6.patch
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+2007-01-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * 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.
+
+@DPATCH@
+diff -urNad binutils-2.18~cvs20070812~/ld/NEWS binutils-2.18~cvs20070812/ld/NEWS
+--- binutils-2.18~cvs20070812~/ld/NEWS 2007-08-12 10:00:32.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/NEWS  2007-08-12 13:09:23.000000000 +0200
+@@ -1,6 +1,9 @@
+ -*- text -*-
+ Changes in 2.18:
++* ELF: Support environment variables, LD_SYMBOLIC for -Bsymbolic and
++  LD_SYMBOLIC_FUNCTIONS for -Bsymbolic-functions.
++
+ * Linker sources now released under version 3 of the GNU General Public
+   License.
+diff -urNad binutils-2.18~cvs20070812~/ld/ld.texinfo binutils-2.18~cvs20070812/ld/ld.texinfo
+--- binutils-2.18~cvs20070812~/ld/ld.texinfo   2007-07-25 16:56:22.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/ld.texinfo    2007-08-12 13:08:46.000000000 +0200
+@@ -1142,14 +1142,21 @@
+ 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}
+diff -urNad binutils-2.18~cvs20070812~/ld/ldmain.c binutils-2.18~cvs20070812/ld/ldmain.c
+--- binutils-2.18~cvs20070812~/ld/ldmain.c     2007-07-06 16:09:41.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/ldmain.c      2007-08-12 13:08:46.000000000 +0200
+@@ -254,6 +254,11 @@
+   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
diff --git a/debian/patches/201-hjl-bfd-ref_addr.dpatch b/debian/patches/201-hjl-bfd-ref_addr.dpatch
new file mode 100755 (executable)
index 0000000..a463150
--- /dev/null
@@ -0,0 +1,193 @@
+#!/bin/sh -e
+## 201-hjl-bfd-ref-addr.dpatch
+##
+## DP: Description: Support DW_FORM_ref_addr in Dwarf 2 reader in linker.
+## DP: Author: H.J. Lu  <hongjiu.lu@intel.com>
+## DP: Upstream status: hjl post 2.17.50.0.18, PR ld/3191
+## DP: Original patch: bfd-ref_addr-6.patch
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+2006-09-29  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/3191
+       * dwarf2.c (find_abstract_instance_name): Pass a pointer to
+       attribute instead of offset.  For DW_FORM_ref_addr, get the
+       entry at the offset from the .debug_info section.
+       (scan_unit_for_symbols): Updated.
+       (_bfd_dwarf2_find_nearest_line): Adjust debug_info
+       section vma when needed.
+
+@DPATCH@
+diff -urNad binutils-2.18~cvs20070812~/bfd/dwarf2.c binutils-2.18~cvs20070812/bfd/dwarf2.c
+--- binutils-2.18~cvs20070812~/bfd/dwarf2.c    2007-07-26 10:31:03.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/dwarf2.c     2007-08-12 13:15:54.000000000 +0200
+@@ -1710,16 +1710,30 @@
+ }
+ static char *
+-find_abstract_instance_name (struct comp_unit *unit, bfd_uint64_t die_ref)
++find_abstract_instance_name (struct comp_unit *unit,
++                           struct attribute *attr_ptr)
+ {
+   bfd *abfd = unit->abfd;
+   bfd_byte *info_ptr;
+   unsigned int abbrev_number, bytes_read, i;
+   struct abbrev_info *abbrev;
++  bfd_uint64_t die_ref = attr_ptr->u.val;
+   struct attribute attr;
+   char *name = 0;
+-  info_ptr = unit->info_ptr_unit + die_ref;
++  /* DW_FORM_ref_addr can reference an entry in a different CU. It
++     is an offset from the .debug_info section, not the current CU.  */
++  if (attr_ptr->form == DW_FORM_ref_addr)
++    {
++      /* FIXME: How to handle DW_FORM_ref_addr references an entry in
++       a different file?  */ 
++      if (!die_ref)
++      abort ();
++
++      info_ptr = unit->stash->sec_info_ptr + die_ref;
++    }
++  else 
++    info_ptr = unit->info_ptr_unit + die_ref;
+   abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+   info_ptr += bytes_read;
+@@ -1745,7 +1759,7 @@
+                   name = attr.u.str;
+                 break;
+               case DW_AT_specification:
+-                name = find_abstract_instance_name (unit, attr.u.val);
++                name = find_abstract_instance_name (unit, &attr);
+                 break;
+               case DW_AT_MIPS_linkage_name:
+                 name = attr.u.str;
+@@ -1907,7 +1921,7 @@
+                 break;
+               case DW_AT_abstract_origin:
+-                func->name = find_abstract_instance_name (unit, attr.u.val);
++                func->name = find_abstract_instance_name (unit, &attr);
+                 break;
+               case DW_AT_name:
+@@ -2876,6 +2890,11 @@
+       bfd *debug_bfd;
+       bfd_size_type total_size;
+       asection *msec;
++      bfd_vma last_vma;
++      bfd_size_type size;
++      asection *first_msec;
++      asection **msecs = NULL;
++      unsigned int i, count;
+       *pinfo = stash;
+@@ -2909,9 +2928,28 @@
+        Read them all in and produce one large stash.  We do this in two
+        passes - in the first pass we just accumulate the section sizes.
+        In the second pass we read in the section's contents.  The allows
+-       us to avoid reallocing the data as we add sections to the stash.  */
++       us to avoid reallocing the data as we add sections to the stash.
++       
++       We may need to adjust debug_info section vmas since we will
++       concatenate them together.  Otherwise relocations may be
++       incorrect.  */
++      first_msec = msec;
++      last_vma = 0;
++      count = 0;
+       for (total_size = 0; msec; msec = find_debug_info (debug_bfd, msec))
+-      total_size += msec->size;
++      {
++        size = msec->size;
++        if (size == 0)
++          continue;
++
++        total_size += size;
++
++        BFD_ASSERT (msec->vma == 0 && msec->alignment_power == 0);
++
++        msec->vma = last_vma;
++        last_vma += size;
++        count++;
++      }
+       stash->info_ptr = bfd_alloc (debug_bfd, total_size);
+       if (stash->info_ptr == NULL)
+@@ -2919,17 +2957,27 @@
+       stash->info_ptr_end = stash->info_ptr;
+-      for (msec = find_debug_info (debug_bfd, NULL);
++      if (count > 1)
++      {
++        count--;
++        msecs = (asection **) bfd_malloc2 (count, sizeof (*msecs));
++      }
++
++      for (i = 0, msec = first_msec;
+          msec;
+          msec = find_debug_info (debug_bfd, msec))
+       {
+-        bfd_size_type size;
+         bfd_size_type start;
+         size = msec->size;
+         if (size == 0)
+           continue;
++        if (i && msecs)
++          msecs [i - 1] = msec;
++
++        i++;
++
+         start = stash->info_ptr_end - stash->info_ptr;
+         if ((bfd_simple_get_relocated_section_contents
+@@ -2939,9 +2987,27 @@
+         stash->info_ptr_end = stash->info_ptr + start + size;
+       }
++      /* Restore section vma. */
++      if (count)
++      {
++        if (msecs)
++          {
++            for (i = 0; i < count; i++)
++              msecs [i]->vma = 0;
++            free (msecs);
++          }
++        else
++          {
++            for (msec = find_debug_info (debug_bfd, first_msec);
++                 msec;
++                 msec = find_debug_info (debug_bfd, msec))
++              msec->vma = 0;
++          }
++      }
++
+       BFD_ASSERT (stash->info_ptr_end == stash->info_ptr + total_size);
+-      stash->sec = find_debug_info (debug_bfd, NULL);
++      stash->sec = first_msec;
+       stash->sec_info_ptr = stash->info_ptr;
+       stash->syms = symbols;
+       stash->bfd = debug_bfd;
diff --git a/debian/patches/203-hjl-binutils-indirect.dpatch b/debian/patches/203-hjl-binutils-indirect.dpatch
new file mode 100755 (executable)
index 0000000..3d37bf7
--- /dev/null
@@ -0,0 +1,573 @@
+#!/bin/sh -e
+## 203-hjl-binutils-indirect.dpatch
+##
+## DP: Description: PR ld/3351; avoid linker crash on ia64
+## DP: Author: H.J. Lu  <hongjiu.lu@intel.com>
+## DP: Upstream status: hjl 2.17.50.0.18
+## DP: Original patch: binutils-indirect-1.patch
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+bfd/
+
+2006-10-17  H.J. Lu  <hongjiu.lu@intel.com>
+
+       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  <hongjiu.lu@intel.com>
+
+       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.
+
+@DPATCH@
+diff -urNad binutils-2.18~cvs20070812~/bfd/elflink.c binutils-2.18~cvs20070812/bfd/elflink.c
+--- binutils-2.18~cvs20070812~/bfd/elflink.c   2007-07-27 03:04:29.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elflink.c    2007-08-12 13:27:51.000000000 +0200
+@@ -823,6 +823,33 @@
+   return dynsymcount;
+ }
++/* 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
+@@ -851,6 +878,7 @@
+ {
+   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;
+@@ -887,8 +915,9 @@
+   if (info->hash->creator != abfd->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;
+@@ -1047,23 +1076,11 @@
+   /* 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
+@@ -1075,6 +1092,7 @@
+       *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.
+@@ -1609,6 +1627,7 @@
+         if (! dynamic)
+           {
+             if (info->shared
++                || hi->def_dynamic
+                 || hi->ref_dynamic)
+               *dynsym = TRUE;
+           }
+@@ -3737,6 +3756,7 @@
+       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;
+@@ -4026,6 +4046,9 @@
+       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;
+@@ -4232,22 +4255,36 @@
+               }
+             else
+               h->def_regular = 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;
+           }
+@@ -8396,6 +8433,10 @@
+   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:
+@@ -8604,11 +8645,17 @@
+       && !h->dynamic_weak
+       && ! elf_link_check_versioned_symbol (finfo->info, bed, h))
+     {
++      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;
++
+       (*_bfd_error_handler)
+       (_("%B: %s symbol `%s' in %B is referenced by DSO"),
+        finfo->output_bfd,
+-       h->root.u.def.section == bfd_abs_section_ptr
+-       ? finfo->output_bfd : h->root.u.def.section->owner,
++       hi->root.u.def.section == bfd_abs_section_ptr
++       ? finfo->output_bfd : hi->root.u.def.section->owner,
+        ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
+        ? "internal"
+        : ELF_ST_VISIBILITY (h->other) == STV_HIDDEN
+@@ -8804,6 +8851,23 @@
+     {
+       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 -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect.exp binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect.exp
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect.exp        1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect.exp 2007-08-12 13:27:51.000000000 +0200
+@@ -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: Nonrepresentable section on output"
++
++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 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 -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect1a.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect1a.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect1a.c        1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect1a.c 2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,8 @@
++extern void bar (void);
++
++int
++start (void)
++{
++  bar ();
++  return 0;
++}
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect1b.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect1b.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect1b.c        1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect1b.c 2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,6 @@
++void
++foo (void)
++{
++}
++
++asm (".symver foo,foo@FOO");
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect1c.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect1c.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect1c.c        1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect1c.c 2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,7 @@
++extern void foo (void);
++
++void
++bar (void)
++{
++  foo ();
++}
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect2.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect2.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect2.c 1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect2.c  2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,9 @@
++extern void foo (void);
++
++asm (".symver foo,foo@@@FOO");
++
++void
++bar (void)
++{
++  foo ();
++}
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect3.out binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect3.out
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect3.out       1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect3.out        2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,2 @@
++MAIN
++DSO
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect3a.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect3a.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect3a.c        1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect3a.c 2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,10 @@
++extern void bar (void);
++extern void foo (void);
++
++int
++main (void)
++{
++  foo ();
++  bar ();
++  return 0;
++}
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect3b.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect3b.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect3b.c        1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect3b.c 2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,9 @@
++#include <stdio.h>
++
++void
++foo (void)
++{
++  printf ("MAIN\n");
++}
++
++asm (".symver foo,foo@FOO");
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect3c.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect3c.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect3c.c        1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect3c.c 2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,15 @@
++#include <stdio.h>
++
++extern void foo (void);
++
++void
++foo (void)
++{
++  printf ("DSO\n");
++}
++
++void
++bar (void)
++{
++  foo ();
++}
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect4.out binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect4.out
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect4.out       1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect4.out        2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,2 @@
++MAIN2
++MAIN2
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect4a.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect4a.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect4a.c        1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect4a.c 2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,10 @@
++extern void bar (void);
++extern void foo (void);
++
++int
++main (void)
++{
++  foo ();
++  bar ();
++  return 0;
++}
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect4b.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect4b.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect4b.c        1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect4b.c 2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,17 @@
++#include <stdio.h>
++
++void
++foo2 (void)
++{
++  printf ("MAIN2\n");
++}
++
++asm (".symver foo2,foo@@FOO2");
++
++void
++foo1 (void)
++{
++  printf ("MAIN1\n");
++}
++
++asm (".symver foo1,foo@FOO1");
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect4c.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect4c.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/indirect4c.c        1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/indirect4c.c 2007-08-12 13:27:51.000000000 +0200
+@@ -0,0 +1,15 @@
++#include <stdio.h>
++
++extern void foo (void);
++
++void
++foo (void)
++{
++  printf ("DSO\n");
++}
++
++void
++bar (void)
++{
++  foo ();
++}
diff --git a/debian/patches/204-hjl-binutils-tls-relro.dpatch b/debian/patches/204-hjl-binutils-tls-relro.dpatch
new file mode 100755 (executable)
index 0000000..9ab4ab6
--- /dev/null
@@ -0,0 +1,587 @@
+#!/bin/sh -e
+## 204-hjl-binutils-tls-relro.dpatch
+##
+## DP: Description: PR binutils/3281; objcopy changes PT_GNU_RELRO when there is PT_TLS
+## DP: Author: H.J. Lu  <hongjiu.lu@intel.com>
+## DP: Upstream status: hjl 2.17.50.0.18
+## DP: Original patch: binutils-tls-relro-14.patch
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+bfd/
+
+2007-01-23  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/3281
+       * elf-bfd.h (elf_obj_tdata): Remove relro.
+
+       * elf.c (get_program_header_size): Check info->relro instead
+       of elf_tdata (abfd)->relro.
+       (_bfd_elf_map_sections_to_segments): Likewise.
+       (assign_file_positions_for_load_sections): Don't set
+       PT_GNU_RELRO segment alignment here.
+       (assign_file_positions_for_non_load_sections): Properly set up
+       PT_GNU_RELRO segment for copying executable/shared library.
+       (elf_section_status): New enum.
+       (rewrite_elf_program_header): Add elf_section_status. Remove
+       PT_GNU_RELRO segment if a section is modified.
+       (copy_private_bfd_data): Updated rewrite_elf_program_header
+       call.
+
+include/elf/
+
+2006-10-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/3281
+       * internal.h (ELF_IS_SECTION_IN_SEGMENT): Allow SHF_TLS
+       sections in PT_GNU_RELRO segments.
+
+ld/
+
+2006-10-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/3281
+       * ldexp.h (ldexp_control): Add relro, relro_start_stat and
+       relro_end_stat.
+
+       * ldexp.c (fold_binary): Set expld.dataseg.relro to
+       exp_dataseg_relro_start or exp_dataseg_relro_end when
+       seeing DATA_SEGMENT_ALIGN or DATA_SEGMENT_RELRO_END,
+       respectively.
+
+       * ldlang.c (lang_size_sections_1): Properly set
+       expld.dataseg.relro_start_stat and
+       expld.dataseg.relro_end_stat.
+       (find_relro_section_callback): New function.
+       (lang_find_relro_sections_1): Likewise.
+       (lang_find_relro_sections): Likewise.
+       (lang_process): Call lang_find_relro_sections for
+       non-relocatable link.
+
+ld/testsuite/
+
+2006-10-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/3281
+       * ld-elf/binutils.exp: Update "-z relro" tests to use relro.s.
+       Add "-z relro" tests with TLS for objcopy.
+
+       * ld-elf/relro.s: New file.
+
+@DPATCH@
+diff -urNad binutils-2.18~cvs20070812~/bfd/elf-bfd.h binutils-2.18~cvs20070812/bfd/elf-bfd.h
+--- binutils-2.18~cvs20070812~/bfd/elf-bfd.h   2007-08-04 18:31:00.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf-bfd.h    2007-08-12 13:31:23.000000000 +0200
+@@ -1428,9 +1428,6 @@
+   /* Segment flags for the PT_GNU_STACK segment.  */
+   unsigned int stack_flags;
+-  /* Should the PT_GNU_RELRO segment be emitted?  */
+-  bfd_boolean relro;
+-
+   /* Symbol version definitions in external objects.  */
+   Elf_Internal_Verdef *verdef;
+diff -urNad binutils-2.18~cvs20070812~/bfd/elf.c binutils-2.18~cvs20070812/bfd/elf.c
+--- binutils-2.18~cvs20070812~/bfd/elf.c       2007-08-07 02:06:14.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf.c        2007-08-12 13:31:23.000000000 +0200
+@@ -3321,7 +3321,7 @@
+       /* We need a PT_DYNAMIC segment.  */
+       ++segs;
+-      if (elf_tdata (abfd)->relro)
++      if (info->relro)
+       {
+         /* We need a PT_GNU_RELRO segment only when there is a
+            PT_DYNAMIC segment.  */
+@@ -3848,7 +3848,7 @@
+         pm = &m->next;
+       }
+-      if (dynsec != NULL && elf_tdata (abfd)->relro)
++      if (dynsec != NULL && info->relro)
+       {
+         /* We make a PT_GNU_RELRO segment only when there is a
+            PT_DYNAMIC segment.  */
+@@ -4323,12 +4323,10 @@
+                   p->p_memsz += this_hdr->sh_size;
+               }
+-            if (p->p_type == PT_GNU_RELRO)
+-              p->p_align = 1;
+-            else if (align > p->p_align
+-                     && !m->p_align_valid
+-                     && (p->p_type != PT_LOAD
+-                         || (abfd->flags & D_PAGED) == 0))
++            if (align > p->p_align
++                && !m->p_align_valid
++                && (p->p_type != PT_LOAD
++                    || (abfd->flags & D_PAGED) == 0))
+               p->p_align = align;
+           }
+@@ -4477,18 +4475,53 @@
+       if (m->count != 0)
+       {
+         if (p->p_type != PT_LOAD
+-            && (p->p_type != PT_NOTE || bfd_get_format (abfd) != bfd_core))
++            && (p->p_type != PT_NOTE
++                || bfd_get_format (abfd) != bfd_core))
+           {
+             Elf_Internal_Shdr *hdr;
++            asection *sect;
++
+             BFD_ASSERT (!m->includes_filehdr && !m->includes_phdrs);
+-            hdr = &elf_section_data (m->sections[m->count - 1])->this_hdr;
+-            p->p_filesz = (m->sections[m->count - 1]->filepos
+-                           - m->sections[0]->filepos);
++            sect = m->sections[m->count - 1];
++            hdr = &elf_section_data (sect)->this_hdr;
++            p->p_filesz = sect->filepos - m->sections[0]->filepos;
+             if (hdr->sh_type != SHT_NOBITS)
+               p->p_filesz += hdr->sh_size;
+-            p->p_offset = m->sections[0]->filepos;
++            if (p->p_type == PT_GNU_RELRO)
++              {
++                /* When we get here, we are copying executable
++                   or shared library. But we need to use the same
++                   linker logic.  */
++                Elf_Internal_Phdr *lp;
++
++                for (lp = phdrs; lp < phdrs + count; ++lp)
++                  {
++                    if (lp->p_type == PT_LOAD
++                        && lp->p_paddr == p->p_paddr)
++                      break;
++                  }
++        
++                if (lp < phdrs + count)
++                  {
++                    /* The end of PT_GNU_RELRO segment is the next
++                       SEC_ALLOC section after it if it exists.  */
++                    if (sect->next != NULL
++                        && (sect->next->flags & SEC_ALLOC) != 0)
++                      p->p_filesz = sect->next->lma - lp->p_vaddr;
++                    else
++                      p->p_filesz += p->p_vaddr - lp->p_vaddr;
++                    p->p_vaddr = lp->p_vaddr;
++                    p->p_offset = lp->p_offset;
++                    p->p_memsz = p->p_filesz;
++                    p->p_align = 1;
++                  }
++                else
++                  abort ();
++              }
++            else
++              p->p_offset = m->sections[0]->filepos;
+           }
+       }
+       else
+@@ -4923,8 +4956,17 @@
+ /* Rewrite program header information.  */
++enum elf_section_status
++{
++  unknown,
++  added,
++  removed,
++  modified
++};
++
+ static bfd_boolean
+-rewrite_elf_program_header (bfd *ibfd, bfd *obfd)
++rewrite_elf_program_header (bfd *ibfd, bfd *obfd,
++                          enum elf_section_status status)
+ {
+   Elf_Internal_Ehdr *iehdr;
+   struct elf_segment_map *map;
+@@ -5077,7 +5119,14 @@
+           }
+       if (segment->p_type != PT_LOAD)
+-      continue;
++      {
++        /* If a section is added or mofied, remove PT_GNU_RELRO
++           segment.  */
++        if (status != removed &&
++            segment->p_type == PT_GNU_RELRO)
++          segment->p_type = PT_NULL;
++        continue;
++      }
+       /* Determine if this segment overlaps any previous segments.  */
+       for (j = 0, segment2 = elf_tdata (ibfd)->phdr; j < i; j++, segment2 ++)
+@@ -5657,6 +5706,12 @@
+ static bfd_boolean
+ copy_private_bfd_data (bfd *ibfd, bfd *obfd)
+ {
++  enum elf_section_status status;
++  Elf_Internal_Phdr *segment;
++  asection *section, *osec;
++  unsigned int i, num_segments;
++  Elf_Internal_Shdr *this_hdr;
++
+   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+     return TRUE;
+@@ -5664,16 +5719,13 @@
+   if (elf_tdata (ibfd)->phdr == NULL)
+     return TRUE;
++  status = unknown;
+   if (ibfd->xvec == obfd->xvec)
+     {
+-      /* Check to see if any sections in the input BFD
+-       covered by ELF program header have changed.  */
+-      Elf_Internal_Phdr *segment;
+-      asection *section, *osec;
+-      unsigned int i, num_segments;
+-      Elf_Internal_Shdr *this_hdr;
++      /* Check to see if any sections in the input BFD covered by ELF
++       program header have changed.
+-      /* Initialize the segment mark field.  */
++       Initialize the segment mark field.  */
+       for (section = obfd->sections; section != NULL;
+          section = section->next)
+       section->segment_mark = FALSE;
+@@ -5725,7 +5777,10 @@
+          section = section->next)
+       {
+         if (section->segment_mark == FALSE)
+-          goto rewrite;
++          { 
++            status = added;
++            goto rewrite;
++          }
+         else
+           section->segment_mark = FALSE;
+       }
+@@ -5734,7 +5789,42 @@
+     }
+ rewrite:
+-  return rewrite_elf_program_header (ibfd, obfd);
++  if (status == unknown)
++    {
++      /* We need to find out how we are changed.  */
++      num_segments = elf_elfheader (ibfd)->e_phnum;
++      for (i = 0, segment = elf_tdata (ibfd)->phdr;
++         i < num_segments;
++         i++, segment++)
++      {
++        for (section = ibfd->sections;
++             section != NULL; section = section->next)
++          {
++            osec = section->output_section;
++
++            /* Check if this section is covered by the segment.  */
++            this_hdr = &(elf_section_data(section)->this_hdr);
++            if (ELF_IS_SECTION_IN_SEGMENT_FILE (this_hdr, segment))
++              {
++                if (osec == NULL)
++                  status = removed;
++                else if (section->flags != osec->flags
++                         || section->lma != osec->lma
++                         || section->vma != osec->vma
++                         || section->size != osec->size
++                         || section->rawsize != osec->rawsize
++                         || section->alignment_power != osec->alignment_power)
++                  {
++                    /* Stop if a section is modified.  */
++                    status = modified;
++                    break;
++                  }
++              }
++          }
++      }
++    }
++  BFD_ASSERT (status != unknown);
++  return rewrite_elf_program_header (ibfd, obfd, status);
+ }
+ /* Initialize private output section information from input section.  */
+diff -urNad binutils-2.18~cvs20070812~/bfd/elflink.c binutils-2.18~cvs20070812/bfd/elflink.c
+--- binutils-2.18~cvs20070812~/bfd/elflink.c   2007-08-12 13:30:46.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elflink.c    2007-08-12 13:31:23.000000000 +0200
+@@ -5364,7 +5364,6 @@
+     return TRUE;
+   bed = get_elf_backend_data (output_bfd);
+-  elf_tdata (output_bfd)->relro = info->relro;
+   if (info->execstack)
+     elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
+   else if (info->noexecstack)
+diff -urNad binutils-2.18~cvs20070812~/include/elf/internal.h binutils-2.18~cvs20070812/include/elf/internal.h
+--- binutils-2.18~cvs20070812~/include/elf/internal.h  2007-05-02 15:44:36.000000000 +0200
++++ binutils-2.18~cvs20070812/include/elf/internal.h   2007-08-12 13:31:23.000000000 +0200
+@@ -266,11 +266,12 @@
+      || segment->p_type == PT_TLS) ? sec_hdr->sh_size : 0)
+ /* Decide if the given sec_hdr is in the given segment.  PT_TLS segment
+-   contains only SHF_TLS sections.  Only PT_LOAD and PT_TLS segments
+-   can contain SHF_TLS sections.  */
++   contains only SHF_TLS sections.  Only PT_LOAD, PT_GNU_RELRO and
++   and PT_TLS segments can contain SHF_TLS sections.  */
+ #define ELF_IS_SECTION_IN_SEGMENT(sec_hdr, segment)                   \
+   (((((sec_hdr->sh_flags & SHF_TLS) != 0)                             \
+      && (segment->p_type == PT_TLS                                    \
++       || segment->p_type == PT_GNU_RELRO                             \
+        || segment->p_type == PT_LOAD))                                \
+     || ((sec_hdr->sh_flags & SHF_TLS) == 0                            \
+       && segment->p_type != PT_TLS))                                  \
+diff -urNad binutils-2.18~cvs20070812~/ld/ldexp.c binutils-2.18~cvs20070812/ld/ldexp.c
+--- binutils-2.18~cvs20070812~/ld/ldexp.c      2007-07-06 16:09:41.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/ldexp.c       2007-08-12 13:31:23.000000000 +0200
+@@ -390,6 +390,7 @@
+             break;
+           case DATA_SEGMENT_ALIGN:
++            expld.dataseg.relro = exp_dataseg_relro_start;
+             if (expld.phase != lang_first_phase_enum
+                 && expld.section == bfd_abs_section_ptr
+                 && (expld.dataseg.phase == exp_dataseg_none
+@@ -425,6 +426,7 @@
+             break;
+           case DATA_SEGMENT_RELRO_END:
++            expld.dataseg.relro = exp_dataseg_relro_end;
+             if (expld.phase != lang_first_phase_enum
+                 && (expld.dataseg.phase == exp_dataseg_align_seen
+                     || expld.dataseg.phase == exp_dataseg_adjust
+diff -urNad binutils-2.18~cvs20070812~/ld/ldexp.h binutils-2.18~cvs20070812/ld/ldexp.h
+--- binutils-2.18~cvs20070812~/ld/ldexp.h      2007-07-06 16:09:41.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/ldexp.h       2007-08-12 13:31:23.000000000 +0200
+@@ -98,6 +98,8 @@
+   lang_final_phase_enum
+ } lang_phase_type;
++union lang_statement_union;
++
+ struct ldexp_control {
+   /* Modify expression evaluation depending on this.  */
+   lang_phase_type phase;
+@@ -125,6 +127,15 @@
+     } phase;
+     bfd_vma base, min_base, relro_end, end, pagesize, maxpagesize;
++
++    enum {
++      exp_dataseg_relro_none,
++      exp_dataseg_relro_start,
++      exp_dataseg_relro_end,
++    } relro;
++
++    union lang_statement_union *relro_start_stat;
++    union lang_statement_union *relro_end_stat;
+   } dataseg;
+ };
+diff -urNad binutils-2.18~cvs20070812~/ld/ldlang.c binutils-2.18~cvs20070812/ld/ldlang.c
+--- binutils-2.18~cvs20070812~/ld/ldlang.c     2007-07-29 14:33:37.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/ldlang.c      2007-08-12 13:31:23.000000000 +0200
+@@ -4631,10 +4631,32 @@
+           bfd_vma newdot = dot;
+           etree_type *tree = s->assignment_statement.exp;
++          expld.dataseg.relro = exp_dataseg_relro_none;
++
+           exp_fold_tree (tree,
+                          output_section_statement->bfd_section,
+                          &newdot);
++          if (expld.dataseg.relro == exp_dataseg_relro_start)
++            {
++              if (!expld.dataseg.relro_start_stat)
++                expld.dataseg.relro_start_stat = s;
++              else
++                {
++                  ASSERT (expld.dataseg.relro_start_stat == s);
++                }
++            }
++          else if (expld.dataseg.relro == exp_dataseg_relro_end)
++            {
++              if (!expld.dataseg.relro_end_stat)
++                expld.dataseg.relro_end_stat = s;
++              else
++                {
++                  ASSERT (expld.dataseg.relro_end_stat == s);
++                }
++            }
++          expld.dataseg.relro = exp_dataseg_relro_none;
++
+           /* This symbol is relative to this section.  */
+           if ((tree->type.node_class == etree_provided
+                || tree->type.node_class == etree_assign)
+@@ -5660,6 +5682,81 @@
+     bfd_gc_sections (output_bfd, &link_info);
+ }
++/* Worker for lang_find_relro_sections_1.  */
++
++static void
++find_relro_section_callback (lang_wild_statement_type *ptr ATTRIBUTE_UNUSED,
++                           struct wildcard_list *sec ATTRIBUTE_UNUSED,
++                           asection *section,
++                           lang_input_statement_type *file ATTRIBUTE_UNUSED,
++                           void *data)
++{
++  /* Discarded, excluded and ignored sections effectively have zero
++     size.  */
++  if (section->output_section != NULL
++      && section->output_section->owner == output_bfd
++      && (section->output_section->flags & SEC_EXCLUDE) == 0
++      && !IGNORE_SECTION (section)
++      && section->size != 0)
++    {
++      bfd_boolean *has_relro_section = (bfd_boolean *) data;
++      *has_relro_section = TRUE;
++    }
++}
++
++/* Iterate over sections for relro sections.  */
++
++static void
++lang_find_relro_sections_1 (lang_statement_union_type *s,
++                          bfd_boolean *has_relro_section)
++{
++  if (*has_relro_section)
++    return;
++
++  for (; s != NULL; s = s->header.next)
++    {
++      if (s == expld.dataseg.relro_end_stat)
++      break;
++
++      switch (s->header.type)
++      {
++      case lang_wild_statement_enum:
++        walk_wild (&s->wild_statement,
++                   find_relro_section_callback,
++                   has_relro_section);
++        break;
++      case lang_constructors_statement_enum:
++        lang_find_relro_sections_1 (constructor_list.head,
++                                    has_relro_section);
++        break;
++      case lang_output_section_statement_enum:
++        lang_find_relro_sections_1 (s->output_section_statement.children.head,
++                                    has_relro_section);
++        break;
++      case lang_group_statement_enum:
++        lang_find_relro_sections_1 (s->group_statement.children.head,
++                                    has_relro_section);
++        break;
++      default:
++        break;
++      }
++    }
++}
++
++static void
++lang_find_relro_sections (void)
++{
++  bfd_boolean has_relro_section = FALSE;
++
++  /* Check all sections in the link script.  */
++
++  lang_find_relro_sections_1 (expld.dataseg.relro_start_stat,
++                            &has_relro_section);
++
++  if (!has_relro_section)
++    link_info.relro = FALSE;
++}
++
+ /* Relax all sections until bfd_relax_section gives up.  */
+ static void
+@@ -5787,6 +5884,10 @@
+      section positions, since they will affect SIZEOF_HEADERS.  */
+   lang_record_phdrs ();
++  /* Check relro sections.  */
++  if (link_info.relro && ! link_info.relocatable)
++    lang_find_relro_sections ();
++
+   /* Size up the sections.  */
+   lang_size_sections (NULL, !command_line.relax);
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/binutils.exp binutils-2.18~cvs20070812/ld/testsuite/ld-elf/binutils.exp
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/binutils.exp        2007-07-06 16:09:43.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/binutils.exp 2007-08-12 13:31:23.000000000 +0200
+@@ -104,24 +104,33 @@
+ binutils_test objcopy "" maxpage1
+ binutils_test objcopy "-shared" maxpage1
+-binutils_test strip "-z relro" maxpage1
+-binutils_test strip "-z relro -shared" maxpage1
+-binutils_test objcopy "-z relro" maxpage1
+-binutils_test objcopy "-z relro -shared" maxpage1
++binutils_test strip "-z relro" relro
++binutils_test strip "-z relro -shared" relro
++binutils_test objcopy "-z relro" relro
++binutils_test objcopy "-z relro -shared" relro
+ binutils_test objcopy "" tbss1
++binutils_test objcopy "-z relro" tbss1
+ binutils_test objcopy "-shared" tbss1
++binutils_test objcopy "-shared -z relro" tbss1
+ binutils_test objcopy "-z max-page-size=0x100000" tbss1
+ binutils_test objcopy "-z max-page-size=0x100000 -z common-page-size=0x1000" tbss1
+ binutils_test objcopy "" tdata1
++binutils_test objcopy "-z relro" tdata1
+ binutils_test objcopy "-shared" tdata1
++binutils_test objcopy "-shared -z relro" tdata1
+ binutils_test objcopy "-z max-page-size=0x100000" tdata1
+ binutils_test objcopy "-z max-page-size=0x100000 -z common-page-size=0x1000" tdata1
+ binutils_test objcopy "" tbss2
++binutils_test objcopy "-z relro" tbss2
+ binutils_test objcopy "-shared" tbss2
++binutils_test objcopy "-shared -z relro" tbss2
+ binutils_test objcopy "-z max-page-size=0x100000" tbss2
+ binutils_test objcopy "-z max-page-size=0x100000 -z common-page-size=0x1000" tbss2
+-binutils_test objcopy "-z max-page-size=0x100000" tdata2
++
+ binutils_test objcopy "" tdata2
++binutils_test objcopy "-z relro" tdata2
+ binutils_test objcopy "-shared" tdata2
++binutils_test objcopy "-shared -z relro" tdata2
++binutils_test objcopy "-z max-page-size=0x100000" tdata2
+ binutils_test objcopy "-z max-page-size=0x100000 -z common-page-size=0x1000" tdata2
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/relro.s binutils-2.18~cvs20070812/ld/testsuite/ld-elf/relro.s
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/relro.s     1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/relro.s      2007-08-12 13:31:23.000000000 +0200
+@@ -0,0 +1,14 @@
++      .globl main
++      .globl start
++      .globl _start
++      .globl __start
++      .text
++main:
++start:
++_start:
++__start:
++      .long   0
++      .data
++      .long   0
++      .section .data.rel.ro,"aw",%progbits
++      .long   0
diff --git a/debian/patches/206-hjl-binutils-shr.dpatch b/debian/patches/206-hjl-binutils-shr.dpatch
new file mode 100644 (file)
index 0000000..fac5ecc
--- /dev/null
@@ -0,0 +1,1235 @@
+#!/bin/sh -e
+## 206-hjl-binutils-shr.dpatch
+##
+## DP: Description: implementation of ELF sharable section proposal
+## DP: Author: H.J. Lu  <hongjiu.lu@intel.com>
+## DP: Upstream status: hjl 2.17.50.0.18
+## DP: Original patch: binutils-shr-82.patch
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+http://groups.google.com/group/generic-abi/browse_thread/thread/f7b3e06417ead85a
+http://groups.google.com/group/generic-abi/browse_thread/thread/bca08f6560f61b0d
+
+bfd/
+
+2007-01-23  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * 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  <hongjiu.lu@intel.com>
+
+       * 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  <hongjiu.lu@intel.com>
+
+       * 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  <hongjiu.lu@intel.com>
+
+       * bfdlink.h (bfd_link_info): Add sharable_sections.
+
+include/elf/
+
+2007-01-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * common.h (PT_GNU_SHR): New.
+       (SHF_GNU_SHARABLE): Likewise.
+       (SHN_GNU_SHARABLE_COMMON): Likewise.
+
+ld/
+
+2007-01-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * 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.
+
+@DPATCH@
+diff -urNad binutils-2.18~cvs20070812~/bfd/elf-bfd.h binutils-2.18~cvs20070812/bfd/elf-bfd.h
+--- binutils-2.18~cvs20070812~/bfd/elf-bfd.h   2007-08-12 13:32:34.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf-bfd.h    2007-08-12 13:32:59.000000000 +0200
+@@ -1929,6 +1929,28 @@
+   (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 -urNad binutils-2.18~cvs20070812~/bfd/elf.c binutils-2.18~cvs20070812/bfd/elf.c
+--- binutils-2.18~cvs20070812~/bfd/elf.c       2007-08-12 13:32:34.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf.c        2007-08-12 13:32:59.000000000 +0200
+@@ -1992,6 +1992,8 @@
+   { 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 }
+ };
+@@ -2046,6 +2048,8 @@
+   /* 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 }
+ };
+@@ -3374,6 +3378,32 @@
+       }
+     }
++  /* 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)
+@@ -3514,6 +3544,8 @@
+       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;
+@@ -3785,6 +3817,22 @@
+               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.  */
+@@ -3814,6 +3862,60 @@
+         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 i;
++
++        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 (i = 0; i < sharable_data_count; ++i)
++          {
++            m->sections[i] = 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 i;
++
++        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 (i = 0; i < sharable_bss_count; ++i)
++          {
++            m->sections[i] = 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;
+@@ -4247,6 +4349,7 @@
+         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)
+           {
+             bfd_signed_vma adjust = sec->lma - (p->p_paddr + p->p_memsz);
+diff -urNad binutils-2.18~cvs20070812~/bfd/elf32-i386.c binutils-2.18~cvs20070812/bfd/elf32-i386.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-i386.c        2007-07-27 20:50:18.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-i386.c 2007-08-12 13:32:59.000000000 +0200
+@@ -661,6 +661,8 @@
+   asection *srelplt;
+   asection *sdynbss;
+   asection *srelbss;
++  asection *sdynsharablebss;
++  asection *srelsharablebss;
+   /* The (unloaded but important) .rel.plt.unloaded section on VxWorks.  */
+   asection *srelplt2;
+@@ -753,6 +755,8 @@
+   ret->srelplt = NULL;
+   ret->sdynbss = NULL;
+   ret->srelbss = NULL;
++  ret->sdynsharablebss = NULL;
++  ret->srelsharablebss = NULL;
+   ret->tls_ldm_got.refcount = 0;
+   ret->next_tls_desc_index = 0;
+   ret->sgotplt_jump_table_size = 0;
+@@ -813,10 +817,19 @@
+   htab->srelplt = bfd_get_section_by_name (dynobj, ".rel.plt");
+   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->splt || !htab->srelplt || !htab->sdynbss
+-      || (!info->shared && !htab->srelbss))
++      || (!info->shared
++        && (!htab->srelbss
++            || !htab->sdynsharablebss
++            || !htab->srelsharablebss)))
+     abort ();
+   if (htab->is_vxworks
+@@ -1534,17 +1547,23 @@
+      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);
+ }
+@@ -1998,7 +2017,8 @@
+       if (s == htab->splt
+         || s == htab->sgot
+         || s == htab->sgotplt
+-        || s == htab->sdynbss)
++        || s == htab->sdynbss
++        || s == htab->sdynsharablebss)
+       {
+         /* Strip this section if we don't need it; see the
+            comment below.  */
+@@ -3536,21 +3556,27 @@
+     {
+       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);
+     }
+@@ -3838,6 +3864,21 @@
+ #define elf_backend_plt_sym_val                     elf_i386_plt_sym_val
+ #define elf_backend_hash_symbol                     elf_i386_hash_symbol
++#define elf_backend_add_symbol_hook \
++  _bfd_elf_add_sharable_symbol
++#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 -urNad binutils-2.18~cvs20070812~/bfd/elf64-x86-64.c binutils-2.18~cvs20070812/bfd/elf64-x86-64.c
+--- binutils-2.18~cvs20070812~/bfd/elf64-x86-64.c      2007-07-03 16:26:42.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf64-x86-64.c       2007-08-12 13:32:59.000000000 +0200
+@@ -470,6 +470,8 @@
+   asection *srelplt;
+   asection *sdynbss;
+   asection *srelbss;
++  asection *sdynsharablebss;
++  asection *srelsharablebss;
+   /* The offset into splt of the PLT entry for the TLS descriptor
+      resolver.  Special values are 0, if not necessary (or not found
+@@ -557,6 +559,8 @@
+   ret->srelplt = NULL;
+   ret->sdynbss = NULL;
+   ret->srelbss = NULL;
++  ret->sdynsharablebss = NULL;
++  ret->srelsharablebss = NULL;
+   ret->sym_sec.abfd = NULL;
+   ret->tlsdesc_plt = 0;
+   ret->tlsdesc_got = 0;
+@@ -615,10 +619,19 @@
+   htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
+   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->splt || !htab->srelplt || !htab->sdynbss
+-      || (!info->shared && !htab->srelbss))
++      || (!info->shared
++        && (!htab->srelbss
++            || !htab->sdynsharablebss
++            || !htab->srelsharablebss)))
+     abort ();
+   return TRUE;
+@@ -1396,17 +1409,23 @@
+   htab = elf64_x86_64_hash_table (info);
++  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.  */
+   if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+     {
+-      htab->srelbss->size += sizeof (Elf64_External_Rela);
++      if (elf_section_flags (h->root.u.def.section) & SHF_GNU_SHARABLE)
++      {
++        htab->srelsharablebss->size += sizeof (Elf64_External_Rela);
++        s = htab->sdynsharablebss;
++      }
++      else
++      htab->srelbss->size += sizeof (Elf64_External_Rela);
+       h->needs_copy = 1;
+     }
+-  s = htab->sdynbss;
+-
+   return _bfd_elf_adjust_dynamic_copy (h, s);
+ }
+@@ -1854,7 +1873,8 @@
+       if (s == htab->splt
+         || s == htab->sgot
+         || s == htab->sgotplt
+-        || s == htab->sdynbss)
++        || s == htab->sdynbss
++        || s == htab->sdynsharablebss)
+       {
+         /* Strip this section if we don't need it; see the
+            comment below.  */
+@@ -3193,13 +3213,19 @@
+     {
+       Elf_Internal_Rela rela;
+       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 ();
+       rela.r_offset = (h->root.u.def.value
+@@ -3207,8 +3233,8 @@
+                      + h->root.u.def.section->output_offset);
+       rela.r_info = ELF64_R_INFO (h->dynindx, R_X86_64_COPY);
+       rela.r_addend = 0;
+-      loc = htab->srelbss->contents;
+-      loc += htab->srelbss->reloc_count++ * sizeof (Elf64_External_Rela);
++      loc = s->contents;
++      loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
+       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
+     }
+@@ -3472,9 +3498,12 @@
+       }
+       *secp = lcomm;
+       *valp = sym->st_size;
++      return TRUE;
+       break;
+     }
+-  return TRUE;
++
++  return _bfd_elf_add_sharable_symbol (abfd, info, sym, namep, flagsp,
++                                     secp, valp);
+ }
+@@ -3490,7 +3519,7 @@
+       *index = SHN_X86_64_LCOMMON;
+       return TRUE;
+     }
+-  return FALSE;
++  return _bfd_elf_sharable_section_from_bfd_section (abfd, sec, index);
+ }
+ /* Process a symbol.  */
+@@ -3508,22 +3537,26 @@
+       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
+ elf64_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
+ elf64_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;
+ }
+@@ -3532,7 +3565,7 @@
+ elf64_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;
+ }
+@@ -3569,7 +3602,8 @@
+       && 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)
+@@ -3577,13 +3611,26 @@
+         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 -urNad binutils-2.18~cvs20070812~/bfd/elflink.c binutils-2.18~cvs20070812/bfd/elflink.c
+--- binutils-2.18~cvs20070812~/bfd/elflink.c   2007-08-12 13:32:34.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elflink.c    2007-08-12 13:32:59.000000000 +0200
+@@ -353,6 +353,27 @@
+         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;
++          }
+       }
+     }
+@@ -12319,3 +12340,219 @@
+ {
+   return bfd_com_section_ptr;
+ }
++
++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)
++{
++  if (sec == &_bfd_elf_sharable_com_section)
++    {
++      *index = 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 -urNad binutils-2.18~cvs20070812~/bfd/elfxx-ia64.c binutils-2.18~cvs20070812/bfd/elfxx-ia64.c
+--- binutils-2.18~cvs20070812~/bfd/elfxx-ia64.c        2007-07-03 16:26:42.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elfxx-ia64.c 2007-08-12 13:32:59.000000000 +0200
+@@ -1637,7 +1637,8 @@
+       *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.  */
+@@ -5901,6 +5902,19 @@
+ #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 -urNad binutils-2.18~cvs20070812~/binutils/readelf.c binutils-2.18~cvs20070812/binutils/readelf.c
+--- binutils-2.18~cvs20070812~/binutils/readelf.c      2007-07-27 02:48:30.000000000 +0200
++++ binutils-2.18~cvs20070812/binutils/readelf.c       2007-08-12 13:32:59.000000000 +0200
+@@ -1266,6 +1266,8 @@
+                       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)
+                       sec_name = "SCOMMON";
+@@ -2464,6 +2466,7 @@
+     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";
+@@ -6971,6 +6974,8 @@
+     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 -urNad binutils-2.18~cvs20070812~/gas/config/obj-elf.c binutils-2.18~cvs20070812/gas/config/obj-elf.c
+--- binutils-2.18~cvs20070812~/gas/config/obj-elf.c    2007-07-03 13:01:04.000000000 +0200
++++ binutils-2.18~cvs20070812/gas/config/obj-elf.c     2007-08-12 13:32:59.000000000 +0200
+@@ -73,6 +73,7 @@
+ 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 @@
+   {"tls_common", obj_elf_tls_common, 0},
++  {"sharable_common", obj_elf_sharable_common, 0},
++
+   /* End sentinel.  */
+   {NULL, NULL, 0},
+ };
+@@ -374,6 +377,39 @@
+ }
+ 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);
+@@ -587,11 +623,17 @@
+                .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 -urNad binutils-2.18~cvs20070812~/include/bfdlink.h binutils-2.18~cvs20070812/include/bfdlink.h
+--- binutils-2.18~cvs20070812~/include/bfdlink.h       2007-07-09 23:21:42.000000000 +0200
++++ binutils-2.18~cvs20070812/include/bfdlink.h        2007-08-12 13:32:59.000000000 +0200
+@@ -351,6 +351,9 @@
+   /* 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 -urNad binutils-2.18~cvs20070812~/include/elf/common.h binutils-2.18~cvs20070812/include/elf/common.h
+--- binutils-2.18~cvs20070812~/include/elf/common.h    2007-07-09 23:17:42.000000000 +0200
++++ binutils-2.18~cvs20070812/include/elf/common.h     2007-08-12 13:32:59.000000000 +0200
+@@ -309,6 +309,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.  */
+@@ -381,6 +382,8 @@
+ #define SHF_MASKOS    0x0FF00000      /* New value, Oct 4, 1999 Draft */
+ #define SHF_MASKPROC  0xF0000000      /* Processor-specific semantics */
++#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 */
+@@ -505,6 +508,9 @@
+ #define SHN_HIRESERVE 0xFFFF          /* End range of reserved indices */
+ #define SHN_BAD               ((unsigned) -1) /* Used internally by bfd */
++/* 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 -urNad binutils-2.18~cvs20070812~/ld/emulparams/elf64_ia64.sh binutils-2.18~cvs20070812/ld/emulparams/elf64_ia64.sh
+--- binutils-2.18~cvs20070812~/ld/emulparams/elf64_ia64.sh     2006-05-30 18:45:32.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/emulparams/elf64_ia64.sh      2007-08-12 13:32:59.000000000 +0200
+@@ -37,3 +37,4 @@
+ # .dtors.  They have to be next to .sbss/.sbss2/.sdata/.sdata2.
+ SMALL_DATA_CTOR=" "
+ SMALL_DATA_DTOR=" "
++SHARABLE_SECTIONS=yes
+diff -urNad binutils-2.18~cvs20070812~/ld/emulparams/elf_i386.sh binutils-2.18~cvs20070812/ld/emulparams/elf_i386.sh
+--- binutils-2.18~cvs20070812~/ld/emulparams/elf_i386.sh       2007-08-12 13:32:34.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/emulparams/elf_i386.sh        2007-08-12 13:33:45.000000000 +0200
+@@ -11,6 +11,7 @@
+ GENERATE_PIE_SCRIPT=yes
+ NO_SMALL_DATA=yes
+ SEPARATE_GOTPLT=12
++SHARABLE_SECTIONS=yes
+ # Linux modify the default library search path to first include
+ # a 32-bit specific directory.
+diff -urNad binutils-2.18~cvs20070812~/ld/emulparams/elf_x86_64.sh binutils-2.18~cvs20070812/ld/emulparams/elf_x86_64.sh
+--- binutils-2.18~cvs20070812~/ld/emulparams/elf_x86_64.sh     2007-08-12 10:00:33.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/emulparams/elf_x86_64.sh      2007-08-12 13:32:59.000000000 +0200
+@@ -13,6 +13,7 @@
+ NO_SMALL_DATA=yes
+ LARGE_SECTIONS=yes
+ SEPARATE_GOTPLT=24
++SHARABLE_SECTIONS=yes
+ if [ "x${host}" = "x${target}" ]; then
+   case " $EMULATION_LIBPATH " in
+diff -urNad binutils-2.18~cvs20070812~/ld/emultempl/elf32.em binutils-2.18~cvs20070812/ld/emultempl/elf32.em
+--- binutils-2.18~cvs20070812~/ld/emultempl/elf32.em   2007-08-12 13:32:34.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/emultempl/elf32.em    2007-08-12 13:32:59.000000000 +0200
+@@ -101,6 +101,7 @@
+   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
+@@ -1679,6 +1680,12 @@
+   secname = bfd_get_section_name (s->owner, s);
++  /* 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 -urNad binutils-2.18~cvs20070812~/ld/ldmain.c binutils-2.18~cvs20070812/ld/ldmain.c
+--- binutils-2.18~cvs20070812~/ld/ldmain.c     2007-07-06 16:09:41.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/ldmain.c      2007-08-12 13:32:59.000000000 +0200
+@@ -275,6 +275,7 @@
+   link_info.relax_pass = 1;
+   link_info.pei386_auto_import = -1;
+   link_info.spare_dynamic_tags = 5;
++  link_info.sharable_sections = FALSE;
+   ldfile_add_arch ("");
+   emulation = get_emulation (argc, argv);
+diff -urNad binutils-2.18~cvs20070812~/ld/scripttempl/elf.sc binutils-2.18~cvs20070812/ld/scripttempl/elf.sc
+--- binutils-2.18~cvs20070812~/ld/scripttempl/elf.sc   2007-07-28 00:33:24.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/scripttempl/elf.sc    2007-08-12 13:32:59.000000000 +0200
+@@ -238,6 +238,40 @@
+     ${RELOCATING+_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.*}) }
++"
+ # if this is for an embedded system, don't add SIZEOF_HEADERS.
+ if [ -z "$EMBEDDED" ]; then
+@@ -308,6 +342,7 @@
+   .rel.got      ${RELOCATING-0} : { *(.rel.got) }
+   .rela.got     ${RELOCATING-0} : { *(.rela.got) }
+   ${OTHER_GOT_RELOC_SECTIONS}
++  ${REL_SHARABLE}
+   ${REL_SDATA}
+   ${REL_SBSS}
+   ${REL_SDATA2}
diff --git a/debian/patches/208-hjl-libtool-relink.dpatch b/debian/patches/208-hjl-libtool-relink.dpatch
new file mode 100644 (file)
index 0000000..d549ac3
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh -e
+## 208-hjl-libtool-relink.dpatch
+##
+## DP: Description: Avoid unnecessary linker messages when running "make check"
+## DP: Author: H.J. Lu  <hongjiu.lu@intel.com>
+## DP: Upstream status: hjl 2.17.50.0.13
+## DP: Original patch: libtool-relink-1.patch
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+2006-09-18  H.J. Lu <hjl@gnu.org>
+
+       * ltmain.sh (relink_command): Redirect all messages to
+       /dev/null to avoid unecessary linker messages for "make check".
+
+@DPATCH@
+--- ./ltmain.sh.patch  2006-09-18 10:07:59.000000000 -0700
++++ ./ltmain.sh        2006-09-18 10:49:50.000000000 -0700
+@@ -3990,7 +3997,7 @@ sed_quote_subst='$sed_quote_subst'
+ # if CDPATH is set.
+ if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
+-relink_command=\"$relink_command\"
++relink_command=\"$relink_command > /dev/null 2>&1\"
+ # This environment variable determines our operation mode.
+ if test \"\$libtool_install_magic\" = \"$magic\"; then
diff --git a/debian/patches/209-hjl-binutils-error.dpatch b/debian/patches/209-hjl-binutils-error.dpatch
new file mode 100755 (executable)
index 0000000..9a768c9
--- /dev/null
@@ -0,0 +1,1010 @@
+#!/bin/sh -e
+## 209-hjl-binutils-error.dpatch
+##
+## DP: Description: Avoid unnecessary linker messages when running "make check"
+## DP: Author: H.J. Lu  <hongjiu.lu@intel.com>
+## DP: Upstream status: hjl 2.17.50.0.18
+## DP: Original patch: binutils-error-3.patch
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+bfd/
+
+2007-05-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       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-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-m68hc1x.c (elf32_m68hc11_relocate_section): Likewise.
+       * elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+       * elf32-mcore.c (mcore_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-s390.c (elf_s390_relocate_section): Likewise.
+       * elf32-spu.c (spu_elf_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/testsuite/
+
+2007-05-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/4409
+       * ld-ia64/error1.d: New file.
+       * ld-ia64/error1.s: Likewise.
+
+@DPATCH@
+diff -urNad binutils-2.18~cvs20070812~/bfd/elf-bfd.h binutils-2.18~cvs20070812/bfd/elf-bfd.h
+--- binutils-2.18~cvs20070812~/bfd/elf-bfd.h   2007-08-12 13:36:50.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf-bfd.h    2007-08-12 13:37:05.000000000 +0200
+@@ -2064,7 +2064,7 @@
+ #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               \
+@@ -2079,6 +2079,7 @@
+       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                               \
+@@ -2101,7 +2102,7 @@
+       ;                                                               \
+       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;                                              \
+diff -urNad binutils-2.18~cvs20070812~/bfd/elf-m10200.c binutils-2.18~cvs20070812/bfd/elf-m10200.c
+--- binutils-2.18~cvs20070812~/bfd/elf-m10200.c        2007-07-03 16:26:40.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf-m10200.c 2007-08-12 13:37:05.000000000 +0200
+@@ -392,12 +392,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf-m10300.c binutils-2.18~cvs20070812/bfd/elf-m10300.c
+--- binutils-2.18~cvs20070812~/bfd/elf-m10300.c        2007-07-03 16:26:40.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf-m10300.c 2007-08-12 13:37:05.000000000 +0200
+@@ -1417,13 +1417,13 @@
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-arm.c binutils-2.18~cvs20070812/bfd/elf32-arm.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-arm.c 2007-08-06 20:47:21.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-arm.c  2007-08-12 13:37:05.000000000 +0200
+@@ -6398,12 +6398,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-avr.c binutils-2.18~cvs20070812/bfd/elf32-avr.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-avr.c 2007-07-03 16:26:40.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-avr.c  2007-08-12 13:37:05.000000000 +0200
+@@ -1204,12 +1204,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-bfin.c binutils-2.18~cvs20070812/bfd/elf32-bfin.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-bfin.c        2007-07-03 16:26:40.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-bfin.c 2007-08-12 13:37:05.000000000 +0200
+@@ -2197,13 +2197,13 @@
+       }
+       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;
+       }
+@@ -2895,12 +2895,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-cr16.c binutils-2.18~cvs20070812/bfd/elf32-cr16.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-cr16.c        2007-07-03 16:26:40.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-cr16.c 2007-08-12 13:37:05.000000000 +0200
+@@ -837,12 +837,12 @@
+         }
+       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);
+         }
+       r = cr16_elf_final_link_relocate (howto, input_bfd, output_bfd,
+diff -urNad binutils-2.18~cvs20070812~/bfd/elf32-cr16c.c binutils-2.18~cvs20070812/bfd/elf32-cr16c.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-cr16c.c       2007-07-03 16:26:40.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-cr16c.c        2007-08-12 13:37:05.000000000 +0200
+@@ -718,12 +718,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-cris.c binutils-2.18~cvs20070812/bfd/elf32-cris.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-cris.c        2007-07-03 16:26:40.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-cris.c 2007-08-12 13:37:05.000000000 +0200
+@@ -996,13 +996,13 @@
+       }
+       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);
+         if (unresolved_reloc
+             /* Perhaps we should detect the cases that
+diff -urNad binutils-2.18~cvs20070812~/bfd/elf32-crx.c binutils-2.18~cvs20070812/bfd/elf32-crx.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-crx.c 2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-crx.c  2007-08-12 13:37:05.000000000 +0200
+@@ -869,12 +869,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-d10v.c binutils-2.18~cvs20070812/bfd/elf32-d10v.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-d10v.c        2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-d10v.c 2007-08-12 13:37:05.000000000 +0200
+@@ -456,12 +456,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-fr30.c binutils-2.18~cvs20070812/bfd/elf32-fr30.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-fr30.c        2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-fr30.c 2007-08-12 13:37:05.000000000 +0200
+@@ -567,12 +567,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-frv.c binutils-2.18~cvs20070812/bfd/elf32-frv.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-frv.c 2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-frv.c  2007-08-12 13:37:05.000000000 +0200
+@@ -2813,13 +2813,13 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-h8300.c binutils-2.18~cvs20070812/bfd/elf32-h8300.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-h8300.c       2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-h8300.c        2007-08-12 13:37:05.000000000 +0200
+@@ -452,12 +452,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-hppa.c binutils-2.18~cvs20070812/bfd/elf32-hppa.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-hppa.c        2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-hppa.c 2007-08-12 13:37:05.000000000 +0200
+@@ -3676,13 +3676,14 @@
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-i386.c binutils-2.18~cvs20070812/bfd/elf32-i386.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-i386.c        2007-07-27 20:50:18.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-i386.c 2007-08-12 13:37:06.000000000 +0200
+@@ -2346,12 +2346,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-i860.c binutils-2.18~cvs20070812/bfd/elf32-i860.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-i860.c        2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-i860.c 2007-08-12 13:37:06.000000000 +0200
+@@ -1120,12 +1120,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-ip2k.c binutils-2.18~cvs20070812/bfd/elf32-ip2k.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-ip2k.c        2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-ip2k.c 2007-08-12 13:37:06.000000000 +0200
+@@ -1449,13 +1449,13 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-iq2000.c binutils-2.18~cvs20070812/bfd/elf32-iq2000.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-iq2000.c      2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-iq2000.c       2007-08-12 13:37:06.000000000 +0200
+@@ -586,12 +586,12 @@
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-m68hc1x.c binutils-2.18~cvs20070812/bfd/elf32-m68hc1x.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-m68hc1x.c     2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-m68hc1x.c      2007-08-12 13:37:06.000000000 +0200
+@@ -945,12 +945,12 @@
+       }
+       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));
+         stub_name = h->root.root.string;
+diff -urNad binutils-2.18~cvs20070812~/bfd/elf32-m68k.c binutils-2.18~cvs20070812/bfd/elf32-m68k.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-m68k.c        2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-m68k.c 2007-08-12 13:37:06.000000000 +0200
+@@ -1646,12 +1646,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-mcore.c binutils-2.18~cvs20070812/bfd/elf32-mcore.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-mcore.c       2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-mcore.c        2007-08-12 13:37:06.000000000 +0200
+@@ -458,12 +458,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-msp430.c binutils-2.18~cvs20070812/bfd/elf32-msp430.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-msp430.c      2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-msp430.c       2007-08-12 13:37:06.000000000 +0200
+@@ -450,12 +450,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-mt.c binutils-2.18~cvs20070812/bfd/elf32-mt.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-mt.c  2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-mt.c   2007-08-12 13:37:06.000000000 +0200
+@@ -344,12 +344,12 @@
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-openrisc.c binutils-2.18~cvs20070812/bfd/elf32-openrisc.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-openrisc.c    2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-openrisc.c     2007-08-12 13:37:06.000000000 +0200
+@@ -365,12 +365,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-ppc.c binutils-2.18~cvs20070812/bfd/elf32-ppc.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-ppc.c 2007-07-10 09:42:30.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-ppc.c  2007-08-12 13:37:06.000000000 +0200
+@@ -5718,10 +5718,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-s390.c binutils-2.18~cvs20070812/bfd/elf32-s390.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-s390.c        2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-s390.c 2007-08-12 13:37:06.000000000 +0200
+@@ -2311,11 +2311,12 @@
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-spu.c binutils-2.18~cvs20070812/bfd/elf32-spu.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-spu.c 2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-spu.c  2007-08-12 13:37:06.000000000 +0200
+@@ -2724,10 +2724,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-v850.c binutils-2.18~cvs20070812/bfd/elf32-v850.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-v850.c        2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-v850.c 2007-08-12 13:37:06.000000000 +0200
+@@ -1624,7 +1624,7 @@
+       }
+       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
+@@ -1641,7 +1641,7 @@
+         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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-vax.c binutils-2.18~cvs20070812/bfd/elf32-vax.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-vax.c 2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-vax.c  2007-08-12 13:37:06.000000000 +0200
+@@ -1415,12 +1415,12 @@
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-xc16x.c binutils-2.18~cvs20070812/bfd/elf32-xc16x.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-xc16x.c       2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-xc16x.c        2007-08-12 13:37:06.000000000 +0200
+@@ -374,12 +374,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-xstormy16.c binutils-2.18~cvs20070812/bfd/elf32-xstormy16.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-xstormy16.c   2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-xstormy16.c    2007-08-12 13:37:06.000000000 +0200
+@@ -821,12 +821,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf32-xtensa.c binutils-2.18~cvs20070812/bfd/elf32-xtensa.c
+--- binutils-2.18~cvs20070812~/bfd/elf32-xtensa.c      2007-07-18 23:06:06.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf32-xtensa.c       2007-08-12 13:37:06.000000000 +0200
+@@ -2055,10 +2055,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf64-alpha.c binutils-2.18~cvs20070812/bfd/elf64-alpha.c
+--- binutils-2.18~cvs20070812~/bfd/elf64-alpha.c       2007-07-10 06:08:11.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf64-alpha.c        2007-08-12 13:37:06.000000000 +0200
+@@ -4176,7 +4176,7 @@
+       }
+       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);
+@@ -4184,7 +4184,7 @@
+         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 -urNad binutils-2.18~cvs20070812~/bfd/elf64-mmix.c binutils-2.18~cvs20070812/bfd/elf64-mmix.c
+--- binutils-2.18~cvs20070812~/bfd/elf64-mmix.c        2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf64-mmix.c 2007-08-12 13:37:06.000000000 +0200
+@@ -1402,12 +1402,13 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf64-ppc.c binutils-2.18~cvs20070812/bfd/elf64-ppc.c
+--- binutils-2.18~cvs20070812~/bfd/elf64-ppc.c 2007-07-03 16:26:41.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf64-ppc.c  2007-08-12 13:37:06.000000000 +0200
+@@ -9900,10 +9900,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf64-s390.c binutils-2.18~cvs20070812/bfd/elf64-s390.c
+--- binutils-2.18~cvs20070812~/bfd/elf64-s390.c        2007-07-10 06:08:11.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf64-s390.c 2007-08-12 13:37:06.000000000 +0200
+@@ -2285,11 +2285,12 @@
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elf64-x86-64.c binutils-2.18~cvs20070812/bfd/elf64-x86-64.c
+--- binutils-2.18~cvs20070812~/bfd/elf64-x86-64.c      2007-07-03 16:26:42.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elf64-x86-64.c       2007-08-12 13:37:06.000000000 +0200
+@@ -2104,12 +2104,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elfxx-ia64.c binutils-2.18~cvs20070812/bfd/elfxx-ia64.c
+--- binutils-2.18~cvs20070812~/bfd/elfxx-ia64.c        2007-07-03 16:26:42.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elfxx-ia64.c 2007-08-12 13:37:06.000000000 +0200
+@@ -4741,17 +4741,17 @@
+       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 -urNad binutils-2.18~cvs20070812~/bfd/elfxx-sparc.c binutils-2.18~cvs20070812/bfd/elfxx-sparc.c
+--- binutils-2.18~cvs20070812~/bfd/elfxx-sparc.c       2007-07-03 16:26:42.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elfxx-sparc.c        2007-08-12 13:37:06.000000000 +0200
+@@ -2533,12 +2533,12 @@
+       }
+       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 -urNad binutils-2.18~cvs20070812~/ld/ldmain.c binutils-2.18~cvs20070812/ld/ldmain.c
+--- binutils-2.18~cvs20070812~/ld/ldmain.c     2007-07-06 16:09:41.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/ldmain.c      2007-08-12 13:37:06.000000000 +0200
+@@ -103,6 +103,9 @@
+ /* 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;
+@@ -348,6 +351,27 @@
+   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 -urNad binutils-2.18~cvs20070812~/ld/ldmain.h binutils-2.18~cvs20070812/ld/ldmain.h
+--- binutils-2.18~cvs20070812~/ld/ldmain.h     2007-07-06 16:09:41.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/ldmain.h      2007-08-12 13:37:06.000000000 +0200
+@@ -35,6 +35,7 @@
+ extern bfd_boolean as_needed;
+ extern bfd_boolean add_needed;
+ 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 -urNad binutils-2.18~cvs20070812~/ld/lexsup.c binutils-2.18~cvs20070812/ld/lexsup.c
+--- binutils-2.18~cvs20070812~/ld/lexsup.c     2007-07-06 16:09:41.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/lexsup.c      2007-08-12 13:37:06.000000000 +0200
+@@ -567,7 +567,6 @@
+   struct option *longopts;
+   struct option *really_longopts;
+   int last_optind;
+-  enum report_method how_to_report_unresolved_symbols = RM_GENERATE_ERROR;
+   shortopts = xmalloc (OPTION_COUNT * 3 + 2);
+   longopts = xmalloc (sizeof (*longopts) * (OPTION_COUNT + 1));
+@@ -1113,12 +1112,7 @@
+         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"));
+@@ -1444,14 +1438,6 @@
+       set_default_dirlist (default_dirlist);
+       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;
+ }
+ /* Add the (colon-separated) elements of DIRLIST_PTR to the
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-ia64/error1.d binutils-2.18~cvs20070812/ld/testsuite/ld-ia64/error1.d
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-ia64/error1.d   1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-ia64/error1.d    2007-08-12 13:37:06.000000000 +0200
+@@ -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 -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-ia64/error1.s binutils-2.18~cvs20070812/ld/testsuite/ld-ia64/error1.s
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-ia64/error1.s   1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-ia64/error1.s    2007-08-12 13:37:06.000000000 +0200
+@@ -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 -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-ia64/error2.d binutils-2.18~cvs20070812/ld/testsuite/ld-ia64/error2.d
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-ia64/error2.d   1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-ia64/error2.d    2007-08-12 13:37:06.000000000 +0200
+@@ -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 -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-ia64/error3.d binutils-2.18~cvs20070812/ld/testsuite/ld-ia64/error3.d
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-ia64/error3.d   1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-ia64/error3.d    2007-08-12 13:37:06.000000000 +0200
+@@ -0,0 +1,7 @@
++#source: error1.s
++#ld: -pie -shared
++#readelf: -s
++
++#...
++[     ]+[0-9]+:[      ]+[0]+[         ]+0[    ]+NOTYPE[       ]+GLOBAL DEFAULT[       ]+UND[  ]+foo
++#pass
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-ia64/error4.d binutils-2.18~cvs20070812/ld/testsuite/ld-ia64/error4.d
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-ia64/error4.d   1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-ia64/error4.d    2007-08-12 13:37:06.000000000 +0200
+@@ -0,0 +1,3 @@
++#source: error1.s
++#ld: -shared -pie
++#error: .*undefined reference to `foo'
diff --git a/debian/patches/210-hjl-binutils-signed.dpatch b/debian/patches/210-hjl-binutils-signed.dpatch
new file mode 100755 (executable)
index 0000000..0621c82
--- /dev/null
@@ -0,0 +1,716 @@
+#!/bin/sh -e
+## 210-hjl-binutils-signed.dpatch
+##
+## DP: Description: objdump.c (disassemble_bytes,dump_reloc_set): Print addend as signed.
+## DP: Author: H.J. Lu  <hongjiu.lu@intel.com>
+## DP: Upstream status: hjl 2.17.50.0.18
+## DP: Original patch: binutils-signed-2.patch
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+binutils/
+
+2007-06-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * objdump.c (disassemble_bytes): Print addend as signed.
+       (dump_reloc_set): Likewise.
+
+gas/testsuite/
+
+2007-06-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * 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.
+
+@DPATCH@
+diff -urNad binutils-2.18~cvs20070812~/binutils/objdump.c binutils-2.18~cvs20070812/binutils/objdump.c
+--- binutils-2.18~cvs20070812~/binutils/objdump.c      2007-07-10 15:52:39.000000000 +0200
++++ binutils-2.18~cvs20070812/binutils/objdump.c       2007-08-12 13:45:01.000000000 +0200
+@@ -1650,8 +1650,15 @@
+             if (q->addend)
+               {
+-                printf ("+0x");
+-                objdump_print_value (q->addend, info, TRUE);
++                bfd_signed_vma addend = q->addend;
++                if (addend < 0)
++                  {
++                    printf ("-0x");
++                    addend = -addend;
++                  }
++                else
++                  printf ("+0x");
++                objdump_print_value (addend, info, TRUE);
+               }
+             printf ("\n");
+@@ -2710,8 +2717,15 @@
+       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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/alpha/elf-reloc-1.d binutils-2.18~cvs20070812/gas/testsuite/gas/alpha/elf-reloc-1.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/alpha/elf-reloc-1.d   2003-06-17 13:16:16.000000000 +0200
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/alpha/elf-reloc-1.d    2007-08-12 13:45:01.000000000 +0200
+@@ -16,6 +16,6 @@
+ 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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/i386/mixed-mode-reloc64.d binutils-2.18~cvs20070812/gas/testsuite/gas/i386/mixed-mode-reloc64.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/i386/mixed-mode-reloc64.d     2005-09-28 17:31:21.000000000 +0200
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/i386/mixed-mode-reloc64.d      2007-08-12 13:45:01.000000000 +0200
+@@ -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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/i386/reloc64.d binutils-2.18~cvs20070812/gas/testsuite/gas/i386/reloc64.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/i386/reloc64.d        2007-05-04 02:44:36.000000000 +0200
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/i386/reloc64.d 2007-08-12 13:45:01.000000000 +0200
+@@ -16,31 +16,31 @@
+ .*[   ]+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_PC8[         ]+xtrn\+0xf+f
++.*[   ]+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_-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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/ia64/pcrel.d binutils-2.18~cvs20070812/gas/testsuite/gas/ia64/pcrel.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/ia64/pcrel.d  2005-03-29 00:34:20.000000000 +0200
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/ia64/pcrel.d   2007-08-12 13:45:01.000000000 +0200
+@@ -9,28 +9,28 @@
+ 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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/mips/branch-misc-2-64.d binutils-2.18~cvs20070812/gas/testsuite/gas/mips/branch-misc-2-64.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/mips/branch-misc-2-64.d       2005-11-23 15:04:18.000000000 +0100
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/mips/branch-misc-2-64.d        2007-08-12 13:45:01.000000000 +0200
+@@ -12,51 +12,51 @@
+       \.\.\.
+       \.\.\.
+ 0+003c <[^>]*> 04110000       bal     0000000000000040 <x\+0x4>
+-[     ]*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 <x\+0xc>
+-[     ]*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 <x\+0x14>
+-[     ]*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 <x\+0x1c>
+-[     ]*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 <x\+0x24>
+-[     ]*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 <x\+0x2c>
+-[     ]*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 <g6\+0x4>
+-[     ]*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 <g6\+0xc>
+-[     ]*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 <g6\+0x14>
+-[     ]*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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/mips/branch-misc-2pic-64.d binutils-2.18~cvs20070812/gas/testsuite/gas/mips/branch-misc-2pic-64.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/mips/branch-misc-2pic-64.d    2005-11-23 15:04:18.000000000 +0100
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/mips/branch-misc-2pic-64.d     2007-08-12 13:45:01.000000000 +0200
+@@ -12,51 +12,51 @@
+       \.\.\.
+       \.\.\.
+ 0+003c <[^>]*> 04110000       bal     0000000000000040 <x\+0x4>
+-[     ]*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 <x\+0xc>
+-[     ]*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 <x\+0x14>
+-[     ]*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 <x\+0x1c>
+-[     ]*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 <x\+0x24>
+-[     ]*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 <x\+0x2c>
+-[     ]*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 <g6\+0x4>
+-[     ]*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 <g6\+0xc>
+-[     ]*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 <g6\+0x14>
+-[     ]*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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/mips/ldstla-n64-sym32.d binutils-2.18~cvs20070812/gas/testsuite/gas/mips/ldstla-n64-sym32.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/mips/ldstla-n64-sym32.d       2005-03-04 10:51:11.000000000 +0100
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/mips/ldstla-n64-sym32.d        2007-08-12 13:45:01.000000000 +0200
+@@ -196,19 +196,19 @@
+ .*: 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 @@
+ .*: 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 @@
+ .*: 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 @@
+ .*    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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/mips/mips16-hilo-n32.d binutils-2.18~cvs20070812/gas/testsuite/gas/mips/mips16-hilo-n32.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/mips/mips16-hilo-n32.d        2005-02-15 20:57:53.000000000 +0100
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/mips/mips16-hilo-n32.d 2007-08-12 13:45:01.000000000 +0200
+@@ -141,45 +141,45 @@
+  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 @@
+  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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/astest.d binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/astest.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/astest.d  2005-03-02 14:25:01.000000000 +0100
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/astest.d   2007-08-12 13:45:01.000000000 +0200
+@@ -52,11 +52,11 @@
+   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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/astest2.d binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/astest2.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/astest2.d 2005-03-02 14:25:01.000000000 +0100
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/astest2.d  2007-08-12 13:45:01.000000000 +0200
+@@ -48,11 +48,11 @@
+   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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/astest2_64.d binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/astest2_64.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/astest2_64.d      2005-03-02 14:25:01.000000000 +0100
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/astest2_64.d       2007-08-12 13:45:01.000000000 +0200
+@@ -45,11 +45,11 @@
+   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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/astest64.d binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/astest64.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/astest64.d        2005-03-02 14:25:01.000000000 +0100
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/astest64.d 2007-08-12 13:45:01.000000000 +0200
+@@ -49,11 +49,11 @@
+   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 -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/test1elf32.d binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/test1elf32.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/test1elf32.d      2005-03-02 14:25:01.000000000 +0100
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/test1elf32.d       2007-08-12 13:45:01.000000000 +0200
+@@ -79,7 +79,7 @@
+ 0+000c <dat0>:
+    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 <dat1>:
+   10: 00 00 00 00     \.long 0x0
+diff -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/test1elf64.d binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/test1elf64.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/ppc/test1elf64.d      2005-03-02 14:25:01.000000000 +0100
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/ppc/test1elf64.d       2007-08-12 13:45:01.000000000 +0200
+@@ -114,7 +114,7 @@
+ 0000000000000014 <dat0>:
+   14: ff ff ff fc     fnmsub  f31,f31,f31,f31
+-                      14: R_PPC64_REL32       jk\+0xfffffffffffffffc
++                      14: R_PPC64_REL32       jk-0x4
+ 0000000000000018 <dat1>:
+   18: 00 00 00 00     \.long 0x0
+diff -urNad binutils-2.18~cvs20070812~/gas/testsuite/gas/sparc/reloc64.d binutils-2.18~cvs20070812/gas/testsuite/gas/sparc/reloc64.d
+--- binutils-2.18~cvs20070812~/gas/testsuite/gas/sparc/reloc64.d       1999-06-10 23:08:04.000000000 +0200
++++ binutils-2.18~cvs20070812/gas/testsuite/gas/sparc/reloc64.d        2007-08-12 13:45:01.000000000 +0200
+@@ -35,13 +35,13 @@
+                       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 <foo>
+-                      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 @@
+                       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 
diff --git a/debian/patches/211-hjl-binutils-weakdef.dpatch b/debian/patches/211-hjl-binutils-weakdef.dpatch
new file mode 100755 (executable)
index 0000000..bab2c63
--- /dev/null
@@ -0,0 +1,131 @@
+#!/bin/sh -e
+## 211-hjl-binutils-weakdef.dpatch
+##
+## DP: Description: elflink.c (elf_link_add_object_symbols): Check symbol type
+## DP: Description: for symbol alias in a dynamic object.
+## DP: Author: H.J. Lu  <hongjiu.lu@intel.com>
+## DP: Upstream status: hjl 2.17.50.0.18
+## DP: Original patch: binutils-weakdef-1.patch
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+bfd/
+
+2007-07-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * 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  <hongjiu.lu@intel.com>
+
+       * ld-elf/data2.c: New.
+       * ld-elf/weakdef1.c: Likewise.
+
+       * ld-elf/shared.exp: Add tests for libdata2 and weakdef1.
+
+@DPATCH@
+diff -urNad binutils-2.18~cvs20070812~/bfd/elflink.c binutils-2.18~cvs20070812/bfd/elflink.c
+--- binutils-2.18~cvs20070812~/bfd/elflink.c   2007-08-12 13:48:32.000000000 +0200
++++ binutils-2.18~cvs20070812/bfd/elflink.c    2007-08-12 13:48:41.000000000 +0200
+@@ -4558,6 +4558,7 @@
+         asection *slook;
+         bfd_vma vlook;
+         long ilook;
++        int tlook;
+         size_t i, j, idx;
+         hlook = weaks;
+@@ -4570,6 +4571,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;
+@@ -4607,9 +4609,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)
+               {
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/data2.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/data2.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/data2.c     1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/data2.c      2007-08-12 13:48:41.000000000 +0200
+@@ -0,0 +1,9 @@
++int foo = 0;
++extern int foo_alias __attribute__ ((weak, alias ("foo")));
++
++void
++bar (void)
++{
++  foo = -1;
++}
++
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/shared.exp binutils-2.18~cvs20070812/ld/testsuite/ld-elf/shared.exp
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/shared.exp  2007-07-06 16:09:43.000000000 +0200
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/shared.exp   2007-08-12 13:48:41.000000000 +0200
+@@ -123,6 +123,9 @@
+   {"Build libdata1.so"
+    "-shared" "-fPIC"
+    {data1.c} {} "libdata1.so"}
++  {"Build libdata2.so"
++   "-shared" "-fPIC"
++   {data2.c} {} "libdata2.so"}
+ }
+ set run_tests {
+@@ -235,6 +238,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_cc_link_tests $build_tests
+diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/weakdef1.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/weakdef1.c
+--- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/weakdef1.c  1970-01-01 01:00:00.000000000 +0100
++++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/weakdef1.c   2007-08-12 13:48:41.000000000 +0200
+@@ -0,0 +1,15 @@
++#include <stdio.h>
++#include <stdlib.h>
++
++extern int foo_alias;
++extern void bar (void);
++
++int
++main (void)
++{
++  bar ();
++  if (foo_alias != -1)
++    abort ();
++  printf ("PASS\n");
++  return 0;
++}
diff --git a/debian/patches/304_pr4476.dpatch b/debian/patches/304_pr4476.dpatch
new file mode 100755 (executable)
index 0000000..7bad7b7
--- /dev/null
@@ -0,0 +1,431 @@
+#!/bin/sh -e
+## 304_pr4476.dpatch
+##
+## DP: Description: Fix PR binutils/4476
+## DP: Upstream status: Not yet accepted in CVS head
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+binutils/
+
+2007-05-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/4476
+       * readelf.c (print_dynamic_symbol): New.
+       (process_symbol_table): Handle DT_GNU_HASH for dynamic symbols.
+
+ld/testsuite/
+
+2007-05-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/4476
+       * ld-elf/hash.d: Check "-s -D" for readelf.
+
+@DPATCH@
+--- binutils/binutils/readelf.c.hash   2007-05-09 10:54:22.000000000 -0700
++++ binutils/binutils/readelf.c        2007-05-09 17:24:46.000000000 -0700
+@@ -7033,6 +7033,39 @@ get_dynamic_data (FILE *file, unsigned i
+   return i_data;
+ }
++static void
++print_dynamic_symbol (bfd_vma si, unsigned long hn)
++{
++  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);
++  print_vma (psym->st_value, LONG_HEX);
++  putchar (' ');
++  print_vma (psym->st_size, DEC_5);
++
++  printf ("  %6s", get_symbol_type (ELF_ST_TYPE (psym->st_info)));
++  printf (" %6s",  get_symbol_binding (ELF_ST_BIND (psym->st_info)));
++  printf (" %3s",  get_symbol_visibility (ELF_ST_VISIBILITY (psym->st_other)));
++  /* Check to see if any other bits in the st_other field are set.
++     Note - displaying this information disrupts the layout of the
++     table being generated, but for the moment this case is very
++     rare.  */
++  if (psym->st_other ^ ELF_ST_VISIBILITY (psym->st_other))
++    printf (" [%s] ", get_symbol_other (psym->st_other ^ ELF_ST_VISIBILITY (psym->st_other)));
++  printf (" %3.3s ", get_symbol_index_type (psym->st_shndx));
++  if (VALID_DYNAMIC_NAME (psym->st_name))
++    print_symbol (25, GET_DYNAMIC_NAME (psym->st_name));
++  else
++    printf (" <corrupt: %14ld>", psym->st_name);
++  putchar ('\n');
++}
++
+ /* Dump the symbol table.  */
+ static int
+ process_symbol_table (FILE *file)
+@@ -7045,12 +7078,14 @@ process_symbol_table (FILE *file)
+   bfd_vma ngnubuckets = 0;
+   bfd_vma *gnubuckets = NULL;
+   bfd_vma *gnuchains = NULL;
++  bfd_vma gnusymidx = 0;
+   if (! do_syms && !do_histogram)
+     return 1;
+-  if (dynamic_info[DT_HASH] && ((do_using_dynamic && dynamic_strings != NULL)
+-                              || do_histogram))
++  if (dynamic_info[DT_HASH]
++      && (do_histogram
++        || (do_using_dynamic && dynamic_strings != NULL)))
+     {
+       unsigned char nb[8];
+       unsigned char nc[8];
+@@ -7094,54 +7129,157 @@ process_symbol_table (FILE *file)
+       return 0;
+     }
+-  if (do_syms
+-      && dynamic_info[DT_HASH] && do_using_dynamic && dynamic_strings != NULL)
++  if (dynamic_info_DT_GNU_HASH
++      && (do_histogram
++        || (do_using_dynamic && dynamic_strings != NULL)))
+     {
+-      unsigned long hn;
+-      bfd_vma si;
++      unsigned char nb[16];
++      bfd_vma i, maxchain = 0xffffffff, bitmaskwords;
++      bfd_vma buckets_vma;
++
++      if (fseek (file,
++               (archive_file_offset
++                + offset_from_vma (file, dynamic_info_DT_GNU_HASH,
++                                   sizeof nb)),
++               SEEK_SET))
++      {
++        error (_("Unable to seek to start of dynamic information\n"));
++        return 0;
++      }
++
++      if (fread (nb, 16, 1, file) != 1)
++      {
++        error (_("Failed to read in number of buckets\n"));
++        return 0;
++      }
+-      printf (_("\nSymbol table for image:\n"));
++      ngnubuckets = byte_get (nb, 4);
++      gnusymidx = byte_get (nb + 4, 4);
++      bitmaskwords = byte_get (nb + 8, 4);
++      buckets_vma = dynamic_info_DT_GNU_HASH + 16;
+       if (is_32bit_elf)
+-      printf (_("  Num Buc:    Value  Size   Type   Bind Vis      Ndx Name\n"));
++      buckets_vma += bitmaskwords * 4;
+       else
+-      printf (_("  Num Buc:    Value          Size   Type   Bind Vis      Ndx Name\n"));
++      buckets_vma += bitmaskwords * 8;
+-      for (hn = 0; hn < nbuckets; hn++)
++      if (fseek (file,
++               (archive_file_offset
++                + offset_from_vma (file, buckets_vma, 4)),
++               SEEK_SET))
+       {
+-        if (! buckets[hn])
+-          continue;
++        error (_("Unable to seek to start of dynamic information\n"));
++        return 0;
++      }
++
++      gnubuckets = get_dynamic_data (file, ngnubuckets, 4);
++
++      if (gnubuckets == NULL)
++      return 0;
++
++      for (i = 0; i < ngnubuckets; i++)
++      if (gnubuckets[i] != 0)
++        {
++          if (gnubuckets[i] < gnusymidx)
++            return 0;
++
++          if (maxchain == 0xffffffff || gnubuckets[i] > maxchain)
++            maxchain = gnubuckets[i];
++        }
++
++      if (maxchain == 0xffffffff)
++      return 0;
+-        for (si = buckets[hn]; si < nchains && si > 0; si = chains[si])
++      maxchain -= gnusymidx;
++
++      if (fseek (file,
++               (archive_file_offset
++                + offset_from_vma (file, buckets_vma
++                                         + 4 * (ngnubuckets + maxchain), 4)),
++               SEEK_SET))
++      {
++        error (_("Unable to seek to start of dynamic information\n"));
++        return 0;
++      }
++
++      do
++      {
++        if (fread (nb, 4, 1, file) != 1)
+           {
+-            Elf_Internal_Sym *psym;
+-            int n;
++            error (_("Failed to determine last chain length\n"));
++            return 0;
++          }
+-            psym = dynamic_symbols + si;
++        if (maxchain + 1 == 0)
++          return 0;
+-            n = print_vma (si, DEC_5);
+-            if (n < 5)
+-              fputs ("     " + n, stdout);
+-            printf (" %3lu: ", hn);
+-            print_vma (psym->st_value, LONG_HEX);
+-            putchar (' ');
+-            print_vma (psym->st_size, DEC_5);
++        ++maxchain;
++      }
++      while ((byte_get (nb, 4) & 1) == 0);
+-            printf ("  %6s", get_symbol_type (ELF_ST_TYPE (psym->st_info)));
+-            printf (" %6s",  get_symbol_binding (ELF_ST_BIND (psym->st_info)));
+-            printf (" %3s",  get_symbol_visibility (ELF_ST_VISIBILITY (psym->st_other)));
+-            /* Check to see if any other bits in the st_other field are set.
+-               Note - displaying this information disrupts the layout of the
+-               table being generated, but for the moment this case is very rare.  */
+-            if (psym->st_other ^ ELF_ST_VISIBILITY (psym->st_other))
+-              printf (" [%s] ", get_symbol_other (psym->st_other ^ ELF_ST_VISIBILITY (psym->st_other)));
+-            printf (" %3.3s ", get_symbol_index_type (psym->st_shndx));
+-            if (VALID_DYNAMIC_NAME (psym->st_name))
+-              print_symbol (25, GET_DYNAMIC_NAME (psym->st_name));
+-            else
+-              printf (" <corrupt: %14ld>", psym->st_name);
+-            putchar ('\n');
++      if (fseek (file,
++               (archive_file_offset
++                + offset_from_vma (file, buckets_vma + 4 * ngnubuckets, 4)),
++               SEEK_SET))
++      {
++        error (_("Unable to seek to start of dynamic information\n"));
++        return 0;
++      }
++
++      gnuchains = get_dynamic_data (file, maxchain, 4);
++
++      if (gnuchains == NULL)
++      return 0;
++    }
++
++  if ((dynamic_info[DT_HASH] || dynamic_info_DT_GNU_HASH)
++      && do_syms
++      && do_using_dynamic
++      && dynamic_strings != NULL)
++    {
++      unsigned long hn;
++
++      if (dynamic_info[DT_HASH])
++      {
++        bfd_vma si;
++
++        printf (_("\nSymbol table for image:\n"));
++        if (is_32bit_elf)
++          printf (_("  Num Buc:    Value  Size   Type   Bind Vis      Ndx Name\n"));
++        else
++          printf (_("  Num Buc:    Value          Size   Type   Bind Vis      Ndx Name\n"));
++
++        for (hn = 0; hn < nbuckets; hn++)
++          {
++            if (! buckets[hn])
++              continue;
++
++            for (si = buckets[hn]; si < nchains && si > 0; si = chains[si])
++              print_dynamic_symbol (si, hn);
+           }
+       }
++
++      if (dynamic_info_DT_GNU_HASH)
++      {
++        printf (_("\nSymbol table of `.gnu.hash' for image:\n"));
++        if (is_32bit_elf)
++          printf (_("  Num Buc:    Value  Size   Type   Bind Vis      Ndx Name\n"));
++        else
++          printf (_("  Num Buc:    Value          Size   Type   Bind Vis      Ndx Name\n"));
++
++        for (hn = 0; hn < ngnubuckets; ++hn)
++          if (gnubuckets[hn] != 0)
++            {
++              bfd_vma si = gnubuckets[hn];
++              bfd_vma off = si - gnusymidx;
++
++              do
++                {
++                  print_dynamic_symbol (si, hn);
++                  si++;
++                }
++              while ((gnuchains[off++] & 1) == 0);
++            }
++      }
+     }
+   else if (do_syms && !do_using_dynamic)
+     {
+@@ -7426,108 +7564,12 @@ process_symbol_table (FILE *file)
+   if (do_histogram && dynamic_info_DT_GNU_HASH)
+     {
+-      unsigned char nb[16];
+-      bfd_vma i, maxchain = 0xffffffff, symidx, bitmaskwords;
+       unsigned long *lengths;
+       unsigned long *counts;
+       unsigned long hn;
+       unsigned long maxlength = 0;
+       unsigned long nzero_counts = 0;
+       unsigned long nsyms = 0;
+-      bfd_vma buckets_vma;
+-
+-      if (fseek (file,
+-               (archive_file_offset
+-                + offset_from_vma (file, dynamic_info_DT_GNU_HASH,
+-                                   sizeof nb)),
+-               SEEK_SET))
+-      {
+-        error (_("Unable to seek to start of dynamic information\n"));
+-        return 0;
+-      }
+-
+-      if (fread (nb, 16, 1, file) != 1)
+-      {
+-        error (_("Failed to read in number of buckets\n"));
+-        return 0;
+-      }
+-
+-      ngnubuckets = byte_get (nb, 4);
+-      symidx = byte_get (nb + 4, 4);
+-      bitmaskwords = byte_get (nb + 8, 4);
+-      buckets_vma = dynamic_info_DT_GNU_HASH + 16;
+-      if (is_32bit_elf)
+-      buckets_vma += bitmaskwords * 4;
+-      else
+-      buckets_vma += bitmaskwords * 8;
+-
+-      if (fseek (file,
+-               (archive_file_offset
+-                + offset_from_vma (file, buckets_vma, 4)),
+-               SEEK_SET))
+-      {
+-        error (_("Unable to seek to start of dynamic information\n"));
+-        return 0;
+-      }
+-
+-      gnubuckets = get_dynamic_data (file, ngnubuckets, 4);
+-
+-      if (gnubuckets == NULL)
+-      return 0;
+-
+-      for (i = 0; i < ngnubuckets; i++)
+-      if (gnubuckets[i] != 0)
+-        {
+-          if (gnubuckets[i] < symidx)
+-            return 0;
+-
+-          if (maxchain == 0xffffffff || gnubuckets[i] > maxchain)
+-            maxchain = gnubuckets[i];
+-        }
+-
+-      if (maxchain == 0xffffffff)
+-      return 0;
+-
+-      maxchain -= symidx;
+-
+-      if (fseek (file,
+-               (archive_file_offset
+-                + offset_from_vma (file, buckets_vma
+-                                         + 4 * (ngnubuckets + maxchain), 4)),
+-               SEEK_SET))
+-      {
+-        error (_("Unable to seek to start of dynamic information\n"));
+-        return 0;
+-      }
+-
+-      do
+-      {
+-        if (fread (nb, 4, 1, file) != 1)
+-          {
+-            error (_("Failed to determine last chain length\n"));
+-            return 0;
+-          }
+-
+-        if (maxchain + 1 == 0)
+-          return 0;
+-
+-        ++maxchain;
+-      }
+-      while ((byte_get (nb, 4) & 1) == 0);
+-
+-      if (fseek (file,
+-               (archive_file_offset
+-                + offset_from_vma (file, buckets_vma + 4 * ngnubuckets, 4)),
+-               SEEK_SET))
+-      {
+-        error (_("Unable to seek to start of dynamic information\n"));
+-        return 0;
+-      }
+-
+-      gnuchains = get_dynamic_data (file, maxchain, 4);
+-
+-      if (gnuchains == NULL)
+-      return 0;
+       lengths = calloc (ngnubuckets, sizeof (*lengths));
+       if (lengths == NULL)
+@@ -7545,7 +7587,7 @@ process_symbol_table (FILE *file)
+         {
+           bfd_vma off, length = 1;
+-          for (off = gnubuckets[hn] - symidx;
++          for (off = gnubuckets[hn] - gnusymidx;
+                (gnuchains[off] & 1) == 0; ++off)
+             ++length;
+           lengths[hn] = length;
+--- binutils/ld/testsuite/ld-elf/hash.d.hash   2006-09-15 07:55:42.000000000 -0700
++++ binutils/ld/testsuite/ld-elf/hash.d        2007-05-09 15:46:56.000000000 -0700
+@@ -1,5 +1,5 @@
+ #source: start.s
+-#readelf: -d 
++#readelf: -d -s -D
+ #ld: -shared --hash-style=gnu
+ #target: *-*-linux*
+ #notarget: mips*-*-*
+@@ -7,3 +7,11 @@
+ #...
+ [     ]*0x[0-9a-z]+[  ]+\(GNU_HASH\)[         ]+0x[0-9a-z]+
+ #...
++[     ]+[0-9]+[       ]+[0-9]+:[      ]+[0-9a-f]+[    ]+[0-9]+[       ]+NOTYPE[        ]+GLOBAL DEFAULT[      ]+[1-9] _start
++#...
++[     ]+[0-9]+[       ]+[0-9]+:[      ]+[0-9a-f]+[    ]+[0-9]+[       ]+NOTYPE[        ]+GLOBAL DEFAULT[      ]+[1-9] main
++#...
++[     ]+[0-9]+[       ]+[0-9]+:[      ]+[0-9a-f]+[    ]+[0-9]+[       ]+NOTYPE[        ]+GLOBAL DEFAULT[      ]+[1-9] start
++#...
++[     ]+[0-9]+[       ]+[0-9]+:[      ]+[0-9a-f]+[    ]+[0-9]+[       ]+NOTYPE[        ]+GLOBAL DEFAULT[      ]+[1-9] __start
++#...
diff --git a/debian/patches/305_arm-dis.dpatch b/debian/patches/305_arm-dis.dpatch
new file mode 100755 (executable)
index 0000000..c7ac296
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh -e
+## 305_arm-dis.dpatch
+##
+## DP: Description: Fix segfault when disassembling ARM code
+## DP: Upstream status: Fix in CVS head
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -u -r1.86 -r1.87
+--- src/opcodes/arm-dis.c      2007/07/05 09:49:00     1.86
++++ src/opcodes/arm-dis.c      2007/10/26 11:27:12     1.87
+@@ -3989,6 +3989,7 @@
+   /* First check the full symtab for a mapping symbol, even if there
+      are no usable non-mapping symbols for this address.  */
+   if (info->symtab != NULL
++      && * info->symtab
+       && bfd_asymbol_flavour (*info->symtab) == bfd_target_elf_flavour)
+     {
+       bfd_vma addr;
diff --git a/debian/patches/311_pr5006.dpatch b/debian/patches/311_pr5006.dpatch
new file mode 100755 (executable)
index 0000000..5278fc6
--- /dev/null
@@ -0,0 +1,115 @@
+#!/bin/sh -e
+## 311_pr5006.dpatch
+##
+## DP: Description: Fix PR ld/5006
+## DP: Upstream status: CVS head 20070908
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+This one turns out to be nothing to do with --gc-sections, but a
+rather more serious bug.  If an input section with contents is linked
+in to a bss output section, the ELF linker currently leaves the output
+section as NOBITS.  File space is thus not allocated for the output
+section, but a number of places write to the file regardless,
+typically trashing the symbol table, string table, or debug sections.
+
+bfd/
+       PR ld/2864, ld/5006
+       * elf.c (special_sections): Comment typo.
+       (elf_fake_sections): Force SHT_PROGBITS for sections that are
+       SHT_NOBITS if BFD section flags say they have contents.
+ld/
+       * ldwrite.c (build_link_order <lang_padding_statement_enum>): Correct
+       condition under which we build a bfd_data_link_order.
+
+@DPATCH@
+Index: bfd/elf.c
+===================================================================
+RCS file: /cvs/src/src/bfd/elf.c,v
+retrieving revision 1.413
+diff -u -p -r1.413 elf.c
+--- ./bfd/elf.c        25 Aug 2007 13:20:41 -0000      1.413
++++ ./bfd/elf.c        8 Sep 2007 08:07:42 -0000
+@@ -2084,7 +2084,7 @@ static const struct bfd_elf_special_sect
+ static const struct bfd_elf_special_section *special_sections[] =
+ {
+   special_sections_b,         /* 'b' */
+-  special_sections_c,         /* 'b' */
++  special_sections_c,         /* 'c' */
+   special_sections_d,         /* 'd' */
+   NULL,                               /* 'e' */
+   special_sections_f,         /* 'f' */
+@@ -2475,16 +2475,28 @@ elf_fake_sections (bfd *abfd, asection *
+   /* If the section type is unspecified, we set it based on
+      asect->flags.  */
++  if ((asect->flags & SEC_GROUP) != 0)
++    sh_type = SHT_GROUP;
++  else if ((asect->flags & SEC_ALLOC) != 0
++         && (((asect->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
++             || (asect->flags & SEC_NEVER_LOAD) != 0))
++    sh_type = SHT_NOBITS;
++  else
++    sh_type = SHT_PROGBITS;
++
+   if (this_hdr->sh_type == SHT_NULL)
+-    {
+-      if ((asect->flags & SEC_GROUP) != 0)
+-      this_hdr->sh_type = SHT_GROUP;
+-      else if ((asect->flags & SEC_ALLOC) != 0
+-             && (((asect->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
+-                 || (asect->flags & SEC_NEVER_LOAD) != 0))
+-      this_hdr->sh_type = SHT_NOBITS;
+-      else
+-      this_hdr->sh_type = SHT_PROGBITS;
++    this_hdr->sh_type = sh_type;
++  else if (this_hdr->sh_type == SHT_NOBITS
++         && sh_type == SHT_PROGBITS
++         && (asect->flags & SEC_ALLOC) != 0)
++    {
++      /* Warn if we are changing a NOBITS section to PROGBITS, but
++       allow the link to proceed.  This can happen when users link
++       non-bss input sections to bss output sections, or emit data
++       to a bss output section via a linker script.  */
++      (*_bfd_error_handler)
++      (_("section `%A' type changed to PROGBITS"), asect);
++      this_hdr->sh_type = sh_type;
+     }
+   switch (this_hdr->sh_type)
+Index: ld/ldwrite.c
+===================================================================
+RCS file: /cvs/src/src/ld/ldwrite.c,v
+retrieving revision 1.26
+diff -u -p -r1.26 ldwrite.c
+--- ./ld/ldwrite.c     6 Jul 2007 14:09:41 -0000       1.26
++++ ./ld/ldwrite.c     8 Sep 2007 08:08:37 -0000
+@@ -270,7 +270,10 @@ build_link_order (lang_statement_union_t
+       output_section = statement->padding_statement.output_section;
+       ASSERT (statement->padding_statement.output_section->owner
+               == output_bfd);
+-      if ((output_section->flags & SEC_HAS_CONTENTS) != 0)
++      if (((output_section->flags & SEC_HAS_CONTENTS) != 0
++           || ((output_section->flags & SEC_LOAD) != 0
++               && (output_section->flags & SEC_THREAD_LOCAL)))
++          && (output_section->flags & SEC_NEVER_LOAD) == 0)
+         {
+           link_order = bfd_new_link_order (output_bfd, output_section);
+           link_order->type = bfd_data_link_order;
+
diff --git a/debian/patches/312_pr5011.dpatch b/debian/patches/312_pr5011.dpatch
new file mode 100755 (executable)
index 0000000..9eaec42
--- /dev/null
@@ -0,0 +1,158 @@
+#!/bin/sh -e
+## 312_pr5011.dpatch
+##
+## DP: Description: Fix PR binutils/5011
+## DP: Upstream status: CVS head 20070908
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+
+       PR binutils/5011
+       * readelf.c (process_version_sections): Don't read past end of
+       various section buffers.
+
+@DPATCH@
+Index: ./binutils/readelf.c
+===================================================================
+RCS file: /cvs/src/src/binutils/readelf.c,v
+retrieving revision 1.376
+diff -u -p -r1.376 readelf.c
+--- ./binutils/readelf.c       30 Aug 2007 13:47:35 -0000      1.376
++++ ./binutils/readelf.c       10 Sep 2007 08:59:40 -0000
+@@ -6454,6 +6454,7 @@ process_version_sections (FILE *file)
+           Elf_External_Verdef *edefs;
+           unsigned int idx;
+           unsigned int cnt;
++          char *endbuf;
+           found = 1;
+@@ -6473,6 +6474,7 @@ process_version_sections (FILE *file)
+           edefs = get_data (NULL, file, section->sh_offset, 1,
+                             section->sh_size,
+                             _("version definition section"));
++          endbuf = (char *) edefs + section->sh_size;
+           if (!edefs)
+             break;
+@@ -6487,6 +6489,8 @@ process_version_sections (FILE *file)
+               int isum;
+               vstart = ((char *) edefs) + idx;
++              if (vstart + sizeof (*edef) > endbuf)
++                break;
+               edef = (Elf_External_Verdef *) vstart;
+@@ -6524,6 +6528,8 @@ process_version_sections (FILE *file)
+                   vstart += aux.vda_next;
+                   eaux = (Elf_External_Verdaux *) vstart;
++                  if (vstart + sizeof (*eaux) > endbuf)
++                    break;
+                   aux.vda_name = BYTE_GET (eaux->vda_name);
+                   aux.vda_next = BYTE_GET (eaux->vda_next);
+@@ -6535,9 +6541,13 @@ process_version_sections (FILE *file)
+                     printf (_("  %#06x: Parent %d, name index: %ld\n"),
+                             isum, j, aux.vda_name);
+                 }
++              if (j < ent.vd_cnt)
++                printf (_("  Version def aux past end of section\n"));
+               idx += ent.vd_next;
+             }
++          if (cnt < section->sh_info)
++            printf (_("  Version definition past end of section\n"));
+           free (edefs);
+         }
+@@ -6548,6 +6558,7 @@ process_version_sections (FILE *file)
+           Elf_External_Verneed *eneed;
+           unsigned int idx;
+           unsigned int cnt;
++          char *endbuf;
+           found = 1;
+@@ -6566,6 +6577,7 @@ process_version_sections (FILE *file)
+           eneed = get_data (NULL, file, section->sh_offset, 1,
+                             section->sh_size,
+                             _("version need section"));
++          endbuf = (char *) eneed + section->sh_size;
+           if (!eneed)
+             break;
+@@ -6578,6 +6590,8 @@ process_version_sections (FILE *file)
+               char *vstart;
+               vstart = ((char *) eneed) + idx;
++              if (vstart + sizeof (*entry) > endbuf)
++                break;
+               entry = (Elf_External_Verneed *) vstart;
+@@ -6603,6 +6617,8 @@ process_version_sections (FILE *file)
+                   Elf_External_Vernaux *eaux;
+                   Elf_Internal_Vernaux aux;
++                  if (vstart + sizeof (*eaux) > endbuf)
++                    break;
+                   eaux = (Elf_External_Vernaux *) vstart;
+                   aux.vna_hash  = BYTE_GET (eaux->vna_hash);
+@@ -6624,9 +6640,13 @@ process_version_sections (FILE *file)
+                   isum   += aux.vna_next;
+                   vstart += aux.vna_next;
+                 }
++              if (j < ent.vn_cnt)
++                printf (_("  Version need aux past end of section\n"));
+               idx += ent.vn_next;
+             }
++          if (cnt < section->sh_info)
++            printf (_("  Version need past end of section\n"));
+           free (eneed);
+         }
+@@ -6771,7 +6791,10 @@ process_version_sections (FILE *file)
+                               {
+                                 ivna.vna_name = BYTE_GET (evna.vna_name);
+-                                name = strtab + ivna.vna_name;
++                                if (ivna.vna_name >= string_sec->sh_size)
++                                  name = _("*invalid*");
++                                else
++                                  name = strtab + ivna.vna_name;
+                                 nn += printf ("(%s%-*s",
+                                               name,
+                                               12 - (int) strlen (name),
+@@ -6823,7 +6846,10 @@ process_version_sections (FILE *file)
+                             ivda.vda_name = BYTE_GET (evda.vda_name);
+-                            name = strtab + ivda.vda_name;
++                            if (ivda.vda_name >= string_sec->sh_size)
++                              name = _("*invalid*");
++                            else
++                              name = strtab + ivda.vda_name;
+                             nn += printf ("(%s%-*s",
+                                           name,
+                                           12 - (int) strlen (name),
+
diff --git a/debian/patches/313_pr5025.dpatch b/debian/patches/313_pr5025.dpatch
new file mode 100755 (executable)
index 0000000..12b6dcb
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh -e
+## 313_pr5025.dpatch
+##
+## DP: Description: Fix PR ld/5025
+## DP: Upstream status: CVS head 20070908
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+                exit 1;;
+esac
+
+exit 0
+
+       PR ld/5025
+       * emultempl/elf32.em (write_build_id_section): Correct test for
+       "missing" .note.gnu.build-id.  Downgrade error to a warning if
+       it has been discarded.
+
+@DPATCH@
+Subject: Fix 5025, discarded .note.gnu.build-id
+
+Index: ld/emultempl/elf32.em
+===================================================================
+RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
+retrieving revision 1.186
+diff -u -p -r1.186 elf32.em
+--- ./ld/emultempl/elf32.em    17 Aug 2007 13:50:48 -0000      1.186
++++ ./ld/emultempl/elf32.em    15 Sep 2007 03:39:19 -0000
+@@ -936,10 +936,11 @@ gld${EMULATION_NAME}_write_build_id_sect
+   Elf_External_Note *e_note;
+   asec = info->sec;
+-  if (asec->output_section == NULL)
++  if (bfd_is_abs_section (asec->output_section))
+     {
+-      einfo (_("%P: .note.gnu.build-id section missing"));
+-      return FALSE;
++      einfo (_("%P: warning: .note.gnu.build-id section discarded,"
++             " --build-id ignored.\n"));
++      return TRUE;
+     }
+   i_shdr = &elf_section_data (asec->output_section)->this_hdr;
+
diff --git a/debian/patches/500-binutils-msp-new-cpus1.dpatch b/debian/patches/500-binutils-msp-new-cpus1.dpatch
new file mode 100755 (executable)
index 0000000..bf39c37
--- /dev/null
@@ -0,0 +1,1687 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 500-binutils-msp-new-cpus1.dpatch by  <smckown@stevex2>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Add new cpu variations to the msp430 architecture
+
+@DPATCH@
+
+diff -ur binutils-2.18.orig/bfd/archures.c binutils-2.18/bfd/archures.c
+--- binutils-2.18.orig/bfd/archures.c  2007-08-06 22:59:14.000000000 +0300
++++ binutils-2.18/bfd/archures.c       2008-05-25 16:57:13.406250000 +0300
+@@ -374,7 +374,9 @@
+ .#define bfd_mach_msp14          14
+ .#define bfd_mach_msp15          15
+ .#define bfd_mach_msp16          16
++.#define bfd_mach_msp20          20
+ .#define bfd_mach_msp21          21
++.#define bfd_mach_msp22          22
+ .#define bfd_mach_msp31          31
+ .#define bfd_mach_msp32          32
+ .#define bfd_mach_msp33          33
+@@ -382,6 +384,7 @@
+ .#define bfd_mach_msp42          42
+ .#define bfd_mach_msp43          43
+ .#define bfd_mach_msp44          44
++.#define bfd_mach_msp46          46
+ .  bfd_arch_xc16x,     {* Infineon's XC16X Series.               *}
+ .#define bfd_mach_xc16x         1
+ .#define bfd_mach_xc16xl        2
+diff -ur binutils-2.18.orig/bfd/bfd-in2.h binutils-2.18/bfd/bfd-in2.h
+--- binutils-2.18.orig/bfd/bfd-in2.h   2007-08-06 22:59:15.000000000 +0300
++++ binutils-2.18/bfd/bfd-in2.h        2008-05-25 16:57:13.437500000 +0300
+@@ -2045,7 +2045,9 @@
+ #define bfd_mach_msp14          14
+ #define bfd_mach_msp15          15
+ #define bfd_mach_msp16          16
++#define bfd_mach_msp20          20
+ #define bfd_mach_msp21          21
++#define bfd_mach_msp22          22
+ #define bfd_mach_msp31          31
+ #define bfd_mach_msp32          32
+ #define bfd_mach_msp33          33
+@@ -2053,6 +2055,7 @@
+ #define bfd_mach_msp42          42
+ #define bfd_mach_msp43          43
+ #define bfd_mach_msp44          44
++#define bfd_mach_msp46          46
+   bfd_arch_xc16x,     /* Infineon's XC16X Series.               */
+ #define bfd_mach_xc16x         1
+ #define bfd_mach_xc16xl        2
+diff -ur binutils-2.18.orig/bfd/cpu-msp430.c binutils-2.18/bfd/cpu-msp430.c
+--- binutils-2.18.orig/bfd/cpu-msp430.c        2007-08-06 22:59:20.000000000 +0300
++++ binutils-2.18/bfd/cpu-msp430.c     2008-05-25 16:57:13.437500000 +0300
+@@ -65,29 +65,38 @@
+   /* msp430x16x.  */
+   N (16, bfd_mach_msp16, "msp:16", FALSE, & arch_info_struct[7]),
++  /* msp430x20x.  */
++  N (16, bfd_mach_msp20, "msp:20", FALSE, & arch_info_struct[8]),
++
+   /* msp430x21x.  */
+-  N (16, bfd_mach_msp21, "msp:21", FALSE, & arch_info_struct[8]),
++  N (16, bfd_mach_msp21, "msp:21", FALSE, & arch_info_struct[9]),
++
++  /* msp430x22x.  */
++  N (16, bfd_mach_msp22, "msp:22", FALSE, & arch_info_struct[10]),
+   /* msp430x31x.  */
+-  N (16, bfd_mach_msp31, "msp:31", FALSE, & arch_info_struct[9]), 
++  N (16, bfd_mach_msp31, "msp:31", FALSE, & arch_info_struct[11]), 
+   /* msp430x32x.  */
+-  N (16, bfd_mach_msp32, "msp:32", FALSE, & arch_info_struct[10]), 
++  N (16, bfd_mach_msp32, "msp:32", FALSE, & arch_info_struct[12]), 
+   /* msp430x33x.  */
+-  N (16, bfd_mach_msp33, "msp:33", FALSE, & arch_info_struct[11]),
++  N (16, bfd_mach_msp33, "msp:33", FALSE, & arch_info_struct[13]),
+   
+   /* msp430x41x.  */
+-  N (16, bfd_mach_msp41, "msp:41", FALSE, & arch_info_struct[12]),
++  N (16, bfd_mach_msp41, "msp:41", FALSE, & arch_info_struct[14]),
+   /* msp430x42x.  */
+-  N (16, bfd_mach_msp42, "msp:42", FALSE, & arch_info_struct[13]),
++  N (16, bfd_mach_msp42, "msp:42", FALSE, & arch_info_struct[15]),
+   /* msp430x43x.  */
+-  N (16, bfd_mach_msp43, "msp:43", FALSE, & arch_info_struct[14]),
++  N (16, bfd_mach_msp43, "msp:43", FALSE, & arch_info_struct[16]),
+   /* msp430x44x.  */
+-  N (16, bfd_mach_msp43, "msp:44", FALSE, NULL)
++  N (16, bfd_mach_msp44, "msp:44", FALSE, & arch_info_struct[17]),
++
++  /* msp430x46xx.  */
++  N (16, bfd_mach_msp46, "msp:46", FALSE, NULL)
+ };
+ const bfd_arch_info_type bfd_msp430_arch =
+diff -ur binutils-2.18.orig/bfd/doc/archures.texi binutils-2.18/bfd/doc/archures.texi
+--- binutils-2.18.orig/bfd/doc/archures.texi   2007-08-06 23:39:25.000000000 +0300
++++ binutils-2.18/bfd/doc/archures.texi        2008-05-25 16:57:13.453125000 +0300
+@@ -339,7 +339,9 @@
+ #define bfd_mach_msp14          14
+ #define bfd_mach_msp15          15
+ #define bfd_mach_msp16          16
++#define bfd_mach_msp20          20
+ #define bfd_mach_msp21          21
++#define bfd_mach_msp22          22
+ #define bfd_mach_msp31          31
+ #define bfd_mach_msp32          32
+ #define bfd_mach_msp33          33
+@@ -347,6 +349,7 @@
+ #define bfd_mach_msp42          42
+ #define bfd_mach_msp43          43
+ #define bfd_mach_msp44          44
++#define bfd_mach_msp46          46
+   bfd_arch_xc16x,     /* Infineon's XC16X Series.               */
+ #define bfd_mach_xc16x         1
+ #define bfd_mach_xc16xl        2
+diff -ur binutils-2.18.orig/bfd/elf32-msp430.c binutils-2.18/bfd/elf32-msp430.c
+--- binutils-2.18.orig/bfd/elf32-msp430.c      2007-08-06 22:59:28.000000000 +0300
++++ binutils-2.18/bfd/elf32-msp430.c   2008-05-25 16:57:13.468750000 +0300
+@@ -564,6 +564,18 @@
+       val = E_MSP430_MACH_MSP430x16;
+       break;
++    case bfd_mach_msp20:
++      val = E_MSP430_MACH_MSP430x20;
++      break;
++
++    case bfd_mach_msp21:
++      val = E_MSP430_MACH_MSP430x21;
++      break;
++
++    case bfd_mach_msp22:
++      val = E_MSP430_MACH_MSP430x22;
++      break;
++
+     case bfd_mach_msp31:
+       val = E_MSP430_MACH_MSP430x31;
+       break;
+@@ -591,6 +603,10 @@
+     case bfd_mach_msp44:
+       val = E_MSP430_MACH_MSP430x44;
+       break;
++
++    case bfd_mach_msp46:
++      val = E_MSP430_MACH_MSP430x46;
++      break;
+     }
+   elf_elfheader (abfd)->e_machine = EM_MSP430;
+@@ -641,6 +657,18 @@
+         e_set = bfd_mach_msp16;
+         break;
++      case E_MSP430_MACH_MSP430x20:
++        e_set = bfd_mach_msp20;
++        break;
++
++      case E_MSP430_MACH_MSP430x21:
++        e_set = bfd_mach_msp21;
++        break;
++
++      case E_MSP430_MACH_MSP430x22:
++        e_set = bfd_mach_msp22;
++        break;
++
+       case E_MSP430_MACH_MSP430x31:
+         e_set = bfd_mach_msp31;
+         break;
+@@ -668,6 +696,10 @@
+       case E_MSP430_MACH_MSP430x44:
+         e_set = bfd_mach_msp44;
+         break;
++
++      case E_MSP430_MACH_MSP430x46:
++        e_set = bfd_mach_msp46;
++        break;
+       }
+     }
+diff -ur binutils-2.18.orig/gas/config/tc-msp430.c binutils-2.18/gas/config/tc-msp430.c
+--- binutils-2.18.orig/gas/config/tc-msp430.c  2007-08-06 23:00:02.000000000 +0300
++++ binutils-2.18/gas/config/tc-msp430.c       2008-05-25 16:57:13.484375000 +0300
+@@ -247,7 +247,9 @@
+ #define MSP430_ISA_14   14
+ #define MSP430_ISA_15   15
+ #define MSP430_ISA_16   16
++#define MSP430_ISA_20   20
+ #define MSP430_ISA_21   21
++#define MSP430_ISA_22   22
+ #define MSP430_ISA_31   31
+ #define MSP430_ISA_32   32
+ #define MSP430_ISA_33   33
+@@ -255,83 +257,113 @@
+ #define MSP430_ISA_42   42
+ #define MSP430_ISA_43   43
+ #define MSP430_ISA_44   44
++#define MSP430_ISA_46   46
+ #define CHECK_RELOC_MSP430            ((imm_op || byte_op)?BFD_RELOC_MSP430_16_BYTE:BFD_RELOC_MSP430_16)
+ #define CHECK_RELOC_MSP430_PCREL      ((imm_op || byte_op)?BFD_RELOC_MSP430_16_PCREL_BYTE:BFD_RELOC_MSP430_16_PCREL)
+ static struct mcu_type_s mcu_types[] =
+ {
+-  {"msp1",        MSP430_ISA_11, bfd_mach_msp11},
+-  {"msp2",        MSP430_ISA_14, bfd_mach_msp14},
+-  {"msp430x110",  MSP430_ISA_11, bfd_mach_msp11},
+-  {"msp430x112",  MSP430_ISA_11, bfd_mach_msp11},
+-  {"msp430x1101", MSP430_ISA_110, bfd_mach_msp110},
+-  {"msp430x1111", MSP430_ISA_110, bfd_mach_msp110},
+-  {"msp430x1121", MSP430_ISA_110, bfd_mach_msp110},
+-  {"msp430x1122", MSP430_ISA_11, bfd_mach_msp110},
+-  {"msp430x1132", MSP430_ISA_11, bfd_mach_msp110},
+-
+-  {"msp430x122",  MSP430_ISA_12, bfd_mach_msp12},
+-  {"msp430x123",  MSP430_ISA_12, bfd_mach_msp12},
+-  {"msp430x1222", MSP430_ISA_12, bfd_mach_msp12},
+-  {"msp430x1232", MSP430_ISA_12, bfd_mach_msp12},
+-
+-  {"msp430x133",  MSP430_ISA_13, bfd_mach_msp13},
+-  {"msp430x135",  MSP430_ISA_13, bfd_mach_msp13},
+-  {"msp430x1331", MSP430_ISA_13, bfd_mach_msp13},
+-  {"msp430x1351", MSP430_ISA_13, bfd_mach_msp13},
+-  {"msp430x147",  MSP430_ISA_14, bfd_mach_msp14},
+-  {"msp430x148",  MSP430_ISA_14, bfd_mach_msp14},
+-  {"msp430x149",  MSP430_ISA_14, bfd_mach_msp14},
+-
+-  {"msp430x155",  MSP430_ISA_15, bfd_mach_msp15},
+-  {"msp430x156",  MSP430_ISA_15, bfd_mach_msp15},
+-  {"msp430x157",  MSP430_ISA_15, bfd_mach_msp15},
+-  {"msp430x167",  MSP430_ISA_16, bfd_mach_msp16},
+-  {"msp430x168",  MSP430_ISA_16, bfd_mach_msp16},
+-  {"msp430x169",  MSP430_ISA_16, bfd_mach_msp16},
+-  {"msp430x1610", MSP430_ISA_16, bfd_mach_msp16},
+-  {"msp430x1611", MSP430_ISA_16, bfd_mach_msp16},
+-  {"msp430x1612", MSP430_ISA_16, bfd_mach_msp16},
+-
+-  {"msp430x2101", MSP430_ISA_21, bfd_mach_msp21},
+-  {"msp430x2111", MSP430_ISA_21, bfd_mach_msp21},
+-  {"msp430x2121", MSP430_ISA_21, bfd_mach_msp21},
+-  {"msp430x2131", MSP430_ISA_21, bfd_mach_msp21},
++  {"msp1",         MSP430_ISA_11,  bfd_mach_msp11},
++  {"msp2",         MSP430_ISA_14,  bfd_mach_msp14},
++  {"msp430x110",   MSP430_ISA_11,  bfd_mach_msp11},
++  {"msp430x112",   MSP430_ISA_11,  bfd_mach_msp11},
++  {"msp430x1101",  MSP430_ISA_110, bfd_mach_msp110},
++  {"msp430x1111",  MSP430_ISA_110, bfd_mach_msp110},
++  {"msp430x1121",  MSP430_ISA_110, bfd_mach_msp110},
++  {"msp430x1122",  MSP430_ISA_11,  bfd_mach_msp110},
++  {"msp430x1132",  MSP430_ISA_11,  bfd_mach_msp110},
++
++  {"msp430x122",   MSP430_ISA_12,  bfd_mach_msp12},
++  {"msp430x123",   MSP430_ISA_12,  bfd_mach_msp12},
++  {"msp430x1222",  MSP430_ISA_12,  bfd_mach_msp12},
++  {"msp430x1232",  MSP430_ISA_12,  bfd_mach_msp12},
++
++  {"msp430x133",   MSP430_ISA_13,  bfd_mach_msp13},
++  {"msp430x135",   MSP430_ISA_13,  bfd_mach_msp13},
++  {"msp430x1331",  MSP430_ISA_13,  bfd_mach_msp13},
++  {"msp430x1351",  MSP430_ISA_13,  bfd_mach_msp13},
++  {"msp430x147",   MSP430_ISA_14,  bfd_mach_msp14},
++  {"msp430x148",   MSP430_ISA_14,  bfd_mach_msp14},
++  {"msp430x149",   MSP430_ISA_14,  bfd_mach_msp14},
++  {"msp430x1471",  MSP430_ISA_14,  bfd_mach_msp14},
++  {"msp430x1481",  MSP430_ISA_14,  bfd_mach_msp14},
++  {"msp430x1491",  MSP430_ISA_14,  bfd_mach_msp14},
++
++  {"msp430x155",   MSP430_ISA_15,  bfd_mach_msp15},
++  {"msp430x156",   MSP430_ISA_15,  bfd_mach_msp15},
++  {"msp430x157",   MSP430_ISA_15,  bfd_mach_msp15},
++  {"msp430x167",   MSP430_ISA_16,  bfd_mach_msp16},
++  {"msp430x168",   MSP430_ISA_16,  bfd_mach_msp16},
++  {"msp430x169",   MSP430_ISA_16,  bfd_mach_msp16},
++  {"msp430x1610",  MSP430_ISA_16,  bfd_mach_msp16},
++  {"msp430x1611",  MSP430_ISA_16,  bfd_mach_msp16},
++  {"msp430x1612",  MSP430_ISA_16,  bfd_mach_msp16},
++
++  {"msp430x2001",  MSP430_ISA_20,  bfd_mach_msp20},
++  {"msp430x2011",  MSP430_ISA_20,  bfd_mach_msp20},
++
++  {"msp430x2002",  MSP430_ISA_20,  bfd_mach_msp20},
++  {"msp430x2012",  MSP430_ISA_20,  bfd_mach_msp20},
++
++  {"msp430x2003",  MSP430_ISA_20,  bfd_mach_msp20},
++  {"msp430x2013",  MSP430_ISA_20,  bfd_mach_msp20},
++
++  {"msp430x2101",  MSP430_ISA_21,  bfd_mach_msp21},
++  {"msp430x2111",  MSP430_ISA_21,  bfd_mach_msp21},
++  {"msp430x2121",  MSP430_ISA_21,  bfd_mach_msp21},
++  {"msp430x2131",  MSP430_ISA_21,  bfd_mach_msp21},
++
++  {"msp430x2234",  MSP430_ISA_22,  bfd_mach_msp22},
++  {"msp430x2254",  MSP430_ISA_22,  bfd_mach_msp22},
++  {"msp430x2274",  MSP430_ISA_22,  bfd_mach_msp22},
+   
+-  {"msp430x311",  MSP430_ISA_31, bfd_mach_msp31},
+-  {"msp430x312",  MSP430_ISA_31, bfd_mach_msp31},
+-  {"msp430x313",  MSP430_ISA_31, bfd_mach_msp31},
+-  {"msp430x314",  MSP430_ISA_31, bfd_mach_msp31},
+-  {"msp430x315",  MSP430_ISA_31, bfd_mach_msp31},
+-  {"msp430x323",  MSP430_ISA_32, bfd_mach_msp32},
+-  {"msp430x325",  MSP430_ISA_32, bfd_mach_msp32},
+-  {"msp430x336",  MSP430_ISA_33, bfd_mach_msp33},
+-  {"msp430x337",  MSP430_ISA_33, bfd_mach_msp33},
+-
+-  {"msp430x412",  MSP430_ISA_41, bfd_mach_msp41},
+-  {"msp430x413",  MSP430_ISA_41, bfd_mach_msp41},
+-  {"msp430x415",  MSP430_ISA_41, bfd_mach_msp41},
+-  {"msp430x417",  MSP430_ISA_41, bfd_mach_msp41},
+-
+-  {"msp430xE423", MSP430_ISA_42, bfd_mach_msp42},
+-  {"msp430xE425", MSP430_ISA_42, bfd_mach_msp42},
+-  {"msp430xE427", MSP430_ISA_42, bfd_mach_msp42},
+-
+-  {"msp430xW423", MSP430_ISA_42, bfd_mach_msp42},
+-  {"msp430xW425", MSP430_ISA_42, bfd_mach_msp42},
+-  {"msp430xW427", MSP430_ISA_42, bfd_mach_msp42},
+-
+-  {"msp430xG437", MSP430_ISA_43, bfd_mach_msp43},
+-  {"msp430xG438", MSP430_ISA_43, bfd_mach_msp43},
+-  {"msp430xG439", MSP430_ISA_43, bfd_mach_msp43},
+-
+-  {"msp430x435",  MSP430_ISA_43, bfd_mach_msp43},
+-  {"msp430x436",  MSP430_ISA_43, bfd_mach_msp43},
+-  {"msp430x437",  MSP430_ISA_43, bfd_mach_msp43},
+-  {"msp430x447",  MSP430_ISA_44, bfd_mach_msp44},
+-  {"msp430x448",  MSP430_ISA_44, bfd_mach_msp44},
+-  {"msp430x449",  MSP430_ISA_44, bfd_mach_msp44},
++  {"msp430x311",   MSP430_ISA_31,  bfd_mach_msp31},
++  {"msp430x312",   MSP430_ISA_31,  bfd_mach_msp31},
++  {"msp430x313",   MSP430_ISA_31,  bfd_mach_msp31},
++  {"msp430x314",   MSP430_ISA_31,  bfd_mach_msp31},
++  {"msp430x315",   MSP430_ISA_31,  bfd_mach_msp31},
++  {"msp430x323",   MSP430_ISA_32,  bfd_mach_msp32},
++  {"msp430x325",   MSP430_ISA_32,  bfd_mach_msp32},
++  {"msp430x336",   MSP430_ISA_33,  bfd_mach_msp33},
++  {"msp430x337",   MSP430_ISA_33,  bfd_mach_msp33},
++
++  {"msp430x412",   MSP430_ISA_41,  bfd_mach_msp41},
++  {"msp430x413",   MSP430_ISA_41,  bfd_mach_msp41},
++  {"msp430x415",   MSP430_ISA_41,  bfd_mach_msp41},
++  {"msp430x417",   MSP430_ISA_41,  bfd_mach_msp41},
++
++  {"msp430x423",   MSP430_ISA_42,  bfd_mach_msp42},
++  {"msp430x425",   MSP430_ISA_42,  bfd_mach_msp42},
++  {"msp430x427",   MSP430_ISA_42,  bfd_mach_msp42},
++
++  {"msp430x4250",  MSP430_ISA_42,  bfd_mach_msp42},
++  {"msp430x4260",  MSP430_ISA_42,  bfd_mach_msp42},
++  {"msp430x4270",  MSP430_ISA_42,  bfd_mach_msp42},
++
++  {"msp430xE423",  MSP430_ISA_42,  bfd_mach_msp42},
++  {"msp430xE425",  MSP430_ISA_42,  bfd_mach_msp42},
++  {"msp430xE427",  MSP430_ISA_42,  bfd_mach_msp42},
++
++  {"msp430xW423",  MSP430_ISA_42,  bfd_mach_msp42},
++  {"msp430xW425",  MSP430_ISA_42,  bfd_mach_msp42},
++  {"msp430xW427",  MSP430_ISA_42,  bfd_mach_msp42},
++
++  {"msp430xG437",  MSP430_ISA_43,  bfd_mach_msp43},
++  {"msp430xG438",  MSP430_ISA_43,  bfd_mach_msp43},
++  {"msp430xG439",  MSP430_ISA_43,  bfd_mach_msp43},
++
++  {"msp430x435",   MSP430_ISA_43,  bfd_mach_msp43},
++  {"msp430x436",   MSP430_ISA_43,  bfd_mach_msp43},
++  {"msp430x437",   MSP430_ISA_43,  bfd_mach_msp43},
++  {"msp430x447",   MSP430_ISA_44,  bfd_mach_msp44},
++  {"msp430x448",   MSP430_ISA_44,  bfd_mach_msp44},
++  {"msp430x449",   MSP430_ISA_44,  bfd_mach_msp44},
++
++  {"msp430xG4616", MSP430_ISA_46,  bfd_mach_msp46},
++  {"msp430xG4617", MSP430_ISA_46,  bfd_mach_msp46},
++  {"msp430xG4618", MSP430_ISA_46,  bfd_mach_msp46},
++  {"msp430xG4619", MSP430_ISA_46,  bfd_mach_msp46},
+   {NULL, 0, 0}
+ };
+@@ -795,26 +827,35 @@
+   fprintf (stream,
+          _("MSP430 options:\n"
+            "  -mmcu=[msp430-name] select microcontroller type\n"
+-           "                  msp430x110  msp430x112\n"
+-           "                  msp430x1101 msp430x1111\n"
+-           "                  msp430x1121 msp430x1122 msp430x1132\n"
+-           "                  msp430x122  msp430x123\n"
+-           "                  msp430x1222 msp430x1232\n"
+-           "                  msp430x133  msp430x135\n"
+-           "                  msp430x1331 msp430x1351\n"
+-           "                  msp430x147  msp430x148  msp430x149\n"
+-           "                  msp430x155  msp430x156  msp430x157\n"
+-           "                  msp430x167  msp430x168  msp430x169\n"
+-           "                  msp430x1610 msp430x1611 msp430x1612\n"
+-           "                  msp430x311  msp430x312  msp430x313  msp430x314  msp430x315\n"
+-           "                  msp430x323  msp430x325\n"
+-           "                  msp430x336  msp430x337\n"
+-           "                  msp430x412  msp430x413  msp430x415  msp430x417\n"
+-           "                  msp430xE423 msp430xE425 msp430E427\n"
+-           "                  msp430xW423 msp430xW425 msp430W427\n"
+-           "                  msp430xG437 msp430xG438 msp430G439\n"
+-           "                  msp430x435  msp430x436  msp430x437\n"
+-           "                  msp430x447  msp430x448  msp430x449\n"));
++           "                  msp430x110   msp430x112\n"
++           "                  msp430x1101  msp430x1111  msp430x1121\n"
++           "                  msp430x1122  msp430x1132\n"
++           "                  msp430x122   msp430x123\n"
++           "                  msp430x1222  msp430x1232\n"
++           "                  msp430x133   msp430x135\n"
++           "                  msp430x1331  msp430x1351\n"
++           "                  msp430x147   msp430x148   msp430x149\n"
++           "                  msp430x1471  msp430x1481  msp430x1491\n"
++           "                  msp430x155   msp430x156   msp430x157\n"
++           "                  msp430x167   msp430x168   msp430x169\n"
++           "                  msp430x1610  msp430x1611  msp430x1612\n"
++           "                  msp430x2001  msp430x2011\n"
++           "                  msp430x2002  msp430x2012\n"
++           "                  msp430x2003  msp430x2013\n"
++           "                  msp430x2101  msp430x2111  msp430x2121  msp430x2131\n"
++           "                  msp430x2234  msp430x2254  msp430x2274\n"
++           "                  msp430x311   msp430x312   msp430x313   msp430x314  msp430x315\n"
++           "                  msp430x323   msp430x325\n" 
++           "                  msp430x336   msp430x337\n"
++           "                  msp430x412   msp430x413   msp430x415   msp430x417\n"
++           "                  msp430x423   msp430x425   msp430427\n"
++           "                  msp430x4250  msp430x4260  msp4304270\n"
++           "                  msp430xE423  msp430xE425  msp430E427\n"
++           "                  msp430xW423  msp430xW425  msp430W427\n"
++           "                  msp430xG437  msp430xG438  msp430G439\n"
++           "                  msp430x435   msp430x436   msp430x437\n"
++           "                  msp430x447   msp430x448   msp430x449\n"
++           "                  msp430xG4616 msp430xG4617 msp430xG4618 msp430xG4619\n"));
+   fprintf (stream,
+          _("  -mQ - enable relaxation at assembly time. DANGEROUS!\n"
+            "  -mP - enable polymorph instructions\n"));
+diff -ur binutils-2.18.orig/include/elf/msp430.h binutils-2.18/include/elf/msp430.h
+--- binutils-2.18.orig/include/elf/msp430.h    2005-05-10 13:21:10.000000000 +0300
++++ binutils-2.18/include/elf/msp430.h 2008-05-25 16:57:13.484375000 +0300
+@@ -26,20 +26,24 @@
+ /* Processor specific flags for the ELF header e_flags field.  */
+ #define EF_MSP430_MACH                0xff
+-#define E_MSP430_MACH_MSP430x11  11
+-#define E_MSP430_MACH_MSP430x11x1  110
+-#define E_MSP430_MACH_MSP430x12  12
+-#define E_MSP430_MACH_MSP430x13  13
+-#define E_MSP430_MACH_MSP430x14  14
+-#define E_MSP430_MACH_MSP430x15  15
+-#define E_MSP430_MACH_MSP430x16  16
+-#define E_MSP430_MACH_MSP430x31  31
+-#define E_MSP430_MACH_MSP430x32  32
+-#define E_MSP430_MACH_MSP430x33  33
+-#define E_MSP430_MACH_MSP430x41  41
+-#define E_MSP430_MACH_MSP430x42  42
+-#define E_MSP430_MACH_MSP430x43  43
+-#define E_MSP430_MACH_MSP430x44  44
++#define E_MSP430_MACH_MSP430x11   11
++#define E_MSP430_MACH_MSP430x11x1 110
++#define E_MSP430_MACH_MSP430x12   12
++#define E_MSP430_MACH_MSP430x13   13
++#define E_MSP430_MACH_MSP430x14   14
++#define E_MSP430_MACH_MSP430x15   15
++#define E_MSP430_MACH_MSP430x16   16
++#define E_MSP430_MACH_MSP430x20   20
++#define E_MSP430_MACH_MSP430x21   21
++#define E_MSP430_MACH_MSP430x22   22
++#define E_MSP430_MACH_MSP430x31   31
++#define E_MSP430_MACH_MSP430x32   32
++#define E_MSP430_MACH_MSP430x33   33
++#define E_MSP430_MACH_MSP430x41   41
++#define E_MSP430_MACH_MSP430x42   42
++#define E_MSP430_MACH_MSP430x43   43
++#define E_MSP430_MACH_MSP430x44   44
++#define E_MSP430_MACH_MSP430x46   46
+ /* Relocations.  */
+ START_RELOC_NUMBERS (elf_msp430_reloc_type)
+diff -ur binutils-2.18.orig/ld/Makefile.am binutils-2.18/ld/Makefile.am
+--- binutils-2.18.orig/ld/Makefile.am  2007-08-06 23:00:17.000000000 +0300
++++ binutils-2.18/ld/Makefile.am       2008-05-25 16:57:13.531250000 +0300
+@@ -296,6 +296,9 @@
+       emsp430x147.o \
+       emsp430x148.o \
+       emsp430x149.o \
++      emsp430x1471.o \
++      emsp430x1481.o \
++      emsp430x1491.o \
+       emsp430x155.o \
+       emsp430x156.o \
+       emsp430x157.o \
+@@ -305,10 +308,19 @@
+       emsp430x1610.o \
+       emsp430x1611.o \
+       emsp430x1612.o \
++      emsp430x2001.o \
++      emsp430x2011.o \
++      emsp430x2002.o \
++      emsp430x2012.o \
++      emsp430x2003.o \
++      emsp430x2014.o \
+       emsp430x2101.o \
+       emsp430x2111.o \
+       emsp430x2121.o \
+       emsp430x2131.o \
++      emsp430x2234.o \
++      emsp430x2254.o \
++      emsp430x2274.o \
+       emsp430x311.o \
+       emsp430x312.o \
+       emsp430x313.o \
+@@ -322,6 +334,12 @@
+       emsp430x413.o \
+       emsp430x415.o \
+       emsp430x417.o \
++      emsp430x423.o \
++      emsp430x425.o \
++      emsp430x427.o \
++      emsp430x4250.o \
++      emsp430x4260.o \
++      emsp430x4270.o \
+       emsp430xE423.o \
+       emsp430xE425.o \
+       emsp430xE427.o \
+@@ -337,6 +355,10 @@
+       emsp430x447.o \
+       emsp430x448.o \
+       emsp430x449.o \
++      emsp430xG4616.o \
++      emsp430xG4617.o \
++      emsp430xG4618.o \
++      emsp430xG4619.o \
+       enews.o \
+       ens32knbsd.o \
+       eor32.o \
+@@ -1311,6 +1333,18 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x149 "$(tdir_msp430x149)" msp430all
++emsp430x1471.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x1471 "$(tdir_msp430x1471)" msp430all
++emsp430x1481.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x1481 "$(tdir_msp430x1481)" msp430all
++emsp430x1491.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x1491 "$(tdir_msp430x1491)" msp430all
+ emsp430x155.c: $(srcdir)/emulparams/msp430all.sh \
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+@@ -1347,6 +1381,30 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x1612 "$(tdir_msp430x1612)" msp430all
++emsp430x2001.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2001 "$(tdir_msp430x2001)" msp430all
++emsp430x2011.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2011 "$(tdir_msp430x2011)" msp430all
++emsp430x2002.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2002 "$(tdir_msp430x2002)" msp430all
++emsp430x2012.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2012 "$(tdir_msp430x2012)" msp430all
++emsp430x2003.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2003 "$(tdir_msp430x2003)" msp430all
++emsp430x2013.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2013 "$(tdir_msp430x2013)" msp430all
+ emsp430x2101.c: $(srcdir)/emulparams/msp430all.sh \
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+@@ -1363,6 +1421,18 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x2131 "$(tdir_msp430x2131)" msp430all
++emsp430x2234.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2234 "$(tdir_msp430x2234)" msp430all
++emsp430x2254.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2254 "$(tdir_msp430x2254)" msp430all
++emsp430x2274.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2274 "$(tdir_msp430x2274)" msp430all
+ emsp430x311.c: $(srcdir)/emulparams/msp430all.sh \
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430_3.sc \
+   ${GEN_DEPENDS}
+@@ -1415,6 +1485,30 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x417 "$(tdir_msp430x417)" msp430all
++emsp430x423.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x423 "$(tdir_msp430x423)" msp430all
++emsp430x425.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x425 "$(tdir_msp430x425)" msp430all
++emsp430x427.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x427 "$(tdir_msp430x427)" msp430all
++emsp430x4250.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x4250 "$(tdir_msp430x4250)" msp430all
++emsp430x4260.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x4260 "$(tdir_msp430x4260)" msp430all
++emsp430x4270.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x4270 "$(tdir_msp430x4270)" msp430all
+ emsp430xE423.c: $(srcdir)/emulparams/msp430all.sh \
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+@@ -1475,6 +1569,22 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x449 "$(tdir_msp430x449)" msp430all
++emsp430xG4616.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430xG4616 "$(tdir_msp430xG4616)" msp430all
++emsp430xG4617.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430xG4617 "$(tdir_msp430xG4617)" msp430all
++emsp430xG4618.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430xG4618 "$(tdir_msp430xG4618)" msp430all
++emsp430xG4619.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430xG4619 "$(tdir_msp430xG4619)" msp430all
+ enews.c: $(srcdir)/emulparams/news.sh \
+   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
+       ${GENSCRIPTS} news "$(tdir_news)"
+diff -ur binutils-2.18.orig/ld/Makefile.in binutils-2.18/ld/Makefile.in
+--- binutils-2.18.orig/ld/Makefile.in  2007-08-06 23:29:54.000000000 +0300
++++ binutils-2.18/ld/Makefile.in       2008-05-25 16:57:13.546875000 +0300
+@@ -543,6 +543,9 @@
+       emsp430x147.o \
+       emsp430x148.o \
+       emsp430x149.o \
++      emsp430x1471.o \
++      emsp430x1481.o \
++      emsp430x1491.o \
+       emsp430x155.o \
+       emsp430x156.o \
+       emsp430x157.o \
+@@ -552,10 +555,19 @@
+       emsp430x1610.o \
+       emsp430x1611.o \
+       emsp430x1612.o \
++      emsp430x2001.o \
++      emsp430x2011.o \
++      emsp430x2002.o \
++      emsp430x2012.o \
++      emsp430x2003.o \
++      emsp430x2013.o \
+       emsp430x2101.o \
+       emsp430x2111.o \
+       emsp430x2121.o \
+       emsp430x2131.o \
++      emsp430x2234.o \
++      emsp430x2254.o \
++      emsp430x2274.o \
+       emsp430x311.o \
+       emsp430x312.o \
+       emsp430x313.o \
+@@ -569,6 +581,12 @@
+       emsp430x413.o \
+       emsp430x415.o \
+       emsp430x417.o \
++      emsp430x423.o \
++      emsp430x425.o \
++      emsp430x427.o \
++      emsp430x4250.o \
++      emsp430x4260.o \
++      emsp430x4270.o \
+       emsp430xE423.o \
+       emsp430xE425.o \
+       emsp430xE427.o \
+@@ -584,6 +602,10 @@
+       emsp430x447.o \
+       emsp430x448.o \
+       emsp430x449.o \
++      emsp430xG4616.o \
++      emsp430xG4617.o \
++      emsp430xG4618.o \
++      emsp430xG4619.o \
+       enews.o \
+       ens32knbsd.o \
+       eor32.o \
+@@ -2137,6 +2159,18 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x149 "$(tdir_msp430x149)" msp430all
++emsp430x1471.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x1471 "$(tdir_msp430x1471)" msp430all
++emsp430x1481.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x1481 "$(tdir_msp430x1481)" msp430all
++emsp430x1491.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x1491 "$(tdir_msp430x1491)" msp430all
+ emsp430x155.c: $(srcdir)/emulparams/msp430all.sh \
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+@@ -2173,6 +2207,30 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x1612 "$(tdir_msp430x1612)" msp430all
++emsp430x2001.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2001 "$(tdir_msp430x2001)" msp430all
++emsp430x2011.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2011 "$(tdir_msp430x2011)" msp430all
++emsp430x2002.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2002 "$(tdir_msp430x2002)" msp430all
++emsp430x2012.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2012 "$(tdir_msp430x2012)" msp430all
++emsp430x2003.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2003 "$(tdir_msp430x2003)" msp430all
++emsp430x2013.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2013 "$(tdir_msp430x2013)" msp430all
+ emsp430x2101.c: $(srcdir)/emulparams/msp430all.sh \
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+@@ -2189,6 +2247,18 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x2131 "$(tdir_msp430x2131)" msp430all
++emsp430x2234.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2234 "$(tdir_msp430x2234)" msp430all
++emsp430x2254.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2254 "$(tdir_msp430x2254)" msp430all
++emsp430x2274.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2274 "$(tdir_msp430x2274)" msp430all
+ emsp430x311.c: $(srcdir)/emulparams/msp430all.sh \
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430_3.sc \
+   ${GEN_DEPENDS}
+@@ -2241,6 +2311,30 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x417 "$(tdir_msp430x417)" msp430all
++emsp430x423.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x423 "$(tdir_msp430x423)" msp430all
++emsp430x425.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x425 "$(tdir_msp430x425)" msp430all
++emsp430x427.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x427 "$(tdir_msp430x427)" msp430all
++emsp430x4250.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x4250 "$(tdir_msp430x4250)" msp430all
++emsp430x4260.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x4260 "$(tdir_msp430x4260)" msp430all
++emsp430x4270.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x4270 "$(tdir_msp430x4270)" msp430all
+ emsp430xE423.c: $(srcdir)/emulparams/msp430all.sh \
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+@@ -2301,6 +2395,22 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x449 "$(tdir_msp430x449)" msp430all
++emsp430xG4616.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430xG4616 "$(tdir_msp430xG4616)" msp430all
++emsp430xG4617.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430xG4617 "$(tdir_msp430xG4617)" msp430all
++emsp430xG4618.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430xG4618 "$(tdir_msp430xG4618)" msp430all
++emsp430xG4619.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430xG4619 "$(tdir_msp430xG4619)" msp430all
+ enews.c: $(srcdir)/emulparams/news.sh \
+   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
+       ${GENSCRIPTS} news "$(tdir_news)"
+diff -ur binutils-2.18.orig/ld/configure.tgt binutils-2.18/ld/configure.tgt
+--- binutils-2.18.orig/ld/configure.tgt        2007-08-28 20:19:42.000000000 +0300
++++ binutils-2.18/ld/configure.tgt     2008-05-25 16:57:13.500000000 +0300
+@@ -407,7 +407,7 @@
+ mt-*elf)                targ_emul=elf32mt
+                       ;;
+ msp430-*-*)             targ_emul=msp430x110
+-                        targ_extra_emuls="msp430x112 msp430x1101 msp430x1111 msp430x1121 msp430x1122 msp430x1132 msp430x122 msp430x123 msp430x1222 msp430x1232 msp430x133 msp430x135 msp430x1331 msp430x1351 msp430x147 msp430x148 msp430x149 msp430x155 msp430x156 msp430x157 msp430x167 msp430x168 msp430x169 msp430x1610 msp430x1611 msp430x1612 msp430x2101 msp430x2111 msp430x2121 msp430x2131 msp430x311 msp430x312 msp430x313 msp430x314 msp430x315 msp430x323 msp430x325 msp430x336 msp430x337 msp430x412 msp430x413 msp430x415 msp430x417 msp430xE423 msp430xE425 msp430xE427 msp430xW423 msp430xW425 msp430xW427 msp430xG437 msp430xG438 msp430xG439 msp430x435 msp430x436 msp430x437 msp430x447 msp430x448 msp430x449"
++                        targ_extra_emuls="msp430x112 msp430x1101 msp430x1111 msp430x1121 msp430x1122 msp430x1132 msp430x122 msp430x123 msp430x1222 msp430x1232 msp430x133 msp430x135 msp430x1331 msp430x1351 msp430x147 msp430x148 msp430x149 msp430x1471 msp430x1481 msp430x1491 msp430x155 msp430x156 msp430x157 msp430x167 msp430x168 msp430x169 msp430x1610 msp430x1611 msp430x1612 msp430x2001 msp430x2011 msp430x2002 msp430x2012 msp430x2003 msp430x2013 msp430x2101 msp430x2111 msp430x2121 msp430x2131 msp430x2234 msp430x2254 msp430x2274 msp430x311 msp430x312 msp430x313 msp430x314 msp430x315 msp430x323 msp430x325 msp430x336 msp430x337 msp430x412 msp430x413 msp430x415 msp430x417 msp430x423 msp430x425 msp430x427 msp430x4250 msp430x4260 msp430x4270 msp430xE423 msp430xE425 msp430xE427 msp430xW423 msp430xW425 msp430xW427 msp430xG437 msp430xG438 msp430xG439 msp430x435 msp430x436 msp430x437 msp430x447 msp430x448 msp430x449 msp430xG4616 msp430xG4617 msp430xG4618 msp430xG4619"
+                       ;;
+ ns32k-pc532-mach* | ns32k-pc532-ux*)  targ_emul=pc532macha ;;
+ ns32k-*-netbsd* | ns32k-pc532-lites*) targ_emul=ns32knbsd
+diff -ur binutils-2.18.orig/ld/emulparams/msp430all.sh binutils-2.18/ld/emulparams/msp430all.sh
+--- binutils-2.18.orig/ld/emulparams/msp430all.sh      2006-06-20 05:22:14.000000000 +0300
++++ binutils-2.18/ld/emulparams/msp430all.sh   2008-05-25 16:57:13.515625000 +0300
+@@ -18,6 +18,8 @@
+ ROM_SIZE=0x3e0
+ RAM_START=0x0200
+ RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x280
+ fi
+@@ -27,6 +29,8 @@
+ ROM_SIZE=0x3e0
+ RAM_START=0x0200
+ RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x280
+ fi
+@@ -36,6 +40,8 @@
+ ROM_SIZE=0x07e0
+ RAM_START=0x0200
+ RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x280
+ fi
+@@ -45,6 +51,8 @@
+ ROM_SIZE=0xfe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -54,6 +62,8 @@
+ ROM_SIZE=0x0fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -63,6 +73,8 @@
+ ROM_SIZE=0x0fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -72,6 +84,8 @@
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -81,6 +95,8 @@
+ ROM_SIZE=0xfe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -90,6 +106,8 @@
+ ROM_SIZE=0xfe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -99,6 +117,8 @@
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -108,6 +128,8 @@
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -117,6 +139,8 @@
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -126,6 +150,8 @@
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -135,6 +161,8 @@
+ ROM_SIZE=0x3fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -144,6 +172,8 @@
+ ROM_SIZE=0x3fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -153,6 +183,8 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x0200
+ RAM_SIZE=1K
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+@@ -162,6 +194,8 @@
+ ROM_SIZE=0xbfe0
+ RAM_START=0x0200
+ RAM_SIZE=0x0800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0xa00
+ fi
+@@ -171,6 +205,41 @@
+ ROM_SIZE=0xeee0
+ RAM_START=0x0200
+ RAM_SIZE=0x0800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0xa00
++fi
++
++if [ "${MSP430_NAME}" = "msp430x1471" ] ; then
++ARCH=msp:14
++ROM_START=0x8000
++ROM_SIZE=0x7fe0
++RAM_START=0x0200
++RAM_SIZE=1K
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x600
++fi
++
++if [ "${MSP430_NAME}" = "msp430x1481" ] ; then
++ARCH=msp:14
++ROM_START=0x4000
++ROM_SIZE=0xbfe0
++RAM_START=0x0200
++RAM_SIZE=0x0800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0xa00
++fi
++
++if [ "${MSP430_NAME}" = "msp430x1491" ] ; then
++ARCH=msp:14
++ROM_START=0x1100
++ROM_SIZE=0xeee0
++RAM_START=0x0200
++RAM_SIZE=0x0800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0xa00
+ fi
+@@ -180,6 +249,8 @@
+ ROM_SIZE=0x3fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -189,6 +260,8 @@
+ ROM_SIZE=0x5fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -198,6 +271,8 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x0200
+ RAM_SIZE=1K
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+@@ -207,6 +282,8 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x0200
+ RAM_SIZE=1K
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+@@ -216,6 +293,8 @@
+ ROM_SIZE=0xbfe0
+ RAM_START=0x0200
+ RAM_SIZE=0x0800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0xa00
+ fi
+@@ -225,6 +304,8 @@
+ ROM_SIZE=0xeee0
+ RAM_START=0x0200
+ RAM_SIZE=0x0800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0xa00
+ fi
+@@ -234,6 +315,8 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x1100
+ RAM_SIZE=0x1400
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x2500
+ fi
+@@ -243,6 +326,8 @@
+ ROM_SIZE=0xbfe0
+ RAM_START=0x1100
+ RAM_SIZE=0x2800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x3900
+ fi
+@@ -252,15 +337,85 @@
+ ROM_SIZE=0xdae0
+ RAM_START=0x1100
+ RAM_SIZE=0x1400
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x2500
+ fi
++if [ "${MSP430_NAME}" = "msp430x2001" ] ; then
++ARCH=msp:20
++ROM_START=0xFC00
++ROM_SIZE=0x03e0
++RAM_START=0x0200
++RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x280
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2011" ] ; then
++ARCH=msp:20
++ROM_START=0xF800
++ROM_SIZE=0x07e0
++RAM_START=0x0200
++RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x280
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2002" ] ; then
++ARCH=msp:20
++ROM_START=0xFC00
++ROM_SIZE=0x03e0
++RAM_START=0x0200
++RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x280
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2012" ] ; then
++ARCH=msp:20
++ROM_START=0xF800
++ROM_SIZE=0x07e0
++RAM_START=0x0200
++RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x280
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2003" ] ; then
++ARCH=msp:20
++ROM_START=0xFC00
++ROM_SIZE=0x03e0
++RAM_START=0x0200
++RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x280
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2013" ] ; then
++ARCH=msp:20
++ROM_START=0xF800
++ROM_SIZE=0x07e0
++RAM_START=0x0200
++RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x280
++fi
++
+ if [ "${MSP430_NAME}" = "msp430x2101" ] ; then
+ ARCH=msp:21
+ ROM_START=0xFC00
+ ROM_SIZE=0x03e0
+ RAM_START=0x0200
+ RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x280
+ fi
+@@ -270,6 +425,8 @@
+ ROM_SIZE=0x07e0
+ RAM_START=0x0200
+ RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x280
+ fi
+@@ -279,6 +436,8 @@
+ ROM_SIZE=0x0fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -288,9 +447,44 @@
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
++if [ "${MSP430_NAME}" = "msp430x2234" ] ; then
++ARCH=msp:22
++ROM_START=0xe000
++ROM_SIZE=0x1fe0
++RAM_START=0x0200
++RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x300
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2254" ] ; then
++ARCH=msp:22
++ROM_START=0xc000
++ROM_SIZE=0x3fe0
++RAM_START=0x0200
++RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x400
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2274" ] ; then
++ARCH=msp:22
++ROM_START=0x8000
++ROM_SIZE=0x7fe0
++RAM_START=0x0200
++RAM_SIZE=1024
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x600
++fi
++
+ if [ "${MSP430_NAME}" = "msp430x311" ] ; then
+ ARCH=msp:31
+ SCRIPT_NAME=elf32msp430_3
+@@ -298,6 +492,8 @@
+ ROM_SIZE=0x07e0
+ RAM_START=0x0200
+ RAM_SIZE=128
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x280
+ fi
+@@ -308,6 +504,8 @@
+ ROM_SIZE=0x0fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -318,6 +516,8 @@
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -328,6 +528,8 @@
+ ROM_SIZE=0x2fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -338,6 +540,8 @@
+ ROM_SIZE=0x3fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -348,6 +552,8 @@
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -358,6 +564,8 @@
+ ROM_SIZE=0x3fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -368,6 +576,8 @@
+ ROM_SIZE=0x5fe0
+ RAM_START=0x0200
+ RAM_SIZE=1024
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+@@ -378,6 +588,8 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x0200
+ RAM_SIZE=1024
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+@@ -387,6 +599,8 @@
+ ROM_SIZE=0x0fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -396,6 +610,8 @@
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -405,6 +621,8 @@
+ ROM_SIZE=0x3fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -414,15 +632,85 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x0200
+ RAM_SIZE=1024
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x600
++fi
++
++if [ "${MSP430_NAME}" = "msp430x423" ] ; then
++ARCH=msp:42
++ROM_START=0xe000
++ROM_SIZE=0x1fe0
++RAM_START=0x0200
++RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x300
++fi
++
++if [ "${MSP430_NAME}" = "msp430x425" ] ; then
++ARCH=msp:42
++ROM_START=0xc000
++ROM_SIZE=0x3fe0
++RAM_START=0x0200
++RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x400
++fi
++
++if [ "${MSP430_NAME}" = "msp430x427" ] ; then
++ARCH=msp:42
++ROM_START=0x8000
++ROM_SIZE=0x7fe0
++RAM_START=0x0200
++RAM_SIZE=1024
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
++if [ "${MSP430_NAME}" = "msp430x4250" ] ; then
++ARCH=msp:42
++ROM_START=0xc000
++ROM_SIZE=0x3fe0
++RAM_START=0x0200
++RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x300
++fi
++
++if [ "${MSP430_NAME}" = "msp430x4260" ] ; then
++ARCH=msp:42
++ROM_START=0xa000
++ROM_SIZE=0x5fe0
++RAM_START=0x0200
++RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x300
++fi
++
++if [ "${MSP430_NAME}" = "msp430x4270" ] ; then
++ARCH=msp:42
++ROM_START=0x8000
++ROM_SIZE=0x7fe0
++RAM_START=0x0200
++RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x300
++fi
++
+ if [ "${MSP430_NAME}" = "msp430x435" ] ; then
+ ARCH=msp:43
+ ROM_START=0xc000
+ ROM_SIZE=0x3fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -432,6 +720,8 @@
+ ROM_SIZE=0x5fe0
+ RAM_START=0x0200
+ RAM_SIZE=1024
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+@@ -441,6 +731,8 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x0200
+ RAM_SIZE=1024
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+@@ -450,6 +742,8 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x0200
+ RAM_SIZE=1024
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+@@ -459,6 +753,8 @@
+ ROM_SIZE=0xbfe0
+ RAM_START=0x0200
+ RAM_SIZE=0x0800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0xa00
+ fi
+@@ -468,6 +764,8 @@
+ ROM_SIZE=0xeee0
+ RAM_START=0x0200
+ RAM_SIZE=0x0800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0xa00
+ fi
+@@ -477,6 +775,8 @@
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -486,6 +786,8 @@
+ ROM_SIZE=0x3fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -495,6 +797,8 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x0200
+ RAM_SIZE=1024
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+@@ -504,6 +808,8 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x0200
+ RAM_SIZE=1024
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+@@ -513,6 +819,8 @@
+ ROM_SIZE=0xbef0
+ RAM_START=0x0200
+ RAM_SIZE=0x0800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0xa00
+ fi
+@@ -522,15 +830,63 @@
+ ROM_SIZE=0xeee0
+ RAM_START=0x0200
+ RAM_SIZE=0x0800
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0xa00
+ fi
++if [ "${MSP430_NAME}" = "msp430xG4616" ] ; then
++ARCH=msp:46
++ROM_START=0x9100
++ROM_SIZE=0x6ec0
++RAM_START=0x1100
++RAM_SIZE=0x1000
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x2100
++fi
++
++if [ "${MSP430_NAME}" = "msp430xG4617" ] ; then
++ARCH=msp:46
++ROM_START=0x9100
++ROM_SIZE=0x6ec0
++RAM_START=0x1100
++RAM_SIZE=0x2000
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x3100
++fi
++
++if [ "${MSP430_NAME}" = "msp430xG4618" ] ; then
++ARCH=msp:46
++ROM_START=0x3100
++ROM_SIZE=0xcec0
++RAM_START=0x1100
++RAM_SIZE=0x2000
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x3100
++fi
++
++if [ "${MSP430_NAME}" = "msp430xG4619" ] ; then
++ARCH=msp:46
++ROM_START=0x2100
++ROM_SIZE=0xdec0
++RAM_START=0x1100
++RAM_SIZE=0x1000
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x2100
++fi
++
+ if [ "${MSP430_NAME}" = "msp430xW423" ] ; then
+ ARCH=msp:42
+ ROM_START=0xe000
+ ROM_SIZE=0x1fe0
+ RAM_START=0x0200
+ RAM_SIZE=256
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x300
+ fi
+@@ -540,6 +896,8 @@
+ ROM_SIZE=0x3fe0
+ RAM_START=0x0200
+ RAM_SIZE=512
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x400
+ fi
+@@ -549,5 +907,7 @@
+ ROM_SIZE=0x7fe0
+ RAM_START=0x0200
+ RAM_SIZE=0x400
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
+ STACK=0x600
+ fi
+diff -ur binutils-2.18.orig/ld/scripttempl/elf32msp430.sc binutils-2.18/ld/scripttempl/elf32msp430.sc
+--- binutils-2.18.orig/ld/scripttempl/elf32msp430.sc   2004-08-25 15:54:10.000000000 +0300
++++ binutils-2.18/ld/scripttempl/elf32msp430.sc        2008-05-25 16:57:13.562500000 +0300
+@@ -24,12 +24,12 @@
+ MEMORY
+ {
+-  text   (rx)         : ORIGIN = $ROM_START,  LENGTH = $ROM_SIZE
+-  data   (rwx)        : ORIGIN = $RAM_START,  LENGTH = $RAM_SIZE
+-  vectors (rw)        : ORIGIN = 0xffe0,      LENGTH = 0x20
+-  bootloader(rx)      : ORIGIN = 0x0c00,      LENGTH = 1K
+-  infomem(rx)         : ORIGIN = 0x1000,      LENGTH = 256
+-  infomemnobits(rx)   : ORIGIN = 0x1000,      LENGTH = 256
++  text   (rx)         : ORIGIN = $ROM_START,    LENGTH = $ROM_SIZE
++  data   (rwx)        : ORIGIN = $RAM_START,    LENGTH = $RAM_SIZE
++  vectors (rw)        : ORIGIN = $VECTORS_START LENGTH = $VECTORS_SIZE
++  bootloader(rx)      : ORIGIN = 0x0c00,            LENGTH = 1K
++  infomem(rx)         : ORIGIN = 0x1000,            LENGTH = 256
++  infomemnobits(rx)   : ORIGIN = 0x1000,        LENGTH = 256
+   ${HEAP_MEMORY_MSP430}
+ }
+diff -ur binutils-2.18.orig/ld/scripttempl/elf32msp430_3.sc binutils-2.18/ld/scripttempl/elf32msp430_3.sc
+--- binutils-2.18.orig/ld/scripttempl/elf32msp430_3.sc 2003-04-09 14:07:51.000000000 +0300
++++ binutils-2.18/ld/scripttempl/elf32msp430_3.sc      2008-05-25 16:57:13.546875000 +0300
+@@ -4,9 +4,9 @@
+ MEMORY
+ {
+-  text   (rx)   : ORIGIN = $ROM_START,  LENGTH = $ROM_SIZE
+-  data   (rwx)  : ORIGIN = $RAM_START,        LENGTH = $RAM_SIZE
+-  vectors (rw)  : ORIGIN = 0xffe0,      LENGTH = 0x20
++  text   (rx)   : ORIGIN = $ROM_START,    LENGTH = $ROM_SIZE
++  data   (rwx)  : ORIGIN = $RAM_START,          LENGTH = $RAM_SIZE
++  vectors (rw)  : ORIGIN = $VECTORS_START LENGTH = $VECTORS_SIZE
+ }
+ SECTIONS
+diff -ur binutils-2.18.orig/opcodes/msp430-dis.c binutils-2.18/opcodes/msp430-dis.c
+--- binutils-2.18.orig/opcodes/msp430-dis.c    2007-08-06 22:59:07.000000000 +0300
++++ binutils-2.18/opcodes/msp430-dis.c 2008-05-25 16:57:13.578125000 +0300
+@@ -679,7 +679,9 @@
+   insn = msp430dis_opcode (addr, info);
+   sprintf (dinfo, "0x%04x", insn);
+-  if (((int) addr & 0xffff) > 0xffdf)
++  if (((int) addr & 0xffff) >= 0xffe0
++      ||
++      (info->mach == 46  &&  ((int) addr & 0xffff) >= 0xffc0))
+     {
+       (*prin) (stream, "interrupt service routine at 0x%04x", 0xffff & insn);
+       return 2;
diff --git a/debian/patches/501-binutils-msp-new-cpus2.dpatch b/debian/patches/501-binutils-msp-new-cpus2.dpatch
new file mode 100755 (executable)
index 0000000..a19ee40
--- /dev/null
@@ -0,0 +1,586 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 501-binutils-msp-new-cpus2.dpatch by  <smckown@stevex2>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Add new cpu variations to the msp430 architecture
+
+@DPATCH@
+
+diff -ur binutils-2.18.orig/bfd/archures.c binutils-2.18/bfd/archures.c
+--- binutils-2.18.orig/bfd/archures.c  2008-05-25 16:57:13.406250000 +0300
++++ binutils-2.18/bfd/archures.c       2008-05-25 17:07:00.437500000 +0300
+@@ -377,6 +377,9 @@
+ .#define bfd_mach_msp20          20
+ .#define bfd_mach_msp21          21
+ .#define bfd_mach_msp22          22
++.#define bfd_mach_msp24          24
++.#define bfd_mach_msp241         241
++.#define bfd_mach_msp26          26
+ .#define bfd_mach_msp31          31
+ .#define bfd_mach_msp32          32
+ .#define bfd_mach_msp33          33
+diff -ur binutils-2.18.orig/bfd/bfd-in2.h binutils-2.18/bfd/bfd-in2.h
+--- binutils-2.18.orig/bfd/bfd-in2.h   2008-05-25 16:57:13.437500000 +0300
++++ binutils-2.18/bfd/bfd-in2.h        2008-05-25 17:07:00.468750000 +0300
+@@ -2048,6 +2048,9 @@
+ #define bfd_mach_msp20          20
+ #define bfd_mach_msp21          21
+ #define bfd_mach_msp22          22
++#define bfd_mach_msp24          24
++#define bfd_mach_msp241         241
++#define bfd_mach_msp26          26
+ #define bfd_mach_msp31          31
+ #define bfd_mach_msp32          32
+ #define bfd_mach_msp33          33
+diff -ur binutils-2.18.orig/bfd/cpu-msp430.c binutils-2.18/bfd/cpu-msp430.c
+--- binutils-2.18.orig/bfd/cpu-msp430.c        2008-05-25 16:57:13.437500000 +0300
++++ binutils-2.18/bfd/cpu-msp430.c     2008-05-25 17:07:00.484375000 +0300
+@@ -74,26 +74,35 @@
+   /* msp430x22x.  */
+   N (16, bfd_mach_msp22, "msp:22", FALSE, & arch_info_struct[10]),
++  /* msp430x24x including msp430x2410 */
++  N (16, bfd_mach_msp24, "msp:24", FALSE, & arch_info_struct[11]),
++
++  /* msp430x241x except msp430x2410 (extended address range) */
++  N (16, bfd_mach_msp241, "msp:241", FALSE, & arch_info_struct[12]),
++
++  /* msp430x26x.  */
++  N (16, bfd_mach_msp26, "msp:26", FALSE, & arch_info_struct[13]),
++
+   /* msp430x31x.  */
+-  N (16, bfd_mach_msp31, "msp:31", FALSE, & arch_info_struct[11]), 
++  N (16, bfd_mach_msp31, "msp:31", FALSE, & arch_info_struct[14]), 
+   /* msp430x32x.  */
+-  N (16, bfd_mach_msp32, "msp:32", FALSE, & arch_info_struct[12]), 
++  N (16, bfd_mach_msp32, "msp:32", FALSE, & arch_info_struct[15]), 
+   /* msp430x33x.  */
+-  N (16, bfd_mach_msp33, "msp:33", FALSE, & arch_info_struct[13]),
++  N (16, bfd_mach_msp33, "msp:33", FALSE, & arch_info_struct[16]),
+   
+   /* msp430x41x.  */
+-  N (16, bfd_mach_msp41, "msp:41", FALSE, & arch_info_struct[14]),
++  N (16, bfd_mach_msp41, "msp:41", FALSE, & arch_info_struct[17]),
+   /* msp430x42x.  */
+-  N (16, bfd_mach_msp42, "msp:42", FALSE, & arch_info_struct[15]),
++  N (16, bfd_mach_msp42, "msp:42", FALSE, & arch_info_struct[18]),
+   /* msp430x43x.  */
+-  N (16, bfd_mach_msp43, "msp:43", FALSE, & arch_info_struct[16]),
++  N (16, bfd_mach_msp43, "msp:43", FALSE, & arch_info_struct[19]),
+   /* msp430x44x.  */
+-  N (16, bfd_mach_msp44, "msp:44", FALSE, & arch_info_struct[17]),
++  N (16, bfd_mach_msp44, "msp:44", FALSE, & arch_info_struct[20]),
+   /* msp430x46xx.  */
+   N (16, bfd_mach_msp46, "msp:46", FALSE, NULL)
+diff -ur binutils-2.18.orig/bfd/doc/archures.texi binutils-2.18/bfd/doc/archures.texi
+--- binutils-2.18.orig/bfd/doc/archures.texi   2008-05-25 16:57:13.453125000 +0300
++++ binutils-2.18/bfd/doc/archures.texi        2008-05-25 17:07:00.500000000 +0300
+@@ -342,6 +342,9 @@
+ #define bfd_mach_msp20          20
+ #define bfd_mach_msp21          21
+ #define bfd_mach_msp22          22
++#define bfd_mach_msp24          24
++#define bfd_mach_msp241         241
++#define bfd_mach_msp26          26
+ #define bfd_mach_msp31          31
+ #define bfd_mach_msp32          32
+ #define bfd_mach_msp33          33
+@@ -599,4 +602,3 @@
+ This routine is provided for those cases where a bfd * is not
+ available
+-
+diff -ur binutils-2.18.orig/bfd/elf32-msp430.c binutils-2.18/bfd/elf32-msp430.c
+--- binutils-2.18.orig/bfd/elf32-msp430.c      2008-05-25 16:57:13.468750000 +0300
++++ binutils-2.18/bfd/elf32-msp430.c   2008-05-25 17:07:00.515625000 +0300
+@@ -576,6 +576,18 @@
+       val = E_MSP430_MACH_MSP430x22;
+       break;
++    case bfd_mach_msp24:
++      val = E_MSP430_MACH_MSP430x24;
++      break;
++
++    case bfd_mach_msp241:
++      val = E_MSP430_MACH_MSP430x241;
++      break;
++
++    case bfd_mach_msp26:
++      val = E_MSP430_MACH_MSP430x26;
++      break;
++
+     case bfd_mach_msp31:
+       val = E_MSP430_MACH_MSP430x31;
+       break;
+@@ -669,6 +681,18 @@
+         e_set = bfd_mach_msp22;
+         break;
++      case E_MSP430_MACH_MSP430x24:
++        e_set = bfd_mach_msp24;
++        break;
++
++      case E_MSP430_MACH_MSP430x241:
++        e_set = bfd_mach_msp241;
++        break;
++
++      case E_MSP430_MACH_MSP430x26:
++        e_set = bfd_mach_msp26;
++        break;
++
+       case E_MSP430_MACH_MSP430x31:
+         e_set = bfd_mach_msp31;
+         break;
+diff -ur binutils-2.18.orig/gas/config/tc-msp430.c binutils-2.18/gas/config/tc-msp430.c
+--- binutils-2.18.orig/gas/config/tc-msp430.c  2008-05-25 16:57:13.484375000 +0300
++++ binutils-2.18/gas/config/tc-msp430.c       2008-05-25 17:07:00.531250000 +0300
+@@ -250,6 +250,9 @@
+ #define MSP430_ISA_20   20
+ #define MSP430_ISA_21   21
+ #define MSP430_ISA_22   22
++#define MSP430_ISA_24   24
++#define MSP430_ISA_241  241
++#define MSP430_ISA_26   26
+ #define MSP430_ISA_31   31
+ #define MSP430_ISA_32   32
+ #define MSP430_ISA_33   33
+@@ -317,6 +320,24 @@
+   {"msp430x2234",  MSP430_ISA_22,  bfd_mach_msp22},
+   {"msp430x2254",  MSP430_ISA_22,  bfd_mach_msp22},
+   {"msp430x2274",  MSP430_ISA_22,  bfd_mach_msp22},
++
++  {"msp430x247",   MSP430_ISA_24,  bfd_mach_msp24},
++  {"msp430x2471",  MSP430_ISA_24,  bfd_mach_msp24},
++  {"msp430x248",   MSP430_ISA_24,  bfd_mach_msp24},
++  {"msp430x2481",  MSP430_ISA_24,  bfd_mach_msp24},
++  {"msp430x249",   MSP430_ISA_24,  bfd_mach_msp24},
++  {"msp430x2491",  MSP430_ISA_24,  bfd_mach_msp24},
++  {"msp430x2410",  MSP430_ISA_24,  bfd_mach_msp24},
++
++  {"msp430x2416",  MSP430_ISA_241, bfd_mach_msp241},
++  {"msp430x2417",  MSP430_ISA_241, bfd_mach_msp241},
++  {"msp430x2418",  MSP430_ISA_241, bfd_mach_msp241},
++  {"msp430x2419",  MSP430_ISA_241, bfd_mach_msp241},
++  
++  {"msp430x2616",  MSP430_ISA_26,  bfd_mach_msp26},
++  {"msp430x2617",  MSP430_ISA_26,  bfd_mach_msp26},
++  {"msp430x2618",  MSP430_ISA_26,  bfd_mach_msp26},
++  {"msp430x2619",  MSP430_ISA_26,  bfd_mach_msp26},
+   
+   {"msp430x311",   MSP430_ISA_31,  bfd_mach_msp31},
+   {"msp430x312",   MSP430_ISA_31,  bfd_mach_msp31},
+@@ -844,6 +865,10 @@
+            "                  msp430x2003  msp430x2013\n"
+            "                  msp430x2101  msp430x2111  msp430x2121  msp430x2131\n"
+            "                  msp430x2234  msp430x2254  msp430x2274\n"
++           "                  msp430x247   msp430x248   msp430x249   msp430x2410\n"
++           "                  msp430x2471  msp430x2481  msp430x2491\n"
++           "                  msp430x2416  msp430x2417  msp430x2418  msp430x2419\n"
++           "                  msp430x2616  msp430x2617  msp430x2618  msp430x2619\n"
+            "                  msp430x311   msp430x312   msp430x313   msp430x314  msp430x315\n"
+            "                  msp430x323   msp430x325\n" 
+            "                  msp430x336   msp430x337\n"
+diff -ur binutils-2.18.orig/include/elf/msp430.h binutils-2.18/include/elf/msp430.h
+--- binutils-2.18.orig/include/elf/msp430.h    2008-05-25 16:57:13.484375000 +0300
++++ binutils-2.18/include/elf/msp430.h 2008-05-25 17:07:00.531250000 +0300
+@@ -36,6 +36,9 @@
+ #define E_MSP430_MACH_MSP430x20   20
+ #define E_MSP430_MACH_MSP430x21   21
+ #define E_MSP430_MACH_MSP430x22   22
++#define E_MSP430_MACH_MSP430x24   24
++#define E_MSP430_MACH_MSP430x241  241
++#define E_MSP430_MACH_MSP430x26   26
+ #define E_MSP430_MACH_MSP430x31   31
+ #define E_MSP430_MACH_MSP430x32   32
+ #define E_MSP430_MACH_MSP430x33   33
+diff -ur binutils-2.18.orig/ld/Makefile.am binutils-2.18/ld/Makefile.am
+--- binutils-2.18.orig/ld/Makefile.am  2008-05-25 16:57:13.531250000 +0300
++++ binutils-2.18/ld/Makefile.am       2008-05-25 17:07:00.578125000 +0300
+@@ -321,6 +321,21 @@
+       emsp430x2234.o \
+       emsp430x2254.o \
+       emsp430x2274.o \
++      emsp430x247.o \
++      emsp430x248.o \
++      emsp430x249.o \
++      emsp430x2410.o \
++      emsp430x2471.o \
++      emsp430x2481.o \
++      emsp430x2491.o \
++      emsp430x2416.o \
++      emsp430x2417.o \
++      emsp430x2418.o \
++      emsp430x2419.o \
++      emsp430x2616.o \
++      emsp430x2617.o \
++      emsp430x2618.o \
++      emsp430x2619.o \
+       emsp430x311.o \
+       emsp430x312.o \
+       emsp430x313.o \
+@@ -1433,6 +1448,66 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x2274 "$(tdir_msp430x2274)" msp430all
++emsp430x247.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x247 "$(tdir_msp430x247)" msp430all
++emsp430x248.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x248 "$(tdir_msp430x248)" msp430all
++emsp430x249.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x249 "$(tdir_msp430x249)" msp430all
++emsp430x2410.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2410 "$(tdir_msp430x2410)" msp430all
++emsp430x2471.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2471 "$(tdir_msp430x2471)" msp430all
++emsp430x2481.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2481 "$(tdir_msp430x2481)" msp430all
++emsp430x2491.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2491 "$(tdir_msp430x2491)" msp430all
++emsp430x2416.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2416 "$(tdir_msp430x2416)" msp430all
++emsp430x2417.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2417 "$(tdir_msp430x2417)" msp430all
++emsp430x2418.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2418 "$(tdir_msp430x2418)" msp430all
++emsp430x2419.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2419 "$(tdir_msp430x2419)" msp430all
++emsp430x2616.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2616 "$(tdir_msp430x2616)" msp430all
++emsp430x2617.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2617 "$(tdir_msp430x2617)" msp430all
++emsp430x2618.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2618 "$(tdir_msp430x2618)" msp430all
++emsp430x2619.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2619 "$(tdir_msp430x2619)" msp430all
+ emsp430x311.c: $(srcdir)/emulparams/msp430all.sh \
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430_3.sc \
+   ${GEN_DEPENDS}
+diff -ur binutils-2.18.orig/ld/Makefile.in binutils-2.18/ld/Makefile.in
+--- binutils-2.18.orig/ld/Makefile.in  2008-05-25 16:57:13.546875000 +0300
++++ binutils-2.18/ld/Makefile.in       2008-05-25 17:07:00.593750000 +0300
+@@ -568,6 +568,21 @@
+       emsp430x2234.o \
+       emsp430x2254.o \
+       emsp430x2274.o \
++      emsp430x247.o \
++      emsp430x248.o \
++      emsp430x249.o \
++      emsp430x2410.o \
++      emsp430x2471.o \
++      emsp430x2481.o \
++      emsp430x2491.o \
++      emsp430x2416.o \
++      emsp430x2417.o \
++      emsp430x2418.o \
++      emsp430x2419.o \
++      emsp430x2616.o \
++      emsp430x2617.o \
++      emsp430x2618.o \
++      emsp430x2619.o \
+       emsp430x311.o \
+       emsp430x312.o \
+       emsp430x313.o \
+@@ -2259,6 +2274,66 @@
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
+   ${GEN_DEPENDS}
+       ${GENSCRIPTS} msp430x2274 "$(tdir_msp430x2274)" msp430all
++emsp430x247.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x247 "$(tdir_msp430x247)" msp430all
++emsp430x248.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x248 "$(tdir_msp430x248)" msp430all
++emsp430x249.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x249 "$(tdir_msp430x249)" msp430all
++emsp430x2410.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2410 "$(tdir_msp430x2410)" msp430all
++emsp430x2471.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2471 "$(tdir_msp430x2471)" msp430all
++emsp430x2481.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2481 "$(tdir_msp430x2481)" msp430all
++emsp430x2491.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2491 "$(tdir_msp430x2491)" msp430all
++emsp430x2416.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2416 "$(tdir_msp430x2416)" msp430all
++emsp430x2417.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2417 "$(tdir_msp430x2417)" msp430all
++emsp430x2418.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2418 "$(tdir_msp430x2418)" msp430all
++emsp430x2419.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2419 "$(tdir_msp430x2419)" msp430all
++emsp430x2616.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2616 "$(tdir_msp430x2616)" msp430all
++emsp430x2617.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2617 "$(tdir_msp430x2617)" msp430all
++emsp430x2618.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2618 "$(tdir_msp430x2618)" msp430all
++emsp430x2619.c: $(srcdir)/emulparams/msp430all.sh \
++  $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430.sc \
++  ${GEN_DEPENDS}
++      ${GENSCRIPTS} msp430x2619 "$(tdir_msp430x2619)" msp430all
+ emsp430x311.c: $(srcdir)/emulparams/msp430all.sh \
+   $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf32msp430_3.sc \
+   ${GEN_DEPENDS}
+diff -ur binutils-2.18.orig/ld/configure.tgt binutils-2.18/ld/configure.tgt
+--- binutils-2.18.orig/ld/configure.tgt        2008-05-25 16:57:13.500000000 +0300
++++ binutils-2.18/ld/configure.tgt     2008-05-25 17:07:00.562500000 +0300
+@@ -407,7 +407,7 @@
+ mt-*elf)                targ_emul=elf32mt
+                       ;;
+ msp430-*-*)             targ_emul=msp430x110
+-                        targ_extra_emuls="msp430x112 msp430x1101 msp430x1111 msp430x1121 msp430x1122 msp430x1132 msp430x122 msp430x123 msp430x1222 msp430x1232 msp430x133 msp430x135 msp430x1331 msp430x1351 msp430x147 msp430x148 msp430x149 msp430x1471 msp430x1481 msp430x1491 msp430x155 msp430x156 msp430x157 msp430x167 msp430x168 msp430x169 msp430x1610 msp430x1611 msp430x1612 msp430x2001 msp430x2011 msp430x2002 msp430x2012 msp430x2003 msp430x2013 msp430x2101 msp430x2111 msp430x2121 msp430x2131 msp430x2234 msp430x2254 msp430x2274 msp430x311 msp430x312 msp430x313 msp430x314 msp430x315 msp430x323 msp430x325 msp430x336 msp430x337 msp430x412 msp430x413 msp430x415 msp430x417 msp430x423 msp430x425 msp430x427 msp430x4250 msp430x4260 msp430x4270 msp430xE423 msp430xE425 msp430xE427 msp430xW423 msp430xW425 msp430xW427 msp430xG437 msp430xG438 msp430xG439 msp430x435 msp430x436 msp430x437 msp430x447 msp430x448 msp430x449 msp430xG4616 msp430xG4617 msp430xG4618 msp430xG4619"
++                        targ_extra_emuls="msp430x112 msp430x1101 msp430x1111 msp430x1121 msp430x1122 msp430x1132 msp430x122 msp430x123 msp430x1222 msp430x1232 msp430x133 msp430x135 msp430x1331 msp430x1351 msp430x147 msp430x148 msp430x149 msp430x1471 msp430x1481 msp430x1491 msp430x155 msp430x156 msp430x157 msp430x167 msp430x168 msp430x169 msp430x1610 msp430x1611 msp430x1612 msp430x2001 msp430x2011 msp430x2002 msp430x2012 msp430x2003 msp430x2013 msp430x2101 msp430x2111 msp430x2121 msp430x2131 msp430x2234 msp430x2254 msp430x2274 msp430x247 msp430x248 msp430x249 msp430x2410 msp430x2471 msp430x2481 msp430x2491 msp430x2416 msp430x2417 msp430x2418 msp430x2419 msp430x2616 msp430x2617 msp430x2618 msp430x2619 msp430x311 msp430x312 msp430x313 msp430x314 msp430x315 msp430x323 msp430x325 msp430x336 msp430x337 msp430x412 msp430x413 msp430x415 msp430x417 msp430x423 msp430x425 msp430x427 msp430x4250 msp430x4260 msp430x4270 msp430xE423 msp430xE425 msp430xE427 msp430xW423 msp430xW425 msp430xW427 msp430xG437 msp430xG438 msp430xG439 msp430x435 msp430x436 msp430x437 msp430x447 msp430x448 msp430x449 msp430xG4616 msp430xG4617 msp430xG4618 msp430xG4619"
+                       ;;
+ ns32k-pc532-mach* | ns32k-pc532-ux*)  targ_emul=pc532macha ;;
+ ns32k-*-netbsd* | ns32k-pc532-lites*) targ_emul=ns32knbsd
+diff -ur binutils-2.18.orig/ld/emulparams/msp430all.sh binutils-2.18/ld/emulparams/msp430all.sh
+--- binutils-2.18.orig/ld/emulparams/msp430all.sh      2008-05-25 16:57:13.515625000 +0300
++++ binutils-2.18/ld/emulparams/msp430all.sh   2008-05-25 17:07:00.562500000 +0300
+@@ -485,6 +485,171 @@
+ STACK=0x600
+ fi
++if [ "${MSP430_NAME}" = "msp430x247" ] ; then
++ARCH=msp:24
++ROM_START=0x8000
++ROM_SIZE=0x7fe0
++RAM_START=0x1100
++RAM_SIZE=4096
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x2100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x248" ] ; then
++ARCH=msp:24
++ROM_START=0x4000
++ROM_SIZE=0xbfe0
++RAM_START=0x1100
++RAM_SIZE=4096
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x2100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x249" ] ; then
++ARCH=msp:24
++ROM_START=0x1100
++ROM_SIZE=0xeee0
++RAM_START=0x0200
++RAM_SIZE=2048
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0xa00
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2410" ] ; then
++ARCH=msp:24
++ROM_START=0x2100
++ROM_SIZE=0xdee0
++RAM_START=0x1100
++RAM_SIZE=4096
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x2100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2471" ] ; then
++ARCH=msp:24
++ROM_START=0x8000
++ROM_SIZE=0x7fe0
++RAM_START=0x1100
++RAM_SIZE=4096
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x2100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2481" ] ; then
++ARCH=msp:24
++ROM_START=0x4000
++ROM_SIZE=0xbfe0
++RAM_START=0x1100
++RAM_SIZE=4096
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0x2100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2491" ] ; then
++ARCH=msp:24
++ROM_START=0x1100
++ROM_SIZE=0xeee0
++RAM_START=0x0200
++RAM_SIZE=2048
++VECTORS_START=0xffe0
++VECTORS_SIZE=32
++STACK=0xa00
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2416" ] ; then
++ARCH=msp:241
++ROM_START=0x2100
++ROM_SIZE=0xdec0
++RAM_START=0x1100
++RAM_SIZE=4096
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x2100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2417" ] ; then
++ARCH=msp:241
++ROM_START=0x3100
++ROM_SIZE=0xcec0
++RAM_START=0x1100
++RAM_SIZE=8192
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x3100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2418" ] ; then
++ARCH=msp:241
++ROM_START=0x3100
++ROM_SIZE=0xcec0
++RAM_START=0x1100
++RAM_SIZE=8192
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x3100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2419" ] ; then
++ARCH=msp:241
++ROM_START=0x2100
++ROM_SIZE=0xdec0
++RAM_START=0x1100
++RAM_SIZE=4096
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x2100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2616" ] ; then
++ARCH=msp:26
++ROM_START=0x2100
++ROM_SIZE=0xdec0
++RAM_START=0x1100
++RAM_SIZE=4096
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x2100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2617" ] ; then
++ARCH=msp:26
++ROM_START=0x3100
++ROM_SIZE=0xcec0
++RAM_START=0x1100
++RAM_SIZE=8192
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x3100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2618" ] ; then
++ARCH=msp:26
++ROM_START=0x3100
++ROM_SIZE=0xcec0
++RAM_START=0x1100
++RAM_SIZE=8192
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x3100
++fi
++
++if [ "${MSP430_NAME}" = "msp430x2619" ] ; then
++ARCH=msp:26
++ROM_START=0x2100
++ROM_SIZE=0xdec0
++RAM_START=0x1100
++RAM_SIZE=4096
++VECTORS_START=0xffc0
++VECTORS_SIZE=64
++STACK=0x2100
++fi
++
+ if [ "${MSP430_NAME}" = "msp430x311" ] ; then
+ ARCH=msp:31
+ SCRIPT_NAME=elf32msp430_3
+diff -ur binutils-2.18.orig/opcodes/msp430-dis.c binutils-2.18/opcodes/msp430-dis.c
+--- binutils-2.18.orig/opcodes/msp430-dis.c    2008-05-25 16:57:13.578125000 +0300
++++ binutils-2.18/opcodes/msp430-dis.c 2008-05-25 17:07:00.609375000 +0300
+@@ -681,7 +681,9 @@
+   if (((int) addr & 0xffff) >= 0xffe0
+       ||
+-      (info->mach == 46  &&  ((int) addr & 0xffff) >= 0xffc0))
++      ((info->mach == 241 || info->mach == 26 || info->mach == 46)
++       &&
++       ((int) addr & 0xffff) >= 0xffc0))
+     {
+       (*prin) (stream, "interrupt service routine at 0x%04x", 0xffff & insn);
+       return 2;
diff --git a/debian/patches/502-binutils-msp-ldscripts.dpatch b/debian/patches/502-binutils-msp-ldscripts.dpatch
new file mode 100755 (executable)
index 0000000..a7cd68d
--- /dev/null
@@ -0,0 +1,315 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 502-binutils-msp-ldscripts.dpatch by  <smckown@stevex2>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Add new ldscripts for cpu variations of the msp430 architecture
+
+@DPATCH@
+
+diff -ru binutils-2.17.orig/ld/scripttempl/elf32msp430.sc binutils-2.17/ld/scripttempl/elf32msp430.sc
+--- binutils-2.17.orig/ld/scripttempl/elf32msp430.sc   2008-05-23 02:00:49.049465400 +0300
++++ binutils-2.17/ld/scripttempl/elf32msp430.sc        2008-05-24 18:13:23.343750000 +0300
+@@ -14,7 +14,7 @@
+     ${RELOCATING+ PROVIDE (__heap_bottom = .) ; }
+     ${RELOCATING+ PROVIDE (__heap_top = ${HEAP_START} + ${HEAP_LENGTH}) ; }
+   } ${RELOCATING+ > heap}"
+-HEAP_MEMORY_MSP430="heap(rwx)                 : ORIGIN = $HEAP_START, LENGTH = $HEAP_LENGTH"
++HEAP_MEMORY_MSP430="heap(rwx)         : ORIGIN = $HEAP_START,    LENGTH = $HEAP_LENGTH"
+ fi
+@@ -24,12 +24,12 @@
+ MEMORY
+ {
+-  text   (rx)         : ORIGIN = $ROM_START,    LENGTH = $ROM_SIZE
+-  data   (rwx)        : ORIGIN = $RAM_START,    LENGTH = $RAM_SIZE
+-  vectors (rw)        : ORIGIN = $VECTORS_START LENGTH = $VECTORS_SIZE
+-  bootloader(rx)      : ORIGIN = 0x0c00,            LENGTH = 1K
+-  infomem(rx)         : ORIGIN = 0x1000,            LENGTH = 256
+-  infomemnobits(rx)   : ORIGIN = 0x1000,        LENGTH = 256
++  text   (rx)       : ORIGIN = $ROM_START,    LENGTH = $ROM_SIZE
++  data   (rwx)      : ORIGIN = $RAM_START,    LENGTH = $RAM_SIZE
++  vectors (rw)      : ORIGIN = $VECTORS_START,    LENGTH = $VECTORS_SIZE
++  bootloader(rx)    : ORIGIN = 0x0c00,     LENGTH = 1K
++  infomem(rx)       : ORIGIN = 0x1000,     LENGTH = 256
++  infomemnobits(rx) : ORIGIN = 0x1000,     LENGTH = 256
+   ${HEAP_MEMORY_MSP430}
+ }
+@@ -100,22 +100,35 @@
+   {
+     ${RELOCATING+. = ALIGN(2);}
+     *(.init)
+-    *(.init0)  /* Start here after reset.  */
+-    *(.init1)
+-    *(.init2)  /* Copy data loop  */
+-    *(.init3)
+-    *(.init4)  /* Clear bss  */
+-    *(.init5)
+-    *(.init6)  /* C++ constructors.  */
+-    *(.init7)
+-    *(.init8)
+-    *(.init9)  /* Call main().  */
++    KEEP(*(.init))
++    *(.init0)  /* Start here after reset.               */
++    KEEP(*(.init0))
++    *(.init1)  /* User definable.                       */
++    KEEP(*(.init1))
++    *(.init2)  /* Initialize stack.                     */
++    KEEP(*(.init2))
++    *(.init3)  /* Initialize hardware, user definable.  */
++    KEEP(*(.init3))
++    *(.init4)  /* Copy data to .data, clear bss.        */
++    KEEP(*(.init4))
++    *(.init5)  /* User definable.                       */
++    KEEP(*(.init5))
++    *(.init6)  /* C++ constructors.                     */
++    KEEP(*(.init6))
++    *(.init7)  /* User definable.                       */
++    KEEP(*(.init7))
++    *(.init8)  /* User definable.                       */
++    KEEP(*(.init8))
++    *(.init9)  /* Call main().                          */
++    KEEP(*(.init9))
+     ${CONSTRUCTING+ __ctors_start = . ; }
+     ${CONSTRUCTING+ *(.ctors) }
++    ${CONSTRUCTING+ KEEP(*(.ctors)) }
+     ${CONSTRUCTING+ __ctors_end = . ; }
+     ${CONSTRUCTING+ __dtors_start = . ; }
+     ${CONSTRUCTING+ *(.dtors) }
++    ${CONSTRUCTING+ KEEP(*(.dtors)) }
+     ${CONSTRUCTING+ __dtors_end = . ; }
+     ${RELOCATING+. = ALIGN(2);}
+@@ -124,31 +137,45 @@
+     *(.text.*)
+     ${RELOCATING+. = ALIGN(2);}
+-    *(.fini9)  /*   */
+-    *(.fini8)
+-    *(.fini7)
+-    *(.fini6)  /* C++ destructors.  */
+-    *(.fini5)
+-    *(.fini4)
+-    *(.fini3)
+-    *(.fini2)
+-    *(.fini1)
++    *(.fini9)  /* Jumps here after main(). User definable.  */
++    KEEP(*(.fini9))
++    *(.fini8)  /* User definable.                           */
++    KEEP(*(.fini8))
++    *(.fini7)  /* User definable.                           */
++    KEEP(*(.fini7))
++    *(.fini6)  /* C++ destructors.                          */
++    KEEP(*(.fini6))
++    *(.fini5)  /* User definable.                           */
++    KEEP(*(.fini5))
++    *(.fini4)  /* User definable.                           */
++    KEEP(*(.fini4))
++    *(.fini3)  /* User definable.                           */
++    KEEP(*(.fini3))
++    *(.fini2)  /* User definable.                           */
++    KEEP(*(.fini2))
++    *(.fini1)  /* User definable.                           */
++    KEEP(*(.fini1))
+     *(.fini0)  /* Infinite loop after program termination.  */
++    KEEP(*(.fini0))
+     *(.fini)
++    KEEP(*(.fini))
+     _etext = .;
+   } ${RELOCATING+ > text}
+-  .data ${RELOCATING-0} : ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text))}
++  .data ${RELOCATING-0} :
+   {  
+     ${RELOCATING+ PROVIDE (__data_start = .) ; }
+     ${RELOCATING+. = ALIGN(2);}
+     *(.data)
++    *(SORT_BY_ALIGNMENT(.data.*))
+     ${RELOCATING+. = ALIGN(2);}
+     *(.gnu.linkonce.d*)
+     ${RELOCATING+. = ALIGN(2);}
+     ${RELOCATING+ _edata = . ; }
+-  } ${RELOCATING+ > data}
++  } ${RELOCATING+ > data AT > text}
++   ${RELOCATING+ PROVIDE (__data_load_start = LOADADDR(.data) ); }
++   ${RELOCATING+ PROVIDE (__data_size = SIZEOF(.data) ); }
+   
+   /* Bootloader.  */
+   .bootloader ${RELOCATING-0} :
+@@ -175,19 +202,22 @@
+     *(.infomemnobits.*)
+   } ${RELOCATING+ > infomemnobits}
+-  .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} :
++  .bss ${RELOCATING-0} :
+   {
+     ${RELOCATING+ PROVIDE (__bss_start = .) ; }
+     *(.bss)
++    *(SORT_BY_ALIGNMENT(.bss.*))
+     *(COMMON)
+     ${RELOCATING+ PROVIDE (__bss_end = .) ; }
+     ${RELOCATING+ _end = . ;  }
+   } ${RELOCATING+ > data}
++   ${RELOCATING+ PROVIDE (__bss_size = SIZEOF(.bss) ); }
+-  .noinit ${RELOCATING+ SIZEOF(.bss) + ADDR(.bss)} :
++  .noinit ${RELOCATING-0} :
+   {
+     ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
+     *(.noinit)
++    *(.noinit.*)
+     *(COMMON)
+     ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
+     ${RELOCATING+ _end = . ;  }
+@@ -197,6 +227,7 @@
+   {
+     ${RELOCATING+ PROVIDE (__vectors_start = .) ; }
+     *(.vectors*)
++    KEEP(*(.vectors*))
+     ${RELOCATING+ _vectors_end = . ; }
+   } ${RELOCATING+ > vectors}
+diff -ru binutils-2.17.orig/ld/scripttempl/elf32msp430_3.sc binutils-2.17/ld/scripttempl/elf32msp430_3.sc
+--- binutils-2.17.orig/ld/scripttempl/elf32msp430_3.sc 2008-05-23 02:00:49.033840400 +0300
++++ binutils-2.17/ld/scripttempl/elf32msp430_3.sc      2008-05-24 17:50:27.953125000 +0300
+@@ -6,7 +6,7 @@
+ {
+   text   (rx)   : ORIGIN = $ROM_START,    LENGTH = $ROM_SIZE
+   data   (rwx)  : ORIGIN = $RAM_START,          LENGTH = $RAM_SIZE
+-  vectors (rw)  : ORIGIN = $VECTORS_START LENGTH = $VECTORS_SIZE
++  vectors (rw)  : ORIGIN = $VECTORS_START,    LENGTH = $VECTORS_SIZE
+ }
+ SECTIONS
+@@ -76,22 +76,35 @@
+   {
+     ${RELOCATING+. = ALIGN(2);}
+     *(.init)
+-    *(.init0)  /* Start here after reset.  */
+-    *(.init1)
+-    *(.init2)
+-    *(.init3)
+-    *(.init4)
+-    *(.init5)
+-    *(.init6)  /* C++ constructors.  */
+-    *(.init7)
+-    *(.init8)
+-    *(.init9)  /* Call main().  */
++    KEEP(*(.init))
++    *(.init0)  /* Start here after reset.               */
++    KEEP(*(.init0))
++    *(.init1)  /* User definable.                       */
++    KEEP(*(.init1))
++    *(.init2)  /* Initialize stack.                     */
++    KEEP(*(.init2))
++    *(.init3)  /* Initialize hardware, user definable.  */
++    KEEP(*(.init3))
++    *(.init4)  /* Copy data to .data, clear bss.        */
++    KEEP(*(.init4))
++    *(.init5)  /* User definable.                       */
++    KEEP(*(.init5))
++    *(.init6)  /* C++ constructors.                     */
++    KEEP(*(.init6))
++    *(.init7)  /* User definable.                       */
++    KEEP(*(.init7))
++    *(.init8)  /* User definable.                       */
++    KEEP(*(.init8))
++    *(.init9)  /* Call main().                          */
++    KEEP(*(.init9))
+     ${CONSTRUCTING+ __ctors_start = . ; }
+     ${CONSTRUCTING+ *(.ctors) }
++    ${CONSTRUCTING+ KEEP(*(.ctors)) }
+     ${CONSTRUCTING+ __ctors_end = . ; }
+     ${CONSTRUCTING+ __dtors_start = . ; }
+     ${CONSTRUCTING+ *(.dtors) }
++    ${CONSTRUCTING+ KEEP(*(.dtors)) }
+     ${CONSTRUCTING+ __dtors_end = . ; }
+     ${RELOCATING+. = ALIGN(2);}
+@@ -100,43 +113,60 @@
+     *(.text.*)
+     ${RELOCATING+. = ALIGN(2);}
+-    *(.fini9)
+-    *(.fini8)
+-    *(.fini7)
+-    *(.fini6)  /* C++ destructors.  */
+-    *(.fini5)
+-    *(.fini4)
+-    *(.fini3)
+-    *(.fini2)
+-    *(.fini1)
++    *(.fini9)  /* Jumps here after main(). User definable.  */
++    KEEP(*(.fini9))
++    *(.fini8)  /* User definable.                           */
++    KEEP(*(.fini8))
++    *(.fini7)  /* User definable.                           */
++    KEEP(*(.fini7))
++    *(.fini6)  /* C++ destructors.                          */
++    KEEP(*(.fini6))
++    *(.fini5)  /* User definable.                           */
++    KEEP(*(.fini5))
++    *(.fini4)  /* User definable.                           */
++    KEEP(*(.fini4))
++    *(.fini3)  /* User definable.                           */
++    KEEP(*(.fini3))
++    *(.fini2)  /* User definable.                           */
++    KEEP(*(.fini2))
++    *(.fini1)  /* User definable.                           */
++    KEEP(*(.fini1))
+     *(.fini0)  /* Infinite loop after program termination.  */
++    KEEP(*(.fini0))
+     *(.fini)
++    KEEP(*(.fini))
+     ${RELOCATING+ _etext = . ; }
+   } ${RELOCATING+ > text}
+-  .data ${RELOCATING-0} : ${RELOCATING+AT (ADDR (.text) + SIZEOF (.text))}
++  .data ${RELOCATING-0} :
+   {  
+     ${RELOCATING+ PROVIDE (__data_start = .) ; }
+     *(.data)
++    *(SORT_BY_ALIGNMENT(.data.*))
+     *(.gnu.linkonce.d*)
+     ${RELOCATING+. = ALIGN(2);}
+     ${RELOCATING+ _edata = . ; }
+-  } ${RELOCATING+ > data}
++  } ${RELOCATING+ > data AT > text}
++   ${RELOCATING+ PROVIDE (__data_load_start = LOADADDR(.data) ); }
++   ${RELOCATING+ PROVIDE (__data_size = SIZEOF(.data) ); }
+   
+-  .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} :
++  .bss ${RELOCATING-0} :
+   {
+     ${RELOCATING+ PROVIDE (__bss_start = .) ; }
+     *(.bss)
++    *(SORT_BY_ALIGNMENT(.bss.*))
+     *(COMMON)
+     ${RELOCATING+ PROVIDE (__bss_end = .) ; }
+     ${RELOCATING+ _end = . ;  }
+   } ${RELOCATING+ > data}
++   ${RELOCATING+ PROVIDE (__bss_size = SIZEOF(.bss) ); }
+-  .noinit ${RELOCATING+ SIZEOF(.bss) + ADDR(.bss)} :
++  .noinit ${RELOCATING-0} :
+   {
+     ${RELOCATING+ PROVIDE (__noinit_start = .) ; }
+     *(.noinit)
++    *(SORT_BY_ALIGNMENT(.noinit.*))
+     *(COMMON)
+     ${RELOCATING+ PROVIDE (__noinit_end = .) ; }
+     ${RELOCATING+ _end = . ;  }
+@@ -146,6 +176,7 @@
+   {
+     ${RELOCATING+ PROVIDE (__vectors_start = .) ; }
+     *(.vectors*)
++    KEEP(*(.vectors*))
+     ${RELOCATING+ _vectors_end = . ; }
+   } ${RELOCATING+ > vectors}
diff --git a/debian/patches/503-binutils-msp-undef-LEX_DOLLAR.dpatch b/debian/patches/503-binutils-msp-undef-LEX_DOLLAR.dpatch
new file mode 100755 (executable)
index 0000000..50daa76
--- /dev/null
@@ -0,0 +1,22 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 503-binutils-msp-undef-LEX_DOLLAR.dpatch by  <smckown@stevex2>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Allow LEX_DOLLAR to be used as an identifier in the msp430 architecture
+
+@DPATCH@
+
+diff -urN binutils-2.18.1~cvs20080103.orig/gas/config/tc-msp430.h binutils-2.18.1~cvs20080103/gas/config/tc-msp430.h
+--- binutils-2.18.1~cvs20080103.orig/gas/config/tc-msp430.h    2007-07-03 05:01:04.000000000 -0600
++++ binutils-2.18.1~cvs20080103/gas/config/tc-msp430.h 2008-08-21 13:46:29.000000000 -0600
+@@ -97,8 +97,8 @@
+      example, a value of 2 might print `1234 5678' where a value of 1
+      would print `12 34 56 78'.  The default value is 4.  */
+-#define LEX_DOLLAR 0
+-/* MSP430 port does not use `$' as a logical line separator */
++#undef LEX_DOLLAR
++/* Allow the MSP430 port to use `$' in identifiers */
+ #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) (P2VAR) = 0
+ /*   An `.lcomm' directive with no explicit alignment parameter will
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..d64a064
--- /dev/null
@@ -0,0 +1,184 @@
+#!/usr/bin/make -f
+# debian/rules file - for binutils (2.17cvs20070426)
+# Based on sample debian/rules file - for GNU Hello (1.3).
+# Copyright 1994,1995 by Ian Jackson.
+# Copyright 1998-2007 James Troup
+# 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
+
+include /usr/share/dpatch/dpatch.make
+
+TARGET = msp430
+rootname = binutils
+package = $(TARGET)-$(rootname)
+
+CC     = gcc
+CFLAGS = -g -O2
+STRIP  = strip --strip-unneeded --remove-section=.comment --remove-section=.note
+
+install_dir    = install -d -m 755
+install_file   = install -m 644
+install_script = install -m 755
+install_binary = install -m 755 -s
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+  CFLAGS = -g -O0
+endif
+
+DISTRIBUTION := $(shell lsb_release -is)
+NJOBS =
+# Support parallel=<n> in DEB_BUILD_OPTIONS (see #209008)
+ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
+  COMMA = ,
+  NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
+endif
+
+
+configure-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-stamp builddir
+       mkdir builddir
+       cd builddir \
+           && env CC="$(CC)" ../configure --host=$(DEB_HOST_GNU_TYPE) \
+             --build=$(DEB_BUILD_GNU_TYPE) --target=$(TARGET) --prefix=/usr \
+             --disable-nls --disable-shared --enable-debug --disable-threads \
+             --with-gcc --with-gnu-as --with-gnu-ld --with-stabs \
+#            --disable-multilib
+#            --with-pkgversion="GNU Binutils for $(TARGET) on $(DISTRIBUTION)"
+       $(MAKE) -C builddir configure-host
+       touch $@
+
+
+build: build-stamp
+build-stamp: configure-stamp
+       $(checkdir)
+       $(MAKE) -C builddir $(NJOBS) CFLAGS="$(CFLAGS)"
+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+ifeq ($(with_check),yes)
+       -$(MAKE) -C builddir -k \
+               CFLAGS="$(CFLAGS)" check
+       cat builddir/binutils/binutils.sum \
+           builddir/gas/testsuite/gas.sum \
+           builddir/ld/ld.sum >> $$(pwd)/test-summary
+       @-[ -x /usr/bin/python ] \
+         && echo "Test results, compared with installed binutils:" \
+         && zcat /usr/share/doc/binutils/test-summary.gz > test-summary-installed \
+         && python debian/test-suite-compare.py test-summary-installed test-summary
+endif
+endif
+       touch $@
+
+
+install: install-stamp
+install-stamp: checkroot build-stamp
+       $(checkdir)
+       rm -rf debian/tmp
+       $(install_dir) debian/tmp
+       $(MAKE) -C builddir prefix=$$(pwd)/debian/tmp/usr \
+               mandir=$$(pwd)/debian/tmp/usr/share/man install
+       #obstack.h? configure.1?
+       rm -rf debian/tmp/usr/share/man/man1/msp430-c++filt* \
+               debian/tmp/usr/bin/msp430-c++filt debian/tmp/usr/lib* \
+               debian/tmp/usr/info debian/tmp/usr/share/locale
+ifeq ($(with_strip),yes)
+       $(STRIP) $$(file debian/tmp/usr/bin/* | awk -F: '$$0 !~ /script/ {print $$1}')
+endif
+       touch $@
+
+
+binary-indep: checkroot build install
+       : # Nothing to do
+
+
+binary-arch: checkroot build install
+       $(checkdir)
+       : # install maintainer scripts
+       $(install_dir) debian/tmp/DEBIAN
+       $(install_script) debian/binutils.postinst debian/tmp/DEBIAN/postinst
+       $(install_script) debian/binutils.postrm debian/tmp/DEBIAN/postrm
+       : # $(install_file) debian/binutils.shlibs debian/tmp/DEBIAN/shlibs
+       : # install docs
+       $(install_dir) debian/tmp/usr/share/doc/$(package)/
+       $(install_file) debian/changelog \
+               debian/tmp/usr/share/doc/$(package)/changelog.Debian
+       $(install_file) debian/copyright debian/tmp/usr/share/doc/$(package)/
+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+ifeq ($(with_check),yes)
+       $(install_file) $$(pwd)/test-summary \
+               debian/tmp/usr/share/doc/$(package)/
+endif
+endif
+       $(install_file) binutils/NEWS debian/README.Debian \
+                        debian/tmp/usr/share/doc/$(package)/
+       $(install_file) binutils/ChangeLog \
+                       debian/tmp/usr/share/doc/$(package)/changelog
+       for pkg in bfd gas gprof ld; do \
+               $(install_dir) debian/tmp/usr/share/doc/$(package)/$$pkg; \
+       done
+       $(install_file) bfd/ChangeLog bfd/PORTING bfd/TODO \
+                       debian/tmp/usr/share/doc/$(package)/bfd/
+       $(install_file) gas/ChangeLog gas/NEWS \
+                       debian/tmp/usr/share/doc/$(package)/gas/
+       $(install_file) gprof/ChangeLog gprof/TODO gprof/TEST \
+                       debian/tmp/usr/share/doc/$(package)/gprof/
+       $(install_file) ld/ChangeLog ld/TODO ld/NEWS \
+                       debian/tmp/usr/share/doc/$(package)/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 \
+                               debian/tmp/usr/share/doc/$(package)/$$dir/; \
+               fi; \
+       done
+       : # Copy bbconv.pl to the doc dir for use by interested people
+       $(install_file) gprof/bbconv.pl \
+                       debian/tmp/usr/share/doc/$(package)/gprof/.
+       : # Compress stuff that needs it
+       gzip -9 debian/tmp/usr/share/man/man1/*
+       find debian/tmp/usr/share/doc/$(package)/ -type f ! -name copyright \
+               -a ! -name bbconv.pl | xargs gzip -9
+       : # Finish it all up
+       find debian/tmp -type f | xargs file | grep ELF | cut -d: -f 1 | \
+               xargs dpkg-shlibdeps
+       dpkg-gencontrol -isp $(CONFLICTS)
+       chown -R root:root debian/tmp
+       chmod -R go=rX  debian/tmp
+       dpkg --build debian/tmp ..
+
+
+binary: binary-indep binary-arch
+
+
+clean: unpatch
+       $(checkdir)
+       -rm -rf debian/tmp builddir
+       -find . -name \*.gmo -o -name \*~ -o -name \*.info | xargs rm -f
+       -rm -f $$(pwd)/test-summary*
+       -rm -fr debian/patched debian/files* debian/substvars
+       -rm -f *-stamp
+
+
+define checkdir
+        test -f bfd/elf32.c -a -f debian/rules
+endef
+
+
+checkroot:
+       $(checkdir)
+       test root = "`whoami`"
+
+
+.PHONY: binary clean checkroot
diff --git a/debian/test-suite-compare.py b/debian/test-suite-compare.py
new file mode 100644 (file)
index 0000000..f81ec4e
--- /dev/null
@@ -0,0 +1,227 @@
+#!/usr/bin/env python
+
+# Quick'n'dirty regression check for dejagnu testsuites
+# Copyright (C) 2003, 2004, 2005, 2006, 2007  James Troup <james@nocrew.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU;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":
+                    regression_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)
+
+################################################################################
+
+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] <OLD> <NEW>
+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()
index 617140b79574996b2cd11212030fb2c681e02aad..52f89f1e59988e8b946ebbaee18c7ec7ae8eca90 100755 (executable)
-/* bfin-aux.h ADI Blackfin Header file for gas\r
-   Copyright 2005, 2007\r
-   Free Software Foundation, Inc.\r
-\r
-   This file is part of GAS, the GNU Assembler.\r
-\r
-   GAS is free software; you can redistribute it and/or modify\r
-   it under the terms of the GNU General Public License as published by\r
-   the Free Software Foundation; either version 3, or (at your option)\r
-   any later version.\r
-\r
-   GAS is distributed in the hope that it will be useful,\r
-   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-   GNU General Public License for more details.\r
-\r
-   You should have received a copy of the GNU General Public License\r
-   along with GAS; see the file COPYING.  If not, write to the Free\r
-   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA\r
-   02110-1301, USA.  */\r
-\r
-#include "bfin-defs.h"\r
-\r
-#define REG_T Register *\r
-\r
-INSTR_T\r
-bfin_gen_dsp32mac (int op1, int mm, int mmod, int w1, int p,\r
-              int h01, int h11, int h00, int h10,\r
-             int op0, REG_T dst, REG_T src0, REG_T src1, int w0);\r
-\r
-INSTR_T\r
-bfin_gen_dsp32mult (int op1, int mm, int mmod, int w1, int p,\r
-               int h01, int h11, int h00, int h10,\r
-              int op0, REG_T dst, REG_T src0, REG_T src1, int w0);\r
-\r
-INSTR_T\r
-bfin_gen_dsp32alu (int HL, int aopcde, int aop, int s, int x,\r
-              REG_T dst0, REG_T dst1, REG_T src0, REG_T src1);\r
-\r
-INSTR_T\r
-bfin_gen_dsp32shift (int sopcde, REG_T dst0, REG_T src0, REG_T src1,\r
-                int sop, int hls);\r
-\r
-INSTR_T\r
-bfin_gen_dsp32shiftimm (int sopcde, REG_T dst0, int immag, REG_T src1,\r
-                   int sop, int hls);\r
-\r
-INSTR_T\r
-bfin_gen_ldimmhalf (REG_T reg, int h, int s, int z, Expr_Node *hword,\r
-               int reloc);\r
-\r
-INSTR_T\r
-bfin_gen_ldstidxi (REG_T ptr, REG_T reg, int w, int sz, int z,\r
-              Expr_Node *offset);\r
-\r
-INSTR_T\r
-bfin_gen_ldst (REG_T ptr, REG_T reg, int aop, int sz, int z, int w);\r
-\r
-INSTR_T\r
-bfin_gen_ldstii (REG_T ptr, REG_T reg, Expr_Node *offset, int w, int op);\r
-\r
-INSTR_T\r
-bfin_gen_ldstiifp (REG_T reg, Expr_Node *offset, int w);\r
-\r
-INSTR_T\r
-bfin_gen_ldstpmod (REG_T ptr, REG_T reg, int aop, int w, REG_T idx);\r
-\r
-INSTR_T\r
-bfin_gen_dspldst (REG_T i, REG_T reg, int aop, int w, int m);\r
-\r
-INSTR_T\r
-bfin_gen_alu2op (REG_T dst, REG_T src, int opc);\r
-\r
-INSTR_T\r
-bfin_gen_compi2opd (REG_T dst, int src, int op);\r
-\r
-INSTR_T\r
-bfin_gen_compi2opp (REG_T dst, int src, int op);\r
-\r
-INSTR_T\r
-bfin_gen_dagmodik (REG_T i, int op);\r
-\r
-INSTR_T\r
-bfin_gen_dagmodim (REG_T i, REG_T m, int op, int br);\r
-\r
-INSTR_T\r
-bfin_gen_ptr2op (REG_T dst, REG_T src, int opc);\r
-\r
-INSTR_T\r
-bfin_gen_logi2op (int dst, int src, int opc);\r
-\r
-INSTR_T\r
-bfin_gen_comp3op (REG_T src0, REG_T src1, REG_T dst, int opc);\r
-\r
-INSTR_T\r
-bfin_gen_ccmv (REG_T src, REG_T dst, int t);\r
-\r
-INSTR_T\r
-bfin_gen_ccflag (REG_T x, int y, int opc, int i, int g);\r
-\r
-INSTR_T\r
-bfin_gen_cc2stat (int cbit, int op, int d);\r
-\r
-INSTR_T\r
-bfin_gen_regmv (REG_T src, REG_T dst);\r
-\r
-INSTR_T\r
-bfin_gen_cc2dreg (int op, REG_T reg);\r
-\r
-INSTR_T\r
-bfin_gen_brcc (int t, int b, Expr_Node *offset);\r
-\r
-INSTR_T\r
-bfin_gen_ujump (Expr_Node *offset);\r
-\r
-INSTR_T\r
-bfin_gen_cactrl (REG_T reg, int a, int op);\r
-\r
-INSTR_T\r
-bfin_gen_progctrl (int prgfunc, int poprnd);\r
-\r
-INSTR_T\r
-bfin_gen_loopsetup (Expr_Node *soffset, REG_T c, int rop,\r
-               Expr_Node *eoffset, REG_T reg);\r
-\r
-INSTR_T\r
-bfin_gen_loop (Expr_Node *expr, REG_T reg, int rop, REG_T preg);\r
-\r
-INSTR_T\r
-bfin_gen_pushpopmultiple (int dr, int pr, int d, int p, int w);\r
-\r
-INSTR_T\r
-bfin_gen_pushpopreg (REG_T reg, int w);\r
-\r
-INSTR_T\r
-bfin_gen_calla (Expr_Node *addr, int s);\r
-\r
-INSTR_T\r
-bfin_gen_linkage (int r, int framesize);\r
-\r
-INSTR_T\r
-bfin_gen_pseudodbg (int fn, int reg, int grp);\r
-\r
-INSTR_T\r
-bfin_gen_pseudodbg_assert (int dbgop, REG_T regtest, int expected);\r
-\r
-bfd_boolean\r
-bfin_resource_conflict (INSTR_T dsp32, INSTR_T dsp16_grp1, INSTR_T dsp16_grp2);\r
-\r
-INSTR_T\r
-bfin_gen_multi_instr (INSTR_T dsp32, INSTR_T dsp16_grp1, INSTR_T dsp16_grp2);\r
+/* bfin-aux.h ADI Blackfin Header file for gas
+   Copyright 2005, 2007
+   Free Software Foundation, Inc.
+
+   This file is part of GAS, the GNU Assembler.
+
+   GAS 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, or (at your option)
+   any later version.
+
+   GAS 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 GAS; see the file COPYING.  If not, write to the Free
+   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#include "bfin-defs.h"
+
+#define REG_T Register *
+
+INSTR_T
+bfin_gen_dsp32mac (int op1, int mm, int mmod, int w1, int p,
+              int h01, int h11, int h00, int h10,
+             int op0, REG_T dst, REG_T src0, REG_T src1, int w0);
+
+INSTR_T
+bfin_gen_dsp32mult (int op1, int mm, int mmod, int w1, int p,
+               int h01, int h11, int h00, int h10,
+              int op0, REG_T dst, REG_T src0, REG_T src1, int w0);
+
+INSTR_T
+bfin_gen_dsp32alu (int HL, int aopcde, int aop, int s, int x,
+              REG_T dst0, REG_T dst1, REG_T src0, REG_T src1);
+
+INSTR_T
+bfin_gen_dsp32shift (int sopcde, REG_T dst0, REG_T src0, REG_T src1,
+                int sop, int hls);
+
+INSTR_T
+bfin_gen_dsp32shiftimm (int sopcde, REG_T dst0, int immag, REG_T src1,
+                   int sop, int hls);
+
+INSTR_T
+bfin_gen_ldimmhalf (REG_T reg, int h, int s, int z, Expr_Node *hword,
+               int reloc);
+
+INSTR_T
+bfin_gen_ldstidxi (REG_T ptr, REG_T reg, int w, int sz, int z,
+              Expr_Node *offset);
+
+INSTR_T
+bfin_gen_ldst (REG_T ptr, REG_T reg, int aop, int sz, int z, int w);
+
+INSTR_T
+bfin_gen_ldstii (REG_T ptr, REG_T reg, Expr_Node *offset, int w, int op);
+
+INSTR_T
+bfin_gen_ldstiifp (REG_T reg, Expr_Node *offset, int w);
+
+INSTR_T
+bfin_gen_ldstpmod (REG_T ptr, REG_T reg, int aop, int w, REG_T idx);
+
+INSTR_T
+bfin_gen_dspldst (REG_T i, REG_T reg, int aop, int w, int m);
+
+INSTR_T
+bfin_gen_alu2op (REG_T dst, REG_T src, int opc);
+
+INSTR_T
+bfin_gen_compi2opd (REG_T dst, int src, int op);
+
+INSTR_T
+bfin_gen_compi2opp (REG_T dst, int src, int op);
+
+INSTR_T
+bfin_gen_dagmodik (REG_T i, int op);
+
+INSTR_T
+bfin_gen_dagmodim (REG_T i, REG_T m, int op, int br);
+
+INSTR_T
+bfin_gen_ptr2op (REG_T dst, REG_T src, int opc);
+
+INSTR_T
+bfin_gen_logi2op (int dst, int src, int opc);
+
+INSTR_T
+bfin_gen_comp3op (REG_T src0, REG_T src1, REG_T dst, int opc);
+
+INSTR_T
+bfin_gen_ccmv (REG_T src, REG_T dst, int t);
+
+INSTR_T
+bfin_gen_ccflag (REG_T x, int y, int opc, int i, int g);
+
+INSTR_T
+bfin_gen_cc2stat (int cbit, int op, int d);
+
+INSTR_T
+bfin_gen_regmv (REG_T src, REG_T dst);
+
+INSTR_T
+bfin_gen_cc2dreg (int op, REG_T reg);
+
+INSTR_T
+bfin_gen_brcc (int t, int b, Expr_Node *offset);
+
+INSTR_T
+bfin_gen_ujump (Expr_Node *offset);
+
+INSTR_T
+bfin_gen_cactrl (REG_T reg, int a, int op);
+
+INSTR_T
+bfin_gen_progctrl (int prgfunc, int poprnd);
+
+INSTR_T
+bfin_gen_loopsetup (Expr_Node *soffset, REG_T c, int rop,
+               Expr_Node *eoffset, REG_T reg);
+
+INSTR_T
+bfin_gen_loop (Expr_Node *expr, REG_T reg, int rop, REG_T preg);
+
+INSTR_T
+bfin_gen_pushpopmultiple (int dr, int pr, int d, int p, int w);
+
+INSTR_T
+bfin_gen_pushpopreg (REG_T reg, int w);
+
+INSTR_T
+bfin_gen_calla (Expr_Node *addr, int s);
+
+INSTR_T
+bfin_gen_linkage (int r, int framesize);
+
+INSTR_T
+bfin_gen_pseudodbg (int fn, int reg, int grp);
+
+INSTR_T
+bfin_gen_pseudodbg_assert (int dbgop, REG_T regtest, int expected);
+
+bfd_boolean
+bfin_resource_conflict (INSTR_T dsp32, INSTR_T dsp16_grp1, INSTR_T dsp16_grp2);
+
+INSTR_T
+bfin_gen_multi_instr (INSTR_T dsp32, INSTR_T dsp16_grp1, INSTR_T dsp16_grp2);
diff --git a/ld/emultempl/spu_ovl.o b/ld/emultempl/spu_ovl.o
deleted file mode 100644 (file)
index a68eea3..0000000
Binary files a/ld/emultempl/spu_ovl.o and /dev/null differ
index 9ed80c5844b454d0ce7fb9a44d27b3600d62b2ab..b3534eecc379efc7c4b079f15a33435e8bfc7f00 100644 (file)
@@ -1,55 +1,55 @@
-#include <stdio.h>\r
-\r
-extern int var;\r
-extern void (*func_ptr)(void);\r
-extern void print_var (void);\r
-extern void print_foo (void);\r
-extern int foo;\r
-extern int var2[2];\r
-\r
-typedef struct\r
-{\r
-  int *   var;\r
-  void (* func_ptr)(void);\r
-}\r
-TEST;\r
-\r
-TEST xyz = { &var, print_var };\r
-\r
-int\r
-main (void)\r
-{\r
-  print_var ();\r
-\r
-  printf ("We see var = %d\n", var);\r
-  printf ("Setting var = 456\n");\r
-\r
-  var = 456;\r
-\r
-  print_var ();\r
-  printf ("We see var = %d\n\n", var);\r
-\r
-  var = 90;\r
-  print_var ();\r
-  printf ("We see var = %d\n\n", var);\r
-\r
-  print_foo ();\r
-  printf ("We see foo = %d\n", foo);\r
-  printf ("Setting foo = 19\n");\r
-  foo = 19;\r
-  print_foo ();\r
-  printf ("We see foo = %d\n\n", foo);\r
-  fflush (stdout);\r
-\r
-  printf ("Calling dllimported function pointer\n");\r
-  func_ptr ();\r
-\r
-  printf ("Calling functions using global structure\n"); \r
-  xyz.func_ptr ();\r
-  * xyz.var = 40;\r
-  xyz.func_ptr ();\r
-\r
-  printf ("We see var2[0] = %d\n\n", var2[0]);\r
-\r
-  return 0;\r
-}\r
+#include <stdio.h>
+
+extern int var;
+extern void (*func_ptr)(void);
+extern void print_var (void);
+extern void print_foo (void);
+extern int foo;
+extern int var2[2];
+
+typedef struct
+{
+  int *   var;
+  void (* func_ptr)(void);
+}
+TEST;
+
+TEST xyz = { &var, print_var };
+
+int
+main (void)
+{
+  print_var ();
+
+  printf ("We see var = %d\n", var);
+  printf ("Setting var = 456\n");
+
+  var = 456;
+
+  print_var ();
+  printf ("We see var = %d\n\n", var);
+
+  var = 90;
+  print_var ();
+  printf ("We see var = %d\n\n", var);
+
+  print_foo ();
+  printf ("We see foo = %d\n", foo);
+  printf ("Setting foo = 19\n");
+  foo = 19;
+  print_foo ();
+  printf ("We see foo = %d\n\n", foo);
+  fflush (stdout);
+
+  printf ("Calling dllimported function pointer\n");
+  func_ptr ();
+
+  printf ("Calling functions using global structure\n"); 
+  xyz.func_ptr ();
+  * xyz.var = 40;
+  xyz.func_ptr ();
+
+  printf ("We see var2[0] = %d\n\n", var2[0]);
+
+  return 0;
+}
index ccf85e4f5779af96ea2a97e460c9c8e6be9ca225..5da2ac8cc4afd97129c7309837138c0cecff35ad 100644 (file)
@@ -1,20 +1,20 @@
-int var = 123;\r
-int foo = 121;\r
-\r
-int var2[2]= { 123, 456 };\r
-\r
-#include <stdio.h>\r
-\r
-void\r
-print_var (void)\r
-{\r
-  printf ("DLL sees var = %d\n", var);\r
-}\r
-\r
-void\r
-print_foo (void)\r
-{\r
-  printf ("DLL sees foo = %d\n", foo);\r
-}\r
-\r
-void (* func_ptr)(void) = print_foo;\r
+int var = 123;
+int foo = 121;
+
+int var2[2]= { 123, 456 };
+
+#include <stdio.h>
+
+void
+print_var (void)
+{
+  printf ("DLL sees var = %d\n", var);
+}
+
+void
+print_foo (void)
+{
+  printf ("DLL sees foo = %d\n", foo);
+}
+
+void (* func_ptr)(void) = print_foo;