diff options
Diffstat (limited to 'gnu')
300 files changed, 55366 insertions, 0 deletions
diff --git a/gnu/COPYING b/gnu/COPYING new file mode 100644 index 000000000000..a43ea2126fb6 --- /dev/null +++ b/gnu/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) 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 +this service 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 make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. 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. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +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 +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE 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. + + END OF TERMS AND CONDITIONS + + Appendix: 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 +convey 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) 19yy <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 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision 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, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This 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 Library General +Public License instead of this License. diff --git a/gnu/COPYING.LIB b/gnu/COPYING.LIB new file mode 100644 index 000000000000..eb685a5ec981 --- /dev/null +++ b/gnu/COPYING.LIB @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, 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 +this service 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 make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +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 +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library 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 Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey 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 library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/gnu/Makefile b/gnu/Makefile new file mode 100644 index 000000000000..7ecf7c8965a3 --- /dev/null +++ b/gnu/Makefile @@ -0,0 +1,13 @@ +# @(#)Makefile 5.33.1.1 (Berkeley) 5/6/91 +# $FreeBSD$ + +.include <src.opts.mk> + +SUBDIR= lib .WAIT \ + usr.bin + +SUBDIR.${MK_TESTS}+= tests + +SUBDIR_PARALLEL= + +.include <bsd.subdir.mk> diff --git a/gnu/Makefile.inc b/gnu/Makefile.inc new file mode 100644 index 000000000000..5de8a1ece6f8 --- /dev/null +++ b/gnu/Makefile.inc @@ -0,0 +1,6 @@ +# $FreeBSD$ + +# Do not lint the GNU stuff. It is all externally maintained and +# lint output is wasteful noise here. + +NO_LINT= diff --git a/gnu/lib/Makefile b/gnu/lib/Makefile new file mode 100644 index 000000000000..5daba7518af0 --- /dev/null +++ b/gnu/lib/Makefile @@ -0,0 +1,29 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +SUBDIR= csu +SUBDIR.${MK_DIALOG}+= libdialog +SUBDIR.${MK_GCC}+= libgcov libgomp +SUBDIR.${MK_SSP}+= libssp +SUBDIR.${MK_TESTS}+= tests + +.if ${MK_GNU_GREP} != "no" || ${MK_GNU_GREP_COMPAT} != "no" || \ + ${MK_GDB} != "no" +SUBDIR+= libregex +.endif + +.if ${MK_LLVM_LIBUNWIND} == "no" +SUBDIR+= libgcc +.endif + +# libsupc++ uses libstdc++ headers, although 'make includes' should +# have taken care of that already. +.if ${MK_GNUCXX} != "no" +SUBDIR+= libstdc++ libsupc++ +SUBDIR_DEPENDS_libsupc++:= libstdc++ +.endif + +SUBDIR_PARALLEL= + +.include <bsd.subdir.mk> diff --git a/gnu/lib/Makefile.inc b/gnu/lib/Makefile.inc new file mode 100644 index 000000000000..265f86d1ed55 --- /dev/null +++ b/gnu/lib/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +.include "../Makefile.inc" diff --git a/gnu/lib/csu/Makefile b/gnu/lib/csu/Makefile new file mode 100644 index 000000000000..d981fb11054e --- /dev/null +++ b/gnu/lib/csu/Makefile @@ -0,0 +1,77 @@ +# $FreeBSD$ + +.include <src.opts.mk> +MK_SSP= no + +GCCDIR= ${SRCTOP}/contrib/gcc +GCCLIB= ${SRCTOP}/contrib/gcclibs +CCDIR= ${SRCTOP}/gnu/usr.bin/cc +.include "${CCDIR}/Makefile.tgt" +.include "${CCDIR}/cc_tools/Makefile.hdrs" + +.PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR} + +SRCS= crtstuff.c ${COMMONHDRS} +OBJS= crtbegin.o crtend.o crtbeginT.o +SOBJS= crtbeginS.o crtendS.o +CSTD?= gnu89 +CFLAGS+= -DIN_GCC -DHAVE_LD_EH_FRAME_HDR -DDT_CONFIG -D__GLIBC__=3 +CFLAGS.gcc+= -finhibit-size-directive -fno-toplevel-reorder +CFLAGS+= -fno-inline-functions -fno-exceptions \ + -fno-zero-initialized-in-bss -fno-asynchronous-unwind-tables \ + -fno-omit-frame-pointer +CFLAGS+= -I${GCCLIB}/include -I${GCCDIR}/config -I${GCCDIR} -I. \ + -I${CCDIR}/cc_tools +CRTS_CFLAGS= -DCRTSTUFFS_O -DSHARED ${PICFLAG} + +.if ${TARGET_CPUARCH} == "arm" +CFLAGS+= -DTARGET_ARM_EABI +.endif + +.if ${MACHINE_CPUARCH} == "powerpc" +TGTOBJS= crtsavres.o +SRCS+= crtsavres.asm +.endif +.if ${MACHINE_CPUARCH} == "sparc64" +TGTOBJS= crtfastmath.o +SRCS+= crtfastmath.c +.endif +BEGINSRC?= crtstuff.c +ENDSRC?= crtstuff.c + +FILES= ${OBJS} ${SOBJS} ${TGTOBJS} +FILESMODE= ${LIBMODE} +FILESOWN= ${LIBOWN} +FILESGRP= ${LIBGRP} +FILESDIR= ${LIBDIR} +# These FILES qualify as libraries for the purpose of LIBRARIES_ONLY. +.undef LIBRARIES_ONLY + +${OBJS} ${SOBJS}: ${SRCS:M*.h} + +CLEANFILES= ${OBJS} ${SOBJS} ${TGTOBJS} + +crtbegin.o: ${BEGINSRC} + ${CC} ${CFLAGS} -g0 -DCRT_BEGIN \ + -c -o ${.TARGET} ${.ALLSRC:N*.h} + +crtbeginT.o: ${BEGINSRC} + ${CC} ${CFLAGS} -g0 -DCRT_BEGIN -DCRTSTUFFT_O \ + -c -o ${.TARGET} ${.ALLSRC:N*.h} + +crtbeginS.o: ${BEGINSRC} + ${CC} ${CFLAGS} -g0 -DCRT_BEGIN ${CRTS_CFLAGS} \ + -c -o ${.TARGET} ${.ALLSRC:N*.h} + +crtend.o: ${ENDSRC} + ${CC} ${CFLAGS} -g0 -DCRT_END \ + -c -o ${.TARGET} ${.ALLSRC:N*.h} + +crtendS.o: ${ENDSRC} + ${CC} ${CFLAGS} -g0 -DCRT_END ${CRTS_CFLAGS} \ + -c -o ${.TARGET} ${.ALLSRC:N*.h} + +COMMONHDRS+= tm.h tconfig.h options.h +CLEANFILES+= ${COMMONHDRS} optionlist cs-tconfig.h cs-tm.h + +.include <bsd.lib.mk> diff --git a/gnu/lib/csu/Makefile.depend b/gnu/lib/csu/Makefile.depend new file mode 100644 index 000000000000..18be76b0cb6f --- /dev/null +++ b/gnu/lib/csu/Makefile.depend @@ -0,0 +1,13 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/lib/libdialog/Makefile b/gnu/lib/libdialog/Makefile new file mode 100644 index 000000000000..67d725657c2f --- /dev/null +++ b/gnu/lib/libdialog/Makefile @@ -0,0 +1,22 @@ +# $FreeBSD$ + +DIALOG= ${SRCTOP}/contrib/dialog + +LIB= dialog +SHLIB_MAJOR= 8 +SRCS= argv.c arrows.c buildlist.c buttons.c calendar.c checklist.c \ + columns.c dlg_keys.c editbox.c fselect.c formbox.c guage.c \ + help.c inputbox.c inputstr.c menubox.c mixedform.c \ + mixedgauge.c mouse.c mousewget.c msgbox.c pause.c prgbox.c \ + progressbox.c rangebox.c rc.c tailbox.c textbox.c timebox.c \ + trace.c treeview.c ttysize.c ui_getc.c util.c version.c yesno.c +INCS= dialog.h dlg_colors.h dlg_config.h dlg_keys.h +MAN= dialog.3 + +LIBADD= ncursesw m + +CFLAGS+= -I${.CURDIR} -I${DIALOG} -D_XOPEN_SOURCE_EXTENDED -DGCC_UNUSED=__unused +.PATH: ${DIALOG} +WARNS?= 4 + +.include <bsd.lib.mk> diff --git a/gnu/lib/libdialog/Makefile.depend b/gnu/lib/libdialog/Makefile.depend new file mode 100644 index 000000000000..a66ab8d1b411 --- /dev/null +++ b/gnu/lib/libdialog/Makefile.depend @@ -0,0 +1,19 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + lib/msun \ + lib/ncurses/ncursesw \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/lib/libdialog/dlg_config.h b/gnu/lib/libdialog/dlg_config.h new file mode 100644 index 000000000000..ee1d3f9ad3cb --- /dev/null +++ b/gnu/lib/libdialog/dlg_config.h @@ -0,0 +1,111 @@ +/* dlg_config.h. Generated automatically by configure. */ +/* + * The configure script expands this as a set of definitions + * + * $FreeBSD$ + */ + +#define CURSES_WACS_ARRAY _nc_wacs +#define DIALOG_PATCHDATE 20180621 +#define DIALOG_VERSION "1.3" +#define HAVE_ALLOCA 1 +#define HAVE_BTOWC 1 +#define HAVE_COLOR 1 +#define HAVE_DIRENT_H 1 +#define HAVE_DLG_FORMBOX 1 +#define HAVE_DLG_GAUGE 1 +#define HAVE_DLG_MIXEDFORM 1 +#define HAVE_DLG_TAILBOX 1 +#define HAVE_DLG_TRACE 1 +#define HAVE_FEOF_UNLOCKED 1 +#define HAVE_FLUSHINP 1 +#define HAVE_FSEEKO 1 +#define HAVE_GETATTRS 1 +#define HAVE_GETBEGX 1 +#define HAVE_GETBEGY 1 +#define HAVE_GETBEGYX 1 +#define HAVE_GETCURX 1 +#define HAVE_GETCURY 1 +#define HAVE_GETCWD 1 +#define HAVE_GETEGID 1 +#define HAVE_GETEUID 1 +#define HAVE_GETGID 1 +#define HAVE_GETMAXX 1 +#define HAVE_GETMAXY 1 +#define HAVE_GETMAXYX 1 +#define HAVE_GETPAGESIZE 1 +#define HAVE_GETPARX 1 +#define HAVE_GETPARY 1 +#define HAVE_GETPARYX 1 +#define HAVE_GETUID 1 +#define HAVE_ICONV 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_LANGINFO_CODESET 1 +#define HAVE_LC_MESSAGES 1 +#define HAVE_LIMITS_H 1 +#define HAVE_LOCALE_H 1 +#define HAVE_MBLEN 1 +#define HAVE_MBRLEN 1 +#define HAVE_MBRTOWC 1 +#define HAVE_MBSTATE_T 1 +#define HAVE_MBTOWC 1 +#define HAVE_MEMORY_H 1 +#define HAVE_MIXEDGAUGE 1 +#define HAVE_MKTIME 1 +#define HAVE_MMAP 1 +#define HAVE_MUNMAP 1 +#define HAVE_NCURSES_H 1 +#define HAVE_NL_TYPES_H 1 +#define HAVE_PUTENV 1 +#define HAVE_RC_FILE 1 +#define HAVE_SEARCH_H 1 +#define HAVE_SETENV 1 +#define HAVE_SETLOCALE 1 +#define HAVE_SIZECHANGE 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STPCPY 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRDUP 1 +#define HAVE_STRFTIME 1 +#define HAVE_STRINGS_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRTOUL 1 +#define HAVE_SYS_IOCTL_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_SYS_WAIT_H 1 +#define HAVE_TERMIOS_H 1 +#define HAVE_TERM_H 1 +#define HAVE_TSEARCH 1 +#define HAVE_TYPE_CHTYPE 1 +#define HAVE_UNCTRL_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_USE_DEFAULT_COLORS 1 +#define HAVE_WAITPID 1 +#define HAVE_WCHGAT 1 +#define HAVE_WCSRTOMBS 1 +#define HAVE_WCSTOMBS 1 +#define HAVE_WCTOB 1 +#define HAVE_WCTOMB 1 +#define HAVE_WCURSYNCUP 1 +#define HAVE_WGETPARENT 1 +#define HAVE_WHIPTAIL 1 +#define HAVE_WSYNCUP 1 +#define HAVE_XDIALOG 1 +#define HAVE_XDIALOG2 1 +#define HAVE__NC_FREE_AND_EXIT 1 +#define ICONV_CONST +#define MIXEDCASE_FILENAMES 1 +#define NCURSES 1 +#define NEED_WCHAR_H 1 +#define PACKAGE "dialog" +#define RETSIGTYPE void +#define STDC_HEADERS 1 +#define SYSTEM_NAME "freebsd12.0" +#define TIME_WITH_SYS_TIME 1 +#define TYPE_CHTYPE_IS_SCALAR 1 +#define USE_WIDE_CURSES 1 diff --git a/gnu/lib/libgcc/Makefile b/gnu/lib/libgcc/Makefile new file mode 100644 index 000000000000..157495368c7e --- /dev/null +++ b/gnu/lib/libgcc/Makefile @@ -0,0 +1,374 @@ +# $FreeBSD$ + +PACKAGE= clibs +GCCDIR= ${.CURDIR}/../../../contrib/gcc +GCCLIB= ${.CURDIR}/../../../contrib/gcclibs +CCDIR= ${.CURDIR}/../../usr.bin/cc + +SHLIB_NAME= libgcc_s.so.1 +SHLIBDIR?= /lib + +.include <src.opts.mk> +# +# libgcc is linked in last and thus cannot depend on ssp symbols coming +# from earlier libraries. Disable stack protection for this library. +# +MK_SSP= no + +.include "${CCDIR}/Makefile.tgt" +.include "${CCDIR}/cc_tools/Makefile.hdrs" + +.if ${TARGET_CPUARCH} == "arm" +CFLAGS+= -DTARGET_ARM_EABI +.endif + +.PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR}/config ${GCCDIR} + +CFLAGS+= -DIN_GCC -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \ + -DHAVE_GTHR_DEFAULT \ + -I${GCCLIB}/include \ + -I${GCCDIR}/config -I${GCCDIR} -I. \ + -I${CCDIR}/cc_tools + +LDFLAGS+= -nodefaultlibs +LIBADD+= c + +SOBJS= # added to below in various ways depending on TARGET_CPUARCH + +#--------------------------------------------------------------------------- +# +# Library members defined in libgcc2.c. +# When upgrading GCC, obtain the following list from mklibgcc.in +# +LIB2FUNCS= _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 \ + _cmpdi2 _ucmpdi2 \ + _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3 \ + _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors \ + _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab \ + _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2 \ + _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 \ + _divxc3 _divtc3 _bswapsi2 _bswapdi2 +.if ${COMPILER_TYPE} != "clang" || ${TARGET_CPUARCH} != "arm" +LIB2FUNCS+= _clear_cache +.endif + +# The floating-point conversion routines that involve a single-word integer. +.for mode in sf df xf +LIB2FUNCS+= _fixuns${mode}si +.endfor + +# Likewise double-word routines. +.if ${TARGET_CPUARCH} != "aarch64" && ${TARGET_CPUARCH} != "arm" && \ + ${TARGET_CPUARCH} != "riscv64" +# These are implemented in an ARM specific file but will not be filtered out. +# RISCVTODO: can't compile +.for mode in sf df xf tf +LIB2FUNCS+= _fix${mode}di _fixuns${mode}di +LIB2FUNCS+= _floatdi${mode} _floatundi${mode} +.endfor +.endif + +LIB2ADD = $(LIB2FUNCS_EXTRA) +LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA) + + +.if ${TARGET_CPUARCH} == "arm" +LIB2ADDEH = unwind-arm.c libunwind-arm.S pr-support.c unwind-c.c +.else +LIB2ADDEH = unwind-dw2.c unwind-dw2-fde-glibc.c unwind-sjlj.c gthr-gnat.c \ + unwind-c.c +.endif + +LIB2ADDEHSTATIC = $(LIB2ADDEH) +LIB2ADDEHSHARED = $(LIB2ADDEH) + +# List of extra C and assembler files to add to static and shared libgcc2. +# Assembler files should have names ending in `.asm'. +LIB2FUNCS_EXTRA = + +# List of extra C and assembler files to add to static libgcc2. +# Assembler files should have names ending in `.asm'. +LIB2FUNCS_STATIC_EXTRA = + +# Defined in libgcc2.c, included only in the static library. +# KAN: Excluded _sf_to_tf and _df_to_tf as TPBIT_FUNCS are not +# built on any of our platforms. +LIB2FUNCS_ST = _eprintf __gcc_bcmp + +FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \ + _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \ + _lt_sf _le_sf _unord_sf _si_to_sf _sf_to_si _negate_sf _make_sf \ + _sf_to_df _thenan_sf _sf_to_usi _usi_to_sf + +DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \ + _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \ + _lt_df _le_df _unord_df _si_to_df _df_to_si _negate_df _make_df \ + _df_to_sf _thenan_df _df_to_usi _usi_to_df + +TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \ + _fpcmp_parts_tf _compare_tf _eq_tf _ne_tf _gt_tf _ge_tf \ + _lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \ + _tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf + +# These might cause a divide overflow trap and so are compiled with +# unwinder info. +LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4 + +#----------------------------------------------------------------------- +# +# Platform specific bits. +# When upgrading GCC, get the following definitions from config/<cpu>/t-* +# +.if ${TARGET_CPUARCH} == "arm" +# from config/arm/t-strongarm-elf +CFLAGS+= -Dinhibit_libc -fno-inline +CFLAGS.clang+= -fheinous-gnu-extensions + +LIB1ASMSRC = lib1funcs.asm +LIB1ASMFUNCS = _dvmd_tls _bb_init_func +# Some compilers generate __aeabi_ functions libgcc_s is missing +LIBADD+= compiler_rt +.endif + +.if ${TARGET_CPUARCH} == mips +LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c +# ABIs other than o32 need this +.if (${TARGET_ARCH:Mmips64*} != "" || ${TARGET_ARCH:Mmipsn32*} != "") && \ + !defined(COMPAT_32BIT) +LIB2FUNCS_EXTRA+= floatdidf.c fixunsdfsi.c +LIB2FUNCS_EXTRA+= floatdisf.c floatundidf.c +LIB2FUNCS_EXTRA+= fixsfdi.c floatundisf.c +LIB2FUNCS_EXTRA+= fixdfdi.c fixunssfsi.c +.endif +.endif + +.if ${TARGET_ARCH} == "powerpc" || ${TARGET_ARCH} == "powerpcspe" +# from config/rs6000/t-ppccomm +LIB2FUNCS_EXTRA = tramp.asm +LIB2FUNCS_STATIC_EXTRA = eabi.asm +.endif + +.if ${TARGET_ARCH} == "powerpc64" +# from config/rs6000/t-ppccomm +LIB2FUNCS_EXTRA = tramp.asm +.endif + +.if ${TARGET_CPUARCH} == "sparc64" +# from config/sparc/t-elf +LIB1ASMSRC = lb1spc.asm +LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3 +.endif + +#----------------------------------------------------------------------- + +# Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are +# defined as optimized assembly code in LIB1ASMFUNCS. +.if defined(LIB1ASMFUNCS) +.for sym in ${LIB1ASMFUNCS} +LIB2FUNCS:= ${LIB2FUNCS:S/${sym}//g} +LIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS:S/${sym}//g} +.endfor +.endif + +COMMONHDRS= tm.h tconfig.h options.h gthr-default.h +COMMONHDRS+= unwind.h + +#----------------------------------------------------------------------- +# +# Helpful shortcuts for compiler invocations. +# +HIDE = -fvisibility=hidden -DHIDE_EXPORTS +CC_T = ${CC} -c ${CFLAGS} ${HIDE} -fPIC +CC_P = ${CC} -c ${CFLAGS} ${HIDE} -p -fPIC +CC_S = ${CC} -c ${CFLAGS} ${SHARED_CFLAGS} ${PICFLAG} -DSHARED + +#----------------------------------------------------------------------- +# +# Functions from libgcc2.c +# +STD_CFLAGS = +DIV_CFLAGS = -fexceptions -fnon-call-exceptions + +STD_FUNCS = ${LIB2FUNCS} +DIV_FUNCS = ${LIB2_DIVMOD_FUNCS} + +STD_CFILE = libgcc2.c +DIV_CFILE = libgcc2.c + +OBJ_GRPS = STD DIV + +#----------------------------------------------------------------------- +# +# Floating point emulation functions +# +.if ${TARGET_CPUARCH} == "armNOT_YET" || \ + ${TARGET_CPUARCH} == "powerpc" || ${TARGET_CPUARCH} == "sparc64" + +FPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES -DFLOAT +DPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES + +FPBIT_CFILE = config/fp-bit.c +DPBIT_CFILE = config/fp-bit.c + +OBJ_GRPS += FPBIT DPBIT +.endif + +#----------------------------------------------------------------------- +# +# Generic build rules for object groups defined above +# +.for T in ${OBJ_GRPS} +${T}_OBJS_T = ${${T}_FUNCS:S/$/.o/} +${T}_OBJS_P = ${${T}_FUNCS:S/$/.po/} +${T}_OBJS_S = ${${T}_FUNCS:S/$/.pico/} +SOBJS += ${${T}_FUNCS:S/$/.pico/} + +${${T}_OBJS_T}: ${${T}_CFILE} ${COMMONHDRS} + ${CC_T} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} +${${T}_OBJS_P}: ${${T}_CFILE} ${COMMONHDRS} + ${CC_P} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} +${${T}_OBJS_S}: ${${T}_CFILE} ${COMMONHDRS} + ${CC_S} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} +.endfor + +#----------------------------------------------------------------------- +# +# Extra objects coming from separate files +# +.if !empty(LIB2ADD) +SOBJS += ${LIB2ADD:R:S/$/.pico/} +.endif + +#----------------------------------------------------------------------- +# +# Objects that should be in static library only. +# +SYMS_ST = ${LIB2FUNCS_ST} ${LIB2ADD_ST} +STAT_OBJS_T = ${SYMS_ST:S/$/.o/} +STAT_OBJS_P = ${SYMS_ST:S/$/.po/} +STATICOBJS = ${SYMS_ST:S/$/.o/} + +${STAT_OBJS_T}: ${STD_CFILE} ${COMMONHDRS} + ${CC_T} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} +${STAT_OBJS_P}: ${STD_CFILE} ${COMMONHDRS} + ${CC_P} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} + +#----------------------------------------------------------------------- +# +# Assembler files. +# +.if defined(LIB1ASMSRC) +ASM_T = ${LIB1ASMFUNCS:S/$/.o/} +ASM_P = ${LIB1ASMFUNCS:S/$/.po/} +ASM_S = ${LIB1ASMFUNCS:S/$/.pico/} +ASM_V = ${LIB1ASMFUNCS:S/$/.vis/} +SOBJS += ${LIB1ASMFUNCS:S/$/.pico/} + +${ASM_T}: ${LIB1ASMSRC} ${.PREFIX}.vis + ${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \ + -o ${.TARGET} -include ${.PREFIX}.vis ${.ALLSRC:N*.h:N*.vis} +${ASM_P}: ${LIB1ASMSRC} ${.PREFIX}.vis + ${CC} -x assembler-with-cpp -p -c ${CFLAGS} -DL${.PREFIX} \ + -o ${.TARGET} -include ${.PREFIX}.vis ${.ALLSRC:N*.h:N*.vis} +${ASM_S}: ${LIB1ASMSRC} + ${CC} -x assembler-with-cpp -c ${PICFLAG} ${CFLAGS} -DL${.PREFIX} \ + -o ${.TARGET} ${.ALLSRC:N*.h} +${ASM_V}: ${LIB1ASMSRC} + ${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \ + -o ${.PREFIX}.vo ${.ALLSRC:N*.h} + ( ${NM} -pg ${.PREFIX}.vo | \ + awk 'NF == 3 && $$2 !~ /^[UN]$$/ { print "\t.hidden ", $$3 }'\ + ) > ${.TARGET} + +CLEANFILES += ${ASM_V} ${ASM_V:R:S/$/.vo/} +.endif + +#----------------------------------------------------------------------- +# +# Exception handling / unwinding support. +# +EH_OBJS_T = ${LIB2ADDEHSTATIC:R:S/$/.o/} +EH_OBJS_P = ${LIB2ADDEHSTATIC:R:S/$/.po/} +EH_OBJS_S = ${LIB2ADDEHSHARED:R:S/$/.pico/} +EH_CFLAGS = -fexceptions -D__GLIBC__=3 -DElfW=__ElfN +.if ${TARGET_CPUARCH} != "riscv64" +# RISCVTODO: unwinding support +SOBJS += ${EH_OBJS_S} +.endif + +.for _src in ${LIB2ADDEHSTATIC:M*.c} +${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS} + ${CC_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} +${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS} + ${CC_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} +.endfor +.for _src in ${LIB2ADDEHSHARED:M*.c} +${_src:R:S/$/.pico/}: ${_src} ${COMMONHDRS} + ${CC_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC} +.endfor + + +CLEANFILES += ${COMMONHDRS} +CLEANFILES += cs-*.h option* + +#----------------------------------------------------------------------- +# +# Build symbol version map +# +SHLIB_MKMAP = ${GCCDIR}/mkmap-symver.awk +SHLIB_MKMAP_OPTS = +SHLIB_MAPFILES = ${GCCDIR}/libgcc-std.ver +.if ${TARGET_CPUARCH} == "arm" +SHLIB_MAPFILES += ${GCCDIR}/config/arm/libgcc-bpabi.ver +.endif +VERSION_MAP = libgcc.map + +libgcc.map: ${SHLIB_MKMAP} ${SHLIB_MAPFILES} ${SOBJS} + ( ${NM} -pg ${SOBJS};echo %% ; \ + cat ${SHLIB_MAPFILES} \ + | sed -e '/^[ ]*#/d' \ + -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \ + | ${CC} ${CFLAGS} -E -xassembler-with-cpp -; \ + ) | awk -f ${SHLIB_MKMAP} ${SHLIB_MKMAP_OPTS} > ${.TARGET} + +CLEANFILES += libgcc.map + +#----------------------------------------------------------------------- +# +# Build additional static libgcc_eh[_p].a libraries. +# +libgcc_eh.a: ${EH_OBJS_T} + @${ECHO} building static gcc_eh library + @rm -f ${.TARGET} + ${AR} ${ARFLAGS} ${.TARGET} `lorder ${EH_OBJS_T} | tsort -q` + ${RANLIB} ${RANLIBFLAGS} ${.TARGET} + +_LIBS+= libgcc_eh.a + +.if ${MK_PROFILE} != "no" +libgcc_eh_p.a: ${EH_OBJS_P} + @${ECHO} building profiled gcc_eh library + @rm -f ${.TARGET} + ${AR} ${ARFLAGS} ${.TARGET} `lorder ${EH_OBJS_P} | tsort -q` + ${RANLIB} ${RANLIBFLAGS} ${.TARGET} + +_LIBS+= libgcc_eh_p.a +.endif + +_libinstall: _lib-eh-install + +_lib-eh-install: +.if ${MK_INSTALLLIB} != "no" + ${INSTALL} ${TAG_ARGS} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} libgcc_eh.a ${DESTDIR}${LIBDIR} +.endif +.if ${MK_PROFILE} != "no" + ${INSTALL} ${TAG_ARGS} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} libgcc_eh_p.a ${DESTDIR}${LIBDIR} +.endif + +CLEANFILES+= libgcc_eh.a libgcc_eh_p.a ${EH_OBJS_T} ${EH_OBJS_P} + +.include <bsd.lib.mk> + +.SUFFIXES: .vis .vo diff --git a/gnu/lib/libgcc/Makefile.depend b/gnu/lib/libgcc/Makefile.depend new file mode 100644 index 000000000000..2f6d8d110c49 --- /dev/null +++ b/gnu/lib/libgcc/Makefile.depend @@ -0,0 +1,16 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/lib/libgcov/Makefile b/gnu/lib/libgcov/Makefile new file mode 100644 index 000000000000..58c765515a6e --- /dev/null +++ b/gnu/lib/libgcov/Makefile @@ -0,0 +1,66 @@ +# $FreeBSD$ + +MK_PROFILE= no +MK_SSP= no + +.include <src.opts.mk> + +GCCDIR= ${SRCTOP}/contrib/gcc +GCCLIB= ${SRCTOP}/contrib/gcclibs +CCDIR= ${SRCTOP}/gnu/usr.bin/cc +.include "${CCDIR}/Makefile.tgt" +.include "${CCDIR}/cc_tools/Makefile.hdrs" + +.PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR} + +LIB= gcov + +CFLAGS+= -DIN_GCC -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED +CFLAGS+= -D_PTHREADS -DGTHREAD_USE_WEAK +CFLAGS+= -I${CCDIR}/cc_tools \ + -I${GCCLIB}/include -I${GCCDIR}/config -I${GCCDIR} -I. + +.if ${TARGET_CPUARCH} == "arm" +CFLAGS+= -DTARGET_ARM_EABI +.endif + +# +# Library members defined in libgcov.c. +# Defined in libgcov.c, included only in gcov library +SYMS = _gcov _gcov_merge_add _gcov_merge_single _gcov_merge_delta \ + _gcov_fork _gcov_execl _gcov_execlp _gcov_execle \ + _gcov_execv _gcov_execvp _gcov_execve \ + _gcov_interval_profiler _gcov_pow2_profiler _gcov_one_value_profiler + +OBJS= ${SYMS:S/$/.o/} +OBJS_T= ${SYMS:S/$/.o/} +OBJS_P= ${SYMS:S/$/.po/} +OBJS_S= ${SYMS:S/$/.pico/} + +#----------------------------------------------------------------------- +# +# Helpful shortcuts for compiler invocations. +# +CC_T = ${CC} -c ${CFLAGS} -fPIC +CC_P = ${CC} -c ${CFLAGS} -p -fPIC +CC_S = ${CC} -c ${CFLAGS} ${PICFLAG} -DSHARED + +COMMONHDRS= tm.h tconfig.h gcov-iov.h options.h +CLEANFILES+= ${COMMONHDRS} cs-tm.h cs-tconfig.h options.h optionlist + +${OBJS} beforedepend: ${COMMONHDRS} + +${OBJS_T}: libgcov.c + ${CC_T} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} + +.if !defined(NO_PIC) +${OBJS_S}: libgcov.c + ${CC_S} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} +.endif + +.if ${MK_PROFILE} != "no" +${OBJS_P}: libgcov.c + ${CC_P} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c} +.endif + +.include <bsd.lib.mk> diff --git a/gnu/lib/libgcov/Makefile.depend b/gnu/lib/libgcov/Makefile.depend new file mode 100644 index 000000000000..18be76b0cb6f --- /dev/null +++ b/gnu/lib/libgcov/Makefile.depend @@ -0,0 +1,13 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/lib/libgomp/Makefile b/gnu/lib/libgomp/Makefile new file mode 100644 index 000000000000..5a97172aad7e --- /dev/null +++ b/gnu/lib/libgomp/Makefile @@ -0,0 +1,61 @@ +# $FreeBSD$ + +GCCDIR= ${SRCTOP}/contrib/gcc +GCCLIB= ${SRCTOP}/contrib/gcclibs +SRCDIR= ${GCCLIB}/libgomp + +.PATH: ${SRCDIR} ${SRCDIR}/config/posix + +LIB= gomp +SHLIB_MAJOR= 1 + +SRCS= alloc.c barrier.c critical.c env.c \ + error.c iter.c loop.c ordered.c parallel.c sections.c \ + single.c team.c work.c lock.c mutex.c proc.c sem.c \ + bar.c time.c fortran.c affinity.c +SRCS+= gstdint.h libgomp_f.h omp.h omp_lib.h + +INCS+= omp.h + +CFLAGS+= -DHAVE_CONFIG_H +CFLAGS+= -I${.CURDIR} -I. -I${SRCDIR} -I${SRCDIR}/config/posix + +VERSION_MAP= ${SRCDIR}/libgomp.map + +# Target-specific OpenMP configuration +.if ${MACHINE_CPUARCH} == arm || ${MACHINE_CPUARCH} == i386 || \ + ${MACHINE_ARCH} == powerpc || ${MACHINE_ARCH} == powerpcspe || \ + (${MACHINE_CPUARCH} == mips && ${MACHINE_ARCH:Mmips64*} == "") +OMP_LOCK_ALIGN = 4 +OMP_LOCK_KIND= 4 +OMP_LOCK_SIZE= 4 +OMP_NEST_LOCK_ALIGN= 4 +OMP_NEST_LOCK_KIND= 8 +OMP_NEST_LOCK_SIZE= 8 +.else +OMP_LOCK_ALIGN = 8 +OMP_LOCK_KIND= 8 +OMP_LOCK_SIZE= 8 +OMP_NEST_LOCK_ALIGN= 8 +OMP_NEST_LOCK_KIND= 8 +OMP_NEST_LOCK_SIZE= 16 +.endif + +gstdint.h: + echo '#include <sys/types.h>' > ${.TARGET} + echo '#include <stdint.h>' >> ${.TARGET} +CLEANFILES+= gstdint.h + +.for HFILE in libgomp_f.h omp.h omp_lib.h +${HFILE}: ${SRCDIR}/${HFILE}.in ${.CURDIR}/Makefile + sed -e 's/@OMP_LOCK_ALIGN@/${OMP_LOCK_ALIGN}/g' \ + -e 's/@OMP_LOCK_KIND@/${OMP_LOCK_KIND}/g' \ + -e 's/@OMP_LOCK_SIZE@/${OMP_LOCK_SIZE}/g' \ + -e 's/@OMP_NEST_LOCK_ALIGN@/${OMP_NEST_LOCK_ALIGN}/g' \ + -e 's/@OMP_NEST_LOCK_KIND@/${OMP_NEST_LOCK_KIND}/g' \ + -e 's/@OMP_NEST_LOCK_SIZE@/${OMP_NEST_LOCK_SIZE}/g' \ + < ${SRCDIR}/${HFILE}.in > ${.TARGET} +CLEANFILES+= ${HFILE} +.endfor + +.include <bsd.lib.mk> diff --git a/gnu/lib/libgomp/Makefile.depend b/gnu/lib/libgomp/Makefile.depend new file mode 100644 index 000000000000..6cfaab1c3644 --- /dev/null +++ b/gnu/lib/libgomp/Makefile.depend @@ -0,0 +1,17 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/lib/libgomp/config.h b/gnu/lib/libgomp/config.h new file mode 100644 index 000000000000..547e6927db35 --- /dev/null +++ b/gnu/lib/libgomp/config.h @@ -0,0 +1,115 @@ +/* config.h. Generated by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ +/* $FreeBSD$ */ + +/* Define to 1 if the target supports __attribute__((alias(...))). */ +#define HAVE_ATTRIBUTE_ALIAS 1 + +/* Define to 1 if the target supports __attribute__((dllexport)). */ +/* #undef HAVE_ATTRIBUTE_DLLEXPORT */ + +/* Define to 1 if the target supports __attribute__((visibility(...))). */ +#define HAVE_ATTRIBUTE_VISIBILITY 1 + +/* Define if the POSIX Semaphores do not work on your system. */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if pthread_{,attr_}{g,s}etaffinity_np is supported. */ +#undef HAVE_PTHREAD_AFFINITY_NP + +/* Define to 1 if you have the <semaphore.h> header file. */ +#define HAVE_SEMAPHORE_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if the target supports __sync_*_compare_and_swap */ +#ifdef __amd64__ +#define HAVE_SYNC_BUILTINS 1 +#endif + +/* Define to 1 if you have the <sys/loadavg.h> header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/sysctl.h> header file. */ +#define HAVE_SYS_SYSCTL_H 1 + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if the target supports thread-local storage. */ +#if !defined(__mips__) +#define HAVE_TLS 1 +#endif + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Name of package */ +#define PACKAGE "libgomp" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "GNU OpenMP Runtime Library" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "GNU OpenMP Runtime Library 1.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libgomp" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.0" + +/* The size of a `char', as computed by sizeof. */ +/* #undef SIZEOF_CHAR */ + +/* The size of a `int', as computed by sizeof. */ +/* #undef SIZEOF_INT */ + +/* The size of a `long', as computed by sizeof. */ +/* #undef SIZEOF_LONG */ + +/* The size of a `short', as computed by sizeof. */ +/* #undef SIZEOF_SHORT */ + +/* The size of a `void *', as computed by sizeof. */ +/* #undef SIZEOF_VOID_P */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#define TIME_WITH_SYS_TIME 1 + +/* Version number of package */ +#define VERSION "1.0" diff --git a/gnu/lib/libregex/Makefile b/gnu/lib/libregex/Makefile new file mode 100644 index 000000000000..b775b74d75ae --- /dev/null +++ b/gnu/lib/libregex/Makefile @@ -0,0 +1,30 @@ +# $FreeBSD$ + +LIB= gnuregex +SHLIB_MAJOR= 5 + +REGEXDIR= ${SRCTOP}/contrib/libgnuregex +.PATH: ${REGEXDIR} + +SRCS= gnuregex.c +INCSGROUPS= INCS WRINCS PXINCS +INCS= regex.h.patched +INCSNAME= regex.h +INCSDIR= ${INCLUDEDIR}/gnu +WRINCS= gnuregex.h +PXINCS= ${REGEXDIR}/regex.h +PXINCSDIR= ${INCSDIR}/posix + +CFLAGS+= -D__attribute_warn_unused_result__="" +CFLAGS+= -DHAVE_CONFIG_H -I${.CURDIR} -I${REGEXDIR} + +CLEANFILES= regex.h.patched gnuregex.c +regex.h.patched: regex.h + sed 's=<posix/regex\.h>=<gnu/posix/regex.h>=g' \ + < ${.ALLSRC} > ${.TARGET} + +gnuregex.c: regex.c + sed 's=<regex\.h>=<gnu/regex.h>=g' \ + < ${.ALLSRC} > ${.TARGET} + +.include <bsd.lib.mk> diff --git a/gnu/lib/libregex/Makefile.depend b/gnu/lib/libregex/Makefile.depend new file mode 100644 index 000000000000..6cfaab1c3644 --- /dev/null +++ b/gnu/lib/libregex/Makefile.depend @@ -0,0 +1,17 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/lib/libregex/config.h b/gnu/lib/libregex/config.h new file mode 100644 index 000000000000..0076f3d76dfc --- /dev/null +++ b/gnu/lib/libregex/config.h @@ -0,0 +1,15 @@ +/* $FreeBSD$ */ + +#define _REGEX_RE_COMP 1 +#define HAVE_LANGINFO_H 1 +#define HAVE_LANGINFO_CODESET 1 +#define HAVE_LOCALE_H 1 +#define HAVE_WCHAR_H 1 +#define HAVE_WCTYPE_H 1 +#define HAVE_ISBLANK 1 +#define HAVE_WCRTOMB 1 +#define HAVE_MBRTOWC 1 +#define HAVE_WCSCOLL 1 +#define HAVE_ALLOCA 1 +#define HAVE_STDBOOL_H 1 +#define HAVE_STDINT_H 1 diff --git a/gnu/lib/libregex/gnuregex.h b/gnu/lib/libregex/gnuregex.h new file mode 100644 index 000000000000..7356f9ffbe42 --- /dev/null +++ b/gnu/lib/libregex/gnuregex.h @@ -0,0 +1,33 @@ +/*- + * Copyright (c) 2004 David E. O'Brien + * Copyright (c) 2004 Andrey A. Chernov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifdef __GNUC__ +#warning "Use -I/usr/include/gnu and <regex.h> instead of <gnuregex.h>" +#endif +#include <gnu/regex.h> diff --git a/gnu/lib/libregex/regex.h b/gnu/lib/libregex/regex.h new file mode 100644 index 000000000000..85410a2a7495 --- /dev/null +++ b/gnu/lib/libregex/regex.h @@ -0,0 +1,54 @@ +/* $FreeBSD$ */ +#ifndef _REGEX_H + +#ifndef __USE_GNU +#define __USE_GNU +#endif + +#include <posix/regex.h> + +/* Document internal interfaces. */ +extern reg_syntax_t __re_set_syntax (reg_syntax_t __syntax); + +extern const char *__re_compile_pattern (const char *__pattern, size_t __length, + struct re_pattern_buffer *__buffer); + +extern int __re_compile_fastmap (struct re_pattern_buffer *__buffer); + +extern int __re_search (struct re_pattern_buffer *__buffer, const char *__string, + int __length, int __start, int __range, + struct re_registers *__regs); + +extern int __re_search_2 (struct re_pattern_buffer *__buffer, + const char *__string1, int __length1, + const char *__string2, int __length2, int __start, + int __range, struct re_registers *__regs, int __stop); + +extern int __re_match (struct re_pattern_buffer *__buffer, const char *__string, + int __length, int __start, struct re_registers *__regs); + +extern int __re_match_2 (struct re_pattern_buffer *__buffer, + const char *__string1, int __length1, + const char *__string2, int __length2, int __start, + struct re_registers *__regs, int __stop); + +extern void __re_set_registers (struct re_pattern_buffer *__buffer, + struct re_registers *__regs, + unsigned int __num_regs, + regoff_t *__starts, regoff_t *__ends); + +extern int __regcomp (regex_t *__restrict __preg, + const char *__restrict __pattern, + int __cflags); + +extern int __regexec (const regex_t *__restrict __preg, + const char *__restrict __string, size_t __nmatch, + regmatch_t __pmatch[__restrict_arr], + int __eflags); + +extern size_t __regerror (int __errcode, const regex_t *__restrict __preg, + char *__restrict __errbuf, size_t __errbuf_size); + +extern void __regfree (regex_t *__preg); + +#endif /* _REGEX_H */ diff --git a/gnu/lib/libssp/Makefile b/gnu/lib/libssp/Makefile new file mode 100644 index 000000000000..e611f5dfee45 --- /dev/null +++ b/gnu/lib/libssp/Makefile @@ -0,0 +1,40 @@ +# $FreeBSD$ + +SHLIBDIR?= /lib + +MK_PROFILE= no +MK_SSP= no + +.include <bsd.own.mk> + +GCCDIR= ${SRCTOP}/contrib/gcc +GCCLIB= ${SRCTOP}/contrib/gcclibs +SRCDIR= ${GCCLIB}/libssp + +.PATH: ${SRCDIR} ${SRCDIR}/ssp + +LIB= ssp +SHLIB_MAJOR= 0 +LD_FATAL_WARNINGS= no + +SRCS= ssp.c gets-chk.c memcpy-chk.c memmove-chk.c mempcpy-chk.c \ + memset-chk.c snprintf-chk.c sprintf-chk.c stpcpy-chk.c \ + strcat-chk.c strcpy-chk.c strncat-chk.c strncpy-chk.c \ + vsnprintf-chk.c vsprintf-chk.c + +CFLAGS+= -DHAVE_CONFIG_H +CFLAGS+= -I${.CURDIR} -I${SRCDIR} -I${GCCLIB}/include + +VERSION_MAP= ${SRCDIR}/ssp.map + + +INCS= ssp.h string.h stdio.h unistd.h +INCSDIR=${INCLUDEDIR}/ssp + +CLEANFILES= ssp.h +ssp.h: ssp.h.in + sed -e 's/@ssp_have_usable_vsnprintf@/define/' ${.ALLSRC} > ${.TARGET} + +SUBDIR+= libssp_nonshared + +.include <bsd.lib.mk> diff --git a/gnu/lib/libssp/Makefile.depend b/gnu/lib/libssp/Makefile.depend new file mode 100644 index 000000000000..6cfaab1c3644 --- /dev/null +++ b/gnu/lib/libssp/Makefile.depend @@ -0,0 +1,17 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/lib/libssp/config.h b/gnu/lib/libssp/config.h new file mode 100644 index 000000000000..680f10754454 --- /dev/null +++ b/gnu/lib/libssp/config.h @@ -0,0 +1,87 @@ +/* config.h. Generated by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ +/* $FreeBSD$ */ + +/* Define to 1 if you have the <alloca.h> header file. */ +/* #undef HAVE_ALLOCA_H */ + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* __attribute__((visibility ("hidden"))) supported */ +#define HAVE_HIDDEN_VISIBILITY 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mempcpy' function. */ +/* #undef HAVE_MEMPCPY */ + +/* Define to 1 if you have the <paths.h> header file. */ +#define HAVE_PATHS_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdio.h> header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strncat' function. */ +#define HAVE_STRNCAT 1 + +/* Define to 1 if you have the `strncpy' function. */ +#define HAVE_STRNCPY 1 + +/* Define to 1 if you have the <syslog.h> header file. */ +#define HAVE_SYSLOG_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* vsnprintf is present and works */ +#define HAVE_USABLE_VSNPRINTF 1 + +/* Name of package */ +#define PACKAGE "libssp" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libssp" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libssp 1.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libssp" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.0" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "1.0" diff --git a/gnu/lib/libssp/libssp_nonshared/Makefile b/gnu/lib/libssp/libssp_nonshared/Makefile new file mode 100644 index 000000000000..64bc98f82ef8 --- /dev/null +++ b/gnu/lib/libssp/libssp_nonshared/Makefile @@ -0,0 +1,18 @@ +# $FreeBSD$ + +GCCDIR= ${SRCTOP}/contrib/gcc +GCCLIB= ${SRCTOP}/contrib/gcclibs + +.PATH: ${GCCLIB}/libssp ${GCCLIB}/libssp/ssp + +LIB= ssp_nonshared +NO_PIC= +MK_PROFILE=no + +SRCS= ssp-local.c + +CFLAGS+= -DHAVE_CONFIG_H +CFLAGS+= -I${.CURDIR}/.. -I${GCCLIB}/libssp -I${GCCLIB}/include +CFLAGS+= -fPIC -DPIC -fvisibility=hidden + +.include <bsd.lib.mk> diff --git a/gnu/lib/libssp/libssp_nonshared/Makefile.depend b/gnu/lib/libssp/libssp_nonshared/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ b/gnu/lib/libssp/libssp_nonshared/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/lib/libstdc++/Makefile b/gnu/lib/libstdc++/Makefile new file mode 100644 index 000000000000..8c4972db4c41 --- /dev/null +++ b/gnu/lib/libstdc++/Makefile @@ -0,0 +1,637 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +GCCVER= 4.2 +GCCDIR= ${SRCTOP}/contrib/gcc +GCCLIB= ${SRCTOP}/contrib/gcclibs +SRCDIR= ${SRCTOP}/contrib/libstdc++ +SUPDIR= ${SRCDIR}/libsupc++ + +.PATH: ${SRCDIR}/src ${SRCDIR}/libmath ${SRCDIR}/config/io \ + ${SRCDIR}/config/locale/darwin ${SRCDIR}/config/locale/generic \ + ${SRCDIR}/include ${SUPDIR} ${GCCDIR} ${GCCLIB}/libiberty + +LIB= stdc++ +SHLIB_MAJOR= 6 + +CFLAGS+= -DIN_GLIBCPP_V3 -DHAVE_CONFIG_H +CFLAGS+= -I${.CURDIR} -I${SUPDIR} -I${GCCDIR} -I${SRCDIR}/include +CFLAGS+= -I${GCCLIB}/include -I${SRCDIR}/include -I. +CFLAGS+= -frandom-seed=RepeatabilityConsideredGood +CXXFLAGS+= -fno-implicit-templates -ffunction-sections -fdata-sections \ + -Wno-deprecated +PO_CXXFLAGS= ${CXXFLAGS:N-ffunction-sections} + +LIBADD+= m +LDADD= -Wl,-f,libsupc++.so.1 + +# libstdc++ sources +SRCS+= bitmap_allocator.cc pool_allocator.cc \ + mt_allocator.cc codecvt.cc compatibility.cc complex_io.cc \ + ctype.cc debug.cc debug_list.cc functexcept.cc globals_io.cc \ + ios.cc ios_failure.cc ios_init.cc ios_locale.cc limits.cc \ + list.cc locale.cc locale_init.cc locale_facets.cc \ + localename.cc stdexcept.cc strstream.cc tree.cc \ + allocator-inst.cc concept-inst.cc fstream-inst.cc ext-inst.cc \ + ios-inst.cc iostream-inst.cc istream-inst.cc istream.cc \ + locale-inst.cc misc-inst.cc ostream-inst.cc sstream-inst.cc \ + streambuf-inst.cc streambuf.cc string-inst.cc valarray-inst.cc \ + wlocale-inst.cc wstring-inst.cc atomicity.cc \ + codecvt_members.cc collate_members.cc ctype_members.cc \ + messages_members.cc monetary_members.cc numeric_members.cc \ + time_members.cc basic_file_stdio.cc c_locale.cc \ +# compatibility-ldbl.cc + +# target sources +SRCS+= atomicity.cc codecvt_members.cc collate_members.cc ctype_members.cc \ + messages_members.cc monetary_members.cc numeric_members.cc \ + time_members.cc + +# target sources extra +SRCS+= basic_file_stdio.cc c_locale.cc + +# C parts of math +SRCS+= stubs.c + +# Embedded copy of libsupc++ +SRCS+= del_op.cc del_opnt.cc del_opv.cc del_opvnt.cc eh_alloc.cc eh_arm.cc \ + eh_aux_runtime.cc eh_call.cc eh_catch.cc eh_exception.cc eh_globals.cc \ + eh_personality.cc eh_term_handler.cc eh_terminate.cc eh_throw.cc \ + eh_type.cc eh_unex_handler.cc guard.cc new_handler.cc new_op.cc \ + new_opnt.cc new_opv.cc new_opvnt.cc pure.cc tinfo.cc tinfo2.cc \ + vec.cc vterminate.cc + +# from libiberty: +SRCS+= cp-demangle.c + +# MD headers location +.if ${MACHINE_CPUARCH} == "sparc64" +MARCHDIR= sparc +.elif ${MACHINE_CPUARCH} == "i386" && ${MACHINE_CPU} != 'i386' +MARCHDIR= i486 +.elif ${MACHINE_CPUARCH} == "amd64" +MARCHDIR= i486 +.else +MARCHDIR= ${MACHINE_CPUARCH} +.endif + +.if exists(${SRCDIR}/config/cpu/${MARCHDIR}/atomicity.h) +ATOMICITY_H= ${SRCDIR}/config/cpu/${MARCHDIR}/atomicity.h +.else +ATOMICITY_H= ${SRCDIR}/config/cpu/generic/atomicity_mutex/atomicity.h +.endif + +.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" +.if exists(${SRCDIR}/config/cpu/generic/atomicity_builtins/atomicity.h) +ATOMICITY_H= ${SRCDIR}/config/cpu/generic/atomicity_builtins/atomicity.h +.endif +.endif + +atomicity.cc: ${ATOMICITY_H} .NOMETA + ln -sf ${.ALLSRC} ${.TARGET} +CLEANFILES+= atomicity.cc + +INCSGROUPS= BITSHDRS BKWHDRS EXTHDRS BASEHDRS BASEXHDRS STDHDRS \ + TARGETHDRS THRHDRS DEBUGHDRS TR1HDRS PBHDRS0 PBHDRS1 +CXXINCLUDEDIR= ${INCLUDEDIR}/c++/${GCCVER} + +STDHDRS= std_algorithm.h std_bitset.h std_complex.h std_deque.h \ + std_fstream.h std_functional.h std_iomanip.h std_ios.h \ + std_iosfwd.h std_iostream.h std_istream.h std_iterator.h \ + std_limits.h std_list.h std_locale.h std_map.h std_memory.h \ + std_numeric.h std_ostream.h std_queue.h std_set.h \ + std_sstream.h std_stack.h std_stdexcept.h std_streambuf.h \ + std_string.h std_utility.h std_valarray.h std_vector.h +.for h in ${STDHDRS} +STDHDRSNAME_$h=${h:R:S;^std_;;} +.endfor +STDHDRS:= ${STDHDRS:S;^;${SRCDIR}/include/std/;} +STDHDRSDIR= ${CXXINCLUDEDIR} + +BITSHDRS= allocator.h basic_ios.h basic_ios.tcc basic_string.h \ + basic_string.tcc boost_concept_check.h char_traits.h codecvt.h \ + concept_check.h cpp_type_traits.h deque.tcc fstream.tcc \ + functexcept.h gslice.h gslice_array.h indirect_array.h \ + ios_base.h istream.tcc list.tcc locale_classes.h \ + locale_facets.h locale_facets.tcc localefwd.h mask_array.h \ + ostream.tcc ostream_insert.h postypes.h stream_iterator.h \ + streambuf_iterator.h slice_array.h sstream.tcc stl_algo.h \ + stl_algobase.h stl_bvector.h stl_construct.h stl_deque.h \ + stl_function.h stl_heap.h stl_iterator.h \ + stl_iterator_base_funcs.h stl_iterator_base_types.h stl_list.h \ + stl_map.h stl_multimap.h stl_multiset.h stl_numeric.h \ + stl_pair.h stl_queue.h stl_raw_storage_iter.h stl_relops.h \ + stl_set.h stl_stack.h stl_tempbuf.h stl_tree.h \ + stl_uninitialized.h stl_vector.h streambuf.tcc stringfwd.h \ + valarray_array.h valarray_array.tcc valarray_before.h \ + valarray_after.h vector.tcc +BITSHDRS:= ${BITSHDRS:S;^;${SRCDIR}/include/bits/;} +BITSHDRSDIR= ${CXXINCLUDEDIR}/bits + +BKWHDRS= complex.h iomanip.h istream.h ostream.h stream.h streambuf.h \ + algo.h algobase.h alloc.h bvector.h defalloc.h deque.h \ + function.h hash_map.h hash_set.h hashtable.h heap.h iostream.h \ + iterator.h list.h map.h multimap.h new.h multiset.h pair.h \ + queue.h rope.h set.h slist.h stack.h tempbuf.h tree.h \ + vector.h fstream.h strstream backward_warning.h +BKWHDRS:= ${BKWHDRS:S;^;${SRCDIR}/include/backward/;} +BKWHDRSDIR= ${CXXINCLUDEDIR}/backward + +EXTHDRS= algorithm atomicity.h array_allocator.h bitmap_allocator.h \ + codecvt_specializations.h concurrence.h debug_allocator.h \ + stdio_filebuf.h stdio_sync_filebuf.h functional \ + hash_map hash_set hash_fun.h hashtable.h iterator \ + malloc_allocator.h memory mt_allocator.h new_allocator.h \ + numeric numeric_traits.h pod_char_traits.h pool_allocator.h \ + rb_tree rope ropeimpl.h slist throw_allocator.h typelist.h \ + type_traits.h rc_string_base.h sso_string_base.h vstring.h \ + vstring.tcc vstring_fwd.h vstring_util.h + +EXTHDRS:= ${EXTHDRS:S;^;${SRCDIR}/include/ext/;} +EXTHDRSDIR= ${CXXINCLUDEDIR}/ext + +TR1HDRS= array bind_repeat.h bind_iterate.h boost_shared_ptr.h cctype \ + cfenv cfloat cinttypes climits cmath common.h complex cstdarg \ + cstdbool cstdint cstdio cstdlib ctgmath ctime ctype.h cwchar \ + cwctype fenv.h float.h functional functional_hash.h \ + functional_iterate.h hashtable hashtable_policy.h inttypes.h \ + limits.h math.h memory mu_iterate.h random random.tcc \ + ref_fwd.h ref_wrap_iterate.h repeat.h stdarg.h stdbool.h \ + stdint.h stdio.h stdlib.h tgmath.h tuple tuple_defs.h \ + tuple_iterate.h type_traits type_traits_fwd.h unordered_set \ + unordered_map utility wchar.h wctype.h + +TR1HDRS:= ${TR1HDRS:S;^;${SRCDIR}/include/tr1/;} +TR1HDRSDIR= ${CXXINCLUDEDIR}/tr1 + +# This is the common subset of files that all three "C" header models use. +BASEHDRS= std_cassert.h std_cctype.h std_cerrno.h std_cfloat.h \ + std_ciso646.h std_climits.h std_clocale.h std_cmath.h \ + std_csetjmp.h std_csignal.h std_cstdarg.h std_cstddef.h \ + std_cstdio.h std_cstdlib.h std_cstring.h std_ctime.h \ + std_cwchar.h std_cwctype.h +.for h in ${BASEHDRS} +BASEHDRSNAME_$h=${h:R:S;^std_;;} +.endfor +BASEHDRS:= ${BASEHDRS:S;^;${SRCDIR}/include/c_std/;} +BASEHDRSDIR= ${CXXINCLUDEDIR} + +# Some of the different "C" header models need extra files. +BASEXHDRS= ${SRCDIR}/include/c_std/cmath.tcc +BASEXHDRSDIR= ${CXXINCLUDEDIR}/bits + +DEBUGHDRS= bitset debug.h deque formatter.h functions.h hash_map \ + hash_map.h hash_multimap.h hash_multiset.h hash_set hash_set.h \ + list macros.h map map.h multimap.h multiset.h safe_base.h \ + safe_iterator.h safe_iterator.tcc safe_sequence.h set set.h \ + string vector +DEBUGHDRS:= ${DEBUGHDRS:S;^;${SRCDIR}/include/debug/;} +DEBUGHDRSDIR= ${CXXINCLUDEDIR}/debug + +# Not installed, but kept here for completeness +COMPATHDRS= assert.h ctype.h errno.h float.h iso646.h limits.h locale.h \ + math.h setjmp.h signal.h stdarg.h stddef.h stdio.h stdlib.h \ + string.h time.h wchar.h wctype.h +COMPATHDRS:= ${COMPATHDRS:S;^;${SRCDIR}/include/debug/;} +COMPATHDRSDIR= ${CXXINCLUDEDIR}/c_compatibility + +PBHDRS0 = \ + assoc_container.hpp \ + exception.hpp \ + hash_policy.hpp \ + list_update_policy.hpp \ + priority_queue.hpp \ + tag_and_trait.hpp \ + tree_policy.hpp \ + trie_policy.hpp +PBHDRS0:= ${PBHDRS0:S;^;${SRCDIR}/include/ext/pb_ds/;} +PBHDRS0DIR= ${CXXINCLUDEDIR}/ext/pb_ds + +PBHDRS1 = \ + basic_types.hpp \ + cond_dealtor.hpp \ + constructors_destructor_fn_imps.hpp \ + container_base_dispatch.hpp \ + map_debug_base.hpp \ + priority_queue_base_dispatch.hpp \ + standard_policies.hpp \ + tree_trace_base.hpp \ + type_utils.hpp \ + types_traits.hpp +PBHDRS1:= ${PBHDRS1:S;^;${SRCDIR}/include/ext/pb_ds/detail/;} +PBHDRS1DIR= ${CXXINCLUDEDIR}/ext/pb_ds/detail + +PBHDRS+= \ + basic_tree_policy/basic_tree_policy_base.hpp \ + basic_tree_policy/null_node_metadata.hpp \ + basic_tree_policy/traits.hpp \ + basic_types.hpp \ + binary_heap_/binary_heap_.hpp \ + binary_heap_/const_iterator.hpp \ + binary_heap_/const_point_iterator.hpp \ + binary_heap_/constructors_destructor_fn_imps.hpp \ + binary_heap_/debug_fn_imps.hpp \ + binary_heap_/entry_cmp.hpp \ + binary_heap_/entry_pred.hpp \ + binary_heap_/erase_fn_imps.hpp \ + binary_heap_/find_fn_imps.hpp \ + binary_heap_/info_fn_imps.hpp \ + binary_heap_/insert_fn_imps.hpp \ + binary_heap_/iterators_fn_imps.hpp \ + binary_heap_/policy_access_fn_imps.hpp \ + binary_heap_/resize_policy.hpp \ + binary_heap_/split_join_fn_imps.hpp \ + binary_heap_/trace_fn_imps.hpp \ + binomial_heap_base_/binomial_heap_base_.hpp \ + binomial_heap_base_/constructors_destructor_fn_imps.hpp \ + binomial_heap_base_/debug_fn_imps.hpp \ + binomial_heap_base_/erase_fn_imps.hpp \ + binomial_heap_base_/find_fn_imps.hpp \ + binomial_heap_base_/insert_fn_imps.hpp \ + binomial_heap_base_/split_join_fn_imps.hpp \ + binomial_heap_/binomial_heap_.hpp \ + binomial_heap_/constructors_destructor_fn_imps.hpp \ + binomial_heap_/debug_fn_imps.hpp \ + bin_search_tree_/bin_search_tree_.hpp \ + bin_search_tree_/cond_dtor_entry_dealtor.hpp \ + bin_search_tree_/cond_key_dtor_entry_dealtor.hpp + +PBHDRS+= \ + bin_search_tree_/constructors_destructor_fn_imps.hpp \ + bin_search_tree_/debug_fn_imps.hpp \ + bin_search_tree_/erase_fn_imps.hpp \ + bin_search_tree_/find_fn_imps.hpp \ + bin_search_tree_/info_fn_imps.hpp \ + bin_search_tree_/insert_fn_imps.hpp \ + bin_search_tree_/iterators_fn_imps.hpp \ + bin_search_tree_/node_iterators.hpp \ + bin_search_tree_/point_iterators.hpp \ + bin_search_tree_/policy_access_fn_imps.hpp \ + bin_search_tree_/r_erase_fn_imps.hpp \ + bin_search_tree_/rotate_fn_imps.hpp \ + bin_search_tree_/split_join_fn_imps.hpp \ + bin_search_tree_/traits.hpp \ + cc_hash_table_map_/cc_ht_map_.hpp \ + cc_hash_table_map_/cmp_fn_imps.hpp \ + cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp \ + cc_hash_table_map_/constructor_destructor_fn_imps.hpp \ + cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp \ + cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp \ + cc_hash_table_map_/debug_fn_imps.hpp \ + cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp \ + cc_hash_table_map_/debug_store_hash_fn_imps.hpp \ + cc_hash_table_map_/entry_list_fn_imps.hpp \ + cc_hash_table_map_/erase_fn_imps.hpp \ + cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp \ + cc_hash_table_map_/erase_store_hash_fn_imps.hpp \ + cc_hash_table_map_/find_fn_imps.hpp \ + cc_hash_table_map_/find_store_hash_fn_imps.hpp \ + cc_hash_table_map_/info_fn_imps.hpp \ + cc_hash_table_map_/insert_fn_imps.hpp \ + cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp \ + cc_hash_table_map_/insert_store_hash_fn_imps.hpp \ + cc_hash_table_map_/iterators_fn_imps.hpp \ + cc_hash_table_map_/policy_access_fn_imps.hpp \ + cc_hash_table_map_/resize_fn_imps.hpp \ + cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp \ + cc_hash_table_map_/resize_store_hash_fn_imps.hpp \ + cc_hash_table_map_/size_fn_imps.hpp \ + cc_hash_table_map_/standard_policies.hpp + +PBHDRS+= \ + cc_hash_table_map_/trace_fn_imps.hpp \ + cond_dealtor.hpp \ + constructors_destructor_fn_imps.hpp \ + container_base_dispatch.hpp \ + eq_fn/eq_by_less.hpp \ + eq_fn/hash_eq_fn.hpp \ + gp_hash_table_map_/constructor_destructor_fn_imps.hpp \ + gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp \ + gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp \ + gp_hash_table_map_/debug_fn_imps.hpp \ + gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp \ + gp_hash_table_map_/debug_store_hash_fn_imps.hpp \ + gp_hash_table_map_/erase_fn_imps.hpp \ + gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp \ + gp_hash_table_map_/erase_store_hash_fn_imps.hpp \ + gp_hash_table_map_/find_fn_imps.hpp \ + gp_hash_table_map_/find_no_store_hash_fn_imps.hpp \ + gp_hash_table_map_/find_store_hash_fn_imps.hpp \ + gp_hash_table_map_/gp_ht_map_.hpp \ + gp_hash_table_map_/info_fn_imps.hpp \ + gp_hash_table_map_/insert_fn_imps.hpp \ + gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp \ + gp_hash_table_map_/insert_store_hash_fn_imps.hpp \ + gp_hash_table_map_/iterator_fn_imps.hpp \ + gp_hash_table_map_/policy_access_fn_imps.hpp \ + gp_hash_table_map_/resize_fn_imps.hpp \ + gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp \ + gp_hash_table_map_/resize_store_hash_fn_imps.hpp \ + gp_hash_table_map_/standard_policies.hpp \ + gp_hash_table_map_/trace_fn_imps.hpp \ + hash_fn/direct_mask_range_hashing_imp.hpp \ + hash_fn/direct_mod_range_hashing_imp.hpp \ + hash_fn/linear_probe_fn_imp.hpp \ + hash_fn/mask_based_range_hashing.hpp \ + hash_fn/mod_based_range_hashing.hpp \ + hash_fn/probe_fn_base.hpp \ + hash_fn/quadratic_probe_fn_imp.hpp \ + hash_fn/ranged_hash_fn.hpp \ + hash_fn/ranged_probe_fn.hpp + +PBHDRS+= \ + hash_fn/sample_probe_fn.hpp \ + hash_fn/sample_ranged_hash_fn.hpp \ + hash_fn/sample_ranged_probe_fn.hpp \ + hash_fn/sample_range_hashing.hpp \ + left_child_next_sibling_heap_/const_iterator.hpp \ + left_child_next_sibling_heap_/const_point_iterator.hpp \ + left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp \ + left_child_next_sibling_heap_/debug_fn_imps.hpp \ + left_child_next_sibling_heap_/erase_fn_imps.hpp \ + left_child_next_sibling_heap_/info_fn_imps.hpp \ + left_child_next_sibling_heap_/insert_fn_imps.hpp \ + left_child_next_sibling_heap_/iterators_fn_imps.hpp \ + left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp \ + left_child_next_sibling_heap_/node.hpp \ + left_child_next_sibling_heap_/null_metadata.hpp \ + left_child_next_sibling_heap_/policy_access_fn_imps.hpp \ + left_child_next_sibling_heap_/trace_fn_imps.hpp \ + list_update_map_/constructor_destructor_fn_imps.hpp \ + list_update_map_/debug_fn_imps.hpp \ + list_update_map_/entry_metadata_base.hpp \ + list_update_map_/erase_fn_imps.hpp \ + list_update_map_/find_fn_imps.hpp \ + list_update_map_/info_fn_imps.hpp \ + list_update_map_/insert_fn_imps.hpp \ + list_update_map_/iterators_fn_imps.hpp \ + list_update_map_/lu_map_.hpp \ + list_update_map_/trace_fn_imps.hpp \ + list_update_policy/counter_lu_metadata.hpp \ + list_update_policy/counter_lu_policy_imp.hpp \ + list_update_policy/mtf_lu_policy_imp.hpp \ + list_update_policy/sample_update_policy.hpp \ + map_debug_base.hpp \ + ov_tree_map_/cond_dtor.hpp \ + ov_tree_map_/constructors_destructor_fn_imps.hpp \ + ov_tree_map_/debug_fn_imps.hpp \ + ov_tree_map_/erase_fn_imps.hpp \ + ov_tree_map_/info_fn_imps.hpp \ + ov_tree_map_/insert_fn_imps.hpp \ + ov_tree_map_/iterators_fn_imps.hpp \ + ov_tree_map_/node_iterators.hpp \ + ov_tree_map_/ov_tree_map_.hpp + +PBHDRS+= \ + ov_tree_map_/policy_access_fn_imps.hpp \ + ov_tree_map_/split_join_fn_imps.hpp \ + ov_tree_map_/traits.hpp \ + pairing_heap_/constructors_destructor_fn_imps.hpp \ + pairing_heap_/debug_fn_imps.hpp \ + pairing_heap_/erase_fn_imps.hpp \ + pairing_heap_/find_fn_imps.hpp \ + pairing_heap_/insert_fn_imps.hpp \ + pairing_heap_/pairing_heap_.hpp \ + pairing_heap_/split_join_fn_imps.hpp \ + pat_trie_/child_iterator.hpp \ + pat_trie_/cond_dtor_entry_dealtor.hpp \ + pat_trie_/const_child_iterator.hpp \ + pat_trie_/constructors_destructor_fn_imps.hpp \ + pat_trie_/debug_fn_imps.hpp \ + pat_trie_/erase_fn_imps.hpp \ + pat_trie_/find_fn_imps.hpp \ + pat_trie_/head.hpp \ + pat_trie_/info_fn_imps.hpp \ + pat_trie_/insert_join_fn_imps.hpp \ + pat_trie_/internal_node.hpp \ + pat_trie_/iterators_fn_imps.hpp \ + pat_trie_/leaf.hpp \ + pat_trie_/node_base.hpp \ + pat_trie_/node_iterators.hpp \ + pat_trie_/node_metadata_base.hpp \ + pat_trie_/pat_trie_.hpp \ + pat_trie_/point_iterators.hpp \ + pat_trie_/policy_access_fn_imps.hpp \ + pat_trie_/r_erase_fn_imps.hpp \ + pat_trie_/rotate_fn_imps.hpp \ + pat_trie_/split_fn_imps.hpp \ + pat_trie_/split_join_branch_bag.hpp \ + pat_trie_/synth_e_access_traits.hpp \ + pat_trie_/trace_fn_imps.hpp \ + pat_trie_/traits.hpp \ + pat_trie_/update_fn_imps.hpp \ + priority_queue_base_dispatch.hpp \ + rb_tree_map_/constructors_destructor_fn_imps.hpp \ + rb_tree_map_/debug_fn_imps.hpp + +PBHDRS+= \ + rb_tree_map_/erase_fn_imps.hpp \ + rb_tree_map_/find_fn_imps.hpp \ + rb_tree_map_/info_fn_imps.hpp \ + rb_tree_map_/insert_fn_imps.hpp \ + rb_tree_map_/node.hpp \ + rb_tree_map_/rb_tree_.hpp \ + rb_tree_map_/split_join_fn_imps.hpp \ + rb_tree_map_/traits.hpp \ + rc_binomial_heap_/constructors_destructor_fn_imps.hpp \ + rc_binomial_heap_/debug_fn_imps.hpp \ + rc_binomial_heap_/erase_fn_imps.hpp \ + rc_binomial_heap_/insert_fn_imps.hpp \ + rc_binomial_heap_/rc_binomial_heap_.hpp \ + rc_binomial_heap_/rc.hpp \ + rc_binomial_heap_/split_join_fn_imps.hpp \ + rc_binomial_heap_/trace_fn_imps.hpp \ + resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp \ + resize_policy/hash_exponential_size_policy_imp.hpp \ + resize_policy/hash_load_check_resize_trigger_imp.hpp \ + resize_policy/hash_load_check_resize_trigger_size_base.hpp \ + resize_policy/hash_prime_size_policy_imp.hpp \ + resize_policy/hash_standard_resize_policy_imp.hpp \ + resize_policy/sample_resize_policy.hpp \ + resize_policy/sample_resize_trigger.hpp \ + resize_policy/sample_size_policy.hpp \ + splay_tree_/constructors_destructor_fn_imps.hpp \ + splay_tree_/debug_fn_imps.hpp \ + splay_tree_/erase_fn_imps.hpp \ + splay_tree_/find_fn_imps.hpp \ + splay_tree_/info_fn_imps.hpp \ + splay_tree_/insert_fn_imps.hpp \ + splay_tree_/node.hpp \ + splay_tree_/splay_fn_imps.hpp \ + splay_tree_/splay_tree_.hpp \ + splay_tree_/split_join_fn_imps.hpp \ + splay_tree_/traits.hpp \ + standard_policies.hpp \ + thin_heap_/constructors_destructor_fn_imps.hpp \ + thin_heap_/debug_fn_imps.hpp \ + thin_heap_/erase_fn_imps.hpp + +PBHDRS+= \ + thin_heap_/find_fn_imps.hpp \ + thin_heap_/insert_fn_imps.hpp \ + thin_heap_/split_join_fn_imps.hpp \ + thin_heap_/thin_heap_.hpp \ + thin_heap_/trace_fn_imps.hpp \ + tree_policy/node_metadata_selector.hpp \ + tree_policy/null_node_update_imp.hpp \ + tree_policy/order_statistics_imp.hpp \ + tree_policy/sample_tree_node_update.hpp \ + tree_trace_base.hpp \ + trie_policy/node_metadata_selector.hpp \ + trie_policy/null_node_update_imp.hpp \ + trie_policy/order_statistics_imp.hpp \ + trie_policy/prefix_search_node_update_imp.hpp \ + trie_policy/sample_trie_e_access_traits.hpp \ + trie_policy/sample_trie_node_update.hpp \ + trie_policy/string_trie_e_access_traits_imp.hpp \ + trie_policy/trie_policy_base.hpp \ + types_traits.hpp \ + type_utils.hpp \ + unordered_iterator/const_iterator.hpp \ + unordered_iterator/const_point_iterator.hpp \ + unordered_iterator/iterator.hpp \ + unordered_iterator/point_iterator.hpp + +PBHDRSDIRS= \ + pairing_heap_ \ + splay_tree_ \ + list_update_map_ \ + basic_tree_policy \ + trie_policy \ + gp_hash_table_map_ \ + tree_policy \ + binomial_heap_base_ \ + resize_policy \ + bin_search_tree_ \ + binomial_heap_ \ + thin_heap_ \ + pat_trie_ \ + cc_hash_table_map_ \ + rc_binomial_heap_ \ + left_child_next_sibling_heap_ \ + unordered_iterator \ + binary_heap_ \ + ov_tree_map_ \ + hash_fn \ + eq_fn \ + rb_tree_map_ \ + list_update_policy + +.for D in ${PBHDRSDIRS} +PHDRGRP$D:= ${PBHDRS:M$D/*:S;^;${SRCDIR}/include/ext/pb_ds/detail/;} +PHDRGRP$DDIR= ${CXXINCLUDEDIR}/ext/pb_ds/detail/$D +INCSGROUPS+= PHDRGRP$D +.endfor + +TARGETHDRS= abi/compatibility.h \ + allocator/new_allocator_base.h \ + io/basic_file_stdio.h \ + io/c_io_stdio.h \ + locale/generic/c_locale.h \ + locale/generic/c++locale_internal.h \ + locale/generic/messages_members.h \ + locale/generic/time_members.h \ + os/bsd/freebsd/ctype_base.h \ + os/bsd/freebsd/ctype_inline.h \ + os/bsd/freebsd/ctype_noninline.h \ + os/bsd/freebsd/os_defines.h +TARGETHDRS:= ${TARGETHDRS:S;^;${SRCDIR}/config/;} +TARGETHDRS+= c++config.h +TARGETHDRSNAME_basic_file_stdio.h= basic_file.h +TARGETHDRSNAME_c_io_stdio.h= c++io.h +TARGETHDRSNAME_c_locale.h= c++locale.h +TARGETHDRSNAME_new_allocator_base.h= c++allocator.h +TARGETHDRSDIR= ${CXXINCLUDEDIR}/bits + +MARCHHDRS= atomic_word.h cpu_defines.h cxxabi_tweaks.h +.for h in ${MARCHHDRS} +.if exists(${SRCDIR}/config/cpu/${MARCHDIR}/${h}) +TARGETHDRS+= ${SRCDIR}/config/cpu/${MARCHDIR}/${h} +.else +TARGETHDRS+= ${SRCDIR}/config/cpu/generic/${h} +.endif +.endfor + +THRHDRS= gthr.h gthr-single.h gthr-posix.h gthr-tpf.h gthr-default.h +THRHDRSDIR= ${CXXINCLUDEDIR}/bits +uppercase = [ABCDEFGHIJKLMNOPQRSTUVWXYZ_] + +gthr.h: ${GCCDIR}/gthr.h + sed -e '/^#pragma/b' \ + -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCXX_\1/g' \ + -e 's/_GLIBCXX_SUPPORTS_WEAK/__GXX_WEAK__/g' \ + -e 's,^#include "\(.*\)",#include <bits/\1>,g' \ + < ${.ALLSRC} > ${.TARGET} + +gthr-single.h: ${GCCDIR}/gthr-single.h + sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ + -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ + < ${.ALLSRC} > ${.TARGET} + +gthr-posix.h: ${GCCDIR}/gthr-posix.h + sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ + -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ + -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ + -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ + < ${.ALLSRC} > ${.TARGET} + +gthr-tpf.h: ${GCCDIR}/gthr-posix.h + sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ + -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ + -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ + -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ + < ${.ALLSRC} > ${.TARGET} + +gthr-default.h: ${GCCDIR}/gthr-posix.h + sed -e 's/\(UNUSED\)/_GLIBCXX_\1/g' \ + -e 's/\(GCC${uppercase}*_H\)/_GLIBCXX_\1/g' \ + -e 's/SUPPORTS_WEAK/__GXX_WEAK__/g' \ + -e 's/\(${uppercase}*USE_WEAK\)/_GLIBCXX_\1/g' \ + -e 's,^#include "\(.*\)",#include <bits/\1>,g' \ + < ${.ALLSRC} > ${.TARGET} + +CLEANFILES+= ${THRHDRS} + +.if ${MACHINE_CPUARCH} == "arm" +unwind.h: ${GCCDIR}/config/arm/unwind-arm.h +.else +unwind.h: ${GCCDIR}/unwind-generic.h +.endif + +unwind.h: .NOMETA + ln -sf ${.ALLSRC} ${.TARGET} + +SRCS+= unwind.h +CLEANFILES+= unwind.h + +DATESTAMP!= cat ${GCCDIR}/DATESTAMP + +c++config.h: ${.CURDIR}/config.h ${SRCDIR}/include/bits/c++config + sed -e "s/\\(define __GLIBCXX__\\)/\1 ${DATESTAMP}/" \ + -e 's/\(define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY\)/\1 1/' \ + -e 's/\(define _GLIBCXX_NAMESPACE_ASSOCIATION_VERSION\)/\1 0/' \ + < ${SRCDIR}/include/bits/c++config > ${.TARGET} && \ + sed -e 's/HAVE_/_GLIBCXX_HAVE_/g' \ + -e 's/PACKAGE/_GLIBCXX_PACKAGE/g' \ + -e 's/VERSION/_GLIBCXX_VERSION/g' \ + -e 's/WORDS_/_GLIBCXX_WORDS_/g' \ + < ${.CURDIR}/config.h >> ${.TARGET} && \ + echo "#endif // _CXXCONFIG_" >> ${.TARGET} +CLEANFILES+= c++config.h + +# Symbol versioning. + +VERSION_MAP= libstdc++.map + +${VERSION_MAP}: ${SRCDIR}/config/abi/pre/gnu.ver .NOMETA + ln -sf ${.ALLSRC} ${.TARGET} + +CLEANFILES+= ${VERSION_MAP} + +CXXFLAGS.clang+= -stdlib=libstdc++ + +.include <bsd.lib.mk> + +# Filter out libc++-specific flags, and -std= flags above c++98 or gnu++98. +CXXFLAGS:= ${CXXFLAGS:N-stdlib=libc++:N-std=c++[01][13x]:N-std=gnu++[01][13x]} diff --git a/gnu/lib/libstdc++/Makefile.depend b/gnu/lib/libstdc++/Makefile.depend new file mode 100644 index 000000000000..905e67cc66c9 --- /dev/null +++ b/gnu/lib/libstdc++/Makefile.depend @@ -0,0 +1,18 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + lib/msun \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/lib/libstdc++/config.h b/gnu/lib/libstdc++/config.h new file mode 100644 index 000000000000..26b363098201 --- /dev/null +++ b/gnu/lib/libstdc++/config.h @@ -0,0 +1,1109 @@ +/* $FreeBSD$ */ +#ifndef __ISO_C_VISIBLE +#include <sys/cdefs.h> +#endif + +/* config.h. Generated by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `acosf' function. */ +#define HAVE_ACOSF 1 + +/* Define to 1 if you have the `acosl' function. */ +/* #undef HAVE_ACOSL */ + +/* Define to 1 if you have the `asinf' function. */ +#define HAVE_ASINF 1 + +/* Define to 1 if you have the `asinl' function. */ +/* #undef HAVE_ASINL */ + +/* Define to 1 if you have the `atan2f' function. */ +#define HAVE_ATAN2F 1 + +/* Define to 1 if you have the `atan2l' function. */ +#define HAVE_ATAN2L 1 + +/* Define to 1 if you have the `atanf' function. */ +#define HAVE_ATANF 1 + +/* Define to 1 if you have the `atanl' function. */ +#define HAVE_ATANL 1 + +/* Define to 1 if you have the `ceilf' function. */ +#define HAVE_CEILF 1 + +/* Define to 1 if you have the `ceill' function. */ +#define HAVE_CEILL 1 + +/* Define to 1 if you have the <complex.h> header file. */ +#define HAVE_COMPLEX_H 1 + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `copysignf' function. */ +#define HAVE_COPYSIGNF 1 + +/* Define to 1 if you have the `copysignl' function. */ +#define HAVE_COPYSIGNL 1 + +/* Define to 1 if you have the `cosf' function. */ +#define HAVE_COSF 1 + +/* Define to 1 if you have the `coshf' function. */ +#define HAVE_COSHF 1 + +/* Define to 1 if you have the `coshl' function. */ +#define HAVE_COSHL 1 + +/* Define to 1 if you have the `cosl' function. */ +#define HAVE_COSL 1 + +/* Define to 1 if you have the <endian.h> header file. */ +/* #undef HAVE_ENDIAN_H */ + +/* Define to 1 if you have the `expf' function. */ +#define HAVE_EXPF 1 + +/* Define to 1 if you have the `expl' function. */ +#define HAVE_EXPL 1 + +/* Define to 1 if you have the `fabsf' function. */ +#define HAVE_FABSF 1 + +/* Define to 1 if you have the `fabsl' function. */ +#define HAVE_FABSL 1 + +/* Define to 1 if you have the <fenv.h> header file. */ +#define HAVE_FENV_H 1 + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `finitef' function. */ +#define HAVE_FINITEF 1 + +/* Define to 1 if you have the `finitel' function. */ +/* #undef HAVE_FINITEL */ + +/* Define to 1 if you have the <float.h> header file. */ +#define HAVE_FLOAT_H 1 + +/* Define to 1 if you have the `floorf' function. */ +#define HAVE_FLOORF 1 + +/* Define to 1 if you have the `floorl' function. */ +#define HAVE_FLOORL 1 + +/* Define to 1 if you have the `fmodf' function. */ +#define HAVE_FMODF 1 + +/* Define to 1 if you have the `fmodl' function. */ +#define HAVE_FMODL 1 + +/* Define to 1 if you have the `fpclass' function. */ +/* #undef HAVE_FPCLASS */ + +/* Define to 1 if you have the <fp.h> header file. */ +/* #undef HAVE_FP_H */ + +/* Define to 1 if you have the `frexpf' function. */ +#define HAVE_FREXPF 1 + +/* Define to 1 if you have the `frexpl' function. */ +#define HAVE_FREXPL 1 + +/* Define to 1 if you have the <gconv.h> header file. */ +/* #undef HAVE_GCONV_H */ + +/* Define if _Unwind_GetIPInfo is available. */ +#define HAVE_GETIPINFO 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if gthr-default.h exists (meaning that threading support is + enabled). */ +#define HAVE_GTHR_DEFAULT 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the `hypotf' function. */ +#define HAVE_HYPOTF 1 + +/* Define to 1 if you have the `hypotl' function. */ +#define HAVE_HYPOTL 1 + +/* Define to 1 if you have the `iconv' function. */ +#define HAVE_ICONV 1 + +/* Define to 1 if you have the `iconv_close' function. */ +#define HAVE_ICONV_CLOSE 1 + +/* Define to 1 if you have the `iconv_open' function. */ +#define HAVE_ICONV_OPEN 1 + +/* Define to 1 if you have the <ieeefp.h> header file. */ +#define HAVE_IEEEFP_H 1 + +/* Define if int64_t is available in <stdint.h>. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `isinf' function. */ +#define HAVE_ISINF 1 + +/* Define to 1 if you have the `isinff' function. */ +/* #undef HAVE_ISINFF */ + +/* Define to 1 if you have the `isinfl' function. */ +/* #undef HAVE_ISINFL */ + +/* Define to 1 if you have the `isnan' function. */ +#define HAVE_ISNAN 1 + +/* Define to 1 if you have the `isnanf' function. */ +#define HAVE_ISNANF 1 + +/* Define to 1 if you have the `isnanl' function. */ +/* #undef HAVE_ISNANL */ + +/* Defined if iswblank exists. */ +#define HAVE_ISWBLANK 1 + +/* Define if LC_MESSAGES is available in <locale.h>. */ +#define HAVE_LC_MESSAGES 1 + +/* Define to 1 if you have the `ldexpf' function. */ +#define HAVE_LDEXPF 1 + +/* Define to 1 if you have the `ldexpl' function. */ +#define HAVE_LDEXPL 1 + +/* Define to 1 if you have the <libintl.h> header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define to 1 if you have the `m' library (-lm). */ +#define HAVE_LIBM 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define HAVE_LIMIT_AS 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define HAVE_LIMIT_DATA 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define HAVE_LIMIT_FSIZE 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define HAVE_LIMIT_RSS 1 + +/* Only used in build directory testsuite_hooks.h. */ +#define HAVE_LIMIT_VMEM 1 + +/* Define to 1 if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the `log10f' function. */ +#define HAVE_LOG10F 1 + +/* Define to 1 if you have the `log10l' function. */ +#define HAVE_LOG10L 1 + +/* Define to 1 if you have the `logf' function. */ +#define HAVE_LOGF 1 + +/* Define to 1 if you have the `logl' function. */ +#define HAVE_LOGL 1 + +/* Define to 1 if you have the <machine/endian.h> header file. */ +#define HAVE_MACHINE_ENDIAN_H 1 + +/* Define to 1 if you have the <machine/param.h> header file. */ +#define HAVE_MACHINE_PARAM_H 1 + +/* Define if mbstate_t exists in wchar.h. */ +#define HAVE_MBSTATE_T 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `modf' function. */ +#define HAVE_MODF 1 + +/* Define to 1 if you have the `modff' function. */ +#define HAVE_MODFF 1 + +/* Define to 1 if you have the `modfl' function. */ +#define HAVE_MODFL 1 + +/* Define to 1 if you have the <nan.h> header file. */ +/* #undef HAVE_NAN_H */ + +/* Define to 1 if you have the `nl_langinfo' function. */ +#define HAVE_NL_LANGINFO 1 + +/* Define if poll is available in <poll.h>. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the `powf' function. */ +#define HAVE_POWF 1 + +/* Define to 1 if you have the `powl' function. */ +#define HAVE_POWL 1 + +/* Define to 1 if you have the `qfpclass' function. */ +/* #undef HAVE_QFPCLASS */ + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define if sigsetjmp is available. */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if you have the `sincos' function. */ +#define HAVE_SINCOS 1 + +/* Define to 1 if you have the `sincosf' function. */ +#define HAVE_SINCOSF 1 + +/* Define to 1 if you have the `sincosl' function. */ +#define HAVE_SINCOSL 1 + +/* Define to 1 if you have the `sinf' function. */ +#define HAVE_SINF 1 + +/* Define to 1 if you have the `sinhf' function. */ +#define HAVE_SINHF 1 + +/* Define to 1 if you have the `sinhl' function. */ +#define HAVE_SINHL 1 + +/* Define to 1 if you have the `sinl' function. */ +#define HAVE_SINL 1 + +/* Define to 1 if you have the `sqrtf' function. */ +#define HAVE_SQRTF 1 + +/* Define to 1 if you have the `sqrtl' function. */ +#define HAVE_SQRTL 1 + +/* Define to 1 if you have the <stdbool.h> header file. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if strerror_l is available in <string.h>. */ +/* #undef HAVE_STRERROR_L */ + +/* Define if strerror_r is available in <string.h>. */ +#define HAVE_STRERROR_R 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtof' function. */ +#define HAVE_STRTOF 1 + +/* Define to 1 if you have the `strtold' function. */ +#define HAVE_STRTOLD 1 + +/* Define if strxfrm_l is available in <string.h>. */ +#define HAVE_STRXFRM_L 1 + +/* Define to 1 if you have the <sys/filio.h> header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define to 1 if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the <sys/ipc.h> header file. */ +#define HAVE_SYS_IPC_H 1 + +/* Define to 1 if you have the <sys/isa_defs.h> header file. */ +/* #undef HAVE_SYS_ISA_DEFS_H */ + +/* Define to 1 if you have the <sys/machine.h> header file. */ +/* #undef HAVE_SYS_MACHINE_H */ + +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the <sys/resource.h> header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the <sys/sem.h> header file. */ +#define HAVE_SYS_SEM_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <sys/uio.h> header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define if S_IFREG is available in <sys/stat.h>. */ +#define HAVE_S_ISREG 1 + +/* Define to 1 if you have the `tanf' function. */ +#define HAVE_TANF 1 + +/* Define to 1 if you have the `tanhf' function. */ +#define HAVE_TANHF 1 + +/* Define to 1 if you have the `tanhl' function. */ +#define HAVE_TANHL 1 + +/* Define to 1 if you have the `tanl' function. */ +#define HAVE_TANL 1 + +/* Define to 1 if the target supports thread-local storage. */ +#if !defined(__mips__) +#define HAVE_TLS 1 +#endif + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +#if __ISO_C_VISIBLE >= 1999 +/* Defined if vfwscanf exists. */ +#define HAVE_VFWSCANF 1 + +/* Defined if vswscanf exists. */ +#define HAVE_VSWSCANF 1 + +/* Defined if vwscanf exists. */ +#define HAVE_VWSCANF 1 +#endif /* __ISO_C_VISIBLE >= 1999 */ + +/* Define to 1 if you have the <wchar.h> header file. */ +#define HAVE_WCHAR_H 1 + +#if __ISO_C_VISIBLE >= 1999 +/* Defined if wcstof exists. */ +#define HAVE_WCSTOF 1 +#endif /* __ISO_C_VISIBLE >= 1999 */ + +/* Define to 1 if you have the <wctype.h> header file. */ +#define HAVE_WCTYPE_H 1 + +/* Define if writev is available in <sys/uio.h>. */ +#define HAVE_WRITEV 1 + +/* Define to 1 if you have the `_acosf' function. */ +/* #undef HAVE__ACOSF */ + +/* Define to 1 if you have the `_acosl' function. */ +/* #undef HAVE__ACOSL */ + +/* Define to 1 if you have the `_asinf' function. */ +/* #undef HAVE__ASINF */ + +/* Define to 1 if you have the `_asinl' function. */ +/* #undef HAVE__ASINL */ + +/* Define to 1 if you have the `_atan2f' function. */ +/* #undef HAVE__ATAN2F */ + +/* Define to 1 if you have the `_atan2l' function. */ +/* #undef HAVE__ATAN2L */ + +/* Define to 1 if you have the `_atanf' function. */ +/* #undef HAVE__ATANF */ + +/* Define to 1 if you have the `_atanl' function. */ +/* #undef HAVE__ATANL */ + +/* Define to 1 if you have the `_ceilf' function. */ +/* #undef HAVE__CEILF */ + +/* Define to 1 if you have the `_ceill' function. */ +/* #undef HAVE__CEILL */ + +/* Define to 1 if you have the `_copysign' function. */ +/* #undef HAVE__COPYSIGN */ + +/* Define to 1 if you have the `_copysignl' function. */ +/* #undef HAVE__COPYSIGNL */ + +/* Define to 1 if you have the `_cosf' function. */ +/* #undef HAVE__COSF */ + +/* Define to 1 if you have the `_coshf' function. */ +/* #undef HAVE__COSHF */ + +/* Define to 1 if you have the `_coshl' function. */ +/* #undef HAVE__COSHL */ + +/* Define to 1 if you have the `_cosl' function. */ +/* #undef HAVE__COSL */ + +/* Define to 1 if you have the `_expf' function. */ +/* #undef HAVE__EXPF */ + +/* Define to 1 if you have the `_expl' function. */ +/* #undef HAVE__EXPL */ + +/* Define to 1 if you have the `_fabsf' function. */ +/* #undef HAVE__FABSF */ + +/* Define to 1 if you have the `_fabsl' function. */ +/* #undef HAVE__FABSL */ + +/* Define to 1 if you have the `_finite' function. */ +/* #undef HAVE__FINITE */ + +/* Define to 1 if you have the `_finitef' function. */ +/* #undef HAVE__FINITEF */ + +/* Define to 1 if you have the `_finitel' function. */ +/* #undef HAVE__FINITEL */ + +/* Define to 1 if you have the `_floorf' function. */ +/* #undef HAVE__FLOORF */ + +/* Define to 1 if you have the `_floorl' function. */ +/* #undef HAVE__FLOORL */ + +/* Define to 1 if you have the `_fmodf' function. */ +/* #undef HAVE__FMODF */ + +/* Define to 1 if you have the `_fmodl' function. */ +/* #undef HAVE__FMODL */ + +/* Define to 1 if you have the `_fpclass' function. */ +/* #undef HAVE__FPCLASS */ + +/* Define to 1 if you have the `_frexpf' function. */ +/* #undef HAVE__FREXPF */ + +/* Define to 1 if you have the `_frexpl' function. */ +/* #undef HAVE__FREXPL */ + +/* Define to 1 if you have the `_hypot' function. */ +/* #undef HAVE__HYPOT */ + +/* Define to 1 if you have the `_hypotf' function. */ +/* #undef HAVE__HYPOTF */ + +/* Define to 1 if you have the `_hypotl' function. */ +/* #undef HAVE__HYPOTL */ + +/* Define to 1 if you have the `_isinf' function. */ +/* #undef HAVE__ISINF */ + +/* Define to 1 if you have the `_isinff' function. */ +/* #undef HAVE__ISINFF */ + +/* Define to 1 if you have the `_isinfl' function. */ +/* #undef HAVE__ISINFL */ + +/* Define to 1 if you have the `_isnan' function. */ +/* #undef HAVE__ISNAN */ + +/* Define to 1 if you have the `_isnanf' function. */ +/* #undef HAVE__ISNANF */ + +/* Define to 1 if you have the `_isnanl' function. */ +/* #undef HAVE__ISNANL */ + +/* Define to 1 if you have the `_ldexpf' function. */ +/* #undef HAVE__LDEXPF */ + +/* Define to 1 if you have the `_ldexpl' function. */ +/* #undef HAVE__LDEXPL */ + +/* Define to 1 if you have the `_log10f' function. */ +/* #undef HAVE__LOG10F */ + +/* Define to 1 if you have the `_log10l' function. */ +/* #undef HAVE__LOG10L */ + +/* Define to 1 if you have the `_logf' function. */ +/* #undef HAVE__LOGF */ + +/* Define to 1 if you have the `_logl' function. */ +/* #undef HAVE__LOGL */ + +/* Define to 1 if you have the `_modf' function. */ +/* #undef HAVE__MODF */ + +/* Define to 1 if you have the `_modff' function. */ +/* #undef HAVE__MODFF */ + +/* Define to 1 if you have the `_modfl' function. */ +/* #undef HAVE__MODFL */ + +/* Define to 1 if you have the `_powf' function. */ +/* #undef HAVE__POWF */ + +/* Define to 1 if you have the `_powl' function. */ +/* #undef HAVE__POWL */ + +/* Define to 1 if you have the `_qfpclass' function. */ +/* #undef HAVE__QFPCLASS */ + +/* Define to 1 if you have the `_sincos' function. */ +/* #undef HAVE__SINCOS */ + +/* Define to 1 if you have the `_sincosf' function. */ +/* #undef HAVE__SINCOSF */ + +/* Define to 1 if you have the `_sincosl' function. */ +/* #undef HAVE__SINCOSL */ + +/* Define to 1 if you have the `_sinf' function. */ +/* #undef HAVE__SINF */ + +/* Define to 1 if you have the `_sinhf' function. */ +/* #undef HAVE__SINHF */ + +/* Define to 1 if you have the `_sinhl' function. */ +/* #undef HAVE__SINHL */ + +/* Define to 1 if you have the `_sinl' function. */ +/* #undef HAVE__SINL */ + +/* Define to 1 if you have the `_sqrtf' function. */ +/* #undef HAVE__SQRTF */ + +/* Define to 1 if you have the `_sqrtl' function. */ +/* #undef HAVE__SQRTL */ + +/* Define to 1 if you have the `_tanf' function. */ +/* #undef HAVE__TANF */ + +/* Define to 1 if you have the `_tanhf' function. */ +/* #undef HAVE__TANHF */ + +/* Define to 1 if you have the `_tanhl' function. */ +/* #undef HAVE__TANHL */ + +/* Define to 1 if you have the `_tanl' function. */ +/* #undef HAVE__TANL */ + +/* Define if the compiler/host combination has __builtin_abs. */ +#define HAVE___BUILTIN_ABS 1 + +/* Define if the compiler/host combination has __builtin_cos. */ +#define HAVE___BUILTIN_COS 1 + +/* Define if the compiler/host combination has __builtin_cosf. */ +#define HAVE___BUILTIN_COSF 1 + +/* Define if the compiler/host combination has __builtin_cosl. */ +#define HAVE___BUILTIN_COSL 1 + +/* Define if the compiler/host combination has __builtin_fabs. */ +#define HAVE___BUILTIN_FABS 1 + +/* Define if the compiler/host combination has __builtin_fabsf. */ +#define HAVE___BUILTIN_FABSF 1 + +/* Define if the compiler/host combination has __builtin_fabsl. */ +#define HAVE___BUILTIN_FABSL 1 + +/* Define if the compiler/host combination has __builtin_labs. */ +#define HAVE___BUILTIN_LABS 1 + +/* Define if the compiler/host combination has __builtin_sin. */ +#define HAVE___BUILTIN_SIN 1 + +/* Define if the compiler/host combination has __builtin_sinf. */ +#define HAVE___BUILTIN_SINF 1 + +/* Define if the compiler/host combination has __builtin_sinl. */ +#define HAVE___BUILTIN_SINL 1 + +/* Define if the compiler/host combination has __builtin_sqrt. */ +#define HAVE___BUILTIN_SQRT 1 + +/* Define if the compiler/host combination has __builtin_sqrtf. */ +#define HAVE___BUILTIN_SQRTF 1 + +/* Define if the compiler/host combination has __builtin_sqrtl. */ +#define HAVE___BUILTIN_SQRTL 1 + +/* Define to 1 if you have the `__signbit' function. */ +#define HAVE___SIGNBIT 1 + +/* Define to 1 if you have the `__signbitf' function. */ +#define HAVE___SIGNBITF 1 + +/* Define to 1 if you have the `__signbitl' function. */ +#define HAVE___SIGNBITL 1 + +/* Name of package */ +/* #undef PACKAGE */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "package-unused" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "package-unused version-unused" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libstdc++" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "version-unused" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +/* #undef VERSION */ + +/* Define if builtin atomic operations are supported on this host. */ +#if defined(__amd64__) || (defined(__i386__) && !defined(__tune_i386__)) +#define _GLIBCXX_ATOMIC_BUILTINS 1 +#endif + +/* Define to use concept checking code from the boost libraries. */ +/* #undef _GLIBCXX_CONCEPT_CHECKS */ + +/* Define if a fully dynamic basic_string is wanted. */ +/* #undef _GLIBCXX_FULLY_DYNAMIC_STRING */ + +/* Define to 1 if a full hosted library is built, or 0 if freestanding. */ +#define _GLIBCXX_HOSTED 1 + +/* Define if compatibility should be provided for -mlong-double-64. */ +/* #undef _GLIBCXX_LONG_DOUBLE_COMPAT */ + +/* Define if ptrdiff_t is int. */ +#if !defined(__LP64__) +#define _GLIBCXX_PTRDIFF_T_IS_INT 1 +#endif + +/* Define if using setrlimit to set resource limits during "make check" */ +#define _GLIBCXX_RES_LIMITS 1 + +/* Define if size_t is unsigned int. */ +#if !defined(__LP64__) +#define _GLIBCXX_SIZE_T_IS_UINT 1 +#endif + +/* Define if the compiler is configured for setjmp/longjmp exceptions. */ +/* #undef _GLIBCXX_SJLJ_EXCEPTIONS */ + +/* Define to use symbol versioning in the shared library. */ +#define _GLIBCXX_SYMVER 1 + +/* Define to use darwin versioning in the shared library. */ +/* #undef _GLIBCXX_SYMVER_DARWIN */ + +/* Define to use GNU versioning in the shared library. */ +#define _GLIBCXX_SYMVER_GNU 1 + +/* Define to use GNU namespace versioning in the shared library. */ +/* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */ + +/* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>, + <stdio.h>, and <stdlib.h> can be used or exposed. */ +/* #undef _GLIBCXX_USE_C99 */ + +/* Define if C99 functions in <complex.h> should be used in <complex>. Using + compiler builtins for these functions requires corresponding C99 library + functions to be present. */ +#define _GLIBCXX_USE_C99_COMPLEX 1 + +/* Define if C99 functions in <complex.h> should be used in <tr1/complex>. + Using compiler builtins for these functions requires corresponding C99 + library functions to be present. */ +/* #undef _GLIBCXX_USE_C99_COMPLEX_TR1 */ + +/* Define if C99 functions in <ctype.h> should be imported in <tr1/cctype> in + namespace std::tr1. */ +#define _GLIBCXX_USE_C99_CTYPE_TR1 1 + +/* Define if C99 functions in <fenv.h> should be imported in <tr1/cfenv> in + namespace std::tr1. */ +#define _GLIBCXX_USE_C99_FENV_TR1 1 + +/* Define if C99 functions in <inttypes.h> should be imported in + <tr1/cinttypes> in namespace std::tr1. */ +#define _GLIBCXX_USE_C99_INTTYPES_TR1 1 + +/* Define if C99 functions or macros in <math.h> should be imported in <cmath> + in namespace std. */ +#define _GLIBCXX_USE_C99_MATH 1 + +/* Define if C99 functions or macros in <math.h> should be imported in + <tr1/cmath> in namespace std::tr1. */ +/* #undef _GLIBCXX_USE_C99_MATH_TR1 */ + +/* Define if C99 types in <stdint.h> should be imported in <tr1/cstdint> in + namespace std::tr1. */ +#define _GLIBCXX_USE_C99_STDINT_TR1 1 + +/* Define if iconv and related functions exist and are usable. */ +#define _GLIBCXX_USE_ICONV 1 + +/* Define if LFS support is available. */ +/* #undef _GLIBCXX_USE_LFS */ + +/* Define if code specialized for long long should be used. */ +#define _GLIBCXX_USE_LONG_LONG 1 + +/* Define if NLS translations are to be used. */ +/* #undef _GLIBCXX_USE_NLS */ + +/* Define if dev/random and dev/urandom are available for the random_device of + TR1 (Chapter 5.1). */ +#define _GLIBCXX_USE_RANDOM_TR1 1 + +/* Define if code specialized for wchar_t should be used. */ +#define _GLIBCXX_USE_WCHAR_T 1 + +#if defined (HAVE__ACOSF) && ! defined (HAVE_ACOSF) +# define HAVE_ACOSF 1 +# define acosf _acosf +#endif + +#if defined (HAVE__ACOSL) && ! defined (HAVE_ACOSL) +# define HAVE_ACOSL 1 +# define acosl _acosl +#endif + +#if defined (HAVE__ASINF) && ! defined (HAVE_ASINF) +# define HAVE_ASINF 1 +# define asinf _asinf +#endif + +#if defined (HAVE__ASINL) && ! defined (HAVE_ASINL) +# define HAVE_ASINL 1 +# define asinl _asinl +#endif + +#if defined (HAVE__ATAN2F) && ! defined (HAVE_ATAN2F) +# define HAVE_ATAN2F 1 +# define atan2f _atan2f +#endif + +#if defined (HAVE__ATAN2L) && ! defined (HAVE_ATAN2L) +# define HAVE_ATAN2L 1 +# define atan2l _atan2l +#endif + +#if defined (HAVE__ATANF) && ! defined (HAVE_ATANF) +# define HAVE_ATANF 1 +# define atanf _atanf +#endif + +#if defined (HAVE__ATANL) && ! defined (HAVE_ATANL) +# define HAVE_ATANL 1 +# define atanl _atanl +#endif + +#if defined (HAVE__CEILF) && ! defined (HAVE_CEILF) +# define HAVE_CEILF 1 +# define ceilf _ceilf +#endif + +#if defined (HAVE__CEILL) && ! defined (HAVE_CEILL) +# define HAVE_CEILL 1 +# define ceill _ceill +#endif + +#if defined (HAVE__COPYSIGN) && ! defined (HAVE_COPYSIGN) +# define HAVE_COPYSIGN 1 +# define copysign _copysign +#endif + +#if defined (HAVE__COPYSIGNL) && ! defined (HAVE_COPYSIGNL) +# define HAVE_COPYSIGNL 1 +# define copysignl _copysignl +#endif + +#if defined (HAVE__COSF) && ! defined (HAVE_COSF) +# define HAVE_COSF 1 +# define cosf _cosf +#endif + +#if defined (HAVE__COSHF) && ! defined (HAVE_COSHF) +# define HAVE_COSHF 1 +# define coshf _coshf +#endif + +#if defined (HAVE__COSHL) && ! defined (HAVE_COSHL) +# define HAVE_COSHL 1 +# define coshl _coshl +#endif + +#if defined (HAVE__COSL) && ! defined (HAVE_COSL) +# define HAVE_COSL 1 +# define cosl _cosl +#endif + +#if defined (HAVE__EXPF) && ! defined (HAVE_EXPF) +# define HAVE_EXPF 1 +# define expf _expf +#endif + +#if defined (HAVE__EXPL) && ! defined (HAVE_EXPL) +# define HAVE_EXPL 1 +# define expl _expl +#endif + +#if defined (HAVE__FABSF) && ! defined (HAVE_FABSF) +# define HAVE_FABSF 1 +# define fabsf _fabsf +#endif + +#if defined (HAVE__FABSL) && ! defined (HAVE_FABSL) +# define HAVE_FABSL 1 +# define fabsl _fabsl +#endif + +#if defined (HAVE__FINITE) && ! defined (HAVE_FINITE) +# define HAVE_FINITE 1 +# define finite _finite +#endif + +#if defined (HAVE__FINITEF) && ! defined (HAVE_FINITEF) +# define HAVE_FINITEF 1 +# define finitef _finitef +#endif + +#if defined (HAVE__FINITEL) && ! defined (HAVE_FINITEL) +# define HAVE_FINITEL 1 +# define finitel _finitel +#endif + +#if defined (HAVE__FLOORF) && ! defined (HAVE_FLOORF) +# define HAVE_FLOORF 1 +# define floorf _floorf +#endif + +#if defined (HAVE__FLOORL) && ! defined (HAVE_FLOORL) +# define HAVE_FLOORL 1 +# define floorl _floorl +#endif + +#if defined (HAVE__FMODF) && ! defined (HAVE_FMODF) +# define HAVE_FMODF 1 +# define fmodf _fmodf +#endif + +#if defined (HAVE__FMODL) && ! defined (HAVE_FMODL) +# define HAVE_FMODL 1 +# define fmodl _fmodl +#endif + +#if defined (HAVE__FPCLASS) && ! defined (HAVE_FPCLASS) +# define HAVE_FPCLASS 1 +# define fpclass _fpclass +#endif + +#if defined (HAVE__FREXPF) && ! defined (HAVE_FREXPF) +# define HAVE_FREXPF 1 +# define frexpf _frexpf +#endif + +#if defined (HAVE__FREXPL) && ! defined (HAVE_FREXPL) +# define HAVE_FREXPL 1 +# define frexpl _frexpl +#endif + +#if defined (HAVE__HYPOT) && ! defined (HAVE_HYPOT) +# define HAVE_HYPOT 1 +# define hypot _hypot +#endif + +#if defined (HAVE__HYPOTF) && ! defined (HAVE_HYPOTF) +# define HAVE_HYPOTF 1 +# define hypotf _hypotf +#endif + +#if defined (HAVE__HYPOTL) && ! defined (HAVE_HYPOTL) +# define HAVE_HYPOTL 1 +# define hypotl _hypotl +#endif + +#if defined (HAVE__ISINF) && ! defined (HAVE_ISINF) +# define HAVE_ISINF 1 +# define isinf _isinf +#endif + +#if defined (HAVE__ISINFF) && ! defined (HAVE_ISINFF) +# define HAVE_ISINFF 1 +# define isinff _isinff +#endif + +#if defined (HAVE__ISINFL) && ! defined (HAVE_ISINFL) +# define HAVE_ISINFL 1 +# define isinfl _isinfl +#endif + +#if defined (HAVE__ISNAN) && ! defined (HAVE_ISNAN) +# define HAVE_ISNAN 1 +# define isnan _isnan +#endif + +#if defined (HAVE__ISNANF) && ! defined (HAVE_ISNANF) +# define HAVE_ISNANF 1 +# define isnanf _isnanf +#endif + +#if defined (HAVE__ISNANL) && ! defined (HAVE_ISNANL) +# define HAVE_ISNANL 1 +# define isnanl _isnanl +#endif + +#if defined (HAVE__LDEXPF) && ! defined (HAVE_LDEXPF) +# define HAVE_LDEXPF 1 +# define ldexpf _ldexpf +#endif + +#if defined (HAVE__LDEXPL) && ! defined (HAVE_LDEXPL) +# define HAVE_LDEXPL 1 +# define ldexpl _ldexpl +#endif + +#if defined (HAVE__LOG10F) && ! defined (HAVE_LOG10F) +# define HAVE_LOG10F 1 +# define log10f _log10f +#endif + +#if defined (HAVE__LOG10L) && ! defined (HAVE_LOG10L) +# define HAVE_LOG10L 1 +# define log10l _log10l +#endif + +#if defined (HAVE__LOGF) && ! defined (HAVE_LOGF) +# define HAVE_LOGF 1 +# define logf _logf +#endif + +#if defined (HAVE__LOGL) && ! defined (HAVE_LOGL) +# define HAVE_LOGL 1 +# define logl _logl +#endif + +#if defined (HAVE__MODF) && ! defined (HAVE_MODF) +# define HAVE_MODF 1 +# define modf _modf +#endif + +#if defined (HAVE__MODFF) && ! defined (HAVE_MODFF) +# define HAVE_MODFF 1 +# define modff _modff +#endif + +#if defined (HAVE__MODFL) && ! defined (HAVE_MODFL) +# define HAVE_MODFL 1 +# define modfl _modfl +#endif + +#if defined (HAVE__POWF) && ! defined (HAVE_POWF) +# define HAVE_POWF 1 +# define powf _powf +#endif + +#if defined (HAVE__POWL) && ! defined (HAVE_POWL) +# define HAVE_POWL 1 +# define powl _powl +#endif + +#if defined (HAVE__QFPCLASS) && ! defined (HAVE_QFPCLASS) +# define HAVE_QFPCLASS 1 +# define qfpclass _qfpclass +#endif + +#if defined (HAVE__SINCOS) && ! defined (HAVE_SINCOS) +# define HAVE_SINCOS 1 +# define sincos _sincos +#endif + +#if defined (HAVE__SINCOSF) && ! defined (HAVE_SINCOSF) +# define HAVE_SINCOSF 1 +# define sincosf _sincosf +#endif + +#if defined (HAVE__SINCOSL) && ! defined (HAVE_SINCOSL) +# define HAVE_SINCOSL 1 +# define sincosl _sincosl +#endif + +#if defined (HAVE__SINF) && ! defined (HAVE_SINF) +# define HAVE_SINF 1 +# define sinf _sinf +#endif + +#if defined (HAVE__SINHF) && ! defined (HAVE_SINHF) +# define HAVE_SINHF 1 +# define sinhf _sinhf +#endif + +#if defined (HAVE__SINHL) && ! defined (HAVE_SINHL) +# define HAVE_SINHL 1 +# define sinhl _sinhl +#endif + +#if defined (HAVE__SINL) && ! defined (HAVE_SINL) +# define HAVE_SINL 1 +# define sinl _sinl +#endif + +#if defined (HAVE__SQRTF) && ! defined (HAVE_SQRTF) +# define HAVE_SQRTF 1 +# define sqrtf _sqrtf +#endif + +#if defined (HAVE__SQRTL) && ! defined (HAVE_SQRTL) +# define HAVE_SQRTL 1 +# define sqrtl _sqrtl +#endif + +#if defined (HAVE__STRTOF) && ! defined (HAVE_STRTOF) +# define HAVE_STRTOF 1 +# define strtof _strtof +#endif + +#if defined (HAVE__STRTOLD) && ! defined (HAVE_STRTOLD) +# define HAVE_STRTOLD 1 +# define strtold _strtold +#endif + +#if defined (HAVE__TANF) && ! defined (HAVE_TANF) +# define HAVE_TANF 1 +# define tanf _tanf +#endif + +#if defined (HAVE__TANHF) && ! defined (HAVE_TANHF) +# define HAVE_TANHF 1 +# define tanhf _tanhf +#endif + +#if defined (HAVE__TANHL) && ! defined (HAVE_TANHL) +# define HAVE_TANHL 1 +# define tanhl _tanhl +#endif + +#if defined (HAVE__TANL) && ! defined (HAVE_TANL) +# define HAVE_TANL 1 +# define tanl _tanl +#endif diff --git a/gnu/lib/libsupc++/Makefile b/gnu/lib/libsupc++/Makefile new file mode 100644 index 000000000000..b78e9d857683 --- /dev/null +++ b/gnu/lib/libsupc++/Makefile @@ -0,0 +1,56 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +GCCVER= 4.2 +GCCDIR= ${.CURDIR}/../../../contrib/gcc +GCCLIB= ${.CURDIR}/../../../contrib/gcclibs +SRCDIR= ${.CURDIR}/../../../contrib/libstdc++/libsupc++ + +.PATH: ${SRCDIR} ${GCCLIB}/libiberty + +LIB= supc++ +SHLIB_MAJOR=1 +SRCS+= del_op.cc del_opnt.cc del_opv.cc del_opvnt.cc eh_alloc.cc eh_arm.cc \ + eh_aux_runtime.cc eh_call.cc eh_catch.cc eh_exception.cc eh_globals.cc \ + eh_personality.cc eh_term_handler.cc eh_terminate.cc eh_throw.cc \ + eh_type.cc eh_unex_handler.cc guard.cc new_handler.cc new_op.cc \ + new_opnt.cc new_opv.cc new_opvnt.cc pure.cc tinfo.cc tinfo2.cc \ + vec.cc vterminate.cc + +# from libiberty: +SRCS+= cp-demangle.c + +CFLAGS+= -DIN_GLIBCPP_V3 -DHAVE_CONFIG_H +CFLAGS+= -I${GCCLIB}/include -I${SRCDIR} -I${GCCDIR} +CFLAGS+= -I${.CURDIR}/../libstdc++ -I. +CFLAGS+= -frandom-seed=RepeatabilityConsideredGood +CXXFLAGS+= -fno-implicit-templates -ffunction-sections -fdata-sections +PO_CXXFLAGS= ${CXXFLAGS:N-ffunction-sections} + +HDRS= exception new typeinfo cxxabi.h exception_defines.h +INCS= ${HDRS:S;^;${SRCDIR}/;} +INCSDIR=${INCLUDEDIR}/c++/${GCCVER} + +.if ${MACHINE_CPUARCH} == "arm" +unwind.h: ${GCCDIR}/config/arm/unwind-arm.h +.else +unwind.h: ${GCCDIR}/unwind-generic.h +.endif + +unwind.h: .NOMETA + ln -sf ${.ALLSRC} ${.TARGET} + +SRCS+= unwind.h +CLEANFILES+= unwind.h + +# Symbol versioning + +VERSION_MAP= ${.CURDIR}/Version.map + +CXXFLAGS.clang+= -stdlib=libstdc++ + +.include <bsd.lib.mk> + +# Filter out libc++-specific flags, and -std= flags above c++98 or gnu++98. +CXXFLAGS:= ${CXXFLAGS:N-stdlib=libc++:N-std=c++[01][13x]:N-std=gnu++[01][13x]} diff --git a/gnu/lib/libsupc++/Makefile.depend b/gnu/lib/libsupc++/Makefile.depend new file mode 100644 index 000000000000..f0b281683f29 --- /dev/null +++ b/gnu/lib/libsupc++/Makefile.depend @@ -0,0 +1,18 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/lib/libstdc++ \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/lib/libsupc++/Version.map b/gnu/lib/libsupc++/Version.map new file mode 100644 index 000000000000..31e6cc61f6ef --- /dev/null +++ b/gnu/lib/libsupc++/Version.map @@ -0,0 +1,193 @@ +## Linker script for GNU versioning (GNU ld 2.13.91+ only.) +## +## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 +## Free Software Foundation, Inc. +## +## This file is part of the GNU ISO C++ Library. This library 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, or (at your option) +## any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this library; see the file COPYING. If not, write to the Free +## Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +## USA. + +## $FreeBSD$ + + +# Symbols in the support library (libsupc++) have their own tag. +CXXABI_1.3 { + + global: + __cxa_allocate_exception; + __cxa_bad_cast; + __cxa_bad_typeid; + __cxa_begin_catch; + __cxa_begin_cleanup; + __cxa_call_unexpected; + __cxa_current_exception_type; + __cxa_demangle; + __cxa_end_catch; + __cxa_end_cleanup; + __cxa_free_exception; + __cxa_get_globals; + __cxa_get_globals_fast; + __cxa_guard_abort; + __cxa_guard_acquire; + __cxa_guard_release; + __cxa_pure_virtual; + __cxa_rethrow; + __cxa_throw; + __cxa_type_match; + __cxa_vec_cctor; + __cxa_vec_cleanup; + __cxa_vec_ctor; + __cxa_vec_delete2; + __cxa_vec_delete3; + __cxa_vec_delete; + __cxa_vec_dtor; + __cxa_vec_new2; + __cxa_vec_new3; + __cxa_vec_new; + __gxx_personality_v0; + __gxx_personality_sj0; + __dynamic_cast; + + # *_type_info classes, ctor and dtor + _ZN10__cxxabiv117__array_type_info*; + _ZN10__cxxabiv117__class_type_info*; + _ZN10__cxxabiv116__enum_type_info*; + _ZN10__cxxabiv120__function_type_info*; + _ZN10__cxxabiv123__fundamental_type_info*; + _ZN10__cxxabiv117__pbase_type_info*; + _ZN10__cxxabiv129__pointer_to_member_type_info*; + _ZN10__cxxabiv119__pointer_type_info*; + _ZN10__cxxabiv120__si_class_type_info*; + _ZN10__cxxabiv121__vmi_class_type_info*; + + # *_type_info classes, member functions + _ZNK10__cxxabiv117__class_type_info*; + _ZNK10__cxxabiv120__function_type_info*; + _ZNK10__cxxabiv117__pbase_type_info*; + _ZNK10__cxxabiv129__pointer_to_member_type_info*; + _ZNK10__cxxabiv119__pointer_type_info*; + _ZNK10__cxxabiv120__si_class_type_info*; + _ZNK10__cxxabiv121__vmi_class_type_info*; + + # virtual table + _ZTVN10__cxxabiv117__array_type_infoE; + _ZTVN10__cxxabiv117__class_type_infoE; + _ZTVN10__cxxabiv116__enum_type_infoE; + _ZTVN10__cxxabiv120__function_type_infoE; + _ZTVN10__cxxabiv123__fundamental_type_infoE; + _ZTVN10__cxxabiv117__pbase_type_infoE; + _ZTVN10__cxxabiv129__pointer_to_member_type_infoE; + _ZTVN10__cxxabiv119__pointer_type_infoE; + _ZTVN10__cxxabiv120__si_class_type_infoE; + _ZTVN10__cxxabiv121__vmi_class_type_infoE; + + # typeinfo structure (and some names) + _ZTI[a-fh-z]; + _ZTIP[a-fh-z]; + _ZTIPK[a-fh-z]; + _ZTIN10__cxxabiv117__array_type_infoE; + _ZTIN10__cxxabiv117__class_type_infoE; + _ZTIN10__cxxabiv116__enum_type_infoE; + _ZTIN10__cxxabiv120__function_type_infoE; + _ZTIN10__cxxabiv123__fundamental_type_infoE; + _ZTIN10__cxxabiv117__pbase_type_infoE; + _ZTIN10__cxxabiv129__pointer_to_member_type_infoE; + _ZTIN10__cxxabiv119__pointer_type_infoE; + _ZTIN10__cxxabiv120__si_class_type_infoE; + _ZTIN10__cxxabiv121__vmi_class_type_infoE; + + # typeinfo name + _ZTS[a-fh-z]; + _ZTSP[a-fh-z]; + _ZTSPK[a-fh-z]; + _ZTSN10__cxxabiv117__array_type_infoE; + _ZTSN10__cxxabiv117__class_type_infoE; + _ZTSN10__cxxabiv116__enum_type_infoE; + _ZTSN10__cxxabiv120__function_type_infoE; + _ZTSN10__cxxabiv123__fundamental_type_infoE; + _ZTSN10__cxxabiv117__pbase_type_infoE; + _ZTSN10__cxxabiv129__pointer_to_member_type_infoE; + _ZTSN10__cxxabiv119__pointer_type_infoE; + _ZTSN10__cxxabiv120__si_class_type_infoE; + _ZTSN10__cxxabiv121__vmi_class_type_infoE; + + # __gnu_cxx::_verbose_terminate_handler() + _ZN9__gnu_cxx27__verbose_terminate_handlerEv; + + local: + *; +}; + +GLIBCXX_3.4 { + # operator new and new[] + _Zna[jm]; + _Zna[jm]RKSt9nothrow_t; + _Znw[jm]; + _Znw[jm]RKSt9nothrow_t; + + # operator delete and delete[] + _ZdaPv; + _ZdaPvRKSt9nothrow_t; + _ZdlPv; + _ZdlPvRKSt9nothrow_t; + extern "C++" { + std::set_new_handler*; + std::set_terminate*; + std::set_unexpected*; + + "std::unexpected()"; + "std::get_terminate()"; + "std::get_unexpected()"; + "std::uncaught_exception()"; + "std::terminate()"; + + + std::bad_alloc; + std::bad_cast; + std::exception*; + + "typeinfo for std::bad_alloc"; + "typeinfo for std::bad_cast"; + "typeinfo for std::exception"; + "typeinfo for std::type_info"; + + "typeinfo name for std::bad_alloc"; + "typeinfo name for std::bad_cast"; + "typeinfo name for std::exception"; + "typeinfo name for std::type_info"; + + "vtable for std::bad_alloc"; + "vtable for std::bad_cast"; + "vtable for std::exception"; + "vtable for std::type_info"; + + std::type_info::__*; + "std::type_info::~type_info()"; + }; +}; + +GLIBCXX_3.4.9 { + extern "C++" { + "std::bad_alloc::what() const"; + "std::bad_cast::what() const"; + "std::bad_typeid::what() const"; + }; +} GLIBCXX_3.4; + +CXXABI_1.3.1 { + + __cxa_get_exception_ptr; + +} CXXABI_1.3; diff --git a/gnu/lib/tests/Makefile b/gnu/lib/tests/Makefile new file mode 100644 index 000000000000..3b3078f8612a --- /dev/null +++ b/gnu/lib/tests/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/tests +KYUAFILE= yes + +.include <bsd.test.mk> diff --git a/gnu/lib/tests/Makefile.depend b/gnu/lib/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ b/gnu/lib/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/tests/Makefile b/gnu/tests/Makefile new file mode 100644 index 000000000000..3b3078f8612a --- /dev/null +++ b/gnu/tests/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/tests +KYUAFILE= yes + +.include <bsd.test.mk> diff --git a/gnu/tests/Makefile.depend b/gnu/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ b/gnu/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/Makefile b/gnu/usr.bin/Makefile new file mode 100644 index 000000000000..a3e749508e68 --- /dev/null +++ b/gnu/usr.bin/Makefile @@ -0,0 +1,22 @@ +# $FreeBSD$ + +.include <src.opts.mk> + + +.if ${MK_CXX} != "no" +SUBDIR.${MK_GCC}+= gperf +.endif + +SUBDIR.${MK_BINUTILS}+= binutils +SUBDIR.${MK_DIALOG}+= dialog +SUBDIR.${MK_GCC}+= cc +SUBDIR.${MK_GNU_DIFF}+= diff3 +SUBDIR.${MK_GNU_GREP}+= grep +SUBDIR.${MK_GDB}+= gdb +SUBDIR_DEPEND_gdb= binutils +SUBDIR.${MK_GPL_DTC}+= dtc +SUBDIR.${MK_TESTS}+= tests + +SUBDIR_PARALLEL= + +.include <bsd.subdir.mk> diff --git a/gnu/usr.bin/Makefile.inc b/gnu/usr.bin/Makefile.inc new file mode 100644 index 000000000000..4cec6fe01a45 --- /dev/null +++ b/gnu/usr.bin/Makefile.inc @@ -0,0 +1,5 @@ +# $FreeBSD$ + +BINDIR?= /usr/bin + +.include "../Makefile.inc" diff --git a/gnu/usr.bin/binutils/Makefile b/gnu/usr.bin/binutils/Makefile new file mode 100644 index 000000000000..c05a5af2374d --- /dev/null +++ b/gnu/usr.bin/binutils/Makefile @@ -0,0 +1,24 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +SUBDIR= doc\ + libiberty \ + libbfd \ + libopcodes \ + libbinutils \ + as \ + ld \ + objdump + + +SUBDIR_DEPEND_libbinutils=libbfd # for bfdver.h +SUBDIR_DEPEND_as=libbfd libiberty libopcodes +SUBDIR_DEPEND_ld=libbfd libiberty +SUBDIR_DEPEND_objdump=libbfd libiberty libbinutils libopcodes + +.if !make(install) +SUBDIR_PARALLEL= +.endif + +.include <bsd.subdir.mk> diff --git a/gnu/usr.bin/binutils/Makefile.inc b/gnu/usr.bin/binutils/Makefile.inc new file mode 100644 index 000000000000..aba3cc7fa5eb --- /dev/null +++ b/gnu/usr.bin/binutils/Makefile.inc @@ -0,0 +1,6 @@ +# $FreeBSD$ + +WARNS?= 3 +PACKAGE= binutils + +.include "../Makefile.inc" diff --git a/gnu/usr.bin/binutils/Makefile.inc0 b/gnu/usr.bin/binutils/Makefile.inc0 new file mode 100644 index 000000000000..c624a1b9f2b1 --- /dev/null +++ b/gnu/usr.bin/binutils/Makefile.inc0 @@ -0,0 +1,52 @@ +# $FreeBSD$ +# +# This is included explicitly at the top of each sub-Makefile. We can't +# use the normal "Makefile.inc" mechanism, because we need some of these +# definitions before the sub-Makefile is processed. + +VERSION= "2.17.50 [FreeBSD] 2007-07-03" + +.if defined(TARGET_ARCH) +TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}} +.else +TARGET_CPUARCH=${MACHINE_CPUARCH} +.endif +TARGET_ARCH?= ${MACHINE_ARCH} +TARGET_VENDOR?= unknown +TARGET_OS?= freebsd +BINUTILS_ARCH=${TARGET_ARCH:C/amd64/x86_64/} +TARGET_TUPLE?= ${BINUTILS_ARCH}-${TARGET_VENDOR}-${TARGET_OS} +.if ${TARGET_ARCH:Marm*eb} != "" || \ + (${TARGET_CPUARCH} == "mips" && ${TARGET_ARCH:Mmips*el*} == "") +TARGET_BIG_ENDIAN=t +.endif + +# GNURELTOP is the relative path to this point in the source or object +# tree, from any subdirectory of same. It gets extra "../" prefixes +# added to it as we descend into subdirectories. +GNURELTOP:= .. + +RELSRC= ${GNURELTOP}/../../../contrib/binutils +SRCDIR= ${.CURDIR}/${RELSRC} + +.if ${TARGET_CPUARCH} == "arm" || ${TARGET_CPUARCH} == "i386" || \ + ${TARGET_ARCH} == "powerpc" || ${TARGET_ARCH} == "powerpcspe" || \ + (${TARGET_CPUARCH} == "mips" && ${TARGET_ARCH:Mmips64*} == "") +CFLAGS+= -DBFD_DEFAULT_TARGET_SIZE=32 +.else +CFLAGS+= -DBFD_DEFAULT_TARGET_SIZE=64 +.endif + +CFLAGS+= -I. +CFLAGS+= -I${.CURDIR} +CFLAGS+= -I${.CURDIR}/${GNURELTOP}/libbfd +CFLAGS+= -I${.OBJDIR}/${GNURELTOP}/libbfd +CFLAGS+= -I${SRCDIR}/include + +ARCHS= ${TARGET_CPUARCH} + +.if exists(${.CURDIR}/Makefile.${TARGET_ARCH}) +.include "${.CURDIR}/Makefile.${TARGET_ARCH}" +.elif exists(${.CURDIR}/Makefile.${TARGET_CPUARCH}) +.include "${.CURDIR}/Makefile.${TARGET_CPUARCH}" +.endif diff --git a/gnu/usr.bin/binutils/as/Makefile b/gnu/usr.bin/binutils/as/Makefile new file mode 100644 index 000000000000..a7db31563706 --- /dev/null +++ b/gnu/usr.bin/binutils/as/Makefile @@ -0,0 +1,103 @@ +# $FreeBSD$ + + +# BINDIR +.include "${.CURDIR}/../../Makefile.inc" +.include "${.CURDIR}/../Makefile.inc0" +.include <src.opts.mk> + +.PATH: ${SRCDIR}/gas ${SRCDIR}/gas/config + +.if ${TARGET_ARCH:Marm*} || ${TARGET_ARCH} == "powerpc64" +NO_WERROR.clang= +.endif + +PROG= as +SRCS+= app.c \ + as.c \ + atof-generic.c \ + atof-ieee.c \ + cond.c \ + depend.c \ + dw2gencfi.c \ + dwarf2dbg.c \ + ecoff.c \ + ehopt.c \ + expr.c \ + flonum-copy.c \ + flonum-konst.c \ + flonum-mult.c \ + frags.c \ + hash.c \ + input-file.c \ + input-scrub.c \ + listing.c \ + literal.c \ + macro.c \ + messages.c \ + obj-elf.c \ + output-file.c \ + read.c \ + sb.c \ + stabs.c \ + subsegs.c \ + symbols.c \ + write.c +# DEO: why not used? +#SRCS+= itbl-ops.c + +.if ${TARGET_ARCH:Marmv6*} != "" +CFLAGS+= -DCPU_DEFAULT=ARM_ARCH_V6K +.endif +.if ${TARGET_ARCH:Marmv7*} != "" +CFLAGS+= -DCPU_DEFAULT=ARM_ARCH_V7A +.endif + +.if ${TARGET_CPUARCH} == "mips" +SRCS+= itbl-ops.c itbl-parse.y itbl-lex.l +.if ${TARGET_ARCH:Mmips64*} != "" +CFLAGS+= -DMIPS_DEFAULT_ABI=N64_ABI -DMIPS_DEFAULT_64BIT=1 +.elif ${TARGET_ARCH:Mmipsn32*} != "" +CFLAGS+= -DMIPS_DEFAULT_ABI=N32_ABI +.else +MIPS_ABI_DEFAULT=ABI_32 +.endif +.endif + +.if ${TARGET_ARCH} == "amd64" +SRCS+= tc-i386.c +.elif ${TARGET_CPUARCH} == "powerpc" +SRCS+= tc-ppc.c +.elif ${TARGET_ARCH} == "sparc64" +SRCS+= tc-sparc.c +.else +SRCS+= tc-${TARGET_CPUARCH}.c +.endif + +.if ${TARGET_ARCH} == "sparc64" +CFLAGS+= -DDEFAULT_ARCH=\"v9-64\" +.else +CFLAGS+= -DDEFAULT_ARCH=\"${BINUTILS_ARCH}\" +.endif +.if defined(TARGET_BIG_ENDIAN) +CFLAGS+= -DTARGET_BYTES_BIG_ENDIAN=1 +.endif +CFLAGS+= -DTARGET_CPU=\"${BINUTILS_ARCH}\" +CFLAGS+= -DTARGET_OS=\"${TARGET_OS}\" +CFLAGS+= -DTARGET_CANONICAL=\"${TARGET_TUPLE}\" +CFLAGS+= -DTARGET_ALIAS=\"${TARGET_TUPLE}\" +CFLAGS+= -DVERSION=\"${VERSION}\" +CFLAGS+= -D_GNU_SOURCE +CFLAGS+= -I${SRCDIR}/gas -I${SRCDIR}/bfd -I${SRCDIR}/gas/config -I${SRCDIR} +CFLAGS+= -I${.CURDIR} -I${.CURDIR}/${TARGET_CPUARCH}-freebsd + +.if ${MK_SHARED_TOOLCHAIN} == "no" +NO_SHARED?= yes +.endif + +DPADD= ${GNURELTOP}/libbfd/libbfd.a +DPADD+= ${GNURELTOP}/libiberty/libiberty.a +DPADD+= ${GNURELTOP}/libopcodes/libopcodes.a +LDADD= ${DPADD} + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/binutils/as/Makefile.depend b/gnu/usr.bin/binutils/as/Makefile.depend new file mode 100644 index 000000000000..1480a25f260e --- /dev/null +++ b/gnu/usr.bin/binutils/as/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/usr.bin/binutils/libbfd \ + gnu/usr.bin/binutils/libiberty \ + gnu/usr.bin/binutils/libopcodes \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/as/alpha-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/alpha-freebsd/targ-cpu.h new file mode 100644 index 000000000000..273884893eb3 --- /dev/null +++ b/gnu/usr.bin/binutils/as/alpha-freebsd/targ-cpu.h @@ -0,0 +1 @@ +#include "tc-alpha.h" diff --git a/gnu/usr.bin/binutils/as/amd64-freebsd/itbl-cpu.h b/gnu/usr.bin/binutils/as/amd64-freebsd/itbl-cpu.h new file mode 100644 index 000000000000..a0fe73b3c8df --- /dev/null +++ b/gnu/usr.bin/binutils/as/amd64-freebsd/itbl-cpu.h @@ -0,0 +1,3 @@ +/* $FreeBSD$ */ + +#include "itbl-i386.h" diff --git a/gnu/usr.bin/binutils/as/amd64-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/amd64-freebsd/targ-cpu.h new file mode 100644 index 000000000000..34219a5293f8 --- /dev/null +++ b/gnu/usr.bin/binutils/as/amd64-freebsd/targ-cpu.h @@ -0,0 +1,3 @@ +/* $FreeBSD$*/ + +#include "tc-i386.h" diff --git a/gnu/usr.bin/binutils/as/arm-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/arm-freebsd/targ-cpu.h new file mode 100644 index 000000000000..ac410744deb0 --- /dev/null +++ b/gnu/usr.bin/binutils/as/arm-freebsd/targ-cpu.h @@ -0,0 +1,3 @@ +/* $FreeBSD$ */ + +#include "tc-arm.h" diff --git a/gnu/usr.bin/binutils/as/as.1 b/gnu/usr.bin/binutils/as/as.1 new file mode 100644 index 000000000000..d53610db7841 --- /dev/null +++ b/gnu/usr.bin/binutils/as/as.1 @@ -0,0 +1,1134 @@ +.\" $FreeBSD$ +.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.ie \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.el \{\ +. de IX +.. +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "AS 1" +.TH AS 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +AS \- the portable GNU assembler. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +as [\fB\-a\fR[\fBcdhlns\fR][=\fIfile\fR]] [\fB\-\-alternate\fR] [\fB\-D\fR] + [\fB\-\-defsym\fR \fIsym\fR=\fIval\fR] [\fB\-f\fR] [\fB\-g\fR] [\fB\-\-gstabs\fR] + [\fB\-\-gstabs+\fR] [\fB\-\-gdwarf\-2\fR] [\fB\-\-help\fR] [\fB\-I\fR \fIdir\fR] [\fB\-J\fR] + [\fB\-K\fR] [\fB\-L\fR] [\fB\-\-listing\-lhs\-width\fR=\fI\s-1NUM\s0\fR] + [\fB\-\-listing\-lhs\-width2\fR=\fI\s-1NUM\s0\fR] [\fB\-\-listing\-rhs\-width\fR=\fI\s-1NUM\s0\fR] + [\fB\-\-listing\-cont\-lines\fR=\fI\s-1NUM\s0\fR] [\fB\-\-keep\-locals\fR] [\fB\-o\fR + \fIobjfile\fR] [\fB\-R\fR] [\fB\-\-reduce\-memory\-overheads\fR] [\fB\-\-statistics\fR] + [\fB\-v\fR] [\fB\-version\fR] [\fB\-\-version\fR] [\fB\-W\fR] [\fB\-\-warn\fR] + [\fB\-\-fatal\-warnings\fR] [\fB\-w\fR] [\fB\-x\fR] [\fB\-Z\fR] [\fB@\fR\fI\s-1FILE\s0\fR] + [\fB\-\-target\-help\fR] [\fItarget-options\fR] + [\fB\-\-\fR|\fIfiles\fR ...] +.PP +\&\fITarget Alpha options:\fR + [\fB\-m\fR\fIcpu\fR] + [\fB\-mdebug\fR | \fB\-no\-mdebug\fR] + [\fB\-relax\fR] [\fB\-g\fR] [\fB\-G\fR\fIsize\fR] + [\fB\-F\fR] [\fB\-32addr\fR] +.PP +\&\fITarget \s-1ARC\s0 options:\fR + [\fB\-marc[5|6|7|8]\fR] + [\fB\-EB\fR|\fB\-EL\fR] +.PP +\&\fITarget \s-1ARM\s0 options:\fR + [\fB\-mcpu\fR=\fIprocessor\fR[+\fIextension\fR...]] + [\fB\-march\fR=\fIarchitecture\fR[+\fIextension\fR...]] + [\fB\-mfpu\fR=\fIfloating-point-format\fR] + [\fB\-mfloat\-abi\fR=\fIabi\fR] + [\fB\-meabi\fR=\fIver\fR] + [\fB\-mthumb\fR] + [\fB\-EB\fR|\fB\-EL\fR] + [\fB\-mapcs\-32\fR|\fB\-mapcs\-26\fR|\fB\-mapcs\-float\fR| + \fB\-mapcs\-reentrant\fR] + [\fB\-mthumb\-interwork\fR] [\fB\-k\fR] +.PP +\&\fITarget \s-1CRIS\s0 options:\fR + [\fB\-\-underscore\fR | \fB\-\-no\-underscore\fR] + [\fB\-\-pic\fR] [\fB\-N\fR] + [\fB\-\-emulation=criself\fR | \fB\-\-emulation=crisaout\fR] + [\fB\-\-march=v0_v10\fR | \fB\-\-march=v10\fR | \fB\-\-march=v32\fR | \fB\-\-march=common_v10_v32\fR] +.PP +\&\fITarget D10V options:\fR + [\fB\-O\fR] +.PP +\&\fITarget D30V options:\fR + [\fB\-O\fR|\fB\-n\fR|\fB\-N\fR] +.PP +\&\fITarget i386 options:\fR + [\fB\-\-32\fR|\fB\-\-64\fR] [\fB\-n\fR] + [\fB\-march\fR=\fI\s-1CPU\s0\fR] [\fB\-mtune\fR=\fI\s-1CPU\s0\fR] +.PP +\&\fITarget i960 options:\fR + [\fB\-ACA\fR|\fB\-ACA_A\fR|\fB\-ACB\fR|\fB\-ACC\fR|\fB\-AKA\fR|\fB\-AKB\fR| + \fB\-AKC\fR|\fB\-AMC\fR] + [\fB\-b\fR] [\fB\-no\-relax\fR] +.PP +\&\fITarget \s-1IA\-64\s0 options:\fR + [\fB\-mconstant\-gp\fR|\fB\-mauto\-pic\fR] + [\fB\-milp32\fR|\fB\-milp64\fR|\fB\-mlp64\fR|\fB\-mp64\fR] + [\fB\-mle\fR|\fBmbe\fR] + [\fB\-mtune=itanium1\fR|\fB\-mtune=itanium2\fR] + [\fB\-munwind\-check=warning\fR|\fB\-munwind\-check=error\fR] + [\fB\-mhint.b=ok\fR|\fB\-mhint.b=warning\fR|\fB\-mhint.b=error\fR] + [\fB\-x\fR|\fB\-xexplicit\fR] [\fB\-xauto\fR] [\fB\-xdebug\fR] +.PP +\&\fITarget \s-1IP2K\s0 options:\fR + [\fB\-mip2022\fR|\fB\-mip2022ext\fR] +.PP +\&\fITarget M32C options:\fR + [\fB\-m32c\fR|\fB\-m16c\fR] +.PP +\&\fITarget M32R options:\fR + [\fB\-\-m32rx\fR|\fB\-\-[no\-]warn\-explicit\-parallel\-conflicts\fR| + \fB\-\-W[n]p\fR] +.PP +\&\fITarget M680X0 options:\fR + [\fB\-l\fR] [\fB\-m68000\fR|\fB\-m68010\fR|\fB\-m68020\fR|...] +.PP +\&\fITarget M68HC11 options:\fR + [\fB\-m68hc11\fR|\fB\-m68hc12\fR|\fB\-m68hcs12\fR] + [\fB\-mshort\fR|\fB\-mlong\fR] + [\fB\-mshort\-double\fR|\fB\-mlong\-double\fR] + [\fB\-\-force\-long\-branches\fR] [\fB\-\-short\-branches\fR] + [\fB\-\-strict\-direct\-mode\fR] [\fB\-\-print\-insn\-syntax\fR] + [\fB\-\-print\-opcodes\fR] [\fB\-\-generate\-example\fR] +.PP +\&\fITarget \s-1MCORE\s0 options:\fR + [\fB\-jsri2bsr\fR] [\fB\-sifilter\fR] [\fB\-relax\fR] + [\fB\-mcpu=[210|340]\fR] +.PP +\&\fITarget \s-1MIPS\s0 options:\fR + [\fB\-nocpp\fR] [\fB\-EL\fR] [\fB\-EB\fR] [\fB\-O\fR[\fIoptimization level\fR]] + [\fB\-g\fR[\fIdebug level\fR]] [\fB\-G\fR \fInum\fR] [\fB\-KPIC\fR] [\fB\-call_shared\fR] + [\fB\-non_shared\fR] [\fB\-xgot\fR [\fB\-mvxworks\-pic\fR] + [\fB\-mabi\fR=\fI\s-1ABI\s0\fR] [\fB\-32\fR] [\fB\-n32\fR] [\fB\-64\fR] [\fB\-mfp32\fR] [\fB\-mgp32\fR] + [\fB\-march\fR=\fI\s-1CPU\s0\fR] [\fB\-mtune\fR=\fI\s-1CPU\s0\fR] [\fB\-mips1\fR] [\fB\-mips2\fR] + [\fB\-mips3\fR] [\fB\-mips4\fR] [\fB\-mips5\fR] [\fB\-mips32\fR] [\fB\-mips32r2\fR] + [\fB\-mips64\fR] [\fB\-mips64r2\fR] + [\fB\-construct\-floats\fR] [\fB\-no\-construct\-floats\fR] + [\fB\-trap\fR] [\fB\-no\-break\fR] [\fB\-break\fR] [\fB\-no\-trap\fR] + [\fB\-mfix7000\fR] [\fB\-mno\-fix7000\fR] + [\fB\-mips16\fR] [\fB\-no\-mips16\fR] + [\fB\-msmartmips\fR] [\fB\-mno\-smartmips\fR] + [\fB\-mips3d\fR] [\fB\-no\-mips3d\fR] + [\fB\-mdmx\fR] [\fB\-no\-mdmx\fR] + [\fB\-mdsp\fR] [\fB\-mno\-dsp\fR] + [\fB\-mdspr2\fR] [\fB\-mno\-dspr2\fR] + [\fB\-mmt\fR] [\fB\-mno\-mt\fR] + [\fB\-mdebug\fR] [\fB\-no\-mdebug\fR] + [\fB\-mpdr\fR] [\fB\-mno\-pdr\fR] +.PP +\&\fITarget \s-1MMIX\s0 options:\fR + [\fB\-\-fixed\-special\-register\-names\fR] [\fB\-\-globalize\-symbols\fR] + [\fB\-\-gnu\-syntax\fR] [\fB\-\-relax\fR] [\fB\-\-no\-predefined\-symbols\fR] + [\fB\-\-no\-expand\fR] [\fB\-\-no\-merge\-gregs\fR] [\fB\-x\fR] + [\fB\-\-linker\-allocated\-gregs\fR] +.PP +\&\fITarget \s-1PDP11\s0 options:\fR + [\fB\-mpic\fR|\fB\-mno\-pic\fR] [\fB\-mall\fR] [\fB\-mno\-extensions\fR] + [\fB\-m\fR\fIextension\fR|\fB\-mno\-\fR\fIextension\fR] + [\fB\-m\fR\fIcpu\fR] [\fB\-m\fR\fImachine\fR] +.PP +\&\fITarget picoJava options:\fR + [\fB\-mb\fR|\fB\-me\fR] +.PP +\&\fITarget PowerPC options:\fR + [\fB\-mpwrx\fR|\fB\-mpwr2\fR|\fB\-mpwr\fR|\fB\-m601\fR|\fB\-mppc\fR|\fB\-mppc32\fR|\fB\-m603\fR|\fB\-m604\fR| + \fB\-m403\fR|\fB\-m405\fR|\fB\-mppc64\fR|\fB\-m620\fR|\fB\-mppc64bridge\fR|\fB\-mbooke\fR| + \fB\-mbooke32\fR|\fB\-mbooke64\fR] + [\fB\-mcom\fR|\fB\-many\fR|\fB\-maltivec\fR] [\fB\-memb\fR] + [\fB\-mregnames\fR|\fB\-mno\-regnames\fR] + [\fB\-mrelocatable\fR|\fB\-mrelocatable\-lib\fR] + [\fB\-mlittle\fR|\fB\-mlittle\-endian\fR|\fB\-mbig\fR|\fB\-mbig\-endian\fR] + [\fB\-msolaris\fR|\fB\-mno\-solaris\fR] +.PP +\&\fITarget \s-1SPARC\s0 options:\fR + [\fB\-Av6\fR|\fB\-Av7\fR|\fB\-Av8\fR|\fB\-Asparclet\fR|\fB\-Asparclite\fR + \fB\-Av8plus\fR|\fB\-Av8plusa\fR|\fB\-Av9\fR|\fB\-Av9a\fR] + [\fB\-xarch=v8plus\fR|\fB\-xarch=v8plusa\fR] [\fB\-bump\fR] + [\fB\-32\fR|\fB\-64\fR] +.PP +\&\fITarget \s-1TIC54X\s0 options:\fR + [\fB\-mcpu=54[123589]\fR|\fB\-mcpu=54[56]lp\fR] [\fB\-mfar\-mode\fR|\fB\-mf\fR] + [\fB\-merrors\-to\-file\fR \fI<filename>\fR|\fB\-me\fR \fI<filename>\fR] +.PP +\&\fITarget Z80 options:\fR + [\fB\-z80\fR] [\fB\-r800\fR] + [ \fB\-ignore\-undocumented\-instructions\fR] [\fB\-Wnud\fR] + [ \fB\-ignore\-unportable\-instructions\fR] [\fB\-Wnup\fR] + [ \fB\-warn\-undocumented\-instructions\fR] [\fB\-Wud\fR] + [ \fB\-warn\-unportable\-instructions\fR] [\fB\-Wup\fR] + [ \fB\-forbid\-undocumented\-instructions\fR] [\fB\-Fud\fR] + [ \fB\-forbid\-unportable\-instructions\fR] [\fB\-Fup\fR] +.PP +\&\fITarget Xtensa options:\fR + [\fB\-\-[no\-]text\-section\-literals\fR] [\fB\-\-[no\-]absolute\-literals\fR] + [\fB\-\-[no\-]target\-align\fR] [\fB\-\-[no\-]longcalls\fR] + [\fB\-\-[no\-]transform\fR] + [\fB\-\-rename\-section\fR \fIoldname\fR=\fInewname\fR] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\s-1GNU\s0 \fBas\fR is really a family of assemblers. +If you use (or have used) the \s-1GNU\s0 assembler on one architecture, you +should find a fairly similar environment when you use it on another +architecture. Each version has much in common with the others, +including object file formats, most assembler directives (often called +\&\fIpseudo-ops\fR) and assembler syntax. +.PP +\&\fBas\fR is primarily intended to assemble the output of the +\&\s-1GNU\s0 C compiler \f(CW\*(C`gcc\*(C'\fR for use by the linker +\&\f(CW\*(C`ld\*(C'\fR. Nevertheless, we've tried to make \fBas\fR +assemble correctly everything that other assemblers for the same +machine would assemble. +Any exceptions are documented explicitly. +This doesn't mean \fBas\fR always uses the same syntax as another +assembler for the same architecture; for example, we know of several +incompatible versions of 680x0 assembly language syntax. +.PP +Each time you run \fBas\fR it assembles exactly one source +program. The source program is made up of one or more files. +(The standard input is also a file.) +.PP +You give \fBas\fR a command line that has zero or more input file +names. The input files are read (from left file name to right). A +command line argument (in any position) that has no special meaning +is taken to be an input file name. +.PP +If you give \fBas\fR no file names it attempts to read one input file +from the \fBas\fR standard input, which is normally your terminal. You +may have to type \fBctl-D\fR to tell \fBas\fR there is no more program +to assemble. +.PP +Use \fB\-\-\fR if you need to explicitly name the standard input file +in your command line. +.PP +If the source is empty, \fBas\fR produces a small, empty object +file. +.PP +\&\fBas\fR may write warnings and error messages to the standard error +file (usually your terminal). This should not happen when a compiler +runs \fBas\fR automatically. Warnings report an assumption made so +that \fBas\fR could keep assembling a flawed program; errors report a +grave problem that stops the assembly. +.PP +If you are invoking \fBas\fR via the \s-1GNU\s0 C compiler, +you can use the \fB\-Wa\fR option to pass arguments through to the assembler. +The assembler arguments must be separated from each other (and the \fB\-Wa\fR) +by commas. For example: +.PP +.Vb 1 +\& gcc \-c \-g \-O \-Wa,\-alh,\-L file.c +.Ve +.PP +This passes two options to the assembler: \fB\-alh\fR (emit a listing to +standard output with high-level and assembly source) and \fB\-L\fR (retain +local symbols in the symbol table). +.PP +Usually you do not need to use this \fB\-Wa\fR mechanism, since many compiler +command-line options are automatically passed to the assembler by the compiler. +(You can call the \s-1GNU\s0 compiler driver with the \fB\-v\fR option to see +precisely what options it passes to each compilation pass, including the +assembler.) +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.IP "\fB\-a[cdhlmns]\fR" 4 +.IX Item "-a[cdhlmns]" +Turn on listings, in any of a variety of ways: +.RS 4 +.IP "\fB\-ac\fR" 4 +.IX Item "-ac" +omit false conditionals +.IP "\fB\-ad\fR" 4 +.IX Item "-ad" +omit debugging directives +.IP "\fB\-ah\fR" 4 +.IX Item "-ah" +include high-level source +.IP "\fB\-al\fR" 4 +.IX Item "-al" +include assembly +.IP "\fB\-am\fR" 4 +.IX Item "-am" +include macro expansions +.IP "\fB\-an\fR" 4 +.IX Item "-an" +omit forms processing +.IP "\fB\-as\fR" 4 +.IX Item "-as" +include symbols +.IP "\fB=file\fR" 4 +.IX Item "=file" +set the name of the listing file +.RE +.RS 4 +.Sp +You may combine these options; for example, use \fB\-aln\fR for assembly +listing without forms processing. The \fB=file\fR option, if used, must be +the last one. By itself, \fB\-a\fR defaults to \fB\-ahls\fR. +.RE +.IP "\fB\-\-alternate\fR" 4 +.IX Item "--alternate" +Begin in alternate macro mode. +.IP "\fB\-D\fR" 4 +.IX Item "-D" +Ignored. This option is accepted for script compatibility with calls to +other assemblers. +.IP "\fB\-\-defsym\fR \fIsym\fR\fB=\fR\fIvalue\fR" 4 +.IX Item "--defsym sym=value" +Define the symbol \fIsym\fR to be \fIvalue\fR before assembling the input file. +\&\fIvalue\fR must be an integer constant. As in C, a leading \fB0x\fR +indicates a hexadecimal value, and a leading \fB0\fR indicates an octal +value. The value of the symbol can be overridden inside a source file via the +use of a \f(CW\*(C`.set\*(C'\fR pseudo-op. +.IP "\fB\-f\fR" 4 +.IX Item "-f" +\&\*(L"fast\*(R"\-\-\-skip whitespace and comment preprocessing (assume source is +compiler output). +.IP "\fB\-g\fR" 4 +.IX Item "-g" +.PD 0 +.IP "\fB\-\-gen\-debug\fR" 4 +.IX Item "--gen-debug" +.PD +Generate debugging information for each assembler source line using whichever +debug format is preferred by the target. This currently means either \s-1STABS\s0, +\&\s-1ECOFF\s0 or \s-1DWARF2\s0. +.IP "\fB\-\-gstabs\fR" 4 +.IX Item "--gstabs" +Generate stabs debugging information for each assembler line. This +may help debugging assembler code, if the debugger can handle it. +.IP "\fB\-\-gstabs+\fR" 4 +.IX Item "--gstabs+" +Generate stabs debugging information for each assembler line, with \s-1GNU\s0 +extensions that probably only gdb can handle, and that could make other +debuggers crash or refuse to read your program. This +may help debugging assembler code. Currently the only \s-1GNU\s0 extension is +the location of the current working directory at assembling time. +.IP "\fB\-\-gdwarf\-2\fR" 4 +.IX Item "--gdwarf-2" +Generate \s-1DWARF2\s0 debugging information for each assembler line. This +may help debugging assembler code, if the debugger can handle it. Note\-\-\-this +option is only supported by some targets, not all of them. +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +Print a summary of the command line options and exit. +.IP "\fB\-\-target\-help\fR" 4 +.IX Item "--target-help" +Print a summary of all target specific options and exit. +.IP "\fB\-I\fR \fIdir\fR" 4 +.IX Item "-I dir" +Add directory \fIdir\fR to the search list for \f(CW\*(C`.include\*(C'\fR directives. +.IP "\fB\-J\fR" 4 +.IX Item "-J" +Don't warn about signed overflow. +.IP "\fB\-K\fR" 4 +.IX Item "-K" +Issue warnings when difference tables altered for long displacements. +.IP "\fB\-L\fR" 4 +.IX Item "-L" +.PD 0 +.IP "\fB\-\-keep\-locals\fR" 4 +.IX Item "--keep-locals" +.PD +Keep (in the symbol table) local symbols. These symbols start with +system-specific local label prefixes, typically \fB.L\fR for \s-1ELF\s0 systems +or \fBL\fR for traditional a.out systems. +.IP "\fB\-\-listing\-lhs\-width=\fR\fInumber\fR" 4 +.IX Item "--listing-lhs-width=number" +Set the maximum width, in words, of the output data column for an assembler +listing to \fInumber\fR. +.IP "\fB\-\-listing\-lhs\-width2=\fR\fInumber\fR" 4 +.IX Item "--listing-lhs-width2=number" +Set the maximum width, in words, of the output data column for continuation +lines in an assembler listing to \fInumber\fR. +.IP "\fB\-\-listing\-rhs\-width=\fR\fInumber\fR" 4 +.IX Item "--listing-rhs-width=number" +Set the maximum width of an input source line, as displayed in a listing, to +\&\fInumber\fR bytes. +.IP "\fB\-\-listing\-cont\-lines=\fR\fInumber\fR" 4 +.IX Item "--listing-cont-lines=number" +Set the maximum number of lines printed in a listing for a single line of input +to \fInumber\fR + 1. +.IP "\fB\-o\fR \fIobjfile\fR" 4 +.IX Item "-o objfile" +Name the object-file output from \fBas\fR \fIobjfile\fR. +.IP "\fB\-R\fR" 4 +.IX Item "-R" +Fold the data section into the text section. +.Sp +Set the default size of \s-1GAS\s0's hash tables to a prime number close to +\&\fInumber\fR. Increasing this value can reduce the length of time it takes the +assembler to perform its tasks, at the expense of increasing the assembler's +memory requirements. Similarly reducing this value can reduce the memory +requirements at the expense of speed. +.IP "\fB\-\-reduce\-memory\-overheads\fR" 4 +.IX Item "--reduce-memory-overheads" +This option reduces \s-1GAS\s0's memory requirements, at the expense of making the +assembly processes slower. Currently this switch is a synonym for +\&\fB\-\-hash\-size=4051\fR, but in the future it may have other effects as well. +.IP "\fB\-\-statistics\fR" 4 +.IX Item "--statistics" +Print the maximum space (in bytes) and total time (in seconds) used by +assembly. +.IP "\fB\-\-strip\-local\-absolute\fR" 4 +.IX Item "--strip-local-absolute" +Remove local absolute symbols from the outgoing symbol table. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-version\fR" 4 +.IX Item "-version" +.PD +Print the \fBas\fR version. +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +Print the \fBas\fR version and exit. +.IP "\fB\-W\fR" 4 +.IX Item "-W" +.PD 0 +.IP "\fB\-\-no\-warn\fR" 4 +.IX Item "--no-warn" +.PD +Suppress warning messages. +.IP "\fB\-\-fatal\-warnings\fR" 4 +.IX Item "--fatal-warnings" +Treat warnings as errors. +.IP "\fB\-\-warn\fR" 4 +.IX Item "--warn" +Don't suppress warning messages or treat them as errors. +.IP "\fB\-w\fR" 4 +.IX Item "-w" +Ignored. +.IP "\fB\-x\fR" 4 +.IX Item "-x" +Ignored. +.IP "\fB\-Z\fR" 4 +.IX Item "-Z" +Generate an object file even after errors. +.IP "\fB\-\- |\fR \fIfiles\fR \fB...\fR" 4 +.IX Item "-- | files ..." +Standard input, or source files to assemble. +.PP +The following options are available when as is configured for +an \s-1ARC\s0 processor. +.IP "\fB\-marc[5|6|7|8]\fR" 4 +.IX Item "-marc[5|6|7|8]" +This option selects the core processor variant. +.IP "\fB\-EB | \-EL\fR" 4 +.IX Item "-EB | -EL" +Select either big-endian (\-EB) or little-endian (\-EL) output. +.PP +The following options are available when as is configured for the \s-1ARM\s0 +processor family. +.IP "\fB\-mcpu=\fR\fIprocessor\fR\fB[+\fR\fIextension\fR\fB...]\fR" 4 +.IX Item "-mcpu=processor[+extension...]" +Specify which \s-1ARM\s0 processor variant is the target. +.IP "\fB\-march=\fR\fIarchitecture\fR\fB[+\fR\fIextension\fR\fB...]\fR" 4 +.IX Item "-march=architecture[+extension...]" +Specify which \s-1ARM\s0 architecture variant is used by the target. +.IP "\fB\-mfpu=\fR\fIfloating-point-format\fR" 4 +.IX Item "-mfpu=floating-point-format" +Select which Floating Point architecture is the target. +.IP "\fB\-mfloat\-abi=\fR\fIabi\fR" 4 +.IX Item "-mfloat-abi=abi" +Select which floating point \s-1ABI\s0 is in use. +.IP "\fB\-mthumb\fR" 4 +.IX Item "-mthumb" +Enable Thumb only instruction decoding. +.IP "\fB\-mapcs\-32 | \-mapcs\-26 | \-mapcs\-float | \-mapcs\-reentrant\fR" 4 +.IX Item "-mapcs-32 | -mapcs-26 | -mapcs-float | -mapcs-reentrant" +Select which procedure calling convention is in use. +.IP "\fB\-EB | \-EL\fR" 4 +.IX Item "-EB | -EL" +Select either big-endian (\-EB) or little-endian (\-EL) output. +.IP "\fB\-mthumb\-interwork\fR" 4 +.IX Item "-mthumb-interwork" +Specify that the code has been generated with interworking between Thumb and +\&\s-1ARM\s0 code in mind. +.IP "\fB\-k\fR" 4 +.IX Item "-k" +Specify that \s-1PIC\s0 code has been generated. +.PP +See the info pages for documentation of the CRIS-specific options. +.PP +The following options are available when as is configured for +a D10V processor. +.IP "\fB\-O\fR" 4 +.IX Item "-O" +Optimize output by parallelizing instructions. +.PP +The following options are available when as is configured for a D30V +processor. +.IP "\fB\-O\fR" 4 +.IX Item "-O" +Optimize output by parallelizing instructions. +.IP "\fB\-n\fR" 4 +.IX Item "-n" +Warn when nops are generated. +.IP "\fB\-N\fR" 4 +.IX Item "-N" +Warn when a nop after a 32\-bit multiply instruction is generated. +.PP +The following options are available when as is configured for the +Intel 80960 processor. +.IP "\fB\-ACA | \-ACA_A | \-ACB | \-ACC | \-AKA | \-AKB | \-AKC | \-AMC\fR" 4 +.IX Item "-ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC" +Specify which variant of the 960 architecture is the target. +.IP "\fB\-b\fR" 4 +.IX Item "-b" +Add code to collect statistics about branches taken. +.IP "\fB\-no\-relax\fR" 4 +.IX Item "-no-relax" +Do not alter compare-and-branch instructions for long displacements; +error if necessary. +.PP +The following options are available when as is configured for the +Ubicom \s-1IP2K\s0 series. +.IP "\fB\-mip2022ext\fR" 4 +.IX Item "-mip2022ext" +Specifies that the extended \s-1IP2022\s0 instructions are allowed. +.IP "\fB\-mip2022\fR" 4 +.IX Item "-mip2022" +Restores the default behaviour, which restricts the permitted instructions to +just the basic \s-1IP2022\s0 ones. +.PP +The following options are available when as is configured for the +Renesas M32C and M16C processors. +.IP "\fB\-m32c\fR" 4 +.IX Item "-m32c" +Assemble M32C instructions. +.IP "\fB\-m16c\fR" 4 +.IX Item "-m16c" +Assemble M16C instructions (the default). +.PP +The following options are available when as is configured for the +Renesas M32R (formerly Mitsubishi M32R) series. +.IP "\fB\-\-m32rx\fR" 4 +.IX Item "--m32rx" +Specify which processor in the M32R family is the target. The default +is normally the M32R, but this option changes it to the M32RX. +.IP "\fB\-\-warn\-explicit\-parallel\-conflicts or \-\-Wp\fR" 4 +.IX Item "--warn-explicit-parallel-conflicts or --Wp" +Produce warning messages when questionable parallel constructs are +encountered. +.IP "\fB\-\-no\-warn\-explicit\-parallel\-conflicts or \-\-Wnp\fR" 4 +.IX Item "--no-warn-explicit-parallel-conflicts or --Wnp" +Do not produce warning messages when questionable parallel constructs are +encountered. +.PP +The following options are available when as is configured for the +Motorola 68000 series. +.IP "\fB\-l\fR" 4 +.IX Item "-l" +Shorten references to undefined symbols, to one word instead of two. +.IP "\fB\-m68000 | \-m68008 | \-m68010 | \-m68020 | \-m68030\fR" 4 +.IX Item "-m68000 | -m68008 | -m68010 | -m68020 | -m68030" +.PD 0 +.IP "\fB| \-m68040 | \-m68060 | \-m68302 | \-m68331 | \-m68332\fR" 4 +.IX Item "| -m68040 | -m68060 | -m68302 | -m68331 | -m68332" +.IP "\fB| \-m68333 | \-m68340 | \-mcpu32 | \-m5200\fR" 4 +.IX Item "| -m68333 | -m68340 | -mcpu32 | -m5200" +.PD +Specify what processor in the 68000 family is the target. The default +is normally the 68020, but this can be changed at configuration time. +.IP "\fB\-m68881 | \-m68882 | \-mno\-68881 | \-mno\-68882\fR" 4 +.IX Item "-m68881 | -m68882 | -mno-68881 | -mno-68882" +The target machine does (or does not) have a floating-point coprocessor. +The default is to assume a coprocessor for 68020, 68030, and cpu32. Although +the basic 68000 is not compatible with the 68881, a combination of the +two can be specified, since it's possible to do emulation of the +coprocessor instructions with the main processor. +.IP "\fB\-m68851 | \-mno\-68851\fR" 4 +.IX Item "-m68851 | -mno-68851" +The target machine does (or does not) have a memory-management +unit coprocessor. The default is to assume an \s-1MMU\s0 for 68020 and up. +.PP +For details about the \s-1PDP\-11\s0 machine dependent features options, +see \fBPDP\-11\-Options\fR. +.IP "\fB\-mpic | \-mno\-pic\fR" 4 +.IX Item "-mpic | -mno-pic" +Generate position-independent (or position-dependent) code. The +default is \fB\-mpic\fR. +.IP "\fB\-mall\fR" 4 +.IX Item "-mall" +.PD 0 +.IP "\fB\-mall\-extensions\fR" 4 +.IX Item "-mall-extensions" +.PD +Enable all instruction set extensions. This is the default. +.IP "\fB\-mno\-extensions\fR" 4 +.IX Item "-mno-extensions" +Disable all instruction set extensions. +.IP "\fB\-m\fR\fIextension\fR \fB| \-mno\-\fR\fIextension\fR" 4 +.IX Item "-mextension | -mno-extension" +Enable (or disable) a particular instruction set extension. +.IP "\fB\-m\fR\fIcpu\fR" 4 +.IX Item "-mcpu" +Enable the instruction set extensions supported by a particular \s-1CPU\s0, and +disable all other extensions. +.IP "\fB\-m\fR\fImachine\fR" 4 +.IX Item "-mmachine" +Enable the instruction set extensions supported by a particular machine +model, and disable all other extensions. +.PP +The following options are available when as is configured for +a picoJava processor. +.IP "\fB\-mb\fR" 4 +.IX Item "-mb" +Generate \*(L"big endian\*(R" format output. +.IP "\fB\-ml\fR" 4 +.IX Item "-ml" +Generate \*(L"little endian\*(R" format output. +.PP +The following options are available when as is configured for the +Motorola 68HC11 or 68HC12 series. +.IP "\fB\-m68hc11 | \-m68hc12 | \-m68hcs12\fR" 4 +.IX Item "-m68hc11 | -m68hc12 | -m68hcs12" +Specify what processor is the target. The default is +defined by the configuration option when building the assembler. +.IP "\fB\-mshort\fR" 4 +.IX Item "-mshort" +Specify to use the 16\-bit integer \s-1ABI\s0. +.IP "\fB\-mlong\fR" 4 +.IX Item "-mlong" +Specify to use the 32\-bit integer \s-1ABI\s0. +.IP "\fB\-mshort\-double\fR" 4 +.IX Item "-mshort-double" +Specify to use the 32\-bit double \s-1ABI\s0. +.IP "\fB\-mlong\-double\fR" 4 +.IX Item "-mlong-double" +Specify to use the 64\-bit double \s-1ABI\s0. +.IP "\fB\-\-force\-long\-branches\fR" 4 +.IX Item "--force-long-branches" +Relative branches are turned into absolute ones. This concerns +conditional branches, unconditional branches and branches to a +sub routine. +.IP "\fB\-S | \-\-short\-branches\fR" 4 +.IX Item "-S | --short-branches" +Do not turn relative branches into absolute ones +when the offset is out of range. +.IP "\fB\-\-strict\-direct\-mode\fR" 4 +.IX Item "--strict-direct-mode" +Do not turn the direct addressing mode into extended addressing mode +when the instruction does not support direct addressing mode. +.IP "\fB\-\-print\-insn\-syntax\fR" 4 +.IX Item "--print-insn-syntax" +Print the syntax of instruction in case of error. +.IP "\fB\-\-print\-opcodes\fR" 4 +.IX Item "--print-opcodes" +print the list of instructions with syntax and then exit. +.IP "\fB\-\-generate\-example\fR" 4 +.IX Item "--generate-example" +print an example of instruction for each possible instruction and then exit. +This option is only useful for testing \fBas\fR. +.PP +The following options are available when \fBas\fR is configured +for the \s-1SPARC\s0 architecture: +.IP "\fB\-Av6 | \-Av7 | \-Av8 | \-Asparclet | \-Asparclite\fR" 4 +.IX Item "-Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite" +.PD 0 +.IP "\fB\-Av8plus | \-Av8plusa | \-Av9 | \-Av9a\fR" 4 +.IX Item "-Av8plus | -Av8plusa | -Av9 | -Av9a" +.PD +Explicitly select a variant of the \s-1SPARC\s0 architecture. +.Sp +\&\fB\-Av8plus\fR and \fB\-Av8plusa\fR select a 32 bit environment. +\&\fB\-Av9\fR and \fB\-Av9a\fR select a 64 bit environment. +.Sp +\&\fB\-Av8plusa\fR and \fB\-Av9a\fR enable the \s-1SPARC\s0 V9 instruction set with +UltraSPARC extensions. +.IP "\fB\-xarch=v8plus | \-xarch=v8plusa\fR" 4 +.IX Item "-xarch=v8plus | -xarch=v8plusa" +For compatibility with the Solaris v9 assembler. These options are +equivalent to \-Av8plus and \-Av8plusa, respectively. +.IP "\fB\-bump\fR" 4 +.IX Item "-bump" +Warn when the assembler switches to another architecture. +.PP +The following options are available when as is configured for the 'c54x +architecture. +.IP "\fB\-mfar\-mode\fR" 4 +.IX Item "-mfar-mode" +Enable extended addressing mode. All addresses and relocations will assume +extended addressing (usually 23 bits). +.IP "\fB\-mcpu=\fR\fI\s-1CPU_VERSION\s0\fR" 4 +.IX Item "-mcpu=CPU_VERSION" +Sets the \s-1CPU\s0 version being compiled for. +.IP "\fB\-merrors\-to\-file\fR \fI\s-1FILENAME\s0\fR" 4 +.IX Item "-merrors-to-file FILENAME" +Redirect error output to a file, for broken systems which don't support such +behaviour in the shell. +.PP +The following options are available when as is configured for +a \s-1MIPS\s0 processor. +.IP "\fB\-G\fR \fInum\fR" 4 +.IX Item "-G num" +This option sets the largest size of an object that can be referenced +implicitly with the \f(CW\*(C`gp\*(C'\fR register. It is only accepted for targets that +use \s-1ECOFF\s0 format, such as a DECstation running Ultrix. The default value is 8. +.IP "\fB\-EB\fR" 4 +.IX Item "-EB" +Generate \*(L"big endian\*(R" format output. +.IP "\fB\-EL\fR" 4 +.IX Item "-EL" +Generate \*(L"little endian\*(R" format output. +.IP "\fB\-mips1\fR" 4 +.IX Item "-mips1" +.PD 0 +.IP "\fB\-mips2\fR" 4 +.IX Item "-mips2" +.IP "\fB\-mips3\fR" 4 +.IX Item "-mips3" +.IP "\fB\-mips4\fR" 4 +.IX Item "-mips4" +.IP "\fB\-mips5\fR" 4 +.IX Item "-mips5" +.IP "\fB\-mips32\fR" 4 +.IX Item "-mips32" +.IP "\fB\-mips32r2\fR" 4 +.IX Item "-mips32r2" +.IP "\fB\-mips64\fR" 4 +.IX Item "-mips64" +.IP "\fB\-mips64r2\fR" 4 +.IX Item "-mips64r2" +.PD +Generate code for a particular \s-1MIPS\s0 Instruction Set Architecture level. +\&\fB\-mips1\fR is an alias for \fB\-march=r3000\fR, \fB\-mips2\fR is an +alias for \fB\-march=r6000\fR, \fB\-mips3\fR is an alias for +\&\fB\-march=r4000\fR and \fB\-mips4\fR is an alias for \fB\-march=r8000\fR. +\&\fB\-mips5\fR, \fB\-mips32\fR, \fB\-mips32r2\fR, \fB\-mips64\fR, and +\&\fB\-mips64r2\fR +correspond to generic +\&\fB\s-1MIPS\s0 V\fR, \fB\s-1MIPS32\s0\fR, \fB\s-1MIPS32\s0 Release 2\fR, \fB\s-1MIPS64\s0\fR, +and \fB\s-1MIPS64\s0 Release 2\fR +\&\s-1ISA\s0 processors, respectively. +.IP "\fB\-march=\fR\fI\s-1CPU\s0\fR" 4 +.IX Item "-march=CPU" +Generate code for a particular \s-1MIPS\s0 cpu. +.IP "\fB\-mtune=\fR\fIcpu\fR" 4 +.IX Item "-mtune=cpu" +Schedule and tune for a particular \s-1MIPS\s0 cpu. +.IP "\fB\-mfix7000\fR" 4 +.IX Item "-mfix7000" +.PD 0 +.IP "\fB\-mno\-fix7000\fR" 4 +.IX Item "-mno-fix7000" +.PD +Cause nops to be inserted if the read of the destination register +of an mfhi or mflo instruction occurs in the following two instructions. +.IP "\fB\-mdebug\fR" 4 +.IX Item "-mdebug" +.PD 0 +.IP "\fB\-no\-mdebug\fR" 4 +.IX Item "-no-mdebug" +.PD +Cause stabs-style debugging output to go into an ECOFF-style .mdebug +section instead of the standard \s-1ELF\s0 .stabs sections. +.IP "\fB\-mpdr\fR" 4 +.IX Item "-mpdr" +.PD 0 +.IP "\fB\-mno\-pdr\fR" 4 +.IX Item "-mno-pdr" +.PD +Control generation of \f(CW\*(C`.pdr\*(C'\fR sections. +.IP "\fB\-mgp32\fR" 4 +.IX Item "-mgp32" +.PD 0 +.IP "\fB\-mfp32\fR" 4 +.IX Item "-mfp32" +.PD +The register sizes are normally inferred from the \s-1ISA\s0 and \s-1ABI\s0, but these +flags force a certain group of registers to be treated as 32 bits wide at +all times. \fB\-mgp32\fR controls the size of general-purpose registers +and \fB\-mfp32\fR controls the size of floating-point registers. +.IP "\fB\-mips16\fR" 4 +.IX Item "-mips16" +.PD 0 +.IP "\fB\-no\-mips16\fR" 4 +.IX Item "-no-mips16" +.PD +Generate code for the \s-1MIPS\s0 16 processor. This is equivalent to putting +\&\f(CW\*(C`.set mips16\*(C'\fR at the start of the assembly file. \fB\-no\-mips16\fR +turns off this option. +.IP "\fB\-msmartmips\fR" 4 +.IX Item "-msmartmips" +.PD 0 +.IP "\fB\-mno\-smartmips\fR" 4 +.IX Item "-mno-smartmips" +.PD +Enables the SmartMIPS extension to the \s-1MIPS32\s0 instruction set. This is +equivalent to putting \f(CW\*(C`.set smartmips\*(C'\fR at the start of the assembly file. +\&\fB\-mno\-smartmips\fR turns off this option. +.IP "\fB\-mips3d\fR" 4 +.IX Item "-mips3d" +.PD 0 +.IP "\fB\-no\-mips3d\fR" 4 +.IX Item "-no-mips3d" +.PD +Generate code for the \s-1MIPS\-3D\s0 Application Specific Extension. +This tells the assembler to accept \s-1MIPS\-3D\s0 instructions. +\&\fB\-no\-mips3d\fR turns off this option. +.IP "\fB\-mdmx\fR" 4 +.IX Item "-mdmx" +.PD 0 +.IP "\fB\-no\-mdmx\fR" 4 +.IX Item "-no-mdmx" +.PD +Generate code for the \s-1MDMX\s0 Application Specific Extension. +This tells the assembler to accept \s-1MDMX\s0 instructions. +\&\fB\-no\-mdmx\fR turns off this option. +.IP "\fB\-mdsp\fR" 4 +.IX Item "-mdsp" +.PD 0 +.IP "\fB\-mno\-dsp\fR" 4 +.IX Item "-mno-dsp" +.PD +Generate code for the \s-1DSP\s0 Release 1 Application Specific Extension. +This tells the assembler to accept \s-1DSP\s0 Release 1 instructions. +\&\fB\-mno\-dsp\fR turns off this option. +.IP "\fB\-mdspr2\fR" 4 +.IX Item "-mdspr2" +.PD 0 +.IP "\fB\-mno\-dspr2\fR" 4 +.IX Item "-mno-dspr2" +.PD +Generate code for the \s-1DSP\s0 Release 2 Application Specific Extension. +This option implies \-mdsp. +This tells the assembler to accept \s-1DSP\s0 Release 2 instructions. +\&\fB\-mno\-dspr2\fR turns off this option. +.IP "\fB\-mmt\fR" 4 +.IX Item "-mmt" +.PD 0 +.IP "\fB\-mno\-mt\fR" 4 +.IX Item "-mno-mt" +.PD +Generate code for the \s-1MT\s0 Application Specific Extension. +This tells the assembler to accept \s-1MT\s0 instructions. +\&\fB\-mno\-mt\fR turns off this option. +.IP "\fB\-\-construct\-floats\fR" 4 +.IX Item "--construct-floats" +.PD 0 +.IP "\fB\-\-no\-construct\-floats\fR" 4 +.IX Item "--no-construct-floats" +.PD +The \fB\-\-no\-construct\-floats\fR option disables the construction of +double width floating point constants by loading the two halves of the +value into the two single width floating point registers that make up +the double width register. By default \fB\-\-construct\-floats\fR is +selected, allowing construction of these floating point constants. +.IP "\fB\-\-emulation=\fR\fIname\fR" 4 +.IX Item "--emulation=name" +This option causes \fBas\fR to emulate \fBas\fR configured +for some other target, in all respects, including output format (choosing +between \s-1ELF\s0 and \s-1ECOFF\s0 only), handling of pseudo-opcodes which may generate +debugging information or store symbol table information, and default +endianness. The available configuration names are: \fBmipsecoff\fR, +\&\fBmipself\fR, \fBmipslecoff\fR, \fBmipsbecoff\fR, \fBmipslelf\fR, +\&\fBmipsbelf\fR. The first two do not alter the default endianness from that +of the primary target for which the assembler was configured; the others change +the default to little\- or big-endian as indicated by the \fBb\fR or \fBl\fR +in the name. Using \fB\-EB\fR or \fB\-EL\fR will override the endianness +selection in any case. +.Sp +This option is currently supported only when the primary target +\&\fBas\fR is configured for is a \s-1MIPS\s0 \s-1ELF\s0 or \s-1ECOFF\s0 target. +Furthermore, the primary target or others specified with +\&\fB\-\-enable\-targets=...\fR at configuration time must include support for +the other format, if both are to be available. For example, the Irix 5 +configuration includes support for both. +.Sp +Eventually, this option will support more configurations, with more +fine-grained control over the assembler's behavior, and will be supported for +more processors. +.IP "\fB\-nocpp\fR" 4 +.IX Item "-nocpp" +\&\fBas\fR ignores this option. It is accepted for compatibility with +the native tools. +.IP "\fB\-\-trap\fR" 4 +.IX Item "--trap" +.PD 0 +.IP "\fB\-\-no\-trap\fR" 4 +.IX Item "--no-trap" +.IP "\fB\-\-break\fR" 4 +.IX Item "--break" +.IP "\fB\-\-no\-break\fR" 4 +.IX Item "--no-break" +.PD +Control how to deal with multiplication overflow and division by zero. +\&\fB\-\-trap\fR or \fB\-\-no\-break\fR (which are synonyms) take a trap exception +(and only work for Instruction Set Architecture level 2 and higher); +\&\fB\-\-break\fR or \fB\-\-no\-trap\fR (also synonyms, and the default) take a +break exception. +.IP "\fB\-n\fR" 4 +.IX Item "-n" +When this option is used, \fBas\fR will issue a warning every +time it generates a nop instruction from a macro. +.PP +The following options are available when as is configured for +an MCore processor. +.IP "\fB\-jsri2bsr\fR" 4 +.IX Item "-jsri2bsr" +.PD 0 +.IP "\fB\-nojsri2bsr\fR" 4 +.IX Item "-nojsri2bsr" +.PD +Enable or disable the \s-1JSRI\s0 to \s-1BSR\s0 transformation. By default this is enabled. +The command line option \fB\-nojsri2bsr\fR can be used to disable it. +.IP "\fB\-sifilter\fR" 4 +.IX Item "-sifilter" +.PD 0 +.IP "\fB\-nosifilter\fR" 4 +.IX Item "-nosifilter" +.PD +Enable or disable the silicon filter behaviour. By default this is disabled. +The default can be overridden by the \fB\-sifilter\fR command line option. +.IP "\fB\-relax\fR" 4 +.IX Item "-relax" +Alter jump instructions for long displacements. +.IP "\fB\-mcpu=[210|340]\fR" 4 +.IX Item "-mcpu=[210|340]" +Select the cpu type on the target hardware. This controls which instructions +can be assembled. +.IP "\fB\-EB\fR" 4 +.IX Item "-EB" +Assemble for a big endian target. +.IP "\fB\-EL\fR" 4 +.IX Item "-EL" +Assemble for a little endian target. +.PP +See the info pages for documentation of the MMIX-specific options. +.PP +The following options are available when as is configured for +an Xtensa processor. +.IP "\fB\-\-text\-section\-literals | \-\-no\-text\-section\-literals\fR" 4 +.IX Item "--text-section-literals | --no-text-section-literals" +With \fB\-\-text\-section\-literals\fR, literal pools are interspersed +in the text section. The default is +\&\fB\-\-no\-text\-section\-literals\fR, which places literals in a +separate section in the output file. These options only affect literals +referenced via PC-relative \f(CW\*(C`L32R\*(C'\fR instructions; literals for +absolute mode \f(CW\*(C`L32R\*(C'\fR instructions are handled separately. +.IP "\fB\-\-absolute\-literals | \-\-no\-absolute\-literals\fR" 4 +.IX Item "--absolute-literals | --no-absolute-literals" +Indicate to the assembler whether \f(CW\*(C`L32R\*(C'\fR instructions use absolute +or PC-relative addressing. The default is to assume absolute addressing +if the Xtensa processor includes the absolute \f(CW\*(C`L32R\*(C'\fR addressing +option. Otherwise, only the PC-relative \f(CW\*(C`L32R\*(C'\fR mode can be used. +.IP "\fB\-\-target\-align | \-\-no\-target\-align\fR" 4 +.IX Item "--target-align | --no-target-align" +Enable or disable automatic alignment to reduce branch penalties at the +expense of some code density. The default is \fB\-\-target\-align\fR. +.IP "\fB\-\-longcalls | \-\-no\-longcalls\fR" 4 +.IX Item "--longcalls | --no-longcalls" +Enable or disable transformation of call instructions to allow calls +across a greater range of addresses. The default is +\&\fB\-\-no\-longcalls\fR. +.IP "\fB\-\-transform | \-\-no\-transform\fR" 4 +.IX Item "--transform | --no-transform" +Enable or disable all assembler transformations of Xtensa instructions. +The default is \fB\-\-transform\fR; +\&\fB\-\-no\-transform\fR should be used only in the rare cases when the +instructions must be exactly as specified in the assembly source. +.PP +The following options are available when as is configured for +a Z80 family processor. +.IP "\fB\-z80\fR" 4 +.IX Item "-z80" +Assemble for Z80 processor. +.IP "\fB\-r800\fR" 4 +.IX Item "-r800" +Assemble for R800 processor. +.IP "\fB\-ignore\-undocumented\-instructions\fR" 4 +.IX Item "-ignore-undocumented-instructions" +.PD 0 +.IP "\fB\-Wnud\fR" 4 +.IX Item "-Wnud" +.PD +Assemble undocumented Z80 instructions that also work on R800 without warning. +.IP "\fB\-ignore\-unportable\-instructions\fR" 4 +.IX Item "-ignore-unportable-instructions" +.PD 0 +.IP "\fB\-Wnup\fR" 4 +.IX Item "-Wnup" +.PD +Assemble all undocumented Z80 instructions without warning. +.IP "\fB\-warn\-undocumented\-instructions\fR" 4 +.IX Item "-warn-undocumented-instructions" +.PD 0 +.IP "\fB\-Wud\fR" 4 +.IX Item "-Wud" +.PD +Issue a warning for undocumented Z80 instructions that also work on R800. +.IP "\fB\-warn\-unportable\-instructions\fR" 4 +.IX Item "-warn-unportable-instructions" +.PD 0 +.IP "\fB\-Wup\fR" 4 +.IX Item "-Wup" +.PD +Issue a warning for undocumented Z80 instructions that do not work on R800. +.IP "\fB\-forbid\-undocumented\-instructions\fR" 4 +.IX Item "-forbid-undocumented-instructions" +.PD 0 +.IP "\fB\-Fud\fR" 4 +.IX Item "-Fud" +.PD +Treat all undocumented instructions as errors. +.IP "\fB\-forbid\-unportable\-instructions\fR" 4 +.IX Item "-forbid-unportable-instructions" +.PD 0 +.IP "\fB\-Fup\fR" 4 +.IX Item "-Fup" +.PD +Treat undocumented Z80 instructions that do not work on R800 as errors. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIgcc\fR\|(1), \fIld\fR\|(1), and the Info entries for \fIbinutils\fR and \fIld\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, 2002, +2006, 2007 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 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 included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/gnu/usr.bin/binutils/as/config.h b/gnu/usr.bin/binutils/as/config.h new file mode 100644 index 000000000000..84cd51590e58 --- /dev/null +++ b/gnu/usr.bin/binutils/as/config.h @@ -0,0 +1,254 @@ +/* $FreeBSD$ */ + +/* config.h. Generated by configure. */ +/* config.in. Generated from configure.in by autoheader. */ + +/* Define if using AIX 5.2 value for C_WEAKEXT. */ +/* #undef AIX_WEAK_SUPPORT */ + +/* assert broken? */ +/* #undef BROKEN_ASSERT */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +/* #undef CRAY_STACKSEG_END */ + +/* Compiling cross-assembler? */ +/* #undef CROSS_COMPILE */ + +/* Define to 1 if using `alloca.c'. */ +/* #undef C_ALLOCA */ + +/* Default architecture. */ +/* #define DEFAULT_ARCH "i386" */ + +/* Default CRIS architecture. */ +/* #undef DEFAULT_CRIS_ARCH */ + +/* Default emulation. */ +/* #define DEFAULT_EMULATION "i386elf" */ + +/* Supported emulations. */ +/* #define EMULATIONS &i386elf, */ + +/* Define if you want run-time sanity checks. */ +/* #undef ENABLE_CHECKING */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +/* #undef ENABLE_NLS */ + +/* Define to 1 if you have `alloca', as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). + */ +/* #undef HAVE_ALLOCA_H */ + +/* Is the prototype for getopt in <unistd.h> in the expected format? */ +#define HAVE_DECL_GETOPT 1 + +/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you + don't. */ +#define HAVE_DECL_VSNPRINTF 1 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the <errno.h> header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `remove' function. */ +/* #undef HAVE_REMOVE */ + +/* Define to 1 if you have the `sbrk' function. */ +/* #undef HAVE_SBRK */ + +/* Define to 1 if you have the <stdarg.h> header file. */ +#define HAVE_STDARG_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlink' function. */ +#define HAVE_UNLINK 1 + +/* Define to 1 if you have the <varargs.h> header file. */ +/* #undef HAVE_VARARGS_H */ + +/* Using i386 COFF? */ +/* #undef I386COFF */ + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Using m68k COFF? */ +/* #undef M68KCOFF */ + +/* Using m88k COFF? */ +/* #undef M88KCOFF */ + +/* Default CPU for MIPS targets. */ +/* #undef MIPS_CPU_STRING_DEFAULT */ + +/* Generate 64-bit code by default on MIPS targets. */ +/* #undef MIPS_DEFAULT_64BIT */ + +/* Choose a default ABI for MIPS targets. */ +/* #undef MIPS_DEFAULT_ABI */ + +/* Define if environ is not declared in system header files. */ +#define NEED_DECLARATION_ENVIRON 1 + +/* Define if errno is not declared in system header files. */ +/* #undef NEED_DECLARATION_ERRNO */ + +/* Define if ffs is not declared in system header files. */ +/* #undef NEED_DECLARATION_FFS */ + +/* Define if free is not declared in system header files. */ +/* #undef NEED_DECLARATION_FREE */ + +/* Define if malloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_MALLOC */ + +/* Define if sbrk is not declared in system header files. */ +/* #undef NEED_DECLARATION_SBRK */ + +/* Define if strstr is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRSTR */ + +/* a.out support? */ +/* #undef OBJ_MAYBE_AOUT */ + +/* b.out support? */ +/* #undef OBJ_MAYBE_BOUT */ + +/* COFF support? */ +/* #undef OBJ_MAYBE_COFF */ + +/* ECOFF support? */ +/* #undef OBJ_MAYBE_ECOFF */ + +/* ELF support? */ +/* #undef OBJ_MAYBE_ELF */ + +/* generic support? */ +/* #undef OBJ_MAYBE_GENERIC */ + +/* SOM support? */ +/* #undef OBJ_MAYBE_SOM */ + +/* Name of package */ +#define PACKAGE "gas" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* Define if defaulting to ELF on SCO 5. */ +/* #undef SCO_ELF */ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +/* #undef STACK_DIRECTION */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Using strict COFF? */ +/* #undef STRICTCOFF */ + +/* Target alias. */ +/* #define TARGET_ALIAS "i386-unknown-freebsd9.0" */ + +/* Define as 1 if big endian. */ +/* #undef TARGET_BYTES_BIG_ENDIAN */ + +/* Canonical target. */ +/* #define TARGET_CANONICAL "i386-unknown-freebsd9.0" */ + +/* Target CPU. */ +/* #define TARGET_CPU "i386" */ + +/* Target OS. */ +/* #define TARGET_OS "freebsd9.0" */ + +/* Define if default target is PowerPC Solaris. */ +/* #undef TARGET_SOLARIS_COMMENT */ + +/* Define if target is Symbian OS. */ +/* #undef TARGET_SYMBIAN */ + +/* Target vendor. */ +/* #define TARGET_VENDOR "unknown" */ + +/* Use b modifier when opening binary files? */ +/* #undef USE_BINARY_FOPEN */ + +/* Use emulation support? */ +/* #undef USE_EMULATIONS */ + +/* Allow use of E_MIPS_ABI_O32 on MIPS targets. */ +/* #undef USE_E_MIPS_ABI_O32 */ + +/* Using cgen code? */ +/* #undef USING_CGEN */ + +/* Version number of package */ +/* #define VERSION "2.17.50" */ + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#define YYTEXT_POINTER 1 + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif diff --git a/gnu/usr.bin/binutils/as/i386-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/i386-freebsd/targ-cpu.h new file mode 100644 index 000000000000..f4be0e50bd8e --- /dev/null +++ b/gnu/usr.bin/binutils/as/i386-freebsd/targ-cpu.h @@ -0,0 +1 @@ +#include "tc-i386.h" diff --git a/gnu/usr.bin/binutils/as/mips-freebsd/itbl-cpu.h b/gnu/usr.bin/binutils/as/mips-freebsd/itbl-cpu.h new file mode 100644 index 000000000000..5e007d18e35c --- /dev/null +++ b/gnu/usr.bin/binutils/as/mips-freebsd/itbl-cpu.h @@ -0,0 +1,22 @@ +/* $FreeBSD$ */ + +#include "itbl-mips.h" + +/* Choose a default ABI for MIPS targets. */ +#ifndef MIPS_DEFAULT_ABI +#define MIPS_DEFAULT_ABI NO_ABI +#endif + +/* Default CPU for MIPS targets. */ +#define MIPS_CPU_STRING_DEFAULT "from-abi" + +/* Generate 64-bit code by default on MIPS targets. */ +#ifndef MIPS_DEFAULT_64BIT +#define MIPS_DEFAULT_64BIT 0 +#endif + +/* Allow use of E_MIPS_ABI_O32 on MIPS targets. */ +#define USE_E_MIPS_ABI_O32 1 + +/* Use traditional mips */ +#define TE_TMIPS 1 diff --git a/gnu/usr.bin/binutils/as/mips-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/mips-freebsd/targ-cpu.h new file mode 100644 index 000000000000..72fa131944e9 --- /dev/null +++ b/gnu/usr.bin/binutils/as/mips-freebsd/targ-cpu.h @@ -0,0 +1,4 @@ +/* $FreeBSD$ */ +#define TE_TMIPS 1 + +#include "tc-mips.h" diff --git a/gnu/usr.bin/binutils/as/obj-format.h b/gnu/usr.bin/binutils/as/obj-format.h new file mode 100644 index 000000000000..02a3030e1ad3 --- /dev/null +++ b/gnu/usr.bin/binutils/as/obj-format.h @@ -0,0 +1,3 @@ +/* $FreeBSD$ */ + +#include "obj-elf.h" diff --git a/gnu/usr.bin/binutils/as/powerpc-freebsd/itbl-cpu.h b/gnu/usr.bin/binutils/as/powerpc-freebsd/itbl-cpu.h new file mode 100644 index 000000000000..b55da9afd1aa --- /dev/null +++ b/gnu/usr.bin/binutils/as/powerpc-freebsd/itbl-cpu.h @@ -0,0 +1,6 @@ +/* $FreeBSD$ */ + +/* Values for processors will be from 0 to NUMBER_OF_PROCESSORS-1 */ +#define NUMBER_OF_PROCESSORS 1 + +#include "itbl-ppc.h" diff --git a/gnu/usr.bin/binutils/as/powerpc-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/powerpc-freebsd/targ-cpu.h new file mode 100644 index 000000000000..891bd6cabaf1 --- /dev/null +++ b/gnu/usr.bin/binutils/as/powerpc-freebsd/targ-cpu.h @@ -0,0 +1,3 @@ +/* $FreeBSD$ */ + +#include "tc-ppc.h" diff --git a/gnu/usr.bin/binutils/as/sparc64-freebsd/targ-cpu.h b/gnu/usr.bin/binutils/as/sparc64-freebsd/targ-cpu.h new file mode 100644 index 000000000000..46e43130fc11 --- /dev/null +++ b/gnu/usr.bin/binutils/as/sparc64-freebsd/targ-cpu.h @@ -0,0 +1,3 @@ +/* $FreeBSD$ */ + +#include "tc-sparc.h" diff --git a/gnu/usr.bin/binutils/as/targ-env.h b/gnu/usr.bin/binutils/as/targ-env.h new file mode 100644 index 000000000000..8e14d63ff12d --- /dev/null +++ b/gnu/usr.bin/binutils/as/targ-env.h @@ -0,0 +1,3 @@ +/* $FreeBSD$ */ + +#include "te-freebsd.h" diff --git a/gnu/usr.bin/binutils/doc/Makefile b/gnu/usr.bin/binutils/doc/Makefile new file mode 100644 index 000000000000..ba17ab997ae3 --- /dev/null +++ b/gnu/usr.bin/binutils/doc/Makefile @@ -0,0 +1,11 @@ +# $FreeBSD$ + +.include "../Makefile.inc0" + +.PATH: ${SRCDIR}/gas/doc \ + ${SRCDIR}/ld \ + ${SRCDIR}/binutils/doc + +MAN= ld.7 ldint.7 as.7 binutils.7 + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/binutils/doc/Makefile.depend b/gnu/usr.bin/binutils/doc/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ b/gnu/usr.bin/binutils/doc/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/ld/Makefile b/gnu/usr.bin/binutils/ld/Makefile new file mode 100644 index 000000000000..5ac308b3dd2c --- /dev/null +++ b/gnu/usr.bin/binutils/ld/Makefile @@ -0,0 +1,86 @@ +# $FreeBSD$ + +ELF_SCR_EXT= x xbn xc xd xdc xdw xn xr xs xsc xsw xu xw +.include "../Makefile.inc0" +.include <src.opts.mk> + +.PATH: ${SRCDIR}/ld + +PROG= ld.bfd +.if (!defined(TOOLS_PREFIX) && ${MK_LLD_IS_LD} == "no") || \ + (defined(TOOLS_PREFIX) && ${MK_LLD_BOOTSTRAP} == "no") +MAN= ld.1 +LINKS= ${BINDIR}/ld.bfd ${BINDIR}/ld +.else +MAN= ld.bfd.1 +CLEANFILES+= ld.bfd.1 +ld.bfd.1: ld.1 + ${CP} ${.ALLSRC} ${.TARGET} +.endif + +SCRIPTDIR= /usr/libdata/ldscripts +SRCS+= ldcref.c \ + ldctor.c \ + ldemul-list.h \ + ldemul.c \ + ldexp.c \ + ldfile.c \ + ldgram.y \ + ldlang.c \ + ldlex.l \ + ldmain.c \ + ldmisc.c \ + ldver.c \ + ldwrite.c \ + lexsup.c \ + mri.c + +CFLAGS+= -DTARGET=\"${TARGET_TUPLE}\" +CFLAGS+= -DDEFAULT_EMULATION=\"${NATIVE_EMULATION}\" +CFLAGS+= -DSCRIPTDIR=\"${TOOLS_PREFIX}/usr/libdata\" +CFLAGS+= -DBFD_VERSION_STRING=\"${VERSION}\" +CFLAGS+= -DBINDIR=\"${BINDIR}\" +.if defined(TOOLS_PREFIX) +CFLAGS+= -DTARGET_SYSTEM_ROOT=\"${TOOLS_PREFIX}\" +.else +CFLAGS+= -DTARGET_SYSTEM_ROOT=\"/\" +.endif +CFLAGS+= -DTOOLBINDIR=\"${TOOLS_PREFIX}/${BINDIR}/libexec\" +CFLAGS+= -D_GNU_SOURCE +CFLAGS+= -I${SRCDIR}/ld -I${SRCDIR}/bfd +.if ${MK_SHARED_TOOLCHAIN} == "no" +NO_SHARED?= yes +.endif +DPADD= ${GNURELTOP}/libbfd/libbfd.a +DPADD+= ${GNURELTOP}/libiberty/libiberty.a +LDADD= ${DPADD} +CLEANDIRS+= ldscripts +CLEANFILES+= ldemul-list.h stringify.sed + +FILES= ${LDSCRIPTS:S|^|ldscripts/|} +FILESDIR= ${SCRIPTDIR} + +HOST= ${TARGET_TUPLE} +LIBSEARCHPATH= \"=/lib\":\"=/usr/lib\" +.for ext in ${ELF_SCR_EXT} +LDSCRIPTS+= ${NATIVE_EMULATION}.${ext} +ldscripts/${NATIVE_EMULATION}.${ext}: e${NATIVE_EMULATION}.c +.endfor + +EMXFR= +EMLST= +.for _e in ${NATIVE_EMULATION} ${EMS} +EMXFR+= extern ld_emulation_xfer_type ld_${_e}_emulation; +EMLST+= &ld_${_e}_emulation, +.endfor + +ldemul-list.h: + echo "${EMXFR}" > ${.TARGET} + echo "#define EMULATION_LIST ${EMLST} 0" >> ${.TARGET} + +stringify.sed: ${SRCDIR}/ld/emultempl/astring.sed .NOMETA + ln -sf ${.ALLSRC} ${.TARGET} + +GENDIRDEPS_FILTER.host+= Nusr.bin/yacc + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/binutils/ld/Makefile.amd64 b/gnu/usr.bin/binutils/ld/Makefile.amd64 new file mode 100644 index 000000000000..c9919bff2987 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/Makefile.amd64 @@ -0,0 +1,29 @@ +# $FreeBSD$ + +NATIVE_EMULATION= elf_x86_64_fbsd + +SRCS+= e${NATIVE_EMULATION}.c +CLEANFILES+= e${NATIVE_EMULATION}.c +e${NATIVE_EMULATION}.c: emulparams/${NATIVE_EMULATION}.sh emultempl/elf32.em \ + scripttempl/elf.sc genscripts.sh stringify.sed + sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ + ${TOOLS_PREFIX}/usr \ + ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ + ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} + +X86_EMULATION= elf_i386_fbsd +_i386_path= \"${TOOLS_PREFIX}/usr/lib32\" +EMS+= ${X86_EMULATION} +.for ext in ${ELF_SCR_EXT} +LDSCRIPTS+= ${X86_EMULATION}.${ext} +ldscripts/${X86_EMULATION}.${ext}: e${X86_EMULATION}.c +.endfor + +SRCS+= e${X86_EMULATION}.c +CLEANFILES+= e${X86_EMULATION}.c +e${X86_EMULATION}.c: emulparams/${X86_EMULATION}.sh emultempl/elf32.em \ + scripttempl/elf.sc genscripts.sh stringify.sed + sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${_i386_path} \ + ${TOOLS_PREFIX}/usr \ + ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ + ${X86_EMULATION} "" no ${X86_EMULATION} ${TARGET_TUPLE} diff --git a/gnu/usr.bin/binutils/ld/Makefile.arm b/gnu/usr.bin/binutils/ld/Makefile.arm new file mode 100644 index 000000000000..9fe573cad219 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/Makefile.arm @@ -0,0 +1,17 @@ +# $FreeBSD$ + +.if ${TARGET_ARCH:Marm*eb} != "" +NATIVE_EMULATION= armelfb_fbsd +.else +NATIVE_EMULATION= armelf_fbsd +.endif + +SRCS+= e${NATIVE_EMULATION}.c +CLEANFILES+= e${NATIVE_EMULATION}.c +e${NATIVE_EMULATION}.c: ${.CURDIR}/${NATIVE_EMULATION}.sh emultempl/elf32.em \ + scripttempl/elf.sc genscripts.sh stringify.sed + sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ + ${TOOLS_PREFIX}/usr \ + ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ + ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} \ + ${.CURDIR}/${NATIVE_EMULATION}.sh diff --git a/gnu/usr.bin/binutils/ld/Makefile.depend b/gnu/usr.bin/binutils/ld/Makefile.depend new file mode 100644 index 000000000000..ace486b47b12 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/usr.bin/binutils/libbfd \ + gnu/usr.bin/binutils/libiberty \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + usr.bin/yacc.host \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/ld/Makefile.depend.host b/gnu/usr.bin/binutils/ld/Makefile.depend.host new file mode 100644 index 000000000000..fea8e8e26bf2 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/Makefile.depend.host @@ -0,0 +1,14 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/usr.bin/binutils/libbfd \ + gnu/usr.bin/binutils/libiberty \ + usr.bin/yacc \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/ld/Makefile.i386 b/gnu/usr.bin/binutils/ld/Makefile.i386 new file mode 100644 index 000000000000..216bfa8a4fd7 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/Makefile.i386 @@ -0,0 +1,12 @@ +# $FreeBSD$ + +NATIVE_EMULATION= elf_i386_fbsd + +SRCS+= e${NATIVE_EMULATION}.c +CLEANFILES+= e${NATIVE_EMULATION}.c +e${NATIVE_EMULATION}.c: emulparams/${NATIVE_EMULATION}.sh emultempl/elf32.em \ + scripttempl/elf.sc genscripts.sh stringify.sed + sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ + ${TOOLS_PREFIX}/usr \ + ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ + ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} diff --git a/gnu/usr.bin/binutils/ld/Makefile.mips b/gnu/usr.bin/binutils/ld/Makefile.mips new file mode 100644 index 000000000000..7ed3a56059f2 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/Makefile.mips @@ -0,0 +1,38 @@ +# $FreeBSD$ + +.if ${TARGET_ARCH:Mmips*el*} != "" +_EMULATION_ENDIAN=l +.else +_EMULATION_ENDIAN=b +.endif + +.if ${TARGET_ARCH:Mmips64*} != "" +NATIVE_EMULATION=elf64${_EMULATION_ENDIAN}tsmip_fbsd +LIBSEARCHPATH.elf32${_EMULATION_ENDIAN}tsmip_fbsd=\"=/usr/lib32\" +.elif ${TARGET_ARCH:Mmipsn32*} != "" +NATIVE_EMULATION=elf32${_EMULATION_ENDIAN}tsmipn32_fbsd +.else +NATIVE_EMULATION?=elf32${_EMULATION_ENDIAN}tsmip_fbsd +.endif + +MIPS_ABIS=elf32btsmip_fbsd elf32ltsmip_fbsd elf64btsmip_fbsd elf64ltsmip_fbsd \ + elf32btsmipn32_fbsd elf32ltsmipn32_fbsd +.for abi in ${MIPS_ABIS} +#.if (${abi} != ${NATIVE_EMULATION}) +EMS+= ${abi} +#.endif +.for ext in ${ELF_SCR_EXT} +LDSCRIPTS+= ${abi}.${ext} +ldscripts/${abi}.${ext}: e${abi}.c +.endfor +SRCS+= e${abi}.c +CLEANFILES+= e${abi}.c +# nb: elf32 handles both elf32 and elf64 targets +e${abi}.c: ${.CURDIR}/${abi}.sh emultempl/elf32.em \ + scripttempl/elf.sc genscripts.sh stringify.sed + sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ + ${TOOLS_PREFIX}/usr \ + ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ + ${abi} "" no ${abi} ${TARGET_TUPLE} \ + ${.CURDIR}/${abi}.sh +.endfor diff --git a/gnu/usr.bin/binutils/ld/Makefile.powerpc b/gnu/usr.bin/binutils/ld/Makefile.powerpc new file mode 100644 index 000000000000..fed52341c089 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/Makefile.powerpc @@ -0,0 +1,12 @@ +# $FreeBSD$ + +NATIVE_EMULATION= elf32ppc_fbsd + +SRCS+= e${NATIVE_EMULATION}.c +CLEANFILES+= e${NATIVE_EMULATION}.c +e${NATIVE_EMULATION}.c: emulparams/${NATIVE_EMULATION}.sh emultempl/elf32.em \ + scripttempl/elf.sc genscripts.sh stringify.sed ldemul-list.h + sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ + ${TOOLS_PREFIX}/usr \ + ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ + ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} diff --git a/gnu/usr.bin/binutils/ld/Makefile.powerpc64 b/gnu/usr.bin/binutils/ld/Makefile.powerpc64 new file mode 100644 index 000000000000..9e18cb4a60a8 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/Makefile.powerpc64 @@ -0,0 +1,30 @@ +# $FreeBSD$ + +NATIVE_EMULATION= elf64ppc_fbsd + +SRCS+= e${NATIVE_EMULATION}.c +CLEANFILES+= e${NATIVE_EMULATION}.c +e${NATIVE_EMULATION}.c: emulparams/${NATIVE_EMULATION}.sh emultempl/elf32.em \ + scripttempl/elf.sc genscripts.sh stringify.sed ldemul-list.h + sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ + ${TOOLS_PREFIX}/usr \ + ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ + ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} + +PPC32_EMULATION= elf32ppc_fbsd +_ppc32_path= \"${TOOLS_PREFIX}/usr/lib32\" +EMS+= ${PPC32_EMULATION} +.for ext in ${ELF_SCR_EXT} +LDSCRIPTS+= ${PPC32_EMULATION}.${ext} +ldscripts/${PPC32_EMULATION}.${ext}: e${PPC32_EMULATION}.c +.endfor + +SRCS+= e${PPC32_EMULATION}.c +CLEANFILES+= e${PPC32_EMULATION}.c +e${PPC32_EMULATION}.c: emulparams/${PPC32_EMULATION}.sh emultempl/elf32.em \ + scripttempl/elf.sc genscripts.sh stringify.sed ldemul-list.h + sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${_ppc32_path} \ + ${TOOLS_PREFIX}/usr \ + ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ + ${PPC32_EMULATION} "" no ${PPC32_EMULATION} ${TARGET_TUPLE} + diff --git a/gnu/usr.bin/binutils/ld/Makefile.sparc64 b/gnu/usr.bin/binutils/ld/Makefile.sparc64 new file mode 100644 index 000000000000..9ce6c6ff6585 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/Makefile.sparc64 @@ -0,0 +1,32 @@ +# $FreeBSD$ + +NATIVE_EMULATION= elf64_sparc_fbsd + +SRCS+= e${NATIVE_EMULATION}.c +CLEANFILES+= e${NATIVE_EMULATION}.c +e${NATIVE_EMULATION}.c: emulparams/${NATIVE_EMULATION}.sh emultempl/elf32.em \ + scripttempl/elf.sc genscripts.sh stringify.sed + sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ + ${TOOLS_PREFIX}/usr \ + ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ + ${NATIVE_EMULATION} "" no ${NATIVE_EMULATION} ${TARGET_TUPLE} + + +.for BITS in 64 32 + +EMS+= elf${BITS}_sparc +.for ext in ${ELF_SCR_EXT} +LDSCRIPTS+= elf${BITS}_sparc.${ext} +ldscripts/elf${BITS}_sparc.${ext}: eelf${BITS}_sparc.c +.endfor + +SRCS+= eelf${BITS}_sparc.c +CLEANFILES+= eelf${BITS}_sparc.c +eelf${BITS}_sparc.c: emulparams/elf${BITS}_sparc.sh emultempl/elf32.em \ + scripttempl/elf.sc genscripts.sh stringify.sed + sh ${.CURDIR}/genscripts.sh ${SRCDIR}/ld ${LIBSEARCHPATH} \ + ${TOOLS_PREFIX}/usr \ + ${HOST} ${TARGET_TUPLE} ${TARGET_TUPLE} \ + elf${BITS}_sparc "" no elf${BITS}_sparc ${TARGET_TUPLE} + +.endfor # BITS diff --git a/gnu/usr.bin/binutils/ld/armelf_fbsd.sh b/gnu/usr.bin/binutils/ld/armelf_fbsd.sh new file mode 100644 index 000000000000..0f888b0805b8 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/armelf_fbsd.sh @@ -0,0 +1,9 @@ +# $FreeBSD$ +. ${srcdir}/emulparams/armelf.sh +. ${srcdir}/emulparams/elf_fbsd.sh +TARGET2_TYPE=got-rel +MAXPAGESIZE=0x8000 +GENERATE_PIE_SCRIPT=yes + +unset STACK_ADDR +unset EMBEDDED diff --git a/gnu/usr.bin/binutils/ld/armelfb_fbsd.sh b/gnu/usr.bin/binutils/ld/armelfb_fbsd.sh new file mode 100644 index 000000000000..39364efe31a2 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/armelfb_fbsd.sh @@ -0,0 +1,14 @@ +# $FreeBSD$ +#XXX: This should be used once those bits are merged back in the FSF repo. +#. ${srcdir}/emulparams/armelf_fbsd.sh +# +#OUTPUT_FORMAT="elf32-bigarm" +. ${srcdir}/emulparams/armelf.sh +. ${srcdir}/emulparams/elf_fbsd.sh +TARGET2_TYPE=got-rel +MAXPAGESIZE=0x8000 +GENERATE_PIE_SCRIPT=yes + +unset STACK_ADDR +unset EMBEDDED +OUTPUT_FORMAT="elf32-bigarm" diff --git a/gnu/usr.bin/binutils/ld/config.h b/gnu/usr.bin/binutils/ld/config.h new file mode 100644 index 000000000000..ac9a78d729de --- /dev/null +++ b/gnu/usr.bin/binutils/ld/config.h @@ -0,0 +1,141 @@ +/* $FreeBSD$ */ + +/* config.h. Generated by configure. */ +/* config.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +/* #undef ENABLE_NLS */ + +/* Additional extension a shared object might have. */ +/* #undef EXTRA_SHLIB_EXTENSION */ + +/* Define to 1 if you have the declaration of `environ', and to 0 if you + don't. */ +#define HAVE_DECL_ENVIRON 0 + +/* Define to 1 if you have the declaration of `free', and to 0 if you don't. + */ +#define HAVE_DECL_FREE 1 + +/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. + */ +#define HAVE_DECL_GETENV 1 + +/* Is the prototype for getopt in <unistd.h> in the expected format? */ +#define HAVE_DECL_GETOPT 1 + +/* Define to 1 if you have the declaration of `sbrk', and to 0 if you don't. + */ +#define HAVE_DECL_SBRK 1 + +/* Define to 1 if you have the declaration of `strstr', and to 0 if you don't. + */ +#define HAVE_DECL_STRSTR 1 + +/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the <elf-hints.h> header file. */ +#define HAVE_ELF_HINTS_H 1 + +/* Define to 1 if you have the `glob' function. */ +#define HAVE_GLOB 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `sbrk' function. */ +/* #undef HAVE_SBRK */ + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "ld" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* The size of a `long', as computed by sizeof. */ +/* #undef SIZEOF_LONG */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Use b modifier when opening binary files? */ +/* #undef USE_BINARY_FOPEN */ + +/* Version number of package */ +/* #define VERSION "2.17.50" */ + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#define YYTEXT_POINTER 1 diff --git a/gnu/usr.bin/binutils/ld/elf32btsmip_fbsd.sh b/gnu/usr.bin/binutils/ld/elf32btsmip_fbsd.sh new file mode 100755 index 000000000000..ef5afbcdf4a6 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/elf32btsmip_fbsd.sh @@ -0,0 +1,4 @@ +# $FreeBSD$ +. ${srcdir}/emulparams/elf32btsmip.sh +. ${srcdir}/emulparams/elf_fbsd.sh +GENERATE_PIE_SCRIPT=yes diff --git a/gnu/usr.bin/binutils/ld/elf32btsmipn32_fbsd.sh b/gnu/usr.bin/binutils/ld/elf32btsmipn32_fbsd.sh new file mode 100755 index 000000000000..2e33346efd98 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/elf32btsmipn32_fbsd.sh @@ -0,0 +1,5 @@ +# $FreeBSD$ +. ${srcdir}/emulparams/elf32btsmipn32.sh +. ${srcdir}/emulparams/elf_fbsd.sh +GENERATE_PIE_SCRIPT=yes +ALIGNMENT=8 diff --git a/gnu/usr.bin/binutils/ld/elf32ltsmip_fbsd.sh b/gnu/usr.bin/binutils/ld/elf32ltsmip_fbsd.sh new file mode 100755 index 000000000000..89c13d8bd056 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/elf32ltsmip_fbsd.sh @@ -0,0 +1,4 @@ +# $FreeBSD$ +. ${srcdir}/emulparams/elf32ltsmip.sh +. ${srcdir}/emulparams/elf_fbsd.sh +GENERATE_PIE_SCRIPT=yes diff --git a/gnu/usr.bin/binutils/ld/elf32ltsmipn32_fbsd.sh b/gnu/usr.bin/binutils/ld/elf32ltsmipn32_fbsd.sh new file mode 100755 index 000000000000..50242102329a --- /dev/null +++ b/gnu/usr.bin/binutils/ld/elf32ltsmipn32_fbsd.sh @@ -0,0 +1,5 @@ +# $FreeBSD$ +. ${srcdir}/emulparams/elf32ltsmipn32.sh +. ${srcdir}/emulparams/elf_fbsd.sh +GENERATE_PIE_SCRIPT=yes +ALIGNMENT=8 diff --git a/gnu/usr.bin/binutils/ld/elf64btsmip_fbsd.sh b/gnu/usr.bin/binutils/ld/elf64btsmip_fbsd.sh new file mode 100755 index 000000000000..e6ca55abf117 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/elf64btsmip_fbsd.sh @@ -0,0 +1,4 @@ +# $FreeBSD$ +. ${srcdir}/emulparams/elf64btsmip.sh +. ${srcdir}/emulparams/elf_fbsd.sh +GENERATE_PIE_SCRIPT=yes diff --git a/gnu/usr.bin/binutils/ld/elf64ltsmip_fbsd.sh b/gnu/usr.bin/binutils/ld/elf64ltsmip_fbsd.sh new file mode 100755 index 000000000000..932600164a25 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/elf64ltsmip_fbsd.sh @@ -0,0 +1,4 @@ +# $FreeBSD$ +. ${srcdir}/emulparams/elf64ltsmip.sh +. ${srcdir}/emulparams/elf_fbsd.sh +GENERATE_PIE_SCRIPT=yes diff --git a/gnu/usr.bin/binutils/ld/genscripts.sh b/gnu/usr.bin/binutils/ld/genscripts.sh new file mode 100755 index 000000000000..238263eb75a1 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/genscripts.sh @@ -0,0 +1,240 @@ +#!/bin/sh +# genscripts.sh - generate the ld-emulation-target specific files +# +# Usage: genscripts.sh srcdir libdir host target target_alias \ +# default_emulation native_lib_dirs this_emulation +# +# Sample usage: +# genscripts.sh /djm/ld-devo/devo/ld /usr/local/lib sparc-sun-sunos4.1.3 \ +# sparc-sun-sunos4.1.3 sparc-sun-sunos4.1.3 sun4 "" sun3 sparc-sun-sunos4.1.3 +# produces sun3.x sun3.xbn sun3.xn sun3.xr sun3.xu em_sun3.c +# +# $FreeBSD$ +# +# This is a cut-down version of the GNU script. Instead of jumping through +# hoops for all possible combinations of paths, just use the libdir +# argument in place of LIB_PATH. +# +# The exec_prefix, target_alias, use_sysroot, NATIVE_LIB_DIRS, TOOL_LIB, CUSTOMIZER_SCRIPT +# arguments are not used in this version. +# + +srcdir=$1 +libdir=$2 +exec_prefix=$3 +host=$4 +target=$5 +target_alias=$6 +EMULATION_LIBPATH=$7 +NATIVE_LIB_DIRS=$8 +use_sysroot=$9 +shift 9 +EMULATION_NAME=$1 +TOOL_LIB=$2 +CUSTOMIZER_SCRIPT=$3 + +# Create the 'CUSTOMIZER_SCRIPT' knob to better sync this script with +# FSF BU ver 2.15 which allows for a more generic emulparams processing. +# To reduce the diff, I also include the ${EMULATION_NAME} parameter in uses +# of 'CUSTOMIZER_SCRIPT'. + +# XXX: arm hack : until those file are merged back into the FSF repo, just +# use the version in this directory. +if !(test -f ${CUSTOMIZER_SCRIPT}"";) then +CUSTOMIZER_SCRIPT="${srcdir}/emulparams/${EMULATION_NAME}.sh" +fi + +# Include the emulation-specific parameters: +. ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + +if test -d ldscripts; then + true +else + mkdir -p ldscripts +fi + +# Set some flags for the emultempl scripts. USE_LIBPATH will +# be set for any libpath-using emulation; NATIVE will be set for a +# emulation to enable 'LD_LIBRARY_PATH=/foo:/bar ld -lfooz' + if [ "x${host}" = "x${target}" ] ; then + NATIVE=yes + fi + USE_LIBPATH=yes + +# Set the library search path, for libraries named by -lfoo. +# If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used. +# Otherwise, the default is set here. +# +# The format is the usual list of colon-separated directories. +# To force a logically empty LIB_PATH, do LIBPATH=":". + +LIB_SEARCH_DIRS=`echo ${libdir} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'` + +# Generate 5 or 6 script files from a master script template in +# ${srcdir}/scripttempl/${SCRIPT_NAME}.sh. Which one of the 5 or 6 +# script files is actually used depends on command line options given +# to ld. (SCRIPT_NAME was set in the emulparams_file.) +# +# A .x script file is the default script. +# A .xr script is for linking without relocation (-r flag). +# A .xu script is like .xr, but *do* create constructors (-Ur flag). +# A .xn script is for linking with -n flag (mix text and data on same page). +# A .xbn script is for linking with -N flag (mix text and data on same page). +# A .xs script is for generating a shared library with the --shared +# flag; it is only generated if $GENERATE_SHLIB_SCRIPT is set by the +# emulation parameters. +# A .xc script is for linking with -z combreloc; it is only generated if +# $GENERATE_COMBRELOC_SCRIPT is set by the emulation parameters or +# $SCRIPT_NAME is "elf". +# A .xsc script is for linking with --shared -z combreloc; it is generated +# if $GENERATE_COMBRELOC_SCRIPT is set by the emulation parameters or +# $SCRIPT_NAME is "elf" and $GENERATE_SHLIB_SCRIPT is set by the emulation +# parameters too. + +if [ "x$SCRIPT_NAME" = "xelf" ]; then + GENERATE_COMBRELOC_SCRIPT=yes +fi + +SEGMENT_SIZE=${SEGMENT_SIZE-${MAXPAGESIZE-${TARGET_PAGE_SIZE}}} + +# Determine DATA_ALIGNMENT for the 5 variants, using +# values specified in the emulparams/<script_to_run>.sh file or default. + +DATA_ALIGNMENT_="${DATA_ALIGNMENT_-${DATA_ALIGNMENT-ALIGN(${SEGMENT_SIZE})}}" +DATA_ALIGNMENT_n="${DATA_ALIGNMENT_n-${DATA_ALIGNMENT_}}" +DATA_ALIGNMENT_N="${DATA_ALIGNMENT_N-${DATA_ALIGNMENT-.}}" +DATA_ALIGNMENT_r="${DATA_ALIGNMENT_r-${DATA_ALIGNMENT-}}" +DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}" + +LD_FLAG=r +DATA_ALIGNMENT=${DATA_ALIGNMENT_r} +DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})" +( echo "/* Script for ld -r: link without relocation */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc +) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xr + +LD_FLAG=u +DATA_ALIGNMENT=${DATA_ALIGNMENT_u} +CONSTRUCTING=" " +( echo "/* Script for ld -Ur: link w/out relocation, do create constructors */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc +) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xu + +LD_FLAG= +DATA_ALIGNMENT=${DATA_ALIGNMENT_} +RELOCATING=" " +( echo "/* Default linker script, for normal executables */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc +) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.x + +LD_FLAG=n +DATA_ALIGNMENT=${DATA_ALIGNMENT_n} +TEXT_START_ADDR=${NONPAGED_TEXT_START_ADDR-${TEXT_START_ADDR}} +( echo "/* Script for -n: mix text and data on same page */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc +) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xn + +LD_FLAG=N +DATA_ALIGNMENT=${DATA_ALIGNMENT_N} +( echo "/* Script for -N: mix text and data on same page; don't align data */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc +) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xbn + +if test -n "$GENERATE_COMBRELOC_SCRIPT"; then + DATA_ALIGNMENT=${DATA_ALIGNMENT_c-${DATA_ALIGNMENT_}} + LD_FLAG=c + COMBRELOC=ldscripts/${EMULATION_NAME}.xc.tmp + ( echo "/* Script for -z combreloc: combine and sort reloc sections */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xc + rm -f ${COMBRELOC} + LD_FLAG=w + RELRO_NOW=" " + COMBRELOC=ldscripts/${EMULATION_NAME}.xw.tmp + ( echo "/* Script for -z combreloc -z now -z relro: combine and sort reloc sections */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xw + rm -f ${COMBRELOC} + COMBRELOC= + unset RELRO_NOW +fi + +if test -n "$GENERATE_SHLIB_SCRIPT"; then + LD_FLAG=shared + DATA_ALIGNMENT=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}} + CREATE_SHLIB=" " + # Note that TEXT_START_ADDR is set to NONPAGED_TEXT_START_ADDR. + ( + echo "/* Script for ld --shared: link shared library */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xs + if test -n "$GENERATE_COMBRELOC_SCRIPT"; then + LD_FLAG=cshared + DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}} + COMBRELOC=ldscripts/${EMULATION_NAME}.xsc.tmp + ( echo "/* Script for --shared -z combreloc: shared library, combine & sort relocs */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsc + rm -f ${COMBRELOC} + LD_FLAG=wshared + RELRO_NOW=" " + COMBRELOC=ldscripts/${EMULATION_NAME}.xsw.tmp + ( echo "/* Script for --shared -z combreloc -z now -z relro: shared library, combine & sort relocs */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsw + rm -f ${COMBRELOC} + COMBRELOC= + unset RELRO_NOW + fi + unset CREATE_SHLIB +fi + +if test -n "$GENERATE_PIE_SCRIPT"; then + LD_FLAG=pie + DATA_ALIGNMENT=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}} + CREATE_PIE=" " + # Note that TEXT_START_ADDR is set to NONPAGED_TEXT_START_ADDR. + ( + echo "/* Script for ld -pie: link position independent executable */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xd + if test -n "$GENERATE_COMBRELOC_SCRIPT"; then + LD_FLAG=cpie + DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}} + COMBRELOC=ldscripts/${EMULATION_NAME}.xdc.tmp + ( echo "/* Script for -pie -z combreloc: position independent executable, combine & sort relocs */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdc + rm -f ${COMBRELOC} + LD_FLAG=wpie + RELRO_NOW=" " + COMBRELOC=ldscripts/${EMULATION_NAME}.xdw.tmp + ( echo "/* Script for -pie -z combreloc -z now -z relro: position independent executable, combine & sort relocs */" + . ${CUSTOMIZER_SCRIPT} ${EMULATION_NAME} + . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc + ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xdw + rm -f ${COMBRELOC} + COMBRELOC= + unset RELRO_NOW + fi + unset CREATE_PIE +fi + +case " $EMULATION_LIBPATH " in + *" ${EMULATION_NAME} "*) COMPILE_IN=true;; +esac + +# Generate e${EMULATION_NAME}.c. +. ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em diff --git a/gnu/usr.bin/binutils/ld/ld.1 b/gnu/usr.bin/binutils/ld/ld.1 new file mode 100644 index 000000000000..04594173b39b --- /dev/null +++ b/gnu/usr.bin/binutils/ld/ld.1 @@ -0,0 +1,2155 @@ +.\" $FreeBSD$ +.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.ie \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.el \{\ +. de IX +.. +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "LD 1" +.TH LD 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +ld \- The GNU linker +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +ld [\fBoptions\fR] \fIobjfile\fR ... +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBld\fR combines a number of object and archive files, relocates +their data and ties up symbol references. Usually the last step in +compiling a program is to run \fBld\fR. +.PP +\&\fBld\fR accepts Linker Command Language files written in +a superset of \s-1AT&T\s0's Link Editor Command Language syntax, +to provide explicit and total control over the linking process. +.PP +This man page does not describe the command language; see the +\&\fBld\fR entry in \f(CW\*(C`info\*(C'\fR for full details on the command +language and on other aspects of the \s-1GNU\s0 linker. +.PP +This version of \fBld\fR uses the general purpose \s-1BFD\s0 libraries +to operate on object files. This allows \fBld\fR to read, combine, and +write object files in many different formats\-\-\-for example, \s-1COFF\s0 or +\&\f(CW\*(C`a.out\*(C'\fR. Different formats may be linked together to produce any +available kind of object file. +.PP +Aside from its flexibility, the \s-1GNU\s0 linker is more helpful than other +linkers in providing diagnostic information. Many linkers abandon +execution immediately upon encountering an error; whenever possible, +\&\fBld\fR continues executing, allowing you to identify other errors +(or, in some cases, to get an output file in spite of the error). +.PP +The \s-1GNU\s0 linker \fBld\fR is meant to cover a broad range of situations, +and to be as compatible as possible with other linkers. As a result, +you have many choices to control its behavior. +.SH "OPTIONS" +.IX Header "OPTIONS" +The linker supports a plethora of command-line options, but in actual +practice few of them are used in any particular context. +For instance, a frequent use of \fBld\fR is to link standard Unix +object files on a standard, supported Unix system. On such a system, to +link a file \f(CW\*(C`hello.o\*(C'\fR: +.PP +.Vb 1 +\& ld \-o <output> /lib/crt0.o hello.o \-lc +.Ve +.PP +This tells \fBld\fR to produce a file called \fIoutput\fR as the +result of linking the file \f(CW\*(C`/lib/crt0.o\*(C'\fR with \f(CW\*(C`hello.o\*(C'\fR and +the library \f(CW\*(C`libc.a\*(C'\fR, which will come from the standard search +directories. (See the discussion of the \fB\-l\fR option below.) +.PP +Some of the command-line options to \fBld\fR may be specified at any +point in the command line. However, options which refer to files, such +as \fB\-l\fR or \fB\-T\fR, cause the file to be read at the point at +which the option appears in the command line, relative to the object +files and other file options. Repeating non-file options with a +different argument will either have no further effect, or override prior +occurrences (those further to the left on the command line) of that +option. Options which may be meaningfully specified more than once are +noted in the descriptions below. +.PP +Non-option arguments are object files or archives which are to be linked +together. They may follow, precede, or be mixed in with command-line +options, except that an object file argument may not be placed between +an option and its argument. +.PP +Usually the linker is invoked with at least one object file, but you can +specify other forms of binary input files using \fB\-l\fR, \fB\-R\fR, +and the script command language. If \fIno\fR binary input files at all +are specified, the linker does not produce any output, and issues the +message \fBNo input files\fR. +.PP +If the linker cannot recognize the format of an object file, it will +assume that it is a linker script. A script specified in this way +augments the main linker script used for the link (either the default +linker script or the one specified by using \fB\-T\fR). This feature +permits the linker to link against a file which appears to be an object +or an archive, but actually merely defines some symbol values, or uses +\&\f(CW\*(C`INPUT\*(C'\fR or \f(CW\*(C`GROUP\*(C'\fR to load other objects. Note that +specifying a script in this way merely augments the main linker script; +use the \fB\-T\fR option to replace the default linker script entirely. +.PP +For options whose names are a single letter, +option arguments must either follow the option letter without intervening +whitespace, or be given as separate arguments immediately following the +option that requires them. +.PP +For options whose names are multiple letters, either one dash or two can +precede the option name; for example, \fB\-trace\-symbol\fR and +\&\fB\-\-trace\-symbol\fR are equivalent. Note\-\-\-there is one exception to +this rule. Multiple letter options that start with a lower case 'o' can +only be preceded by two dashes. This is to reduce confusion with the +\&\fB\-o\fR option. So for example \fB\-omagic\fR sets the output file +name to \fBmagic\fR whereas \fB\-\-omagic\fR sets the \s-1NMAGIC\s0 flag on the +output. +.PP +Arguments to multiple-letter options must either be separated from the +option name by an equals sign, or be given as separate arguments +immediately following the option that requires them. For example, +\&\fB\-\-trace\-symbol foo\fR and \fB\-\-trace\-symbol=foo\fR are equivalent. +Unique abbreviations of the names of multiple-letter options are +accepted. +.PP +Note\-\-\-if the linker is being invoked indirectly, via a compiler driver +(e.g. \fBgcc\fR) then all the linker command line options should be +prefixed by \fB\-Wl,\fR (or whatever is appropriate for the particular +compiler driver) like this: +.PP +.Vb 1 +\& gcc \-Wl,\-\-startgroup foo.o bar.o \-Wl,\-\-endgroup +.Ve +.PP +This is important, because otherwise the compiler driver program may +silently drop the linker options, resulting in a bad link. +.PP +Here is a table of the generic command line switches accepted by the \s-1GNU\s0 +linker: +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.IP "\fB\-a\fR\fIkeyword\fR" 4 +.IX Item "-akeyword" +This option is supported for \s-1HP/UX\s0 compatibility. The \fIkeyword\fR +argument must be one of the strings \fBarchive\fR, \fBshared\fR, or +\&\fBdefault\fR. \fB\-aarchive\fR is functionally equivalent to +\&\fB\-Bstatic\fR, and the other two keywords are functionally equivalent +to \fB\-Bdynamic\fR. This option may be used any number of times. +.IP "\fB\-A\fR\fIarchitecture\fR" 4 +.IX Item "-Aarchitecture" +.PD 0 +.IP "\fB\-\-architecture=\fR\fIarchitecture\fR" 4 +.IX Item "--architecture=architecture" +.PD +In the current release of \fBld\fR, this option is useful only for the +Intel 960 family of architectures. In that \fBld\fR configuration, the +\&\fIarchitecture\fR argument identifies the particular architecture in +the 960 family, enabling some safeguards and modifying the +archive-library search path. +.Sp +Future releases of \fBld\fR may support similar functionality for +other architecture families. +.IP "\fB\-b\fR \fIinput-format\fR" 4 +.IX Item "-b input-format" +.PD 0 +.IP "\fB\-\-format=\fR\fIinput-format\fR" 4 +.IX Item "--format=input-format" +.PD +\&\fBld\fR may be configured to support more than one kind of object +file. If your \fBld\fR is configured this way, you can use the +\&\fB\-b\fR option to specify the binary format for input object files +that follow this option on the command line. Even when \fBld\fR is +configured to support alternative object formats, you don't usually need +to specify this, as \fBld\fR should be configured to expect as a +default input format the most usual format on each machine. +\&\fIinput-format\fR is a text string, the name of a particular format +supported by the \s-1BFD\s0 libraries. (You can list the available binary +formats with \fBobjdump \-i\fR.) +.Sp +You may want to use this option if you are linking files with an unusual +binary format. You can also use \fB\-b\fR to switch formats explicitly (when +linking object files of different formats), by including +\&\fB\-b\fR \fIinput-format\fR before each group of object files in a +particular format. +.Sp +The default format is taken from the environment variable +\&\f(CW\*(C`GNUTARGET\*(C'\fR. +.Sp +You can also define the input format from a script, using the command +\&\f(CW\*(C`TARGET\*(C'\fR; +.IP "\fB\-c\fR \fIMRI-commandfile\fR" 4 +.IX Item "-c MRI-commandfile" +.PD 0 +.IP "\fB\-\-mri\-script=\fR\fIMRI-commandfile\fR" 4 +.IX Item "--mri-script=MRI-commandfile" +.PD +For compatibility with linkers produced by \s-1MRI\s0, \fBld\fR accepts script +files written in an alternate, restricted command language, described in +the \s-1MRI\s0 Compatible Script Files section of \s-1GNU\s0 ld documentation. +Introduce \s-1MRI\s0 script files with +the option \fB\-c\fR; use the \fB\-T\fR option to run linker +scripts written in the general-purpose \fBld\fR scripting language. +If \fIMRI-cmdfile\fR does not exist, \fBld\fR looks for it in the directories +specified by any \fB\-L\fR options. +.IP "\fB\-d\fR" 4 +.IX Item "-d" +.PD 0 +.IP "\fB\-dc\fR" 4 +.IX Item "-dc" +.IP "\fB\-dp\fR" 4 +.IX Item "-dp" +.PD +These three options are equivalent; multiple forms are supported for +compatibility with other linkers. They assign space to common symbols +even if a relocatable output file is specified (with \fB\-r\fR). The +script command \f(CW\*(C`FORCE_COMMON_ALLOCATION\*(C'\fR has the same effect. +.IP "\fB\-e\fR \fIentry\fR" 4 +.IX Item "-e entry" +.PD 0 +.IP "\fB\-\-entry=\fR\fIentry\fR" 4 +.IX Item "--entry=entry" +.PD +Use \fIentry\fR as the explicit symbol for beginning execution of your +program, rather than the default entry point. If there is no symbol +named \fIentry\fR, the linker will try to parse \fIentry\fR as a number, +and use that as the entry address (the number will be interpreted in +base 10; you may use a leading \fB0x\fR for base 16, or a leading +\&\fB0\fR for base 8). +.IP "\fB\-\-exclude\-libs\fR \fIlib\fR\fB,\fR\fIlib\fR\fB,...\fR" 4 +.IX Item "--exclude-libs lib,lib,..." +Specifies a list of archive libraries from which symbols should not be automatically +exported. The library names may be delimited by commas or colons. Specifying +\&\f(CW\*(C`\-\-exclude\-libs ALL\*(C'\fR excludes symbols in all archive libraries from +automatic export. This option is available only for the i386 \s-1PE\s0 targeted +port of the linker and for \s-1ELF\s0 targeted ports. For i386 \s-1PE\s0, symbols +explicitly listed in a .def file are still exported, regardless of this +option. For \s-1ELF\s0 targeted ports, symbols affected by this option will +be treated as hidden. +.IP "\fB\-E\fR" 4 +.IX Item "-E" +.PD 0 +.IP "\fB\-\-export\-dynamic\fR" 4 +.IX Item "--export-dynamic" +.PD +When creating a dynamically linked executable, add all symbols to the +dynamic symbol table. The dynamic symbol table is the set of symbols +which are visible from dynamic objects at run time. +.Sp +If you do not use this option, the dynamic symbol table will normally +contain only those symbols which are referenced by some dynamic object +mentioned in the link. +.Sp +If you use \f(CW\*(C`dlopen\*(C'\fR to load a dynamic object which needs to refer +back to the symbols defined by the program, rather than some other +dynamic object, then you will probably need to use this option when +linking the program itself. +.Sp +You can also use the dynamic list to control what symbols should +be added to the dynamic symbol table if the output format supports it. +See the description of \fB\-\-dynamic\-list\fR. +.IP "\fB\-EB\fR" 4 +.IX Item "-EB" +Link big-endian objects. This affects the default output format. +.IP "\fB\-EL\fR" 4 +.IX Item "-EL" +Link little-endian objects. This affects the default output format. +.IP "\fB\-f\fR" 4 +.IX Item "-f" +.PD 0 +.IP "\fB\-\-auxiliary\fR \fIname\fR" 4 +.IX Item "--auxiliary name" +.PD +When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_AUXILIARY\s0 field +to the specified name. This tells the dynamic linker that the symbol +table of the shared object should be used as an auxiliary filter on the +symbol table of the shared object \fIname\fR. +.Sp +If you later link a program against this filter object, then, when you +run the program, the dynamic linker will see the \s-1DT_AUXILIARY\s0 field. If +the dynamic linker resolves any symbols from the filter object, it will +first check whether there is a definition in the shared object +\&\fIname\fR. If there is one, it will be used instead of the definition +in the filter object. The shared object \fIname\fR need not exist. +Thus the shared object \fIname\fR may be used to provide an alternative +implementation of certain functions, perhaps for debugging or for +machine specific performance. +.Sp +This option may be specified more than once. The \s-1DT_AUXILIARY\s0 entries +will be created in the order in which they appear on the command line. +.IP "\fB\-F\fR \fIname\fR" 4 +.IX Item "-F name" +.PD 0 +.IP "\fB\-\-filter\fR \fIname\fR" 4 +.IX Item "--filter name" +.PD +When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_FILTER\s0 field to +the specified name. This tells the dynamic linker that the symbol table +of the shared object which is being created should be used as a filter +on the symbol table of the shared object \fIname\fR. +.Sp +If you later link a program against this filter object, then, when you +run the program, the dynamic linker will see the \s-1DT_FILTER\s0 field. The +dynamic linker will resolve symbols according to the symbol table of the +filter object as usual, but it will actually link to the definitions +found in the shared object \fIname\fR. Thus the filter object can be +used to select a subset of the symbols provided by the object +\&\fIname\fR. +.Sp +Some older linkers used the \fB\-F\fR option throughout a compilation +toolchain for specifying object-file format for both input and output +object files. +The \s-1GNU\s0 linker uses other mechanisms for this purpose: the +\&\fB\-b\fR, \fB\-\-format\fR, \fB\-\-oformat\fR options, the +\&\f(CW\*(C`TARGET\*(C'\fR command in linker scripts, and the \f(CW\*(C`GNUTARGET\*(C'\fR +environment variable. +The \s-1GNU\s0 linker will ignore the \fB\-F\fR option when not +creating an \s-1ELF\s0 shared object. +.IP "\fB\-fini\fR \fIname\fR" 4 +.IX Item "-fini name" +When creating an \s-1ELF\s0 executable or shared object, call \s-1NAME\s0 when the +executable or shared object is unloaded, by setting \s-1DT_FINI\s0 to the +address of the function. By default, the linker uses \f(CW\*(C`_fini\*(C'\fR as +the function to call. +.IP "\fB\-g\fR" 4 +.IX Item "-g" +Ignored. Provided for compatibility with other tools. +.IP "\fB\-G\fR\fIvalue\fR" 4 +.IX Item "-Gvalue" +.PD 0 +.IP "\fB\-\-gpsize=\fR\fIvalue\fR" 4 +.IX Item "--gpsize=value" +.PD +Set the maximum size of objects to be optimized using the \s-1GP\s0 register to +\&\fIsize\fR. This is only meaningful for object file formats such as +\&\s-1MIPS\s0 \s-1ECOFF\s0 which supports putting large and small objects into different +sections. This is ignored for other object file formats. +.IP "\fB\-h\fR\fIname\fR" 4 +.IX Item "-hname" +.PD 0 +.IP "\fB\-soname=\fR\fIname\fR" 4 +.IX Item "-soname=name" +.PD +When creating an \s-1ELF\s0 shared object, set the internal \s-1DT_SONAME\s0 field to +the specified name. When an executable is linked with a shared object +which has a \s-1DT_SONAME\s0 field, then when the executable is run the dynamic +linker will attempt to load the shared object specified by the \s-1DT_SONAME\s0 +field rather than the using the file name given to the linker. +.IP "\fB\-i\fR" 4 +.IX Item "-i" +Perform an incremental link (same as option \fB\-r\fR). +.IP "\fB\-init\fR \fIname\fR" 4 +.IX Item "-init name" +When creating an \s-1ELF\s0 executable or shared object, call \s-1NAME\s0 when the +executable or shared object is loaded, by setting \s-1DT_INIT\s0 to the address +of the function. By default, the linker uses \f(CW\*(C`_init\*(C'\fR as the +function to call. +.IP "\fB\-l\fR\fInamespec\fR" 4 +.IX Item "-lnamespec" +.PD 0 +.IP "\fB\-\-library=\fR\fInamespec\fR" 4 +.IX Item "--library=namespec" +.PD +Add the archive or object file specified by \fInamespec\fR to the +list of files to link. This option may be used any number of times. +If \fInamespec\fR is of the form \fI:\fIfilename\fI\fR, \fBld\fR +will search the library path for a file called \fIfilename\fR, otherise it +will search the library path for a file called \fIlib\fInamespec\fI.a\fR. +.Sp +On systems which support shared libraries, \fBld\fR may also search for +files other than \fIlib\fInamespec\fI.a\fR. Specifically, on \s-1ELF\s0 +and SunOS systems, \fBld\fR will search a directory for a library +called \fIlib\fInamespec\fI.so\fR before searching for one called +\&\fIlib\fInamespec\fI.a\fR. (By convention, a \f(CW\*(C`.so\*(C'\fR extension +indicates a shared library.) Note that this behavior does not apply +to \fI:\fIfilename\fI\fR, which always specifies a file called +\&\fIfilename\fR. +.Sp +The linker will search an archive only once, at the location where it is +specified on the command line. If the archive defines a symbol which +was undefined in some object which appeared before the archive on the +command line, the linker will include the appropriate file(s) from the +archive. However, an undefined symbol in an object appearing later on +the command line will not cause the linker to search the archive again. +.Sp +See the \fB\-(\fR option for a way to force the linker to search +archives multiple times. +.Sp +You may list the same archive multiple times on the command line. +.Sp +This type of archive searching is standard for Unix linkers. However, +if you are using \fBld\fR on \s-1AIX\s0, note that it is different from the +behaviour of the \s-1AIX\s0 linker. +.IP "\fB\-L\fR\fIsearchdir\fR" 4 +.IX Item "-Lsearchdir" +.PD 0 +.IP "\fB\-\-library\-path=\fR\fIsearchdir\fR" 4 +.IX Item "--library-path=searchdir" +.PD +Add path \fIsearchdir\fR to the list of paths that \fBld\fR will search +for archive libraries and \fBld\fR control scripts. You may use this +option any number of times. The directories are searched in the order +in which they are specified on the command line. Directories specified +on the command line are searched before the default directories. All +\&\fB\-L\fR options apply to all \fB\-l\fR options, regardless of the +order in which the options appear. +.Sp +If \fIsearchdir\fR begins with \f(CW\*(C`=\*(C'\fR, then the \f(CW\*(C`=\*(C'\fR will be replaced +by the \fIsysroot prefix\fR, a path specified when the linker is configured. +.Sp +The default set of paths searched (without being specified with +\&\fB\-L\fR) depends on which emulation mode \fBld\fR is using, and in +some cases also on how it was configured. +.Sp +The paths can also be specified in a link script with the +\&\f(CW\*(C`SEARCH_DIR\*(C'\fR command. Directories specified this way are searched +at the point in which the linker script appears in the command line. +.IP "\fB\-m\fR\fIemulation\fR" 4 +.IX Item "-memulation" +Emulate the \fIemulation\fR linker. You can list the available +emulations with the \fB\-\-verbose\fR or \fB\-V\fR options. +.Sp +If the \fB\-m\fR option is not used, the emulation is taken from the +\&\f(CW\*(C`LDEMULATION\*(C'\fR environment variable, if that is defined. +.Sp +Otherwise, the default emulation depends upon how the linker was +configured. +.IP "\fB\-M\fR" 4 +.IX Item "-M" +.PD 0 +.IP "\fB\-\-print\-map\fR" 4 +.IX Item "--print-map" +.PD +Print a link map to the standard output. A link map provides +information about the link, including the following: +.RS 4 +.IP "\(bu" 4 +Where object files are mapped into memory. +.IP "\(bu" 4 +How common symbols are allocated. +.IP "\(bu" 4 +All archive members included in the link, with a mention of the symbol +which caused the archive member to be brought in. +.IP "\(bu" 4 +The values assigned to symbols. +.Sp +Note \- symbols whose values are computed by an expression which +involves a reference to a previous value of the same symbol may not +have correct result displayed in the link map. This is because the +linker discards intermediate results and only retains the final value +of an expression. Under such circumstances the linker will display +the final value enclosed by square brackets. Thus for example a +linker script containing: +.Sp +.Vb 3 +\& foo = 1 +\& foo = foo * 4 +\& foo = foo + 8 +.Ve +.Sp +will produce the following output in the link map if the \fB\-M\fR +option is used: +.Sp +.Vb 3 +\& 0x00000001 foo = 0x1 +\& [0x0000000c] foo = (foo * 0x4) +\& [0x0000000c] foo = (foo + 0x8) +.Ve +.Sp +See \fBExpressions\fR for more information about expressions in linker +scripts. +.RE +.RS 4 +.RE +.IP "\fB\-n\fR" 4 +.IX Item "-n" +.PD 0 +.IP "\fB\-\-nmagic\fR" 4 +.IX Item "--nmagic" +.PD +Turn off page alignment of sections, and mark the output as +\&\f(CW\*(C`NMAGIC\*(C'\fR if possible. +.IP "\fB\-N\fR" 4 +.IX Item "-N" +.PD 0 +.IP "\fB\-\-omagic\fR" 4 +.IX Item "--omagic" +.PD +Set the text and data sections to be readable and writable. Also, do +not page-align the data segment, and disable linking against shared +libraries. If the output format supports Unix style magic numbers, +mark the output as \f(CW\*(C`OMAGIC\*(C'\fR. Note: Although a writable text section +is allowed for PE-COFF targets, it does not conform to the format +specification published by Microsoft. +.IP "\fB\-\-no\-omagic\fR" 4 +.IX Item "--no-omagic" +This option negates most of the effects of the \fB\-N\fR option. It +sets the text section to be read-only, and forces the data segment to +be page-aligned. Note \- this option does not enable linking against +shared libraries. Use \fB\-Bdynamic\fR for this. +.IP "\fB\-o\fR \fIoutput\fR" 4 +.IX Item "-o output" +.PD 0 +.IP "\fB\-\-output=\fR\fIoutput\fR" 4 +.IX Item "--output=output" +.PD +Use \fIoutput\fR as the name for the program produced by \fBld\fR; if this +option is not specified, the name \fIa.out\fR is used by default. The +script command \f(CW\*(C`OUTPUT\*(C'\fR can also specify the output file name. +.IP "\fB\-O\fR \fIlevel\fR" 4 +.IX Item "-O level" +If \fIlevel\fR is a numeric values greater than zero \fBld\fR optimizes +the output. This might take significantly longer and therefore probably +should only be enabled for the final binary. +.IP "\fB\-q\fR" 4 +.IX Item "-q" +.PD 0 +.IP "\fB\-\-emit\-relocs\fR" 4 +.IX Item "--emit-relocs" +.PD +Leave relocation sections and contents in fully linked executables. +Post link analysis and optimization tools may need this information in +order to perform correct modifications of executables. This results +in larger executables. +.Sp +This option is currently only supported on \s-1ELF\s0 platforms. +.IP "\fB\-\-force\-dynamic\fR" 4 +.IX Item "--force-dynamic" +Force the output file to have dynamic sections. This option is specific +to VxWorks targets. +.IP "\fB\-r\fR" 4 +.IX Item "-r" +.PD 0 +.IP "\fB\-\-relocatable\fR" 4 +.IX Item "--relocatable" +.PD +Generate relocatable output\-\-\-i.e., generate an output file that can in +turn serve as input to \fBld\fR. This is often called \fIpartial +linking\fR. As a side effect, in environments that support standard Unix +magic numbers, this option also sets the output file's magic number to +\&\f(CW\*(C`OMAGIC\*(C'\fR. +If this option is not specified, an absolute file is produced. When +linking \*(C+ programs, this option \fIwill not\fR resolve references to +constructors; to do that, use \fB\-Ur\fR. +.Sp +When an input file does not have the same format as the output file, +partial linking is only supported if that input file does not contain any +relocations. Different output formats can have further restrictions; for +example some \f(CW\*(C`a.out\*(C'\fR\-based formats do not support partial linking +with input files in other formats at all. +.Sp +This option does the same thing as \fB\-i\fR. +.IP "\fB\-R\fR \fIfilename\fR" 4 +.IX Item "-R filename" +.PD 0 +.IP "\fB\-\-just\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--just-symbols=filename" +.PD +Read symbol names and their addresses from \fIfilename\fR, but do not +relocate it or include it in the output. This allows your output file +to refer symbolically to absolute locations of memory defined in other +programs. You may use this option more than once. +.Sp +For compatibility with other \s-1ELF\s0 linkers, if the \fB\-R\fR option is +followed by a directory name, rather than a file name, it is treated as +the \fB\-rpath\fR option. +.IP "\fB\-s\fR" 4 +.IX Item "-s" +.PD 0 +.IP "\fB\-\-strip\-all\fR" 4 +.IX Item "--strip-all" +.PD +Omit all symbol information from the output file. +.IP "\fB\-S\fR" 4 +.IX Item "-S" +.PD 0 +.IP "\fB\-\-strip\-debug\fR" 4 +.IX Item "--strip-debug" +.PD +Omit debugger symbol information (but not all symbols) from the output file. +.IP "\fB\-t\fR" 4 +.IX Item "-t" +.PD 0 +.IP "\fB\-\-trace\fR" 4 +.IX Item "--trace" +.PD +Print the names of the input files as \fBld\fR processes them. +.IP "\fB\-T\fR \fIscriptfile\fR" 4 +.IX Item "-T scriptfile" +.PD 0 +.IP "\fB\-\-script=\fR\fIscriptfile\fR" 4 +.IX Item "--script=scriptfile" +.PD +Use \fIscriptfile\fR as the linker script. This script replaces +\&\fBld\fR's default linker script (rather than adding to it), so +\&\fIcommandfile\fR must specify everything necessary to describe the +output file. If \fIscriptfile\fR does not exist in +the current directory, \f(CW\*(C`ld\*(C'\fR looks for it in the directories +specified by any preceding \fB\-L\fR options. Multiple \fB\-T\fR +options accumulate. +.IP "\fB\-dT\fR \fIscriptfile\fR" 4 +.IX Item "-dT scriptfile" +.PD 0 +.IP "\fB\-\-default\-script=\fR\fIscriptfile\fR" 4 +.IX Item "--default-script=scriptfile" +.PD +Use \fIscriptfile\fR as the default linker script. +.Sp +This option is similar to the \fB\-\-script\fR option except that +processing of the script is delayed until after the rest of the +command line has been processed. This allows options placed after the +\&\fB\-\-default\-script\fR option on the command line to affect the +behaviour of the linker script, which can be important when the linker +command line cannot be directly controlled by the user. (eg because +the command line is being constructed by another tool, such as +\&\fBgcc\fR). +.IP "\fB\-u\fR \fIsymbol\fR" 4 +.IX Item "-u symbol" +.PD 0 +.IP "\fB\-\-undefined=\fR\fIsymbol\fR" 4 +.IX Item "--undefined=symbol" +.PD +Force \fIsymbol\fR to be entered in the output file as an undefined +symbol. Doing this may, for example, trigger linking of additional +modules from standard libraries. \fB\-u\fR may be repeated with +different option arguments to enter additional undefined symbols. This +option is equivalent to the \f(CW\*(C`EXTERN\*(C'\fR linker script command. +.IP "\fB\-Ur\fR" 4 +.IX Item "-Ur" +For anything other than \*(C+ programs, this option is equivalent to +\&\fB\-r\fR: it generates relocatable output\-\-\-i.e., an output file that can in +turn serve as input to \fBld\fR. When linking \*(C+ programs, \fB\-Ur\fR +\&\fIdoes\fR resolve references to constructors, unlike \fB\-r\fR. +It does not work to use \fB\-Ur\fR on files that were themselves linked +with \fB\-Ur\fR; once the constructor table has been built, it cannot +be added to. Use \fB\-Ur\fR only for the last partial link, and +\&\fB\-r\fR for the others. +.IP "\fB\-\-unique[=\fR\fI\s-1SECTION\s0\fR\fB]\fR" 4 +.IX Item "--unique[=SECTION]" +Creates a separate output section for every input section matching +\&\fI\s-1SECTION\s0\fR, or if the optional wildcard \fI\s-1SECTION\s0\fR argument is +missing, for every orphan input section. An orphan section is one not +specifically mentioned in a linker script. You may use this option +multiple times on the command line; It prevents the normal merging of +input sections with the same name, overriding output section assignments +in a linker script. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD +Display the version number for \fBld\fR. The \fB\-V\fR option also +lists the supported emulations. +.IP "\fB\-x\fR" 4 +.IX Item "-x" +.PD 0 +.IP "\fB\-\-discard\-all\fR" 4 +.IX Item "--discard-all" +.PD +Delete all local symbols. +.IP "\fB\-X\fR" 4 +.IX Item "-X" +.PD 0 +.IP "\fB\-\-discard\-locals\fR" 4 +.IX Item "--discard-locals" +.PD +Delete all temporary local symbols. (These symbols start with +system-specific local label prefixes, typically \fB.L\fR for \s-1ELF\s0 systems +or \fBL\fR for traditional a.out systems.) +.IP "\fB\-y\fR \fIsymbol\fR" 4 +.IX Item "-y symbol" +.PD 0 +.IP "\fB\-\-trace\-symbol=\fR\fIsymbol\fR" 4 +.IX Item "--trace-symbol=symbol" +.PD +Print the name of each linked file in which \fIsymbol\fR appears. This +option may be given any number of times. On many systems it is necessary +to prepend an underscore. +.Sp +This option is useful when you have an undefined symbol in your link but +don't know where the reference is coming from. +.IP "\fB\-Y\fR \fIpath\fR" 4 +.IX Item "-Y path" +Add \fIpath\fR to the default library search path. This option exists +for Solaris compatibility. +.IP "\fB\-z\fR \fIkeyword\fR" 4 +.IX Item "-z keyword" +The recognized keywords are: +.RS 4 +.IP "\fBcombreloc\fR" 4 +.IX Item "combreloc" +Combines multiple reloc sections and sorts them to make dynamic symbol +lookup caching possible. +.IP "\fBdefs\fR" 4 +.IX Item "defs" +Disallows undefined symbols in object files. Undefined symbols in +shared libraries are still allowed. +.IP "\fBexecstack\fR" 4 +.IX Item "execstack" +Marks the object as requiring executable stack. +.IP "\fBinitfirst\fR" 4 +.IX Item "initfirst" +This option is only meaningful when building a shared object. +It marks the object so that its runtime initialization will occur +before the runtime initialization of any other objects brought into +the process at the same time. Similarly the runtime finalization of +the object will occur after the runtime finalization of any other +objects. +.IP "\fBinterpose\fR" 4 +.IX Item "interpose" +Marks the object that its symbol table interposes before all symbols +but the primary executable. +.IP "\fBlazy\fR" 4 +.IX Item "lazy" +When generating an executable or shared library, mark it to tell the +dynamic linker to defer function call resolution to the point when +the function is called (lazy binding), rather than at load time. +Lazy binding is the default. +.IP "\fBloadfltr\fR" 4 +.IX Item "loadfltr" +Marks the object that its filters be processed immediately at +runtime. +.IP "\fBmuldefs\fR" 4 +.IX Item "muldefs" +Allows multiple definitions. +.IP "\fBnocombreloc\fR" 4 +.IX Item "nocombreloc" +Disables multiple reloc sections combining. +.IP "\fBnocopyreloc\fR" 4 +.IX Item "nocopyreloc" +Disables production of copy relocs. +.IP "\fBnodefaultlib\fR" 4 +.IX Item "nodefaultlib" +Marks the object that the search for dependencies of this object will +ignore any default library search paths. +.IP "\fBnodelete\fR" 4 +.IX Item "nodelete" +Marks the object shouldn't be unloaded at runtime. +.IP "\fBnodlopen\fR" 4 +.IX Item "nodlopen" +Marks the object not available to \f(CW\*(C`dlopen\*(C'\fR. +.IP "\fBnodump\fR" 4 +.IX Item "nodump" +Marks the object can not be dumped by \f(CW\*(C`dldump\*(C'\fR. +.IP "\fBnoexecstack\fR" 4 +.IX Item "noexecstack" +Marks the object as not requiring executable stack. +.IP "\fBnorelro\fR" 4 +.IX Item "norelro" +Don't create an \s-1ELF\s0 \f(CW\*(C`PT_GNU_RELRO\*(C'\fR segment header in the object. +.IP "\fBnow\fR" 4 +.IX Item "now" +When generating an executable or shared library, mark it to tell the +dynamic linker to resolve all symbols when the program is started, or +when the shared library is linked to using dlopen, instead of +deferring function call resolution to the point when the function is +first called. +.IP "\fBorigin\fR" 4 +.IX Item "origin" +Marks the object may contain \f(CW$ORIGIN\fR. +.IP "\fBrelro\fR" 4 +.IX Item "relro" +Create an \s-1ELF\s0 \f(CW\*(C`PT_GNU_RELRO\*(C'\fR segment header in the object. +.IP "\fBmax\-page\-size=\fR\fIvalue\fR" 4 +.IX Item "max-page-size=value" +Set the emulation maximum page size to \fIvalue\fR. +.IP "\fBcommon\-page\-size=\fR\fIvalue\fR" 4 +.IX Item "common-page-size=value" +Set the emulation common page size to \fIvalue\fR. +.RE +.RS 4 +.Sp +Other keywords are ignored for Solaris compatibility. +.RE +.IP "\fB\-(\fR \fIarchives\fR \fB\-)\fR" 4 +.IX Item "-( archives -)" +.PD 0 +.IP "\fB\-\-start\-group\fR \fIarchives\fR \fB\-\-end\-group\fR" 4 +.IX Item "--start-group archives --end-group" +.PD +The \fIarchives\fR should be a list of archive files. They may be +either explicit file names, or \fB\-l\fR options. +.Sp +The specified archives are searched repeatedly until no new undefined +references are created. Normally, an archive is searched only once in +the order that it is specified on the command line. If a symbol in that +archive is needed to resolve an undefined symbol referred to by an +object in an archive that appears later on the command line, the linker +would not be able to resolve that reference. By grouping the archives, +they all be searched repeatedly until all possible references are +resolved. +.Sp +Using this option has a significant performance cost. It is best to use +it only when there are unavoidable circular references between two or +more archives. +.IP "\fB\-\-accept\-unknown\-input\-arch\fR" 4 +.IX Item "--accept-unknown-input-arch" +.PD 0 +.IP "\fB\-\-no\-accept\-unknown\-input\-arch\fR" 4 +.IX Item "--no-accept-unknown-input-arch" +.PD +Tells the linker to accept input files whose architecture cannot be +recognised. The assumption is that the user knows what they are doing +and deliberately wants to link in these unknown input files. This was +the default behaviour of the linker, before release 2.14. The default +behaviour from release 2.14 onwards is to reject such input files, and +so the \fB\-\-accept\-unknown\-input\-arch\fR option has been added to +restore the old behaviour. +.IP "\fB\-\-add\-needed\fR" 4 +.IX Item "--add-needed" +.PD 0 +.IP "\fB\-\-no\-add\-needed\fR" 4 +.IX Item "--no-add-needed" +.PD +This option affects the treatment of dynamic libraries from \s-1ELF\s0 +\&\s-1DT_NEEDED\s0 tags in dynamic libraries mentioned on the command line after +the \fB\-\-add\-needed\fR option. Normally, the linker will not copy +a \s-1DT_NEEDED\s0 tags from each dynamic library to the produced output object. +\&\fB\-\-add\-needed\fR makes linker to copy \s-1DT_NEEDED\s0 tags from all +dynamic libraries mentioned after this flag. +\fB\-\-no\-add\-needed\fR restores the default behaviour. +.IP "\fB\-\-as\-needed\fR" 4 +.IX Item "--as-needed" +.PD 0 +.IP "\fB\-\-no\-as\-needed\fR" 4 +.IX Item "--no-as-needed" +.PD +This option affects \s-1ELF\s0 \s-1DT_NEEDED\s0 tags for dynamic +libraries mentioned on the command line after the \fB\-\-as\-needed\fR +option when \fB\-\-add\-needed\fR is in effect. +In such a case \fB\-\-as\-needed\fR causes \s-1DT_NEEDED\s0 tags +to only be emitted for libraries that satisfy some symbol reference +from regular objects which is undefined at the point that the library +was linked. +\&\fB\-\-no\-as\-needed\fR restores the default behaviour. +.IP "\fB\-assert\fR \fIkeyword\fR" 4 +.IX Item "-assert keyword" +This option is ignored for SunOS compatibility. +.IP "\fB\-Bdynamic\fR" 4 +.IX Item "-Bdynamic" +.PD 0 +.IP "\fB\-dy\fR" 4 +.IX Item "-dy" +.IP "\fB\-call_shared\fR" 4 +.IX Item "-call_shared" +.PD +Link against dynamic libraries. This is only meaningful on platforms +for which shared libraries are supported. This option is normally the +default on such platforms. The different variants of this option are +for compatibility with various systems. You may use this option +multiple times on the command line: it affects library searching for +\&\fB\-l\fR options which follow it. +.IP "\fB\-Bgroup\fR" 4 +.IX Item "-Bgroup" +Set the \f(CW\*(C`DF_1_GROUP\*(C'\fR flag in the \f(CW\*(C`DT_FLAGS_1\*(C'\fR entry in the dynamic +section. This causes the runtime linker to handle lookups in this +object and its dependencies to be performed only inside the group. +\&\fB\-\-unresolved\-symbols=report\-all\fR is implied. This option is +only meaningful on \s-1ELF\s0 platforms which support shared libraries. +.IP "\fB\-Bstatic\fR" 4 +.IX Item "-Bstatic" +.PD 0 +.IP "\fB\-dn\fR" 4 +.IX Item "-dn" +.IP "\fB\-non_shared\fR" 4 +.IX Item "-non_shared" +.IP "\fB\-static\fR" 4 +.IX Item "-static" +.PD +Do not link against shared libraries. This is only meaningful on +platforms for which shared libraries are supported. The different +variants of this option are for compatibility with various systems. You +may use this option multiple times on the command line: it affects +library searching for \fB\-l\fR options which follow it. This +option also implies \fB\-\-unresolved\-symbols=report\-all\fR. This +option can be used with \fB\-shared\fR. Doing so means that a +shared library is being created but that all of the library's external +references must be resolved by pulling in entries from static +libraries. +.IP "\fB\-Bsymbolic\fR" 4 +.IX Item "-Bsymbolic" +When creating a shared library, bind references to global symbols to the +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 \s-1ELF\s0 +platforms which support shared libraries. +.IP "\fB\-Bsymbolic\-functions\fR" 4 +.IX 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 \s-1ELF\s0 platforms which support shared +libraries. +.IP "\fB\-\-dynamic\-list=\fR\fIdynamic-list-file\fR" 4 +.IX Item "--dynamic-list=dynamic-list-file" +Specify the name of a dynamic list file to the linker. This is +typically used when creating shared libraries to specify a list of +global symbols whose references shouldn't be bound to the definition +within the shared library, or creating dynamically linked executables +to specify a list of symbols which should be added to the symbol table +in the executable. This option is only meaningful on \s-1ELF\s0 platforms +which support shared libraries. +.Sp +The format of the dynamic list is the same as the version node without +scope and node name. See \fB\s-1VERSION\s0\fR for more information. +.IP "\fB\-\-dynamic\-list\-data\fR" 4 +.IX Item "--dynamic-list-data" +Include all global data symbols to the dynamic list. +.IP "\fB\-\-dynamic\-list\-cpp\-new\fR" 4 +.IX Item "--dynamic-list-cpp-new" +Provide the builtin dynamic list for \*(C+ operator new and delete. It +is mainly useful for building shared libstdc++. +.IP "\fB\-\-dynamic\-list\-cpp\-typeinfo\fR" 4 +.IX Item "--dynamic-list-cpp-typeinfo" +Provide the builtin dynamic list for \*(C+ runtime type identification. +.IP "\fB\-\-check\-sections\fR" 4 +.IX Item "--check-sections" +.PD 0 +.IP "\fB\-\-no\-check\-sections\fR" 4 +.IX Item "--no-check-sections" +.PD +Asks the linker \fInot\fR to check section addresses after they have +been assigned to see if there are any overlaps. Normally the linker will +perform this check, and if it finds any overlaps it will produce +suitable error messages. The linker does know about, and does make +allowances for sections in overlays. The default behaviour can be +restored by using the command line switch \fB\-\-check\-sections\fR. +.IP "\fB\-\-cref\fR" 4 +.IX Item "--cref" +Output a cross reference table. If a linker map file is being +generated, the cross reference table is printed to the map file. +Otherwise, it is printed on the standard output. +.Sp +The format of the table is intentionally simple, so that it may be +easily processed by a script if necessary. The symbols are printed out, +sorted by name. For each symbol, a list of file names is given. If the +symbol is defined, the first file listed is the location of the +definition. The remaining files contain references to the symbol. +.IP "\fB\-\-no\-define\-common\fR" 4 +.IX Item "--no-define-common" +This option inhibits the assignment of addresses to common symbols. +The script command \f(CW\*(C`INHIBIT_COMMON_ALLOCATION\*(C'\fR has the same effect. +.Sp +The \fB\-\-no\-define\-common\fR option allows decoupling +the decision to assign addresses to Common symbols from the choice +of the output file type; otherwise a non-Relocatable output type +forces assigning addresses to Common symbols. +Using \fB\-\-no\-define\-common\fR allows Common symbols that are referenced +from a shared library to be assigned addresses only in the main program. +This eliminates the unused duplicate space in the shared library, +and also prevents any possible confusion over resolving to the wrong +duplicate when there are many dynamic modules with specialized search +paths for runtime symbol resolution. +.IP "\fB\-\-defsym\fR \fIsymbol\fR\fB=\fR\fIexpression\fR" 4 +.IX Item "--defsym symbol=expression" +Create a global symbol in the output file, containing the absolute +address given by \fIexpression\fR. You may use this option as many +times as necessary to define multiple symbols in the command line. A +limited form of arithmetic is supported for the \fIexpression\fR in this +context: you may give a hexadecimal constant or the name of an existing +symbol, or use \f(CW\*(C`+\*(C'\fR and \f(CW\*(C`\-\*(C'\fR to add or subtract hexadecimal +constants or symbols. If you need more elaborate expressions, consider +using the linker command language from a script. \fINote:\fR there should be no white +space between \fIsymbol\fR, the equals sign ("\fB=\fR"), and +\&\fIexpression\fR. +.IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4 +.IX Item "--demangle[=style]" +.PD 0 +.IP "\fB\-\-no\-demangle\fR" 4 +.IX Item "--no-demangle" +.PD +These options control whether to demangle symbol names in error messages +and other output. When the linker is told to demangle, it tries to +present symbol names in a readable fashion: it strips leading +underscores if they are used by the object file format, and converts \*(C+ +mangled symbol names into user readable names. Different compilers have +different mangling styles. The optional demangling style argument can be used +to choose an appropriate demangling style for your compiler. The linker will +demangle by default unless the environment variable \fB\s-1COLLECT_NO_DEMANGLE\s0\fR +is set. These options may be used to override the default. +.IP "\fB\-\-dynamic\-linker\fR \fIfile\fR" 4 +.IX Item "--dynamic-linker file" +Set the name of the dynamic linker. This is only meaningful when +generating dynamically linked \s-1ELF\s0 executables. The default dynamic +linker is normally correct; don't use this unless you know what you are +doing. +.IP "\fB\-\-fatal\-warnings\fR" 4 +.IX Item "--fatal-warnings" +Treat all warnings as errors. +.IP "\fB\-\-force\-exe\-suffix\fR" 4 +.IX Item "--force-exe-suffix" +Make sure that an output file has a .exe suffix. +.Sp +If a successfully built fully linked output file does not have a +\&\f(CW\*(C`.exe\*(C'\fR or \f(CW\*(C`.dll\*(C'\fR suffix, this option forces the linker to copy +the output file to one of the same name with a \f(CW\*(C`.exe\*(C'\fR suffix. This +option is useful when using unmodified Unix makefiles on a Microsoft +Windows host, since some versions of Windows won't run an image unless +it ends in a \f(CW\*(C`.exe\*(C'\fR suffix. +.IP "\fB\-\-gc\-sections\fR" 4 +.IX Item "--gc-sections" +.PD 0 +.IP "\fB\-\-no\-gc\-sections\fR" 4 +.IX Item "--no-gc-sections" +.PD +Enable garbage collection of unused input sections. It is ignored on +targets that do not support this option. This option is not compatible +with \fB\-r\fR or \fB\-\-emit\-relocs\fR. The default behaviour (of not +performing this garbage collection) can be restored by specifying +\&\fB\-\-no\-gc\-sections\fR on the command line. +.IP "\fB\-\-print\-gc\-sections\fR" 4 +.IX Item "--print-gc-sections" +.PD 0 +.IP "\fB\-\-no\-print\-gc\-sections\fR" 4 +.IX Item "--no-print-gc-sections" +.PD +List all sections removed by garbage collection. The listing is +printed on stderr. This option is only effective if garbage +collection has been enabled via the \fB\-\-gc\-sections\fR) option. The +default behaviour (of not listing the sections that are removed) can +be restored by specifying \fB\-\-no\-print\-gc\-sections\fR on the command +line. +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +Print a summary of the command-line options on the standard output and exit. +.IP "\fB\-\-target\-help\fR" 4 +.IX Item "--target-help" +Print a summary of all target specific options on the standard output and exit. +.IP "\fB\-Map\fR \fImapfile\fR" 4 +.IX Item "-Map mapfile" +Print a link map to the file \fImapfile\fR. See the description of the +\&\fB\-M\fR option, above. +.IP "\fB\-\-no\-keep\-memory\fR" 4 +.IX Item "--no-keep-memory" +\&\fBld\fR normally optimizes for speed over memory usage by caching the +symbol tables of input files in memory. This option tells \fBld\fR to +instead optimize for memory usage, by rereading the symbol tables as +necessary. This may be required if \fBld\fR runs out of memory space +while linking a large executable. +.IP "\fB\-\-no\-undefined\fR" 4 +.IX Item "--no-undefined" +.PD 0 +.IP "\fB\-z defs\fR" 4 +.IX Item "-z defs" +.PD +Report unresolved symbol references from regular object files. This +is done even if the linker is creating a non-symbolic shared library. +The switch \fB\-\-[no\-]allow\-shlib\-undefined\fR controls the +behaviour for reporting unresolved references found in shared +libraries being linked in. +.IP "\fB\-\-allow\-multiple\-definition\fR" 4 +.IX Item "--allow-multiple-definition" +.PD 0 +.IP "\fB\-z muldefs\fR" 4 +.IX Item "-z muldefs" +.PD +Normally when a symbol is defined multiple times, the linker will +report a fatal error. These options allow multiple definitions and the +first definition will be used. +.IP "\fB\-\-allow\-shlib\-undefined\fR" 4 +.IX Item "--allow-shlib-undefined" +.PD 0 +.IP "\fB\-\-no\-allow\-shlib\-undefined\fR" 4 +.IX Item "--no-allow-shlib-undefined" +.PD +Allows (the default) or disallows undefined symbols in shared libraries. +This switch is similar to \fB\-\-no\-undefined\fR except that it +determines the behaviour when the undefined symbols are in a +shared library rather than a regular object file. It does not affect +how undefined symbols in regular object files are handled. +.Sp +The reason that \fB\-\-allow\-shlib\-undefined\fR is the default is that +the shared library being specified at link time may not be the same as +the one that is available at load time, so the symbols might actually be +resolvable at load time. Plus there are some systems, (eg BeOS) where +undefined symbols in shared libraries is normal. (The kernel patches +them at load time to select which function is most appropriate +for the current architecture. This is used for example to dynamically +select an appropriate memset function). Apparently it is also normal +for \s-1HPPA\s0 shared libraries to have undefined symbols. +.IP "\fB\-\-no\-undefined\-version\fR" 4 +.IX Item "--no-undefined-version" +Normally when a symbol has an undefined version, the linker will ignore +it. This option disallows symbols with undefined version and a fatal error +will be issued instead. +.IP "\fB\-\-default\-symver\fR" 4 +.IX Item "--default-symver" +Create and use a default symbol version (the soname) for unversioned +exported symbols. +.IP "\fB\-\-default\-imported\-symver\fR" 4 +.IX Item "--default-imported-symver" +Create and use a default symbol version (the soname) for unversioned +imported symbols. +.IP "\fB\-\-no\-warn\-mismatch\fR" 4 +.IX Item "--no-warn-mismatch" +Normally \fBld\fR will give an error if you try to link together input +files that are mismatched for some reason, perhaps because they have +been compiled for different processors or for different endiannesses. +This option tells \fBld\fR that it should silently permit such possible +errors. This option should only be used with care, in cases when you +have taken some special action that ensures that the linker errors are +inappropriate. +.IP "\fB\-\-no\-warn\-search\-mismatch\fR" 4 +.IX Item "--no-warn-search-mismatch" +Normally \fBld\fR will give a warning if it finds an incompatible +library during a library search. This option silences the warning. +.IP "\fB\-\-no\-whole\-archive\fR" 4 +.IX Item "--no-whole-archive" +Turn off the effect of the \fB\-\-whole\-archive\fR option for subsequent +archive files. +.IP "\fB\-\-noinhibit\-exec\fR" 4 +.IX Item "--noinhibit-exec" +Retain the executable output file whenever it is still usable. +Normally, the linker will not produce an output file if it encounters +errors during the link process; it exits without writing an output file +when it issues any error whatsoever. +.IP "\fB\-nostdlib\fR" 4 +.IX Item "-nostdlib" +Only search library directories explicitly specified on the +command line. Library directories specified in linker scripts +(including linker scripts specified on the command line) are ignored. +.IP "\fB\-\-oformat\fR \fIoutput-format\fR" 4 +.IX Item "--oformat output-format" +\&\fBld\fR may be configured to support more than one kind of object +file. If your \fBld\fR is configured this way, you can use the +\&\fB\-\-oformat\fR option to specify the binary format for the output +object file. Even when \fBld\fR is configured to support alternative +object formats, you don't usually need to specify this, as \fBld\fR +should be configured to produce as a default output format the most +usual format on each machine. \fIoutput-format\fR is a text string, the +name of a particular format supported by the \s-1BFD\s0 libraries. (You can +list the available binary formats with \fBobjdump \-i\fR.) The script +command \f(CW\*(C`OUTPUT_FORMAT\*(C'\fR can also specify the output format, but +this option overrides it. +.IP "\fB\-pie\fR" 4 +.IX Item "-pie" +.PD 0 +.IP "\fB\-\-pic\-executable\fR" 4 +.IX Item "--pic-executable" +.PD +Create a position independent executable. This is currently only supported on +\&\s-1ELF\s0 platforms. Position independent executables are similar to shared +libraries in that they are relocated by the dynamic linker to the virtual +address the \s-1OS\s0 chooses for them (which can vary between invocations). Like +normal dynamically linked executables they can be executed and symbols +defined in the executable cannot be overridden by shared libraries. +.IP "\fB\-qmagic\fR" 4 +.IX Item "-qmagic" +This option is ignored for Linux compatibility. +.IP "\fB\-Qy\fR" 4 +.IX Item "-Qy" +This option is ignored for \s-1SVR4\s0 compatibility. +.IP "\fB\-\-relax\fR" 4 +.IX Item "--relax" +An option with machine dependent effects. +This option is only supported on a few targets. +.Sp +On some platforms, the \fB\-\-relax\fR option performs global +optimizations that become possible when the linker resolves addressing +in the program, such as relaxing address modes and synthesizing new +instructions in the output object file. +.Sp +On some platforms these link time global optimizations may make symbolic +debugging of the resulting executable impossible. +This is known to be +the case for the Matsushita \s-1MN10200\s0 and \s-1MN10300\s0 family of processors. +.Sp +On platforms where this is not supported, \fB\-\-relax\fR is accepted, +but ignored. +.IP "\fB\-\-retain\-symbols\-file\fR \fIfilename\fR" 4 +.IX Item "--retain-symbols-file filename" +Retain \fIonly\fR the symbols listed in the file \fIfilename\fR, +discarding all others. \fIfilename\fR is simply a flat file, with one +symbol name per line. This option is especially useful in environments +(such as VxWorks) +where a large global symbol table is accumulated gradually, to conserve +run-time memory. +.Sp +\&\fB\-\-retain\-symbols\-file\fR does \fInot\fR discard undefined symbols, +or symbols needed for relocations. +.Sp +You may only specify \fB\-\-retain\-symbols\-file\fR once in the command +line. It overrides \fB\-s\fR and \fB\-S\fR. +.IP "\fB\-rpath\fR \fIdir\fR" 4 +.IX Item "-rpath dir" +Add a directory to the runtime library search path. This is used when +linking an \s-1ELF\s0 executable with shared objects. All \fB\-rpath\fR +arguments are concatenated and passed to the runtime linker, which uses +them to locate shared objects at runtime. The \fB\-rpath\fR option is +also used when locating shared objects which are needed by shared +objects explicitly included in the link; see the description of the +\&\fB\-rpath\-link\fR option. If \fB\-rpath\fR is not used when linking an +\&\s-1ELF\s0 executable, the contents of the environment variable +\&\f(CW\*(C`LD_RUN_PATH\*(C'\fR will be used if it is defined. +.Sp +The \fB\-rpath\fR option may also be used on SunOS. By default, on +SunOS, the linker will form a runtime search patch out of all the +\&\fB\-L\fR options it is given. If a \fB\-rpath\fR option is used, the +runtime search path will be formed exclusively using the \fB\-rpath\fR +options, ignoring the \fB\-L\fR options. This can be useful when using +gcc, which adds many \fB\-L\fR options which may be on \s-1NFS\s0 mounted +file systems. +.Sp +For compatibility with other \s-1ELF\s0 linkers, if the \fB\-R\fR option is +followed by a directory name, rather than a file name, it is treated as +the \fB\-rpath\fR option. +.IP "\fB\-rpath\-link\fR \fI\s-1DIR\s0\fR" 4 +.IX Item "-rpath-link DIR" +When using \s-1ELF\s0 or SunOS, one shared library may require another. This +happens when an \f(CW\*(C`ld \-shared\*(C'\fR link includes a shared library as one +of the input files. +.Sp +When the linker encounters such a dependency when doing a non-shared, +non-relocatable link, it will automatically try to locate the required +shared library and include it in the link, if it is not included +explicitly. In such a case, the \fB\-rpath\-link\fR option +specifies the first set of directories to search. The +\&\fB\-rpath\-link\fR option may specify a sequence of directory names +either by specifying a list of names separated by colons, or by +appearing multiple times. +.Sp +This option should be used with caution as it overrides the search path +that may have been hard compiled into a shared library. In such a case it +is possible to use unintentionally a different search path than the +runtime linker would do. +.Sp +The linker uses the following search paths to locate required shared +libraries: +.RS 4 +.IP "1." 4 +Any directories specified by \fB\-rpath\-link\fR options. +.IP "2." 4 +Any directories specified by \fB\-rpath\fR options. The difference +between \fB\-rpath\fR and \fB\-rpath\-link\fR is that directories +specified by \fB\-rpath\fR options are included in the executable and +used at runtime, whereas the \fB\-rpath\-link\fR option is only effective +at link time. Searching \fB\-rpath\fR in this way is only supported +by native linkers and cross linkers which have been configured with +the \fB\-\-with\-sysroot\fR option. +.IP "3." 4 +On an \s-1ELF\s0 system, if the \fB\-rpath\fR and \f(CW\*(C`rpath\-link\*(C'\fR options +were not used, search the contents of the environment variable +\&\f(CW\*(C`LD_RUN_PATH\*(C'\fR. It is for the native linker only. +.IP "4." 4 +On SunOS, if the \fB\-rpath\fR option was not used, search any +directories specified using \fB\-L\fR options. +.IP "5." 4 +For a native linker, the contents of the environment variable +\&\f(CW\*(C`LD_LIBRARY_PATH\*(C'\fR. +.IP "6." 4 +For a native \s-1ELF\s0 linker, the directories in \f(CW\*(C`DT_RUNPATH\*(C'\fR or +\&\f(CW\*(C`DT_RPATH\*(C'\fR of a shared library are searched for shared +libraries needed by it. The \f(CW\*(C`DT_RPATH\*(C'\fR entries are ignored if +\&\f(CW\*(C`DT_RUNPATH\*(C'\fR entries exist. +.IP "7." 4 +The default directories, normally \fI/lib\fR and \fI/usr/lib\fR. +.IP "8." 4 +For a native linker on an \s-1ELF\s0 system, if the file \fI/etc/ld.so.conf\fR +exists, the list of directories found in that file. +.RE +.RS 4 +.Sp +If the required shared library is not found, the linker will issue a +warning and continue with the link. +.RE +.IP "\fB\-shared\fR" 4 +.IX Item "-shared" +.PD 0 +.IP "\fB\-Bshareable\fR" 4 +.IX Item "-Bshareable" +.PD +Create a shared library. This is currently only supported on \s-1ELF\s0, \s-1XCOFF\s0 +and SunOS platforms. On SunOS, the linker will automatically create a +shared library if the \fB\-e\fR option is not used and there are +undefined symbols in the link. +.IP "\fB\-\-sort\-common\fR" 4 +.IX Item "--sort-common" +This option tells \fBld\fR to sort the common symbols by size when it +places them in the appropriate output sections. First come all the one +byte symbols, then all the two byte, then all the four byte, and then +everything else. This is to prevent gaps between symbols due to +alignment constraints. +.IP "\fB\-\-sort\-section name\fR" 4 +.IX Item "--sort-section name" +This option will apply \f(CW\*(C`SORT_BY_NAME\*(C'\fR to all wildcard section +patterns in the linker script. +.IP "\fB\-\-sort\-section alignment\fR" 4 +.IX Item "--sort-section alignment" +This option will apply \f(CW\*(C`SORT_BY_ALIGNMENT\*(C'\fR to all wildcard section +patterns in the linker script. +.IP "\fB\-\-split\-by\-file [\fR\fIsize\fR\fB]\fR" 4 +.IX Item "--split-by-file [size]" +Similar to \fB\-\-split\-by\-reloc\fR but creates a new output section for +each input file when \fIsize\fR is reached. \fIsize\fR defaults to a +size of 1 if not given. +.IP "\fB\-\-split\-by\-reloc [\fR\fIcount\fR\fB]\fR" 4 +.IX Item "--split-by-reloc [count]" +Tries to creates extra sections in the output file so that no single +output section in the file contains more than \fIcount\fR relocations. +This is useful when generating huge relocatable files for downloading into +certain real time kernels with the \s-1COFF\s0 object file format; since \s-1COFF\s0 +cannot represent more than 65535 relocations in a single section. Note +that this will fail to work with object file formats which do not +support arbitrary sections. The linker will not split up individual +input sections for redistribution, so if a single input section contains +more than \fIcount\fR relocations one output section will contain that +many relocations. \fIcount\fR defaults to a value of 32768. +.IP "\fB\-\-stats\fR" 4 +.IX Item "--stats" +Compute and display statistics about the operation of the linker, such +as execution time and memory usage. +.IP "\fB\-\-sysroot=\fR\fIdirectory\fR" 4 +.IX Item "--sysroot=directory" +Use \fIdirectory\fR as the location of the sysroot, overriding the +configure-time default. This option is only supported by linkers +that were configured using \fB\-\-with\-sysroot\fR. +.IP "\fB\-\-traditional\-format\fR" 4 +.IX Item "--traditional-format" +For some targets, the output of \fBld\fR is different in some ways from +the output of some existing linker. This switch requests \fBld\fR to +use the traditional format instead. +.Sp +For example, on SunOS, \fBld\fR combines duplicate entries in the +symbol string table. This can reduce the size of an output file with +full debugging information by over 30 percent. Unfortunately, the SunOS +\&\f(CW\*(C`dbx\*(C'\fR program can not read the resulting program (\f(CW\*(C`gdb\*(C'\fR has no +trouble). The \fB\-\-traditional\-format\fR switch tells \fBld\fR to not +combine duplicate entries. +.IP "\fB\-\-section\-start\fR \fIsectionname\fR\fB=\fR\fIorg\fR" 4 +.IX Item "--section-start sectionname=org" +Locate a section in the output file at the absolute +address given by \fIorg\fR. You may use this option as many +times as necessary to locate multiple sections in the command +line. +\&\fIorg\fR must be a single hexadecimal integer; +for compatibility with other linkers, you may omit the leading +\&\fB0x\fR usually associated with hexadecimal values. \fINote:\fR there +should be no white space between \fIsectionname\fR, the equals +sign ("\fB=\fR"), and \fIorg\fR. +.IP "\fB\-Tbss\fR \fIorg\fR" 4 +.IX Item "-Tbss org" +.PD 0 +.IP "\fB\-Tdata\fR \fIorg\fR" 4 +.IX Item "-Tdata org" +.IP "\fB\-Ttext\fR \fIorg\fR" 4 +.IX Item "-Ttext org" +.PD +Same as \-\-section\-start, with \f(CW\*(C`.bss\*(C'\fR, \f(CW\*(C`.data\*(C'\fR or +\&\f(CW\*(C`.text\*(C'\fR as the \fIsectionname\fR. +.IP "\fB\-\-unresolved\-symbols=\fR\fImethod\fR" 4 +.IX Item "--unresolved-symbols=method" +Determine how to handle unresolved symbols. There are four possible +values for \fBmethod\fR: +.RS 4 +.IP "\fBignore-all\fR" 4 +.IX Item "ignore-all" +Do not report any unresolved symbols. +.IP "\fBreport-all\fR" 4 +.IX Item "report-all" +Report all unresolved symbols. This is the default. +.IP "\fBignore-in-object-files\fR" 4 +.IX Item "ignore-in-object-files" +Report unresolved symbols that are contained in shared libraries, but +ignore them if they come from regular object files. +.IP "\fBignore-in-shared-libs\fR" 4 +.IX Item "ignore-in-shared-libs" +Report unresolved symbols that come from regular object files, but +ignore them if they come from shared libraries. This can be useful +when creating a dynamic binary and it is known that all the shared +libraries that it should be referencing are included on the linker's +command line. +.RE +.RS 4 +.Sp +The behaviour for shared libraries on their own can also be controlled +by the \fB\-\-[no\-]allow\-shlib\-undefined\fR option. +.Sp +Normally the linker will generate an error message for each reported +unresolved symbol but the option \fB\-\-warn\-unresolved\-symbols\fR +can change this to a warning. +.RE +.IP "\fB\-\-dll\-verbose\fR" 4 +.IX Item "--dll-verbose" +.PD 0 +.IP "\fB\-\-verbose\fR" 4 +.IX Item "--verbose" +.PD +Display the version number for \fBld\fR and list the linker emulations +supported. Display which input files can and cannot be opened. Display +the linker script being used by the linker. +.IP "\fB\-\-version\-script=\fR\fIversion-scriptfile\fR" 4 +.IX Item "--version-script=version-scriptfile" +Specify the name of a version script to the linker. This is typically +used when creating shared libraries to specify additional information +about the version hierarchy for the library being created. This option +is only meaningful on \s-1ELF\s0 platforms which support shared libraries. +.IP "\fB\-\-warn\-common\fR" 4 +.IX Item "--warn-common" +Warn when a common symbol is combined with another common symbol or with +a symbol definition. Unix linkers allow this somewhat sloppy practise, +but linkers on some other operating systems do not. This option allows +you to find potential problems from combining global symbols. +Unfortunately, some C libraries use this practise, so you may get some +warnings about symbols in the libraries as well as in your programs. +.Sp +There are three kinds of global symbols, illustrated here by C examples: +.RS 4 +.IP "\fBint i = 1;\fR" 4 +.IX Item "int i = 1;" +A definition, which goes in the initialized data section of the output +file. +.IP "\fBextern int i;\fR" 4 +.IX Item "extern int i;" +An undefined reference, which does not allocate space. +There must be either a definition or a common symbol for the +variable somewhere. +.IP "\fBint i;\fR" 4 +.IX Item "int i;" +A common symbol. If there are only (one or more) common symbols for a +variable, it goes in the uninitialized data area of the output file. +The linker merges multiple common symbols for the same variable into a +single symbol. If they are of different sizes, it picks the largest +size. The linker turns a common symbol into a declaration, if there is +a definition of the same variable. +.RE +.RS 4 +.Sp +The \fB\-\-warn\-common\fR option can produce five kinds of warnings. +Each warning consists of a pair of lines: the first describes the symbol +just encountered, and the second describes the previous symbol +encountered with the same name. One or both of the two symbols will be +a common symbol. +.IP "1." 4 +Turning a common symbol into a reference, because there is already a +definition for the symbol. +.Sp +.Vb 3 +\& <file>(<section>): warning: common of \`<symbol>\*(Aq +\& overridden by definition +\& <file>(<section>): warning: defined here +.Ve +.IP "2." 4 +Turning a common symbol into a reference, because a later definition for +the symbol is encountered. This is the same as the previous case, +except that the symbols are encountered in a different order. +.Sp +.Vb 3 +\& <file>(<section>): warning: definition of \`<symbol>\*(Aq +\& overriding common +\& <file>(<section>): warning: common is here +.Ve +.IP "3." 4 +Merging a common symbol with a previous same-sized common symbol. +.Sp +.Vb 3 +\& <file>(<section>): warning: multiple common +\& of \`<symbol>\*(Aq +\& <file>(<section>): warning: previous common is here +.Ve +.IP "4." 4 +Merging a common symbol with a previous larger common symbol. +.Sp +.Vb 3 +\& <file>(<section>): warning: common of \`<symbol>\*(Aq +\& overridden by larger common +\& <file>(<section>): warning: larger common is here +.Ve +.IP "5." 4 +Merging a common symbol with a previous smaller common symbol. This is +the same as the previous case, except that the symbols are +encountered in a different order. +.Sp +.Vb 3 +\& <file>(<section>): warning: common of \`<symbol>\*(Aq +\& overriding smaller common +\& <file>(<section>): warning: smaller common is here +.Ve +.RE +.RS 4 +.RE +.IP "\fB\-\-warn\-constructors\fR" 4 +.IX Item "--warn-constructors" +Warn if any global constructors are used. This is only useful for a few +object file formats. For formats like \s-1COFF\s0 or \s-1ELF\s0, the linker can not +detect the use of global constructors. +.IP "\fB\-\-warn\-multiple\-gp\fR" 4 +.IX Item "--warn-multiple-gp" +Warn if multiple global pointer values are required in the output file. +This is only meaningful for certain processors, such as the Alpha. +Specifically, some processors put large-valued constants in a special +section. A special register (the global pointer) points into the middle +of this section, so that constants can be loaded efficiently via a +base-register relative addressing mode. Since the offset in +base-register relative mode is fixed and relatively small (e.g., 16 +bits), this limits the maximum size of the constant pool. Thus, in +large programs, it is often necessary to use multiple global pointer +values in order to be able to address all possible constants. This +option causes a warning to be issued whenever this case occurs. +.IP "\fB\-\-warn\-once\fR" 4 +.IX Item "--warn-once" +Only warn once for each undefined symbol, rather than once per module +which refers to it. +.IP "\fB\-\-warn\-section\-align\fR" 4 +.IX Item "--warn-section-align" +Warn if the address of an output section is changed because of +alignment. Typically, the alignment will be set by an input section. +The address will only be changed if it not explicitly specified; that +is, if the \f(CW\*(C`SECTIONS\*(C'\fR command does not specify a start address for +the section. +.IP "\fB\-\-warn\-shared\-textrel\fR" 4 +.IX Item "--warn-shared-textrel" +Warn if the linker adds a \s-1DT_TEXTREL\s0 to a shared object. +.IP "\fB\-\-warn\-unresolved\-symbols\fR" 4 +.IX Item "--warn-unresolved-symbols" +If the linker is going to report an unresolved symbol (see the option +\&\fB\-\-unresolved\-symbols\fR) it will normally generate an error. +This option makes it generate a warning instead. +.IP "\fB\-\-error\-unresolved\-symbols\fR" 4 +.IX Item "--error-unresolved-symbols" +This restores the linker's default behaviour of generating errors when +it is reporting unresolved symbols. +.IP "\fB\-\-whole\-archive\fR" 4 +.IX Item "--whole-archive" +For each archive mentioned on the command line after the +\&\fB\-\-whole\-archive\fR option, include every object file in the archive +in the link, rather than searching the archive for the required object +files. This is normally used to turn an archive file into a shared +library, forcing every object to be included in the resulting shared +library. This option may be used more than once. +.Sp +Two notes when using this option from gcc: First, gcc doesn't know +about this option, so you have to use \fB\-Wl,\-whole\-archive\fR. +Second, don't forget to use \fB\-Wl,\-no\-whole\-archive\fR after your +list of archives, because gcc will add its own list of archives to +your link and you may not want this flag to affect those as well. +.IP "\fB\-\-wrap\fR \fIsymbol\fR" 4 +.IX Item "--wrap symbol" +Use a wrapper function for \fIsymbol\fR. Any undefined reference to +\&\fIsymbol\fR will be resolved to \f(CW\*(C`_\|_wrap_\f(CIsymbol\f(CW\*(C'\fR. Any +undefined reference to \f(CW\*(C`_\|_real_\f(CIsymbol\f(CW\*(C'\fR will be resolved to +\&\fIsymbol\fR. +.Sp +This can be used to provide a wrapper for a system function. The +wrapper function should be called \f(CW\*(C`_\|_wrap_\f(CIsymbol\f(CW\*(C'\fR. If it +wishes to call the system function, it should call +\&\f(CW\*(C`_\|_real_\f(CIsymbol\f(CW\*(C'\fR. +.Sp +Here is a trivial example: +.Sp +.Vb 6 +\& void * +\& _\|_wrap_malloc (size_t c) +\& { +\& printf ("malloc called with %zu\en", c); +\& return _\|_real_malloc (c); +\& } +.Ve +.Sp +If you link other code with this file using \fB\-\-wrap malloc\fR, then +all calls to \f(CW\*(C`malloc\*(C'\fR will call the function \f(CW\*(C`_\|_wrap_malloc\*(C'\fR +instead. The call to \f(CW\*(C`_\|_real_malloc\*(C'\fR in \f(CW\*(C`_\|_wrap_malloc\*(C'\fR will +call the real \f(CW\*(C`malloc\*(C'\fR function. +.Sp +You may wish to provide a \f(CW\*(C`_\|_real_malloc\*(C'\fR function as well, so that +links without the \fB\-\-wrap\fR option will succeed. If you do this, +you should not put the definition of \f(CW\*(C`_\|_real_malloc\*(C'\fR in the same +file as \f(CW\*(C`_\|_wrap_malloc\*(C'\fR; if you do, the assembler may resolve the +call before the linker has a chance to wrap it to \f(CW\*(C`malloc\*(C'\fR. +.IP "\fB\-\-eh\-frame\-hdr\fR" 4 +.IX Item "--eh-frame-hdr" +Request creation of \f(CW\*(C`.eh_frame_hdr\*(C'\fR section and \s-1ELF\s0 +\&\f(CW\*(C`PT_GNU_EH_FRAME\*(C'\fR segment header. +.IP "\fB\-\-enable\-new\-dtags\fR" 4 +.IX Item "--enable-new-dtags" +.PD 0 +.IP "\fB\-\-disable\-new\-dtags\fR" 4 +.IX Item "--disable-new-dtags" +.PD +This linker can create the new dynamic tags in \s-1ELF\s0. But the older \s-1ELF\s0 +systems may not understand them. If you specify +\&\fB\-\-enable\-new\-dtags\fR, the dynamic tags will be created as needed. +If you specify \fB\-\-disable\-new\-dtags\fR, no new dynamic tags will be +created. By default, the new dynamic tags are not created. Note that +those options are only available for \s-1ELF\s0 systems. +.IP "\fB\-\-hash\-size=\fR\fInumber\fR" 4 +.IX Item "--hash-size=number" +Set the default size of the linker's hash tables to a prime number +close to \fInumber\fR. Increasing this value can reduce the length of +time it takes the linker to perform its tasks, at the expense of +increasing the linker's memory requirements. Similarly reducing this +value can reduce the memory requirements at the expense of speed. +.IP "\fB\-\-hash\-style=\fR\fIstyle\fR" 4 +.IX Item "--hash-style=style" +Set the type of linker's hash table(s). \fIstyle\fR can be either +\&\f(CW\*(C`sysv\*(C'\fR for classic \s-1ELF\s0 \f(CW\*(C`.hash\*(C'\fR section, \f(CW\*(C`gnu\*(C'\fR for +new style \s-1GNU\s0 \f(CW\*(C`.gnu.hash\*(C'\fR section or \f(CW\*(C`both\*(C'\fR for both +the classic \s-1ELF\s0 \f(CW\*(C`.hash\*(C'\fR and new style \s-1GNU\s0 \f(CW\*(C`.gnu.hash\*(C'\fR +hash tables. The default is \f(CW\*(C`sysv\*(C'\fR. +.IP "\fB\-\-reduce\-memory\-overheads\fR" 4 +.IX Item "--reduce-memory-overheads" +This option reduces memory requirements at ld runtime, at the expense of +linking speed. This was introduced to select the old O(n^2) algorithm +for link map file generation, rather than the new O(n) algorithm which uses +about 40% more memory for symbol storage. +.Sp +Another effect of the switch is to set the default hash table size to +1021, which again saves memory at the cost of lengthening the linker's +run time. This is not done however if the \fB\-\-hash\-size\fR switch +has been used. +.Sp +The \fB\-\-reduce\-memory\-overheads\fR switch may be also be used to +enable other tradeoffs in future versions of the linker. +.PP +The i386 \s-1PE\s0 linker supports the \fB\-shared\fR option, which causes +the output to be a dynamically linked library (\s-1DLL\s0) instead of a +normal executable. You should name the output \f(CW\*(C`*.dll\*(C'\fR when you +use this option. In addition, the linker fully supports the standard +\&\f(CW\*(C`*.def\*(C'\fR files, which may be specified on the linker command line +like an object file (in fact, it should precede archives it exports +symbols from, to ensure that they get linked in, just like a normal +object file). +.PP +In addition to the options common to all targets, the i386 \s-1PE\s0 linker +support additional command line options that are specific to the i386 +\&\s-1PE\s0 target. Options that take values may be separated from their +values by either a space or an equals sign. +.IP "\fB\-\-add\-stdcall\-alias\fR" 4 +.IX Item "--add-stdcall-alias" +If given, symbols with a stdcall suffix (@\fInn\fR) will be exported +as-is and also with the suffix stripped. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-base\-file\fR \fIfile\fR" 4 +.IX Item "--base-file file" +Use \fIfile\fR as the name of a file in which to save the base +addresses of all the relocations needed for generating DLLs with +\&\fIdlltool\fR. +[This is an i386 \s-1PE\s0 specific option] +.IP "\fB\-\-dll\fR" 4 +.IX Item "--dll" +Create a \s-1DLL\s0 instead of a regular executable. You may also use +\&\fB\-shared\fR or specify a \f(CW\*(C`LIBRARY\*(C'\fR in a given \f(CW\*(C`.def\*(C'\fR +file. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-enable\-stdcall\-fixup\fR" 4 +.IX Item "--enable-stdcall-fixup" +.PD 0 +.IP "\fB\-\-disable\-stdcall\-fixup\fR" 4 +.IX Item "--disable-stdcall-fixup" +.PD +If the link finds a symbol that it cannot resolve, it will attempt to +do \*(L"fuzzy linking\*(R" by looking for another defined symbol that differs +only in the format of the symbol name (cdecl vs stdcall) and will +resolve that symbol by linking to the match. For example, the +undefined symbol \f(CW\*(C`_foo\*(C'\fR might be linked to the function +\&\f(CW\*(C`_foo@12\*(C'\fR, or the undefined symbol \f(CW\*(C`_bar@16\*(C'\fR might be linked +to the function \f(CW\*(C`_bar\*(C'\fR. When the linker does this, it prints a +warning, since it normally should have failed to link, but sometimes +import libraries generated from third-party dlls may need this feature +to be usable. If you specify \fB\-\-enable\-stdcall\-fixup\fR, this +feature is fully enabled and warnings are not printed. If you specify +\&\fB\-\-disable\-stdcall\-fixup\fR, this feature is disabled and such +mismatches are considered to be errors. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-export\-all\-symbols\fR" 4 +.IX Item "--export-all-symbols" +If given, all global symbols in the objects used to build a \s-1DLL\s0 will +be exported by the \s-1DLL\s0. Note that this is the default if there +otherwise wouldn't be any exported symbols. When symbols are +explicitly exported via \s-1DEF\s0 files or implicitly exported via function +attributes, the default is to not export anything else unless this +option is given. Note that the symbols \f(CW\*(C`DllMain@12\*(C'\fR, +\&\f(CW\*(C`DllEntryPoint@0\*(C'\fR, \f(CW\*(C`DllMainCRTStartup@12\*(C'\fR, and +\&\f(CW\*(C`impure_ptr\*(C'\fR will not be automatically +exported. Also, symbols imported from other DLLs will not be +re-exported, nor will symbols specifying the \s-1DLL\s0's internal layout +such as those beginning with \f(CW\*(C`_head_\*(C'\fR or ending with +\&\f(CW\*(C`_iname\*(C'\fR. In addition, no symbols from \f(CW\*(C`libgcc\*(C'\fR, +\&\f(CW\*(C`libstd++\*(C'\fR, \f(CW\*(C`libmingw32\*(C'\fR, or \f(CW\*(C`crtX.o\*(C'\fR will be exported. +Symbols whose names begin with \f(CW\*(C`_\|_rtti_\*(C'\fR or \f(CW\*(C`_\|_builtin_\*(C'\fR will +not be exported, to help with \*(C+ DLLs. Finally, there is an +extensive list of cygwin-private symbols that are not exported +(obviously, this applies on when building DLLs for cygwin targets). +These cygwin-excludes are: \f(CW\*(C`_cygwin_dll_entry@12\*(C'\fR, +\&\f(CW\*(C`_cygwin_crt0_common@8\*(C'\fR, \f(CW\*(C`_cygwin_noncygwin_dll_entry@12\*(C'\fR, +\&\f(CW\*(C`_fmode\*(C'\fR, \f(CW\*(C`_impure_ptr\*(C'\fR, \f(CW\*(C`cygwin_attach_dll\*(C'\fR, +\&\f(CW\*(C`cygwin_premain0\*(C'\fR, \f(CW\*(C`cygwin_premain1\*(C'\fR, \f(CW\*(C`cygwin_premain2\*(C'\fR, +\&\f(CW\*(C`cygwin_premain3\*(C'\fR, and \f(CW\*(C`environ\*(C'\fR. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-exclude\-symbols\fR \fIsymbol\fR\fB,\fR\fIsymbol\fR\fB,...\fR" 4 +.IX Item "--exclude-symbols symbol,symbol,..." +Specifies a list of symbols which should not be automatically +exported. The symbol names may be delimited by commas or colons. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-file\-alignment\fR" 4 +.IX Item "--file-alignment" +Specify the file alignment. Sections in the file will always begin at +file offsets which are multiples of this number. This defaults to +512. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-heap\fR \fIreserve\fR" 4 +.IX Item "--heap reserve" +.PD 0 +.IP "\fB\-\-heap\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 4 +.IX Item "--heap reserve,commit" +.PD +Specify the amount of memory to reserve (and optionally commit) to be +used as heap for this program. The default is 1Mb reserved, 4K +committed. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-image\-base\fR \fIvalue\fR" 4 +.IX Item "--image-base value" +Use \fIvalue\fR as the base address of your program or dll. This is +the lowest memory location that will be used when your program or dll +is loaded. To reduce the need to relocate and improve performance of +your dlls, each should have a unique base address and not overlap any +other dlls. The default is 0x400000 for executables, and 0x10000000 +for dlls. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-kill\-at\fR" 4 +.IX Item "--kill-at" +If given, the stdcall suffixes (@\fInn\fR) will be stripped from +symbols before they are exported. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-large\-address\-aware\fR" 4 +.IX Item "--large-address-aware" +If given, the appropriate bit in the \*(L"Characteristics\*(R" field of the \s-1COFF\s0 +header is set to indicate that this executable supports virtual addresses +greater than 2 gigabytes. This should be used in conjunction with the /3GB +or /USERVA=\fIvalue\fR megabytes switch in the \*(L"[operating systems]\*(R" +section of the \s-1BOOT\s0.INI. Otherwise, this bit has no effect. +[This option is specific to \s-1PE\s0 targeted ports of the linker] +.IP "\fB\-\-major\-image\-version\fR \fIvalue\fR" 4 +.IX Item "--major-image-version value" +Sets the major number of the \*(L"image version\*(R". Defaults to 1. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-major\-os\-version\fR \fIvalue\fR" 4 +.IX Item "--major-os-version value" +Sets the major number of the \*(L"os version\*(R". Defaults to 4. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-major\-subsystem\-version\fR \fIvalue\fR" 4 +.IX Item "--major-subsystem-version value" +Sets the major number of the \*(L"subsystem version\*(R". Defaults to 4. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-minor\-image\-version\fR \fIvalue\fR" 4 +.IX Item "--minor-image-version value" +Sets the minor number of the \*(L"image version\*(R". Defaults to 0. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-minor\-os\-version\fR \fIvalue\fR" 4 +.IX Item "--minor-os-version value" +Sets the minor number of the \*(L"os version\*(R". Defaults to 0. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-minor\-subsystem\-version\fR \fIvalue\fR" 4 +.IX Item "--minor-subsystem-version value" +Sets the minor number of the \*(L"subsystem version\*(R". Defaults to 0. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-output\-def\fR \fIfile\fR" 4 +.IX Item "--output-def file" +The linker will create the file \fIfile\fR which will contain a \s-1DEF\s0 +file corresponding to the \s-1DLL\s0 the linker is generating. This \s-1DEF\s0 file +(which should be called \f(CW\*(C`*.def\*(C'\fR) may be used to create an import +library with \f(CW\*(C`dlltool\*(C'\fR or may be used as a reference to +automatically or implicitly exported symbols. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-out\-implib\fR \fIfile\fR" 4 +.IX Item "--out-implib file" +The linker will create the file \fIfile\fR which will contain an +import lib corresponding to the \s-1DLL\s0 the linker is generating. This +import lib (which should be called \f(CW\*(C`*.dll.a\*(C'\fR or \f(CW\*(C`*.a\*(C'\fR +may be used to link clients against the generated \s-1DLL\s0; this behaviour +makes it possible to skip a separate \f(CW\*(C`dlltool\*(C'\fR import library +creation step. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-enable\-auto\-image\-base\fR" 4 +.IX Item "--enable-auto-image-base" +Automatically choose the image base for DLLs, unless one is specified +using the \f(CW\*(C`\-\-image\-base\*(C'\fR argument. By using a hash generated +from the dllname to create unique image bases for each \s-1DLL\s0, in-memory +collisions and relocations which can delay program execution are +avoided. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-disable\-auto\-image\-base\fR" 4 +.IX Item "--disable-auto-image-base" +Do not automatically generate a unique image base. If there is no +user-specified image base (\f(CW\*(C`\-\-image\-base\*(C'\fR) then use the platform +default. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-dll\-search\-prefix\fR \fIstring\fR" 4 +.IX Item "--dll-search-prefix string" +When linking dynamically to a dll without an import library, +search for \f(CW\*(C`<string><basename>.dll\*(C'\fR in preference to +\&\f(CW\*(C`lib<basename>.dll\*(C'\fR. This behaviour allows easy distinction +between DLLs built for the various \*(L"subplatforms\*(R": native, cygwin, +uwin, pw, etc. For instance, cygwin DLLs typically use +\&\f(CW\*(C`\-\-dll\-search\-prefix=cyg\*(C'\fR. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-enable\-auto\-import\fR" 4 +.IX Item "--enable-auto-import" +Do sophisticated linking of \f(CW\*(C`_symbol\*(C'\fR to \f(CW\*(C`_\|_imp_\|_symbol\*(C'\fR for +\&\s-1DATA\s0 imports from DLLs, and create the necessary thunking symbols when +building the import libraries with those \s-1DATA\s0 exports. Note: Use of the +\&'auto\-import' extension will cause the text section of the image file +to be made writable. This does not conform to the PE-COFF format +specification published by Microsoft. +.Sp +Using 'auto\-import' generally will 'just work' \*(-- but sometimes you may +see this message: +.Sp +"variable '<var>' can't be auto-imported. Please read the +documentation for ld's \f(CW\*(C`\-\-enable\-auto\-import\*(C'\fR for details." +.Sp +This message occurs when some (sub)expression accesses an address +ultimately given by the sum of two constants (Win32 import tables only +allow one). Instances where this may occur include accesses to member +fields of struct variables imported from a \s-1DLL\s0, as well as using a +constant index into an array variable imported from a \s-1DLL\s0. Any +multiword variable (arrays, structs, long long, etc) may trigger +this error condition. However, regardless of the exact data type +of the offending exported variable, ld will always detect it, issue +the warning, and exit. +.Sp +There are several ways to address this difficulty, regardless of the +data type of the exported variable: +.Sp +One way is to use \-\-enable\-runtime\-pseudo\-reloc switch. This leaves the task +of adjusting references in your client code for runtime environment, so +this method works only when runtime environment supports this feature. +.Sp +A second solution is to force one of the 'constants' to be a variable \*(-- +that is, unknown and un-optimizable at compile time. For arrays, +there are two possibilities: a) make the indexee (the array's address) +a variable, or b) make the 'constant' index a variable. Thus: +.Sp +.Vb 3 +\& extern type extern_array[]; +\& extern_array[1] \-\-> +\& { volatile type *t=extern_array; t[1] } +.Ve +.Sp +or +.Sp +.Vb 3 +\& extern type extern_array[]; +\& extern_array[1] \-\-> +\& { volatile int t=1; extern_array[t] } +.Ve +.Sp +For structs (and most other multiword data types) the only option +is to make the struct itself (or the long long, or the ...) variable: +.Sp +.Vb 3 +\& extern struct s extern_struct; +\& extern_struct.field \-\-> +\& { volatile struct s *t=&extern_struct; t\->field } +.Ve +.Sp +or +.Sp +.Vb 3 +\& extern long long extern_ll; +\& extern_ll \-\-> +\& { volatile long long * local_ll=&extern_ll; *local_ll } +.Ve +.Sp +A third method of dealing with this difficulty is to abandon +\&'auto\-import' for the offending symbol and mark it with +\&\f(CW\*(C`_\|_declspec(dllimport)\*(C'\fR. However, in practise that +requires using compile-time #defines to indicate whether you are +building a \s-1DLL\s0, building client code that will link to the \s-1DLL\s0, or +merely building/linking to a static library. In making the choice +between the various methods of resolving the 'direct address with +constant offset' problem, you should consider typical real-world usage: +.Sp +Original: +.Sp +.Vb 7 +\& \-\-foo.h +\& extern int arr[]; +\& \-\-foo.c +\& #include "foo.h" +\& void main(int argc, char **argv){ +\& printf("%d\en",arr[1]); +\& } +.Ve +.Sp +Solution 1: +.Sp +.Vb 9 +\& \-\-foo.h +\& extern int arr[]; +\& \-\-foo.c +\& #include "foo.h" +\& void main(int argc, char **argv){ +\& /* This workaround is for win32 and cygwin; do not "optimize" */ +\& volatile int *parr = arr; +\& printf("%d\en",parr[1]); +\& } +.Ve +.Sp +Solution 2: +.Sp +.Vb 10 +\& \-\-foo.h +\& /* Note: auto\-export is assumed (no _\|_declspec(dllexport)) */ +\& #if (defined(_WIN32) || defined(_\|_CYGWIN_\|_)) && \e +\& !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC)) +\& #define FOO_IMPORT _\|_declspec(dllimport) +\& #else +\& #define FOO_IMPORT +\& #endif +\& extern FOO_IMPORT int arr[]; +\& \-\-foo.c +\& #include "foo.h" +\& void main(int argc, char **argv){ +\& printf("%d\en",arr[1]); +\& } +.Ve +.Sp +A fourth way to avoid this problem is to re-code your +library to use a functional interface rather than a data interface +for the offending variables (e.g. \fIset_foo()\fR and \fIget_foo()\fR accessor +functions). +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-disable\-auto\-import\fR" 4 +.IX Item "--disable-auto-import" +Do not attempt to do sophisticated linking of \f(CW\*(C`_symbol\*(C'\fR to +\&\f(CW\*(C`_\|_imp_\|_symbol\*(C'\fR for \s-1DATA\s0 imports from DLLs. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-enable\-runtime\-pseudo\-reloc\fR" 4 +.IX Item "--enable-runtime-pseudo-reloc" +If your code contains expressions described in \-\-enable\-auto\-import section, +that is, \s-1DATA\s0 imports from \s-1DLL\s0 with non-zero offset, this switch will create +a vector of 'runtime pseudo relocations' which can be used by runtime +environment to adjust references to such data in your client code. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-disable\-runtime\-pseudo\-reloc\fR" 4 +.IX Item "--disable-runtime-pseudo-reloc" +Do not create pseudo relocations for non-zero offset \s-1DATA\s0 imports from +DLLs. This is the default. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-enable\-extra\-pe\-debug\fR" 4 +.IX Item "--enable-extra-pe-debug" +Show additional debug info related to auto-import symbol thunking. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-section\-alignment\fR" 4 +.IX Item "--section-alignment" +Sets the section alignment. Sections in memory will always begin at +addresses which are a multiple of this number. Defaults to 0x1000. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-stack\fR \fIreserve\fR" 4 +.IX Item "--stack reserve" +.PD 0 +.IP "\fB\-\-stack\fR \fIreserve\fR\fB,\fR\fIcommit\fR" 4 +.IX Item "--stack reserve,commit" +.PD +Specify the amount of memory to reserve (and optionally commit) to be +used as stack for this program. The default is 2Mb reserved, 4K +committed. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.IP "\fB\-\-subsystem\fR \fIwhich\fR" 4 +.IX Item "--subsystem which" +.PD 0 +.IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR" 4 +.IX Item "--subsystem which:major" +.IP "\fB\-\-subsystem\fR \fIwhich\fR\fB:\fR\fImajor\fR\fB.\fR\fIminor\fR" 4 +.IX Item "--subsystem which:major.minor" +.PD +Specifies the subsystem under which your program will execute. The +legal values for \fIwhich\fR are \f(CW\*(C`native\*(C'\fR, \f(CW\*(C`windows\*(C'\fR, +\&\f(CW\*(C`console\*(C'\fR, \f(CW\*(C`posix\*(C'\fR, and \f(CW\*(C`xbox\*(C'\fR. You may optionally set +the subsystem version also. Numeric values are also accepted for +\&\fIwhich\fR. +[This option is specific to the i386 \s-1PE\s0 targeted port of the linker] +.PP +The 68HC11 and 68HC12 linkers support specific options to control the +memory bank switching mapping and trampoline code generation. +.IP "\fB\-\-no\-trampoline\fR" 4 +.IX Item "--no-trampoline" +This option disables the generation of trampoline. By default a trampoline +is generated for each far function which is called using a \f(CW\*(C`jsr\*(C'\fR +instruction (this happens when a pointer to a far function is taken). +.IP "\fB\-\-bank\-window\fR \fIname\fR" 4 +.IX Item "--bank-window name" +This option indicates to the linker the name of the memory region in +the \fB\s-1MEMORY\s0\fR specification that describes the memory bank window. +The definition of such region is then used by the linker to compute +paging and addresses within the memory window. +.SH "ENVIRONMENT" +.IX Header "ENVIRONMENT" +You can change the behaviour of \fBld\fR with the environment variables +\&\f(CW\*(C`GNUTARGET\*(C'\fR, +\&\f(CW\*(C`LDEMULATION\*(C'\fR and \f(CW\*(C`COLLECT_NO_DEMANGLE\*(C'\fR. +.PP +\&\f(CW\*(C`GNUTARGET\*(C'\fR determines the input-file object format if you don't +use \fB\-b\fR (or its synonym \fB\-\-format\fR). Its value should be one +of the \s-1BFD\s0 names for an input format. If there is no +\&\f(CW\*(C`GNUTARGET\*(C'\fR in the environment, \fBld\fR uses the natural format +of the target. If \f(CW\*(C`GNUTARGET\*(C'\fR is set to \f(CW\*(C`default\*(C'\fR then \s-1BFD\s0 +attempts to discover the input format by examining binary input files; +this method often succeeds, but there are potential ambiguities, since +there is no method of ensuring that the magic number used to specify +object-file formats is unique. However, the configuration procedure for +\&\s-1BFD\s0 on each system places the conventional format for that system first +in the search-list, so ambiguities are resolved in favor of convention. +.PP +\&\f(CW\*(C`LDEMULATION\*(C'\fR determines the default emulation if you don't use the +\&\fB\-m\fR option. The emulation can affect various aspects of linker +behaviour, particularly the default linker script. You can list the +available emulations with the \fB\-\-verbose\fR or \fB\-V\fR options. If +the \fB\-m\fR option is not used, and the \f(CW\*(C`LDEMULATION\*(C'\fR environment +variable is not defined, the default emulation depends upon how the +linker was configured. +.PP +Normally, the linker will default to demangling symbols. However, if +\&\f(CW\*(C`COLLECT_NO_DEMANGLE\*(C'\fR is set in the environment, then it will +default to not demangling symbols. This environment variable is used in +a similar fashion by the \f(CW\*(C`gcc\*(C'\fR linker wrapper program. The default +may be overridden by the \fB\-\-demangle\fR and \fB\-\-no\-demangle\fR +options. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIar\fR\|(1), \fInm\fR\|(1), \fIobjcopy\fR\|(1), \fIobjdump\fR\|(1), \fIreadelf\fR\|(1) and +the Info entries for \fIbinutils\fR and +\&\fIld\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 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 included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/gnu/usr.bin/binutils/libbfd/Makefile b/gnu/usr.bin/binutils/libbfd/Makefile new file mode 100644 index 000000000000..3132cd83acce --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/Makefile @@ -0,0 +1,109 @@ +# $FreeBSD$ + +.include "../Makefile.inc0" + +.PATH: ${SRCDIR}/bfd ${SRCDIR}/opcodes + +LIB= bfd +SRCS+= archive.c \ + archive64.c \ + archures.c \ + bfd.c \ + bfdio.c \ + bfdver.h \ + bfdwin.c \ + binary.c \ + cache.c \ + coffgen.c \ + config.h \ + corefile.c \ + dwarf1.c \ + dwarf2.c \ + elf-attrs.c \ + elf-eh-frame.c \ + elf-strtab.c \ + elf-vxworks.c \ + elf.c \ + format.c \ + hash.c \ + ihex.c \ + init.c \ + libbfd.c \ + linker.c \ + merge.c \ + opncls.c \ + reloc.c \ + section.c \ + simple.c \ + srec.c \ + stab-syms.c \ + stabs.c \ + syms.c \ + targets.c \ + targmatch.h \ + tekhex.c +.if ${TARGET_ARCH} == "sparc64" +WARNS?= 2 +.endif +CFLAGS+= -D_GNU_SOURCE +CFLAGS+= -I${SRCDIR}/bfd +INTERNALLIB= +CLEANFILES+= bfdver.h config.h targmatch.h + +SELARCH= +.if ${TARGET_ARCH} == "amd64" +SELARCH= &bfd_i386_arch +.elif ${TARGET_ARCH} == "sparc64" +SELARCH= &bfd_sparc_arch +.else +.for _a in ${ARCHS} +.if ${SELARCH} == "" +SELARCH+= &bfd_${_a}_arch +.else +SELARCH+= ,&bfd_${_a}_arch +.endif +.endfor +.endif +CFLAGS+= -DSELECT_ARCHITECTURES="${SELARCH}" + +SELVEC= +.for _v in ${VECS} +CFLAGS+= -DHAVE_${_v} +.if ${SELVEC} == "" +SELVEC+= &${_v} +.else +SELVEC+= ,&${_v} +.endif +.endfor +CFLAGS+= -DSELECT_VECS="${SELVEC}" +CFLAGS+= -DDEFAULT_VECTOR=${DEFAULT_VECTOR} +CFLAGS+= -DDEBUGDIR="NULL" + +# XXX:DEO should grab BFD_VERSION_DATE from ${VERSION}... +bfdver.h: Makefile + echo '#define BFD_VERSION 217500000' > ${.TARGET} + echo '#define BFD_VERSION_DATE 20070703' >> ${.TARGET} + echo '#define BFD_VERSION_STRING ${VERSION}' >> ${.TARGET} + echo '#define REPORT_BUGS_TO "<http://www.freebsd.org/support.html>"' >> ${.TARGET} + +targmatch.h: targmatch.sed config.bfd + sed -f ${.ALLSRC:M*.sed} ${.ALLSRC:M*.bfd} > ${.TARGET} + +config.h: config.h.fbsd +.if ${TARGET_ARCH} == "i386" + sed -e 's,!!TRAD_HEADER!!,"hosts/i386bsd.h",g' ${.ALLSRC} > ${.TARGET} +.else + sed -e 's,!!TRAD_HEADER!!,,g' ${.ALLSRC} > ${.TARGET} +.endif + +CLEANFILES+= elf32-target.h elf64-target.h +elf32-target.h: elfxx-target.h + sed -e s/NN/32/g ${.ALLSRC} > ${.TARGET} + +elf64-target.h: elfxx-target.h + sed -e s/NN/64/g ${.ALLSRC} > ${.TARGET} + +# avoid cicular dependency +GENDIRDEPS_FILTER+= N*/nm + +.include <bsd.lib.mk> diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.amd64 b/gnu/usr.bin/binutils/libbfd/Makefile.amd64 new file mode 100644 index 000000000000..31ad0d9302be --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/Makefile.amd64 @@ -0,0 +1,29 @@ +# $FreeBSD$ + +.include "${.CURDIR}/Makefile.i386" + +# Get the i386 VECS. +I386_VECS:= ${VECS} + +DEFAULT_VECTOR= bfd_elf64_x86_64_freebsd_vec + +SRCS+= elf64-x86-64.c \ + efi-app-x86_64.c \ + elf64.c \ + elf64-gen.c \ + elf64-target.h \ + pepigen.c \ + pex64igen.c + +VECS= ${DEFAULT_VECTOR} \ + bfd_elf64_x86_64_vec \ + bfd_efi_app_x86_64_vec \ + ${I386_VECS} + +CLEANFILES+= pepigen.c pex64igen.c + +pepigen.c: peXXigen.c + sed -e s/XX/pep/g ${.ALLSRC} > ${.TARGET} + +pex64igen.c: peXXigen.c + sed -e s/XX/pex64/g ${.ALLSRC} > ${.TARGET} diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.arm b/gnu/usr.bin/binutils/libbfd/Makefile.arm new file mode 100644 index 000000000000..9d0a12b26a45 --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/Makefile.arm @@ -0,0 +1,21 @@ +# $FreeBSD$ + +.if ${TARGET_ARCH:Marm*eb} != "" +DEFAULT_VECTOR= bfd_elf32_bigarm_vec +.else +DEFAULT_VECTOR= bfd_elf32_littlearm_vec +.endif + +SRCS+= cpu-arm.c \ + elf32.c \ + elf32-arm.c \ + elf32-gen.c \ + elf32-target.h \ + elflink.c + +VECS+= ${DEFAULT_VECTOR} +.if ${TARGET_ARCH:Marm*eb} != "" +VECS+= bfd_elf32_littlearm_vec +.else +VECS+= bfd_elf32_bigarm_vec +.endif diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.depend b/gnu/usr.bin/binutils/libbfd/Makefile.depend new file mode 100644 index 000000000000..18be76b0cb6f --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/Makefile.depend @@ -0,0 +1,13 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.depend.host b/gnu/usr.bin/binutils/libbfd/Makefile.depend.host new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/Makefile.depend.host @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.i386 b/gnu/usr.bin/binutils/libbfd/Makefile.i386 new file mode 100644 index 000000000000..e41e30d4deab --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/Makefile.i386 @@ -0,0 +1,21 @@ +# $FreeBSD$ + +DEFAULT_VECTOR= bfd_elf32_i386_freebsd_vec + +SRCS+= cofflink.c \ + cpu-i386.c \ + efi-app-ia32.c \ + elf32-i386.c \ + elf32-target.h \ + elf32.c \ + elflink.c \ + peigen.c + +VECS= ${DEFAULT_VECTOR} \ + bfd_elf32_i386_vec \ + bfd_efi_app_ia32_vec + +peigen.c: peXXigen.c + sed -e s/XX/pe/g ${.ALLSRC} > ${.TARGET} + +CLEANFILES+= peigen.c diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.mips b/gnu/usr.bin/binutils/libbfd/Makefile.mips new file mode 100644 index 000000000000..9a2781a410e2 --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/Makefile.mips @@ -0,0 +1,38 @@ +# $FreeBSD$ + +.if ${TARGET_ARCH:Mmips*el*} != "" +_EMULATION_ENDIAN=little +.else +_EMULATION_ENDIAN=big +.endif + +.if ${TARGET_ARCH:Mmips64*} != "" +DEFAULT_VECTOR= bfd_elf64_trad${_EMULATION_ENDIAN}mips_vec +.elif ${TARGET_ARCH:Mmipsn32*} != "" +DEFAULT_VECTOR= bfd_elf32_ntrad${_EMULATION_ENDIAN}mips_vec +.else +DEFAULT_VECTOR=bfd_elf32_trad${_EMULATION_ENDIAN}mips_vec +.endif + +SRCS+= coff-mips.c \ + cpu-mips.c \ + ecoff.c \ + ecofflink.c \ + elf32.c \ + elf64.c \ + elfn32-mips.c \ + elf32-mips.c \ + elf64-mips.c \ + elfxx-mips.c \ + elf32-target.h \ + elf64-target.h \ + elflink.c + +VECS= bfd_elf32_tradbigmips_vec \ + bfd_elf32_tradlittlemips_vec \ + bfd_elf32_ntradbigmips_vec \ + bfd_elf32_ntradlittlemips_vec \ + bfd_elf64_tradbigmips_vec \ + bfd_elf64_tradlittlemips_vec \ + ecoff_little_vec \ + ecoff_big_vec diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.powerpc b/gnu/usr.bin/binutils/libbfd/Makefile.powerpc new file mode 100644 index 000000000000..aa3e4f477a0e --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/Makefile.powerpc @@ -0,0 +1,19 @@ +# $FreeBSD$ + +ARCHS+= rs6000 + +DEFAULT_VECTOR= bfd_elf32_powerpc_vec + +SRCS+= cpu-powerpc.c \ + cpu-rs6000.c \ + elf32.c \ + elf32-gen.c \ + elf32-ppc.c \ + elf32-target.h \ + elflink.c \ + ppcboot.c \ + xcofflink.c + +VECS+= ${DEFAULT_VECTOR} \ + bfd_elf32_powerpcle_vec \ + ppcboot_vec diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.powerpc64 b/gnu/usr.bin/binutils/libbfd/Makefile.powerpc64 new file mode 100644 index 000000000000..a32e95dd3641 --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/Makefile.powerpc64 @@ -0,0 +1,28 @@ +# $FreeBSD$ + +ARCHS+= rs6000 + +DEFAULT_VECTOR= bfd_elf64_powerpc_vec +NO_WERROR.clang= + +SRCS+= cpu-powerpc.c \ + cpu-rs6000.c \ + elf32.c \ + elf32-gen.c \ + elf32-ppc.c \ + elf32-target.h \ + elflink.c \ + elf64.c \ + elf64-gen.c \ + elf64-ppc.c \ + elf64-target.h \ + elflink.c \ + ppcboot.c \ + xcofflink.c + +VECS+= ${DEFAULT_VECTOR} \ + bfd_elf64_powerpcle_vec \ + bfd_elf32_powerpc_vec \ + bfd_elf32_powerpcle_vec \ + ppcboot_vec + diff --git a/gnu/usr.bin/binutils/libbfd/Makefile.sparc64 b/gnu/usr.bin/binutils/libbfd/Makefile.sparc64 new file mode 100644 index 000000000000..f41c1eb1726a --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/Makefile.sparc64 @@ -0,0 +1,23 @@ +# $FreeBSD$ + +DEFAULT_VECTOR= bfd_elf64_sparc_freebsd_vec + +SRCS+= aout32.c \ + cpu-sparc.c \ + elf32.c \ + elf32-sparc.c \ + elf32-target.h \ + elf64.c \ + elf64-sparc.c \ + elf64-target.h \ + elflink.c \ + elfxx-sparc.c \ + elfxx-sparc.h \ + sparcnetbsd.c \ + sunos.c + +VECS= ${DEFAULT_VECTOR} \ + bfd_elf64_sparc_vec \ + bfd_elf32_sparc_vec \ + sparcnetbsd_vec \ + sunos_big_vec diff --git a/gnu/usr.bin/binutils/libbfd/bfd.h b/gnu/usr.bin/binutils/libbfd/bfd.h new file mode 100644 index 000000000000..c6fcc4780c44 --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/bfd.h @@ -0,0 +1,5410 @@ +/* $FreeBSD$ */ + +/* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically + generated from "bfd-in.h", "init.c", "opncls.c", "libbfd.c", + "bfdio.c", "bfdwin.c", "section.c", "archures.c", "reloc.c", + "syms.c", "bfd.c", "archive.c", "corefile.c", "targets.c", "format.c", + "linker.c" and "simple.c". + Run "make headers" in your build bfd/ to regenerate. */ + +/* Main header file for the bfd library -- portable access to object files. + + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + Free Software Foundation, Inc. + + Contributed by Cygnus Support. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef __BFD_H_SEEN__ +#define __BFD_H_SEEN__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ansidecl.h" +#include "symcat.h" +#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) +#ifndef SABER +/* This hack is to avoid a problem with some strict ANSI C preprocessors. + The problem is, "32_" is not a valid preprocessing token, and we don't + want extra underscores (e.g., "nlm_32_"). The XCONCAT2 macro will + cause the inner CONCAT2 macros to be evaluated first, producing + still-valid pp-tokens. Then the final concatenation can be done. */ +#undef CONCAT4 +#define CONCAT4(a,b,c,d) XCONCAT2(CONCAT2(a,b),CONCAT2(c,d)) +#endif +#endif + +/* This is a utility macro to handle the situation where the code + wants to place a constant string into the code, followed by a + comma and then the length of the string. Doing this by hand + is error prone, so using this macro is safer. The macro will + also safely handle the case where a NULL is passed as the arg. */ +#define STRING_COMMA_LEN(STR) (STR), ((STR) ? sizeof (STR) - 1 : 0) +/* Unfortunately it is not possible to use the STRING_COMMA_LEN macro + to create the arguments to another macro, since the preprocessor + will mis-count the number of arguments to the outer macro (by not + evaluating STRING_COMMA_LEN and so missing the comma). This is a + problem for example when trying to use STRING_COMMA_LEN to build + the arguments to the strncmp() macro. Hence this alternative + definition of strncmp is provided here. + + Note - these macros do NOT work if STR2 is not a constant string. */ +#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0) + /* strcpy() can have a similar problem, but since we know we are + copying a constant string, we can use memcpy which will be faster + since there is no need to check for a NUL byte inside STR. We + can also save time if we do not need to copy the terminating NUL. */ +#define LITMEMCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2) - 1) +#define LITSTRCPY(DEST,STR2) memcpy ((DEST), (STR2), sizeof (STR2)) + + +/* The word size used by BFD on the host. This may be 64 with a 32 + bit target if the host is 64 bit, or if other 64 bit targets have + been selected with --enable-targets, or if --enable-64-bit-bfd. */ +#define BFD_ARCH_SIZE 64 + +#if defined(__i386__) || defined(__powerpc__) || defined(__arm__) || defined(__mips__) +#define BFD_HOST_64BIT_LONG 0 +#define BFD_HOST_64_BIT long long +#define BFD_HOST_U_64_BIT unsigned long long +#elif defined(__alpha__) || defined(__sparc64__) || defined(__amd64__) || defined(__aarch64__) +#define BFD_HOST_64BIT_LONG 1 +#define BFD_HOST_64_BIT long +#define BFD_HOST_U_64_BIT unsigned long +#else +#error Unsupported architecture/platform. +#endif /* 64-bit host */ + +#define BFD_HOST_LONG_LONG 1 +typedef BFD_HOST_64_BIT bfd_int64_t; +typedef BFD_HOST_U_64_BIT bfd_uint64_t; + +#if BFD_ARCH_SIZE >= 64 +#define BFD64 +#endif + +#ifndef INLINE +#if __GNUC__ >= 2 +#define INLINE __inline__ +#else +#define INLINE +#endif +#endif + +/* Forward declaration. */ +typedef struct bfd bfd; + +/* Boolean type used in bfd. Too many systems define their own + versions of "boolean" for us to safely typedef a "boolean" of + our own. Using an enum for "bfd_boolean" has its own set of + problems, with strange looking casts required to avoid warnings + on some older compilers. Thus we just use an int. + + General rule: Functions which are bfd_boolean return TRUE on + success and FALSE on failure (unless they're a predicate). */ + +typedef int bfd_boolean; +#undef FALSE +#undef TRUE +#define FALSE 0 +#define TRUE 1 + +#ifdef BFD64 + +#ifndef BFD_HOST_64_BIT + #error No 64 bit integer type available +#endif /* ! defined (BFD_HOST_64_BIT) */ + +typedef BFD_HOST_U_64_BIT bfd_vma; +typedef BFD_HOST_64_BIT bfd_signed_vma; +typedef BFD_HOST_U_64_BIT bfd_size_type; +typedef BFD_HOST_U_64_BIT symvalue; + +#ifndef fprintf_vma +#if BFD_HOST_64BIT_LONG +#define sprintf_vma(s,x) sprintf (s, "%016lx", x) +#define fprintf_vma(f,x) fprintf (f, "%016lx", x) +#else +#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff))) +#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff)) +#define fprintf_vma(s,x) \ + fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x)) +#define sprintf_vma(s,x) \ + sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x)) +#endif +#endif + +#else /* not BFD64 */ + +/* Represent a target address. Also used as a generic unsigned type + which is guaranteed to be big enough to hold any arithmetic types + we need to deal with. */ +typedef unsigned long bfd_vma; + +/* A generic signed type which is guaranteed to be big enough to hold any + arithmetic types we need to deal with. Can be assumed to be compatible + with bfd_vma in the same way that signed and unsigned ints are compatible + (as parameters, in assignment, etc). */ +typedef long bfd_signed_vma; + +typedef unsigned long symvalue; +typedef unsigned long bfd_size_type; + +/* Print a bfd_vma x on stream s. */ +#define fprintf_vma(s,x) fprintf (s, "%08lx", x) +#define sprintf_vma(s,x) sprintf (s, "%08lx", x) + +#endif /* not BFD64 */ + +#define HALF_BFD_SIZE_TYPE \ + (((bfd_size_type) 1) << (8 * sizeof (bfd_size_type) / 2)) + +#ifndef BFD_HOST_64_BIT +/* Fall back on a 32 bit type. The idea is to make these types always + available for function return types, but in the case that + BFD_HOST_64_BIT is undefined such a function should abort or + otherwise signal an error. */ +typedef bfd_signed_vma bfd_int64_t; +typedef bfd_vma bfd_uint64_t; +#endif + +/* An offset into a file. BFD always uses the largest possible offset + based on the build time availability of fseek, fseeko, or fseeko64. */ +typedef BFD_HOST_64_BIT file_ptr; +typedef unsigned BFD_HOST_64_BIT ufile_ptr; + +extern void bfd_sprintf_vma (bfd *, char *, bfd_vma); +extern void bfd_fprintf_vma (bfd *, void *, bfd_vma); + +#define printf_vma(x) fprintf_vma(stdout,x) +#define bfd_printf_vma(abfd,x) bfd_fprintf_vma (abfd,stdout,x) + +typedef unsigned int flagword; /* 32 bits of flags */ +typedef unsigned char bfd_byte; + +/* File formats. */ + +typedef enum bfd_format +{ + bfd_unknown = 0, /* File format is unknown. */ + bfd_object, /* Linker/assembler/compiler output. */ + bfd_archive, /* Object archive file. */ + bfd_core, /* Core dump. */ + bfd_type_end /* Marks the end; don't use it! */ +} +bfd_format; + +/* Values that may appear in the flags field of a BFD. These also + appear in the object_flags field of the bfd_target structure, where + they indicate the set of flags used by that backend (not all flags + are meaningful for all object file formats) (FIXME: at the moment, + the object_flags values have mostly just been copied from backend + to another, and are not necessarily correct). */ + +/* No flags. */ +#define BFD_NO_FLAGS 0x00 + +/* BFD contains relocation entries. */ +#define HAS_RELOC 0x01 + +/* BFD is directly executable. */ +#define EXEC_P 0x02 + +/* BFD has line number information (basically used for F_LNNO in a + COFF header). */ +#define HAS_LINENO 0x04 + +/* BFD has debugging information. */ +#define HAS_DEBUG 0x08 + +/* BFD has symbols. */ +#define HAS_SYMS 0x10 + +/* BFD has local symbols (basically used for F_LSYMS in a COFF + header). */ +#define HAS_LOCALS 0x20 + +/* BFD is a dynamic object. */ +#define DYNAMIC 0x40 + +/* Text section is write protected (if D_PAGED is not set, this is + like an a.out NMAGIC file) (the linker sets this by default, but + clears it for -r or -N). */ +#define WP_TEXT 0x80 + +/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the + linker sets this by default, but clears it for -r or -n or -N). */ +#define D_PAGED 0x100 + +/* BFD is relaxable (this means that bfd_relax_section may be able to + do something) (sometimes bfd_relax_section can do something even if + this is not set). */ +#define BFD_IS_RELAXABLE 0x200 + +/* This may be set before writing out a BFD to request using a + traditional format. For example, this is used to request that when + writing out an a.out object the symbols not be hashed to eliminate + duplicates. */ +#define BFD_TRADITIONAL_FORMAT 0x400 + +/* This flag indicates that the BFD contents are actually cached in + memory. If this is set, iostream points to a bfd_in_memory struct. */ +#define BFD_IN_MEMORY 0x800 + +/* The sections in this BFD specify a memory page. */ +#define HAS_LOAD_PAGE 0x1000 + +/* This BFD has been created by the linker and doesn't correspond + to any input file. */ +#define BFD_LINKER_CREATED 0x2000 + +/* Symbols and relocation. */ + +/* A count of carsyms (canonical archive symbols). */ +typedef unsigned long symindex; + +/* How to perform a relocation. */ +typedef const struct reloc_howto_struct reloc_howto_type; + +#define BFD_NO_MORE_SYMBOLS ((symindex) ~0) + +/* General purpose part of a symbol X; + target specific parts are in libcoff.h, libaout.h, etc. */ + +#define bfd_get_section(x) ((x)->section) +#define bfd_get_output_section(x) ((x)->section->output_section) +#define bfd_set_section(x,y) ((x)->section) = (y) +#define bfd_asymbol_base(x) ((x)->section->vma) +#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value) +#define bfd_asymbol_name(x) ((x)->name) +/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/ +#define bfd_asymbol_bfd(x) ((x)->the_bfd) +#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour) + +/* A canonical archive symbol. */ +/* This is a type pun with struct ranlib on purpose! */ +typedef struct carsym +{ + char *name; + file_ptr file_offset; /* Look here to find the file. */ +} +carsym; /* To make these you call a carsymogen. */ + +/* Used in generating armaps (archive tables of contents). + Perhaps just a forward definition would do? */ +struct orl /* Output ranlib. */ +{ + char **name; /* Symbol name. */ + union + { + file_ptr pos; + bfd *abfd; + } u; /* bfd* or file position. */ + int namidx; /* Index into string table. */ +}; + +/* Linenumber stuff. */ +typedef struct lineno_cache_entry +{ + unsigned int line_number; /* Linenumber from start of function. */ + union + { + struct bfd_symbol *sym; /* Function name. */ + bfd_vma offset; /* Offset into section. */ + } u; +} +alent; + +/* Object and core file sections. */ + +#define align_power(addr, align) \ + (((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align))) + +typedef struct bfd_section *sec_ptr; + +#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0) +#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0) +#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0) +#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0) +#define bfd_section_name(bfd, ptr) ((ptr)->name) +#define bfd_section_size(bfd, ptr) ((ptr)->size) +#define bfd_get_section_size(ptr) ((ptr)->size) +#define bfd_section_vma(bfd, ptr) ((ptr)->vma) +#define bfd_section_lma(bfd, ptr) ((ptr)->lma) +#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power) +#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0) +#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata) + +#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) + +#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE) +#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE) +#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE) +/* Find the address one past the end of SEC. */ +#define bfd_get_section_limit(bfd, sec) \ + (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \ + / bfd_octets_per_byte (bfd)) + +/* Return TRUE if section has been discarded. */ +#define elf_discarded_section(sec) \ + (!bfd_is_abs_section (sec) \ + && bfd_is_abs_section ((sec)->output_section) \ + && (sec)->sec_info_type != ELF_INFO_TYPE_MERGE \ + && (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS) + +/* Forward define. */ +struct stat; + +typedef enum bfd_print_symbol +{ + bfd_print_symbol_name, + bfd_print_symbol_more, + bfd_print_symbol_all +} bfd_print_symbol_type; + +/* Information about a symbol that nm needs. */ + +typedef struct _symbol_info +{ + symvalue value; + char type; + const char *name; /* Symbol name. */ + unsigned char stab_type; /* Stab type. */ + char stab_other; /* Stab other. */ + short stab_desc; /* Stab desc. */ + const char *stab_name; /* String for stab type. */ +} symbol_info; + +/* Get the name of a stabs type code. */ + +extern const char *bfd_get_stab_name (int); + +/* Hash table routines. There is no way to free up a hash table. */ + +/* An element in the hash table. Most uses will actually use a larger + structure, and an instance of this will be the first field. */ + +struct bfd_hash_entry +{ + /* Next entry for this hash code. */ + struct bfd_hash_entry *next; + /* String being hashed. */ + const char *string; + /* Hash code. This is the full hash code, not the index into the + table. */ + unsigned long hash; +}; + +/* A hash table. */ + +struct bfd_hash_table +{ + /* The hash array. */ + struct bfd_hash_entry **table; + /* A function used to create new elements in the hash table. The + first entry is itself a pointer to an element. When this + function is first invoked, this pointer will be NULL. However, + having the pointer permits a hierarchy of method functions to be + built each of which calls the function in the superclass. Thus + each function should be written to allocate a new block of memory + only if the argument is NULL. */ + struct bfd_hash_entry *(*newfunc) + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); + /* An objalloc for this hash table. This is a struct objalloc *, + but we use void * to avoid requiring the inclusion of objalloc.h. */ + void *memory; + /* The number of slots in the hash table. */ + unsigned int size; + /* The number of entries in the hash table. */ + unsigned int count; + /* The size of elements. */ + unsigned int entsize; + /* If non-zero, don't grow the hash table. */ + unsigned int frozen:1; +}; + +/* Initialize a hash table. */ +extern bfd_boolean bfd_hash_table_init + (struct bfd_hash_table *, + struct bfd_hash_entry *(*) (struct bfd_hash_entry *, + struct bfd_hash_table *, + const char *), + unsigned int); + +/* Initialize a hash table specifying a size. */ +extern bfd_boolean bfd_hash_table_init_n + (struct bfd_hash_table *, + struct bfd_hash_entry *(*) (struct bfd_hash_entry *, + struct bfd_hash_table *, + const char *), + unsigned int, unsigned int); + +/* Free up a hash table. */ +extern void bfd_hash_table_free + (struct bfd_hash_table *); + +/* Look up a string in a hash table. If CREATE is TRUE, a new entry + will be created for this string if one does not already exist. The + COPY argument must be TRUE if this routine should copy the string + into newly allocated memory when adding an entry. */ +extern struct bfd_hash_entry *bfd_hash_lookup + (struct bfd_hash_table *, const char *, bfd_boolean create, + bfd_boolean copy); + +/* Replace an entry in a hash table. */ +extern void bfd_hash_replace + (struct bfd_hash_table *, struct bfd_hash_entry *old, + struct bfd_hash_entry *nw); + +/* Base method for creating a hash table entry. */ +extern struct bfd_hash_entry *bfd_hash_newfunc + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); + +/* Grab some space for a hash table entry. */ +extern void *bfd_hash_allocate + (struct bfd_hash_table *, unsigned int); + +/* Traverse a hash table in a random order, calling a function on each + element. If the function returns FALSE, the traversal stops. The + INFO argument is passed to the function. */ +extern void bfd_hash_traverse + (struct bfd_hash_table *, + bfd_boolean (*) (struct bfd_hash_entry *, void *), + void *info); + +/* Allows the default size of a hash table to be configured. New hash + tables allocated using bfd_hash_table_init will be created with + this size. */ +extern void bfd_hash_set_default_size (bfd_size_type); + +/* This structure is used to keep track of stabs in sections + information while linking. */ + +struct stab_info +{ + /* A hash table used to hold stabs strings. */ + struct bfd_strtab_hash *strings; + /* The header file hash table. */ + struct bfd_hash_table includes; + /* The first .stabstr section. */ + struct bfd_section *stabstr; +}; + +#define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table + +/* User program access to BFD facilities. */ + +/* Direct I/O routines, for programs which know more about the object + file than BFD does. Use higher level routines if possible. */ + +extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *); +extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *); +extern int bfd_seek (bfd *, file_ptr, int); +extern file_ptr bfd_tell (bfd *); +extern int bfd_flush (bfd *); +extern int bfd_stat (bfd *, struct stat *); + +/* Deprecated old routines. */ +#if __GNUC__ +#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \ + (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \ + bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD))) +#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \ + (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \ + bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD))) +#else +#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \ + (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \ + bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD))) +#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \ + (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\ + bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD))) +#endif +extern void warn_deprecated (const char *, const char *, int, const char *); + +/* Cast from const char * to char * so that caller can assign to + a char * without a warning. */ +#define bfd_get_filename(abfd) ((char *) (abfd)->filename) +#define bfd_get_cacheable(abfd) ((abfd)->cacheable) +#define bfd_get_format(abfd) ((abfd)->format) +#define bfd_get_target(abfd) ((abfd)->xvec->name) +#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour) +#define bfd_family_coff(abfd) \ + (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \ + bfd_get_flavour (abfd) == bfd_target_xcoff_flavour) +#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG) +#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE) +#define bfd_header_big_endian(abfd) \ + ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG) +#define bfd_header_little_endian(abfd) \ + ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE) +#define bfd_get_file_flags(abfd) ((abfd)->flags) +#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags) +#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags) +#define bfd_my_archive(abfd) ((abfd)->my_archive) +#define bfd_has_map(abfd) ((abfd)->has_armap) + +#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types) +#define bfd_usrdata(abfd) ((abfd)->usrdata) + +#define bfd_get_start_address(abfd) ((abfd)->start_address) +#define bfd_get_symcount(abfd) ((abfd)->symcount) +#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols) +#define bfd_count_sections(abfd) ((abfd)->section_count) + +#define bfd_get_dynamic_symcount(abfd) ((abfd)->dynsymcount) + +#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char) + +#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE) + +extern bfd_boolean bfd_cache_close + (bfd *abfd); +/* NB: This declaration should match the autogenerated one in libbfd.h. */ + +extern bfd_boolean bfd_cache_close_all (void); + +extern bfd_boolean bfd_record_phdr + (bfd *, unsigned long, bfd_boolean, flagword, bfd_boolean, bfd_vma, + bfd_boolean, bfd_boolean, unsigned int, struct bfd_section **); + +/* Byte swapping routines. */ + +bfd_uint64_t bfd_getb64 (const void *); +bfd_uint64_t bfd_getl64 (const void *); +bfd_int64_t bfd_getb_signed_64 (const void *); +bfd_int64_t bfd_getl_signed_64 (const void *); +bfd_vma bfd_getb32 (const void *); +bfd_vma bfd_getl32 (const void *); +bfd_signed_vma bfd_getb_signed_32 (const void *); +bfd_signed_vma bfd_getl_signed_32 (const void *); +bfd_vma bfd_getb16 (const void *); +bfd_vma bfd_getl16 (const void *); +bfd_signed_vma bfd_getb_signed_16 (const void *); +bfd_signed_vma bfd_getl_signed_16 (const void *); +void bfd_putb64 (bfd_uint64_t, void *); +void bfd_putl64 (bfd_uint64_t, void *); +void bfd_putb32 (bfd_vma, void *); +void bfd_putl32 (bfd_vma, void *); +void bfd_putb16 (bfd_vma, void *); +void bfd_putl16 (bfd_vma, void *); + +/* Byte swapping routines which take size and endiannes as arguments. */ + +bfd_uint64_t bfd_get_bits (const void *, int, bfd_boolean); +void bfd_put_bits (bfd_uint64_t, void *, int, bfd_boolean); + +extern bfd_boolean bfd_section_already_linked_table_init (void); +extern void bfd_section_already_linked_table_free (void); + +/* Externally visible ECOFF routines. */ + +#if defined(__STDC__) || defined(ALMOST_STDC) +struct ecoff_debug_info; +struct ecoff_debug_swap; +struct ecoff_extr; +struct bfd_symbol; +struct bfd_link_info; +struct bfd_link_hash_entry; +struct bfd_elf_version_tree; +#endif +extern bfd_vma bfd_ecoff_get_gp_value + (bfd * abfd); +extern bfd_boolean bfd_ecoff_set_gp_value + (bfd *abfd, bfd_vma gp_value); +extern bfd_boolean bfd_ecoff_set_regmasks + (bfd *abfd, unsigned long gprmask, unsigned long fprmask, + unsigned long *cprmask); +extern void *bfd_ecoff_debug_init + (bfd *output_bfd, struct ecoff_debug_info *output_debug, + const struct ecoff_debug_swap *output_swap, struct bfd_link_info *); +extern void bfd_ecoff_debug_free + (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, + const struct ecoff_debug_swap *output_swap, struct bfd_link_info *); +extern bfd_boolean bfd_ecoff_debug_accumulate + (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, + const struct ecoff_debug_swap *output_swap, bfd *input_bfd, + struct ecoff_debug_info *input_debug, + const struct ecoff_debug_swap *input_swap, struct bfd_link_info *); +extern bfd_boolean bfd_ecoff_debug_accumulate_other + (void *handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, + const struct ecoff_debug_swap *output_swap, bfd *input_bfd, + struct bfd_link_info *); +extern bfd_boolean bfd_ecoff_debug_externals + (bfd *abfd, struct ecoff_debug_info *debug, + const struct ecoff_debug_swap *swap, bfd_boolean relocatable, + bfd_boolean (*get_extr) (struct bfd_symbol *, struct ecoff_extr *), + void (*set_index) (struct bfd_symbol *, bfd_size_type)); +extern bfd_boolean bfd_ecoff_debug_one_external + (bfd *abfd, struct ecoff_debug_info *debug, + const struct ecoff_debug_swap *swap, const char *name, + struct ecoff_extr *esym); +extern bfd_size_type bfd_ecoff_debug_size + (bfd *abfd, struct ecoff_debug_info *debug, + const struct ecoff_debug_swap *swap); +extern bfd_boolean bfd_ecoff_write_debug + (bfd *abfd, struct ecoff_debug_info *debug, + const struct ecoff_debug_swap *swap, file_ptr where); +extern bfd_boolean bfd_ecoff_write_accumulated_debug + (void *handle, bfd *abfd, struct ecoff_debug_info *debug, + const struct ecoff_debug_swap *swap, + struct bfd_link_info *info, file_ptr where); + +/* Externally visible ELF routines. */ + +struct bfd_link_needed_list +{ + struct bfd_link_needed_list *next; + bfd *by; + const char *name; +}; + +enum dynamic_lib_link_class { + DYN_NORMAL = 0, + DYN_AS_NEEDED = 1, + DYN_DT_NEEDED = 2, + DYN_NO_ADD_NEEDED = 4, + DYN_NO_NEEDED = 8 +}; + +enum notice_asneeded_action { + notice_as_needed, + notice_not_needed, + notice_needed +}; + +extern bfd_boolean bfd_elf_record_link_assignment + (bfd *, struct bfd_link_info *, const char *, bfd_boolean, + bfd_boolean); +extern struct bfd_link_needed_list *bfd_elf_get_needed_list + (bfd *, struct bfd_link_info *); +extern bfd_boolean bfd_elf_get_bfd_needed_list + (bfd *, struct bfd_link_needed_list **); +extern bfd_boolean bfd_elf_size_dynamic_sections + (bfd *, const char *, const char *, const char *, const char * const *, + struct bfd_link_info *, struct bfd_section **, + struct bfd_elf_version_tree *); +extern bfd_boolean bfd_elf_size_dynsym_hash_dynstr + (bfd *, struct bfd_link_info *); +extern void bfd_elf_set_dt_needed_name + (bfd *, const char *); +extern const char *bfd_elf_get_dt_soname + (bfd *); +extern void bfd_elf_set_dyn_lib_class + (bfd *, enum dynamic_lib_link_class); +extern int bfd_elf_get_dyn_lib_class + (bfd *); +extern struct bfd_link_needed_list *bfd_elf_get_runpath_list + (bfd *, struct bfd_link_info *); +extern bfd_boolean bfd_elf_discard_info + (bfd *, struct bfd_link_info *); +extern unsigned int _bfd_elf_default_action_discarded + (struct bfd_section *); + +/* Return an upper bound on the number of bytes required to store a + copy of ABFD's program header table entries. Return -1 if an error + occurs; bfd_get_error will return an appropriate code. */ +extern long bfd_get_elf_phdr_upper_bound + (bfd *abfd); + +/* Copy ABFD's program header table entries to *PHDRS. The entries + will be stored as an array of Elf_Internal_Phdr structures, as + defined in include/elf/internal.h. To find out how large the + buffer needs to be, call bfd_get_elf_phdr_upper_bound. + + Return the number of program header table entries read, or -1 if an + error occurs; bfd_get_error will return an appropriate code. */ +extern int bfd_get_elf_phdrs + (bfd *abfd, void *phdrs); + +/* Create a new BFD as if by bfd_openr. Rather than opening a file, + reconstruct an ELF file by reading the segments out of remote memory + based on the ELF file header at EHDR_VMA and the ELF program headers it + points to. If not null, *LOADBASEP is filled in with the difference + between the VMAs from which the segments were read, and the VMAs the + file headers (and hence BFD's idea of each section's VMA) put them at. + + The function TARGET_READ_MEMORY is called to copy LEN bytes from the + remote memory at target address VMA into the local buffer at MYADDR; it + should return zero on success or an `errno' code on failure. TEMPL must + be a BFD for an ELF target with the word size and byte order found in + the remote memory. */ +extern bfd *bfd_elf_bfd_from_remote_memory + (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep, + int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len)); + +/* Return the arch_size field of an elf bfd, or -1 if not elf. */ +extern int bfd_get_arch_size + (bfd *); + +/* Return TRUE if address "naturally" sign extends, or -1 if not elf. */ +extern int bfd_get_sign_extend_vma + (bfd *); + +extern struct bfd_section *_bfd_elf_tls_setup + (bfd *, struct bfd_link_info *); + +extern void _bfd_fix_excluded_sec_syms + (bfd *, struct bfd_link_info *); + +extern unsigned bfd_m68k_mach_to_features (int); + +extern int bfd_m68k_features_to_mach (unsigned); + +extern bfd_boolean bfd_m68k_elf32_create_embedded_relocs + (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, + char **); + +extern bfd_boolean bfd_bfin_elf32_create_embedded_relocs + (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, + char **); + +/* SunOS shared library support routines for the linker. */ + +extern struct bfd_link_needed_list *bfd_sunos_get_needed_list + (bfd *, struct bfd_link_info *); +extern bfd_boolean bfd_sunos_record_link_assignment + (bfd *, struct bfd_link_info *, const char *); +extern bfd_boolean bfd_sunos_size_dynamic_sections + (bfd *, struct bfd_link_info *, struct bfd_section **, + struct bfd_section **, struct bfd_section **); + +/* Linux shared library support routines for the linker. */ + +extern bfd_boolean bfd_i386linux_size_dynamic_sections + (bfd *, struct bfd_link_info *); +extern bfd_boolean bfd_m68klinux_size_dynamic_sections + (bfd *, struct bfd_link_info *); +extern bfd_boolean bfd_sparclinux_size_dynamic_sections + (bfd *, struct bfd_link_info *); + +/* mmap hacks */ + +struct _bfd_window_internal; +typedef struct _bfd_window_internal bfd_window_internal; + +typedef struct _bfd_window +{ + /* What the user asked for. */ + void *data; + bfd_size_type size; + /* The actual window used by BFD. Small user-requested read-only + regions sharing a page may share a single window into the object + file. Read-write versions shouldn't until I've fixed things to + keep track of which portions have been claimed by the + application; don't want to give the same region back when the + application wants two writable copies! */ + struct _bfd_window_internal *i; +} +bfd_window; + +extern void bfd_init_window + (bfd_window *); +extern void bfd_free_window + (bfd_window *); +extern bfd_boolean bfd_get_file_window + (bfd *, file_ptr, bfd_size_type, bfd_window *, bfd_boolean); + +/* XCOFF support routines for the linker. */ + +extern bfd_boolean bfd_xcoff_link_record_set + (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_size_type); +extern bfd_boolean bfd_xcoff_import_symbol + (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, bfd_vma, + const char *, const char *, const char *, unsigned int); +extern bfd_boolean bfd_xcoff_export_symbol + (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *); +extern bfd_boolean bfd_xcoff_link_count_reloc + (bfd *, struct bfd_link_info *, const char *); +extern bfd_boolean bfd_xcoff_record_link_assignment + (bfd *, struct bfd_link_info *, const char *); +extern bfd_boolean bfd_xcoff_size_dynamic_sections + (bfd *, struct bfd_link_info *, const char *, const char *, + unsigned long, unsigned long, unsigned long, bfd_boolean, + int, bfd_boolean, bfd_boolean, struct bfd_section **, bfd_boolean); +extern bfd_boolean bfd_xcoff_link_generate_rtinit + (bfd *, const char *, const char *, bfd_boolean); + +/* XCOFF support routines for ar. */ +extern bfd_boolean bfd_xcoff_ar_archive_set_magic + (bfd *, char *); + +/* Externally visible COFF routines. */ + +#if defined(__STDC__) || defined(ALMOST_STDC) +struct internal_syment; +union internal_auxent; +#endif + +extern bfd_boolean bfd_coff_get_syment + (bfd *, struct bfd_symbol *, struct internal_syment *); + +extern bfd_boolean bfd_coff_get_auxent + (bfd *, struct bfd_symbol *, int, union internal_auxent *); + +extern bfd_boolean bfd_coff_set_symbol_class + (bfd *, struct bfd_symbol *, unsigned int); + +extern bfd_boolean bfd_m68k_coff_create_embedded_relocs + (bfd *, struct bfd_link_info *, struct bfd_section *, struct bfd_section *, char **); + +/* ARM VFP11 erratum workaround support. */ +typedef enum +{ + BFD_ARM_VFP11_FIX_DEFAULT, + BFD_ARM_VFP11_FIX_NONE, + BFD_ARM_VFP11_FIX_SCALAR, + BFD_ARM_VFP11_FIX_VECTOR +} bfd_arm_vfp11_fix; + +extern void bfd_elf32_arm_init_maps + (bfd *); + +extern void bfd_elf32_arm_set_vfp11_fix + (bfd *, struct bfd_link_info *); + +extern bfd_boolean bfd_elf32_arm_vfp11_erratum_scan + (bfd *, struct bfd_link_info *); + +extern void bfd_elf32_arm_vfp11_fix_veneer_locations + (bfd *, struct bfd_link_info *); + +/* ARM Interworking support. Called from linker. */ +extern bfd_boolean bfd_arm_allocate_interworking_sections + (struct bfd_link_info *); + +extern bfd_boolean bfd_arm_process_before_allocation + (bfd *, struct bfd_link_info *, int); + +extern bfd_boolean bfd_arm_get_bfd_for_interworking + (bfd *, struct bfd_link_info *); + +/* PE ARM Interworking support. Called from linker. */ +extern bfd_boolean bfd_arm_pe_allocate_interworking_sections + (struct bfd_link_info *); + +extern bfd_boolean bfd_arm_pe_process_before_allocation + (bfd *, struct bfd_link_info *, int); + +extern bfd_boolean bfd_arm_pe_get_bfd_for_interworking + (bfd *, struct bfd_link_info *); + +/* ELF ARM Interworking support. Called from linker. */ +extern bfd_boolean bfd_elf32_arm_allocate_interworking_sections + (struct bfd_link_info *); + +extern bfd_boolean bfd_elf32_arm_process_before_allocation + (bfd *, struct bfd_link_info *); + +void bfd_elf32_arm_set_target_relocs + (bfd *, struct bfd_link_info *, int, char *, int, int, bfd_arm_vfp11_fix, + int, int); + +extern bfd_boolean bfd_elf32_arm_get_bfd_for_interworking + (bfd *, struct bfd_link_info *); + +extern bfd_boolean bfd_elf32_arm_add_glue_sections_to_bfd + (bfd *, struct bfd_link_info *); + +/* ELF ARM mapping symbol support */ +#define BFD_ARM_SPECIAL_SYM_TYPE_MAP (1 << 0) +#define BFD_ARM_SPECIAL_SYM_TYPE_TAG (1 << 1) +#define BFD_ARM_SPECIAL_SYM_TYPE_OTHER (1 << 2) +#define BFD_ARM_SPECIAL_SYM_TYPE_ANY (~0) +extern bfd_boolean bfd_is_arm_special_symbol_name + (const char * name, int type); + +extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int); + +/* ARM Note section processing. */ +extern bfd_boolean bfd_arm_merge_machines + (bfd *, bfd *); + +extern bfd_boolean bfd_arm_update_notes + (bfd *, const char *); + +extern unsigned int bfd_arm_get_mach_from_notes + (bfd *, const char *); + +/* TI COFF load page support. */ +extern void bfd_ticoff_set_section_load_page + (struct bfd_section *, int); + +extern int bfd_ticoff_get_section_load_page + (struct bfd_section *); + +/* H8/300 functions. */ +extern bfd_vma bfd_h8300_pad_address + (bfd *, bfd_vma); + +/* IA64 Itanium code generation. Called from linker. */ +extern void bfd_elf32_ia64_after_parse + (int); + +extern void bfd_elf64_ia64_after_parse + (int); + +/* This structure is used for a comdat section, as in PE. A comdat + section is associated with a particular symbol. When the linker + sees a comdat section, it keeps only one of the sections with a + given name and associated with a given symbol. */ + +struct coff_comdat_info +{ + /* The name of the symbol associated with a comdat section. */ + const char *name; + + /* The local symbol table index of the symbol associated with a + comdat section. This is only meaningful to the object file format + specific code; it is not an index into the list returned by + bfd_canonicalize_symtab. */ + long symbol; +}; + +extern struct coff_comdat_info *bfd_coff_get_comdat_section + (bfd *, struct bfd_section *); + +/* Extracted from init.c. */ +void bfd_init (void); + +/* Extracted from opncls.c. */ +bfd *bfd_fopen (const char *filename, const char *target, + const char *mode, int fd); + +bfd *bfd_openr (const char *filename, const char *target); + +bfd *bfd_fdopenr (const char *filename, const char *target, int fd); + +bfd *bfd_openstreamr (const char *, const char *, void *); + +bfd *bfd_openr_iovec (const char *filename, const char *target, + void *(*open) (struct bfd *nbfd, + void *open_closure), + void *open_closure, + file_ptr (*pread) (struct bfd *nbfd, + void *stream, + void *buf, + file_ptr nbytes, + file_ptr offset), + int (*close) (struct bfd *nbfd, + void *stream), + int (*stat) (struct bfd *abfd, + void *stream, + struct stat *sb)); + +bfd *bfd_openw (const char *filename, const char *target); + +bfd_boolean bfd_close (bfd *abfd); + +bfd_boolean bfd_close_all_done (bfd *); + +bfd *bfd_create (const char *filename, bfd *templ); + +bfd_boolean bfd_make_writable (bfd *abfd); + +bfd_boolean bfd_make_readable (bfd *abfd); + +unsigned long bfd_calc_gnu_debuglink_crc32 + (unsigned long crc, const unsigned char *buf, bfd_size_type len); + +char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir); + +struct bfd_section *bfd_create_gnu_debuglink_section + (bfd *abfd, const char *filename); + +bfd_boolean bfd_fill_in_gnu_debuglink_section + (bfd *abfd, struct bfd_section *sect, const char *filename); + +/* Extracted from libbfd.c. */ + +/* Byte swapping macros for user section data. */ + +#define bfd_put_8(abfd, val, ptr) \ + ((void) (*((unsigned char *) (ptr)) = (val) & 0xff)) +#define bfd_put_signed_8 \ + bfd_put_8 +#define bfd_get_8(abfd, ptr) \ + (*(unsigned char *) (ptr) & 0xff) +#define bfd_get_signed_8(abfd, ptr) \ + (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80) + +#define bfd_put_16(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_putx16, ((val),(ptr))) +#define bfd_put_signed_16 \ + bfd_put_16 +#define bfd_get_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx16, (ptr)) +#define bfd_get_signed_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx_signed_16, (ptr)) + +#define bfd_put_32(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_putx32, ((val),(ptr))) +#define bfd_put_signed_32 \ + bfd_put_32 +#define bfd_get_32(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx32, (ptr)) +#define bfd_get_signed_32(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx_signed_32, (ptr)) + +#define bfd_put_64(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_putx64, ((val), (ptr))) +#define bfd_put_signed_64 \ + bfd_put_64 +#define bfd_get_64(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx64, (ptr)) +#define bfd_get_signed_64(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx_signed_64, (ptr)) + +#define bfd_get(bits, abfd, ptr) \ + ((bits) == 8 ? (bfd_vma) bfd_get_8 (abfd, ptr) \ + : (bits) == 16 ? bfd_get_16 (abfd, ptr) \ + : (bits) == 32 ? bfd_get_32 (abfd, ptr) \ + : (bits) == 64 ? bfd_get_64 (abfd, ptr) \ + : (abort (), (bfd_vma) - 1)) + +#define bfd_put(bits, abfd, val, ptr) \ + ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \ + : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \ + : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \ + : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \ + : (abort (), (void) 0)) + + +/* Byte swapping macros for file header data. */ + +#define bfd_h_put_8(abfd, val, ptr) \ + bfd_put_8 (abfd, val, ptr) +#define bfd_h_put_signed_8(abfd, val, ptr) \ + bfd_put_8 (abfd, val, ptr) +#define bfd_h_get_8(abfd, ptr) \ + bfd_get_8 (abfd, ptr) +#define bfd_h_get_signed_8(abfd, ptr) \ + bfd_get_signed_8 (abfd, ptr) + +#define bfd_h_put_16(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_h_putx16, (val, ptr)) +#define bfd_h_put_signed_16 \ + bfd_h_put_16 +#define bfd_h_get_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx16, (ptr)) +#define bfd_h_get_signed_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr)) + +#define bfd_h_put_32(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_h_putx32, (val, ptr)) +#define bfd_h_put_signed_32 \ + bfd_h_put_32 +#define bfd_h_get_32(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx32, (ptr)) +#define bfd_h_get_signed_32(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr)) + +#define bfd_h_put_64(abfd, val, ptr) \ + BFD_SEND (abfd, bfd_h_putx64, (val, ptr)) +#define bfd_h_put_signed_64 \ + bfd_h_put_64 +#define bfd_h_get_64(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx64, (ptr)) +#define bfd_h_get_signed_64(abfd, ptr) \ + BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr)) + +/* Aliases for the above, which should eventually go away. */ + +#define H_PUT_64 bfd_h_put_64 +#define H_PUT_32 bfd_h_put_32 +#define H_PUT_16 bfd_h_put_16 +#define H_PUT_8 bfd_h_put_8 +#define H_PUT_S64 bfd_h_put_signed_64 +#define H_PUT_S32 bfd_h_put_signed_32 +#define H_PUT_S16 bfd_h_put_signed_16 +#define H_PUT_S8 bfd_h_put_signed_8 +#define H_GET_64 bfd_h_get_64 +#define H_GET_32 bfd_h_get_32 +#define H_GET_16 bfd_h_get_16 +#define H_GET_8 bfd_h_get_8 +#define H_GET_S64 bfd_h_get_signed_64 +#define H_GET_S32 bfd_h_get_signed_32 +#define H_GET_S16 bfd_h_get_signed_16 +#define H_GET_S8 bfd_h_get_signed_8 + + +/* Extracted from bfdio.c. */ +long bfd_get_mtime (bfd *abfd); + +file_ptr bfd_get_size (bfd *abfd); + +/* Extracted from bfdwin.c. */ +/* Extracted from section.c. */ +typedef struct bfd_section +{ + /* The name of the section; the name isn't a copy, the pointer is + the same as that passed to bfd_make_section. */ + const char *name; + + /* A unique sequence number. */ + int id; + + /* Which section in the bfd; 0..n-1 as sections are created in a bfd. */ + int index; + + /* The next section in the list belonging to the BFD, or NULL. */ + struct bfd_section *next; + + /* The previous section in the list belonging to the BFD, or NULL. */ + struct bfd_section *prev; + + /* The field flags contains attributes of the section. Some + flags are read in from the object file, and some are + synthesized from other information. */ + flagword flags; + +#define SEC_NO_FLAGS 0x000 + + /* Tells the OS to allocate space for this section when loading. + This is clear for a section containing debug information only. */ +#define SEC_ALLOC 0x001 + + /* Tells the OS to load the section from the file when loading. + This is clear for a .bss section. */ +#define SEC_LOAD 0x002 + + /* The section contains data still to be relocated, so there is + some relocation information too. */ +#define SEC_RELOC 0x004 + + /* A signal to the OS that the section contains read only data. */ +#define SEC_READONLY 0x008 + + /* The section contains code only. */ +#define SEC_CODE 0x010 + + /* The section contains data only. */ +#define SEC_DATA 0x020 + + /* The section will reside in ROM. */ +#define SEC_ROM 0x040 + + /* The section contains constructor information. This section + type is used by the linker to create lists of constructors and + destructors used by <<g++>>. When a back end sees a symbol + which should be used in a constructor list, it creates a new + section for the type of name (e.g., <<__CTOR_LIST__>>), attaches + the symbol to it, and builds a relocation. To build the lists + of constructors, all the linker has to do is catenate all the + sections called <<__CTOR_LIST__>> and relocate the data + contained within - exactly the operations it would peform on + standard data. */ +#define SEC_CONSTRUCTOR 0x080 + + /* The section has contents - a data section could be + <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be + <<SEC_HAS_CONTENTS>> */ +#define SEC_HAS_CONTENTS 0x100 + + /* An instruction to the linker to not output the section + even if it has information which would normally be written. */ +#define SEC_NEVER_LOAD 0x200 + + /* The section contains thread local data. */ +#define SEC_THREAD_LOCAL 0x400 + + /* The section has GOT references. This flag is only for the + linker, and is currently only used by the elf32-hppa back end. + It will be set if global offset table references were detected + in this section, which indicate to the linker that the section + contains PIC code, and must be handled specially when doing a + static link. */ +#define SEC_HAS_GOT_REF 0x800 + + /* The section contains common symbols (symbols may be defined + multiple times, the value of a symbol is the amount of + space it requires, and the largest symbol value is the one + used). Most targets have exactly one of these (which we + translate to bfd_com_section_ptr), but ECOFF has two. */ +#define SEC_IS_COMMON 0x1000 + + /* The section contains only debugging information. For + example, this is set for ELF .debug and .stab sections. + strip tests this flag to see if a section can be + discarded. */ +#define SEC_DEBUGGING 0x2000 + + /* The contents of this section are held in memory pointed to + by the contents field. This is checked by bfd_get_section_contents, + and the data is retrieved from memory if appropriate. */ +#define SEC_IN_MEMORY 0x4000 + + /* The contents of this section are to be excluded by the + linker for executable and shared objects unless those + objects are to be further relocated. */ +#define SEC_EXCLUDE 0x8000 + + /* The contents of this section are to be sorted based on the sum of + the symbol and addend values specified by the associated relocation + entries. Entries without associated relocation entries will be + appended to the end of the section in an unspecified order. */ +#define SEC_SORT_ENTRIES 0x10000 + + /* When linking, duplicate sections of the same name should be + discarded, rather than being combined into a single section as + is usually done. This is similar to how common symbols are + handled. See SEC_LINK_DUPLICATES below. */ +#define SEC_LINK_ONCE 0x20000 + + /* If SEC_LINK_ONCE is set, this bitfield describes how the linker + should handle duplicate sections. */ +#define SEC_LINK_DUPLICATES 0x40000 + + /* This value for SEC_LINK_DUPLICATES means that duplicate + sections with the same name should simply be discarded. */ +#define SEC_LINK_DUPLICATES_DISCARD 0x0 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if there are any duplicate sections, although + it should still only link one copy. */ +#define SEC_LINK_DUPLICATES_ONE_ONLY 0x80000 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if any duplicate sections are a different size. */ +#define SEC_LINK_DUPLICATES_SAME_SIZE 0x100000 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if any duplicate sections contain different + contents. */ +#define SEC_LINK_DUPLICATES_SAME_CONTENTS \ + (SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE) + + /* This section was created by the linker as part of dynamic + relocation or other arcane processing. It is skipped when + going through the first-pass output, trusting that someone + else up the line will take care of it later. */ +#define SEC_LINKER_CREATED 0x200000 + + /* This section should not be subject to garbage collection. + Also set to inform the linker that this section should not be + listed in the link map as discarded. */ +#define SEC_KEEP 0x400000 + + /* This section contains "short" data, and should be placed + "near" the GP. */ +#define SEC_SMALL_DATA 0x800000 + + /* Attempt to merge identical entities in the section. + Entity size is given in the entsize field. */ +#define SEC_MERGE 0x1000000 + + /* If given with SEC_MERGE, entities to merge are zero terminated + strings where entsize specifies character size instead of fixed + size entries. */ +#define SEC_STRINGS 0x2000000 + + /* This section contains data about section groups. */ +#define SEC_GROUP 0x4000000 + + /* The section is a COFF shared library section. This flag is + only for the linker. If this type of section appears in + the input file, the linker must copy it to the output file + without changing the vma or size. FIXME: Although this + was originally intended to be general, it really is COFF + specific (and the flag was renamed to indicate this). It + might be cleaner to have some more general mechanism to + allow the back end to control what the linker does with + sections. */ +#define SEC_COFF_SHARED_LIBRARY 0x10000000 + + /* This section contains data which may be shared with other + executables or shared objects. This is for COFF only. */ +#define SEC_COFF_SHARED 0x20000000 + + /* When a section with this flag is being linked, then if the size of + the input section is less than a page, it should not cross a page + boundary. If the size of the input section is one page or more, + it should be aligned on a page boundary. This is for TI + TMS320C54X only. */ +#define SEC_TIC54X_BLOCK 0x40000000 + + /* Conditionally link this section; do not link if there are no + references found to any symbol in the section. This is for TI + TMS320C54X only. */ +#define SEC_TIC54X_CLINK 0x80000000 + + /* End of section flags. */ + + /* Some internal packed boolean fields. */ + + /* See the vma field. */ + unsigned int user_set_vma : 1; + + /* A mark flag used by some of the linker backends. */ + unsigned int linker_mark : 1; + + /* Another mark flag used by some of the linker backends. Set for + output sections that have an input section. */ + unsigned int linker_has_input : 1; + + /* Mark flags used by some linker backends for garbage collection. */ + unsigned int gc_mark : 1; + unsigned int gc_mark_from_eh : 1; + + /* The following flags are used by the ELF linker. */ + + /* Mark sections which have been allocated to segments. */ + unsigned int segment_mark : 1; + + /* Type of sec_info information. */ + unsigned int sec_info_type:3; +#define ELF_INFO_TYPE_NONE 0 +#define ELF_INFO_TYPE_STABS 1 +#define ELF_INFO_TYPE_MERGE 2 +#define ELF_INFO_TYPE_EH_FRAME 3 +#define ELF_INFO_TYPE_JUST_SYMS 4 + + /* Nonzero if this section uses RELA relocations, rather than REL. */ + unsigned int use_rela_p:1; + + /* Bits used by various backends. The generic code doesn't touch + these fields. */ + + /* Nonzero if this section has TLS related relocations. */ + unsigned int has_tls_reloc:1; + + /* Nonzero if this section has a call to __tls_get_addr. */ + unsigned int has_tls_get_addr_call:1; + + /* Nonzero if this section has a gp reloc. */ + unsigned int has_gp_reloc:1; + + /* Nonzero if this section needs the relax finalize pass. */ + unsigned int need_finalize_relax:1; + + /* Whether relocations have been processed. */ + unsigned int reloc_done : 1; + + /* End of internal packed boolean fields. */ + + /* The virtual memory address of the section - where it will be + at run time. The symbols are relocated against this. The + user_set_vma flag is maintained by bfd; if it's not set, the + backend can assign addresses (for example, in <<a.out>>, where + the default address for <<.data>> is dependent on the specific + target and various flags). */ + bfd_vma vma; + + /* The load address of the section - where it would be in a + rom image; really only used for writing section header + information. */ + bfd_vma lma; + + /* The size of the section in octets, as it will be output. + Contains a value even if the section has no contents (e.g., the + size of <<.bss>>). */ + bfd_size_type size; + + /* For input sections, the original size on disk of the section, in + octets. This field is used by the linker relaxation code. It is + currently only set for sections where the linker relaxation scheme + doesn't cache altered section and reloc contents (stabs, eh_frame, + SEC_MERGE, some coff relaxing targets), and thus the original size + needs to be kept to read the section multiple times. + For output sections, rawsize holds the section size calculated on + a previous linker relaxation pass. */ + bfd_size_type rawsize; + + /* If this section is going to be output, then this value is the + offset in *bytes* into the output section of the first byte in the + input section (byte ==> smallest addressable unit on the + target). In most cases, if this was going to start at the + 100th octet (8-bit quantity) in the output section, this value + would be 100. However, if the target byte size is 16 bits + (bfd_octets_per_byte is "2"), this value would be 50. */ + bfd_vma output_offset; + + /* The output section through which to map on output. */ + struct bfd_section *output_section; + + /* The alignment requirement of the section, as an exponent of 2 - + e.g., 3 aligns to 2^3 (or 8). */ + unsigned int alignment_power; + + /* If an input section, a pointer to a vector of relocation + records for the data in this section. */ + struct reloc_cache_entry *relocation; + + /* If an output section, a pointer to a vector of pointers to + relocation records for the data in this section. */ + struct reloc_cache_entry **orelocation; + + /* The number of relocation records in one of the above. */ + unsigned reloc_count; + + /* Information below is back end specific - and not always used + or updated. */ + + /* File position of section data. */ + file_ptr filepos; + + /* File position of relocation info. */ + file_ptr rel_filepos; + + /* File position of line data. */ + file_ptr line_filepos; + + /* Pointer to data for applications. */ + void *userdata; + + /* If the SEC_IN_MEMORY flag is set, this points to the actual + contents. */ + unsigned char *contents; + + /* Attached line number information. */ + alent *lineno; + + /* Number of line number records. */ + unsigned int lineno_count; + + /* Entity size for merging purposes. */ + unsigned int entsize; + + /* Points to the kept section if this section is a link-once section, + and is discarded. */ + struct bfd_section *kept_section; + + /* When a section is being output, this value changes as more + linenumbers are written out. */ + file_ptr moving_line_filepos; + + /* What the section number is in the target world. */ + int target_index; + + void *used_by_bfd; + + /* If this is a constructor section then here is a list of the + relocations created to relocate items within it. */ + struct relent_chain *constructor_chain; + + /* The BFD which owns the section. */ + bfd *owner; + + /* A symbol which points at this section only. */ + struct bfd_symbol *symbol; + struct bfd_symbol **symbol_ptr_ptr; + + /* Early in the link process, map_head and map_tail are used to build + a list of input sections attached to an output section. Later, + output sections use these fields for a list of bfd_link_order + structs. */ + union { + struct bfd_link_order *link_order; + struct bfd_section *s; + } map_head, map_tail; +} asection; + +/* These sections are global, and are managed by BFD. The application + and target back end are not permitted to change the values in + these sections. New code should use the section_ptr macros rather + than referring directly to the const sections. The const sections + may eventually vanish. */ +#define BFD_ABS_SECTION_NAME "*ABS*" +#define BFD_UND_SECTION_NAME "*UND*" +#define BFD_COM_SECTION_NAME "*COM*" +#define BFD_IND_SECTION_NAME "*IND*" + +/* The absolute section. */ +extern asection bfd_abs_section; +#define bfd_abs_section_ptr ((asection *) &bfd_abs_section) +#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) +/* Pointer to the undefined section. */ +extern asection bfd_und_section; +#define bfd_und_section_ptr ((asection *) &bfd_und_section) +#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) +/* Pointer to the common section. */ +extern asection bfd_com_section; +#define bfd_com_section_ptr ((asection *) &bfd_com_section) +/* Pointer to the indirect section. */ +extern asection bfd_ind_section; +#define bfd_ind_section_ptr ((asection *) &bfd_ind_section) +#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) + +#define bfd_is_const_section(SEC) \ + ( ((SEC) == bfd_abs_section_ptr) \ + || ((SEC) == bfd_und_section_ptr) \ + || ((SEC) == bfd_com_section_ptr) \ + || ((SEC) == bfd_ind_section_ptr)) + +/* Macros to handle insertion and deletion of a bfd's sections. These + only handle the list pointers, ie. do not adjust section_count, + target_index etc. */ +#define bfd_section_list_remove(ABFD, S) \ + do \ + { \ + asection *_s = S; \ + asection *_next = _s->next; \ + asection *_prev = _s->prev; \ + if (_prev) \ + _prev->next = _next; \ + else \ + (ABFD)->sections = _next; \ + if (_next) \ + _next->prev = _prev; \ + else \ + (ABFD)->section_last = _prev; \ + } \ + while (0) +#define bfd_section_list_append(ABFD, S) \ + do \ + { \ + asection *_s = S; \ + bfd *_abfd = ABFD; \ + _s->next = NULL; \ + if (_abfd->section_last) \ + { \ + _s->prev = _abfd->section_last; \ + _abfd->section_last->next = _s; \ + } \ + else \ + { \ + _s->prev = NULL; \ + _abfd->sections = _s; \ + } \ + _abfd->section_last = _s; \ + } \ + while (0) +#define bfd_section_list_prepend(ABFD, S) \ + do \ + { \ + asection *_s = S; \ + bfd *_abfd = ABFD; \ + _s->prev = NULL; \ + if (_abfd->sections) \ + { \ + _s->next = _abfd->sections; \ + _abfd->sections->prev = _s; \ + } \ + else \ + { \ + _s->next = NULL; \ + _abfd->section_last = _s; \ + } \ + _abfd->sections = _s; \ + } \ + while (0) +#define bfd_section_list_insert_after(ABFD, A, S) \ + do \ + { \ + asection *_a = A; \ + asection *_s = S; \ + asection *_next = _a->next; \ + _s->next = _next; \ + _s->prev = _a; \ + _a->next = _s; \ + if (_next) \ + _next->prev = _s; \ + else \ + (ABFD)->section_last = _s; \ + } \ + while (0) +#define bfd_section_list_insert_before(ABFD, B, S) \ + do \ + { \ + asection *_b = B; \ + asection *_s = S; \ + asection *_prev = _b->prev; \ + _s->prev = _prev; \ + _s->next = _b; \ + _b->prev = _s; \ + if (_prev) \ + _prev->next = _s; \ + else \ + (ABFD)->sections = _s; \ + } \ + while (0) +#define bfd_section_removed_from_list(ABFD, S) \ + ((S)->next == NULL ? (ABFD)->section_last != (S) : (S)->next->prev != (S)) + +#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, NAME, IDX) \ + /* name, id, index, next, prev, flags, user_set_vma, */ \ + { NAME, IDX, 0, NULL, NULL, FLAGS, 0, \ + \ + /* linker_mark, linker_has_input, gc_mark, gc_mark_from_eh, */ \ + 0, 0, 1, 0, \ + \ + /* segment_mark, sec_info_type, use_rela_p, has_tls_reloc, */ \ + 0, 0, 0, 0, \ + \ + /* has_tls_get_addr_call, has_gp_reloc, need_finalize_relax, */ \ + 0, 0, 0, \ + \ + /* reloc_done, vma, lma, size, rawsize */ \ + 0, 0, 0, 0, 0, \ + \ + /* output_offset, output_section, alignment_power, */ \ + 0, (struct bfd_section *) &SEC, 0, \ + \ + /* relocation, orelocation, reloc_count, filepos, rel_filepos, */ \ + NULL, NULL, 0, 0, 0, \ + \ + /* line_filepos, userdata, contents, lineno, lineno_count, */ \ + 0, NULL, NULL, NULL, 0, \ + \ + /* entsize, kept_section, moving_line_filepos, */ \ + 0, NULL, 0, \ + \ + /* target_index, used_by_bfd, constructor_chain, owner, */ \ + 0, NULL, NULL, NULL, \ + \ + /* symbol, symbol_ptr_ptr, */ \ + (struct bfd_symbol *) SYM, &SEC.symbol, \ + \ + /* map_head, map_tail */ \ + { NULL }, { NULL } \ + } + +void bfd_section_list_clear (bfd *); + +asection *bfd_get_section_by_name (bfd *abfd, const char *name); + +asection *bfd_get_section_by_name_if + (bfd *abfd, + const char *name, + bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj), + void *obj); + +char *bfd_get_unique_section_name + (bfd *abfd, const char *templat, int *count); + +asection *bfd_make_section_old_way (bfd *abfd, const char *name); + +asection *bfd_make_section_anyway_with_flags + (bfd *abfd, const char *name, flagword flags); + +asection *bfd_make_section_anyway (bfd *abfd, const char *name); + +asection *bfd_make_section_with_flags + (bfd *, const char *name, flagword flags); + +asection *bfd_make_section (bfd *, const char *name); + +bfd_boolean bfd_set_section_flags + (bfd *abfd, asection *sec, flagword flags); + +void bfd_map_over_sections + (bfd *abfd, + void (*func) (bfd *abfd, asection *sect, void *obj), + void *obj); + +asection *bfd_sections_find_if + (bfd *abfd, + bfd_boolean (*operation) (bfd *abfd, asection *sect, void *obj), + void *obj); + +bfd_boolean bfd_set_section_size + (bfd *abfd, asection *sec, bfd_size_type val); + +bfd_boolean bfd_set_section_contents + (bfd *abfd, asection *section, const void *data, + file_ptr offset, bfd_size_type count); + +bfd_boolean bfd_get_section_contents + (bfd *abfd, asection *section, void *location, file_ptr offset, + bfd_size_type count); + +bfd_boolean bfd_malloc_and_get_section + (bfd *abfd, asection *section, bfd_byte **buf); + +bfd_boolean bfd_copy_private_section_data + (bfd *ibfd, asection *isec, bfd *obfd, asection *osec); + +#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ + BFD_SEND (obfd, _bfd_copy_private_section_data, \ + (ibfd, isection, obfd, osection)) +bfd_boolean bfd_generic_is_group_section (bfd *, const asection *sec); + +bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group); + +/* Extracted from archures.c. */ +enum bfd_architecture +{ + bfd_arch_unknown, /* File arch not known. */ + bfd_arch_obscure, /* Arch known, not one of these. */ + bfd_arch_m68k, /* Motorola 68xxx */ +#define bfd_mach_m68000 1 +#define bfd_mach_m68008 2 +#define bfd_mach_m68010 3 +#define bfd_mach_m68020 4 +#define bfd_mach_m68030 5 +#define bfd_mach_m68040 6 +#define bfd_mach_m68060 7 +#define bfd_mach_cpu32 8 +#define bfd_mach_fido 9 +#define bfd_mach_mcf_isa_a_nodiv 10 +#define bfd_mach_mcf_isa_a 11 +#define bfd_mach_mcf_isa_a_mac 12 +#define bfd_mach_mcf_isa_a_emac 13 +#define bfd_mach_mcf_isa_aplus 14 +#define bfd_mach_mcf_isa_aplus_mac 15 +#define bfd_mach_mcf_isa_aplus_emac 16 +#define bfd_mach_mcf_isa_b_nousp 17 +#define bfd_mach_mcf_isa_b_nousp_mac 18 +#define bfd_mach_mcf_isa_b_nousp_emac 19 +#define bfd_mach_mcf_isa_b 20 +#define bfd_mach_mcf_isa_b_mac 21 +#define bfd_mach_mcf_isa_b_emac 22 +#define bfd_mach_mcf_isa_b_float 23 +#define bfd_mach_mcf_isa_b_float_mac 24 +#define bfd_mach_mcf_isa_b_float_emac 25 +#define bfd_mach_mcf_isa_c 26 +#define bfd_mach_mcf_isa_c_mac 27 +#define bfd_mach_mcf_isa_c_emac 28 + bfd_arch_vax, /* DEC Vax */ + bfd_arch_i960, /* Intel 960 */ + /* The order of the following is important. + lower number indicates a machine type that + only accepts a subset of the instructions + available to machines with higher numbers. + The exception is the "ca", which is + incompatible with all other machines except + "core". */ + +#define bfd_mach_i960_core 1 +#define bfd_mach_i960_ka_sa 2 +#define bfd_mach_i960_kb_sb 3 +#define bfd_mach_i960_mc 4 +#define bfd_mach_i960_xa 5 +#define bfd_mach_i960_ca 6 +#define bfd_mach_i960_jx 7 +#define bfd_mach_i960_hx 8 + + bfd_arch_or32, /* OpenRISC 32 */ + + bfd_arch_sparc, /* SPARC */ +#define bfd_mach_sparc 1 +/* The difference between v8plus and v9 is that v9 is a true 64 bit env. */ +#define bfd_mach_sparc_sparclet 2 +#define bfd_mach_sparc_sparclite 3 +#define bfd_mach_sparc_v8plus 4 +#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns. */ +#define bfd_mach_sparc_sparclite_le 6 +#define bfd_mach_sparc_v9 7 +#define bfd_mach_sparc_v9a 8 /* with ultrasparc add'ns. */ +#define bfd_mach_sparc_v8plusb 9 /* with cheetah add'ns. */ +#define bfd_mach_sparc_v9b 10 /* with cheetah add'ns. */ +/* Nonzero if MACH has the v9 instruction set. */ +#define bfd_mach_sparc_v9_p(mach) \ + ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \ + && (mach) != bfd_mach_sparc_sparclite_le) +/* Nonzero if MACH is a 64 bit sparc architecture. */ +#define bfd_mach_sparc_64bit_p(mach) \ + ((mach) >= bfd_mach_sparc_v9 && (mach) != bfd_mach_sparc_v8plusb) + bfd_arch_spu, /* PowerPC SPU */ +#define bfd_mach_spu 256 + bfd_arch_mips, /* MIPS Rxxxx */ +#define bfd_mach_mips3000 3000 +#define bfd_mach_mips3900 3900 +#define bfd_mach_mips4000 4000 +#define bfd_mach_mips4010 4010 +#define bfd_mach_mips4100 4100 +#define bfd_mach_mips4111 4111 +#define bfd_mach_mips4120 4120 +#define bfd_mach_mips4300 4300 +#define bfd_mach_mips4400 4400 +#define bfd_mach_mips4600 4600 +#define bfd_mach_mips4650 4650 +#define bfd_mach_mips5000 5000 +#define bfd_mach_mips5400 5400 +#define bfd_mach_mips5500 5500 +#define bfd_mach_mips6000 6000 +#define bfd_mach_mips7000 7000 +#define bfd_mach_mips8000 8000 +#define bfd_mach_mips9000 9000 +#define bfd_mach_mips10000 10000 +#define bfd_mach_mips12000 12000 +#define bfd_mach_mips16 16 +#define bfd_mach_mips5 5 +#define bfd_mach_mips_octeon 6502 +#define bfd_mach_mips_sb1 12310201 /* octal 'SB', 01 */ +#define bfd_mach_mipsisa32 32 +#define bfd_mach_mipsisa32r2 33 +#define bfd_mach_mipsisa64 64 +#define bfd_mach_mipsisa64r2 65 + bfd_arch_i386, /* Intel 386 */ +#define bfd_mach_i386_i386 1 +#define bfd_mach_i386_i8086 2 +#define bfd_mach_i386_i386_intel_syntax 3 +#define bfd_mach_x86_64 64 +#define bfd_mach_x86_64_intel_syntax 65 + bfd_arch_we32k, /* AT&T WE32xxx */ + bfd_arch_tahoe, /* CCI/Harris Tahoe */ + bfd_arch_i860, /* Intel 860 */ + bfd_arch_i370, /* IBM 360/370 Mainframes */ + bfd_arch_romp, /* IBM ROMP PC/RT */ + bfd_arch_convex, /* Convex */ + bfd_arch_m88k, /* Motorola 88xxx */ + bfd_arch_m98k, /* Motorola 98xxx */ + bfd_arch_pyramid, /* Pyramid Technology */ + bfd_arch_h8300, /* Renesas H8/300 (formerly Hitachi H8/300) */ +#define bfd_mach_h8300 1 +#define bfd_mach_h8300h 2 +#define bfd_mach_h8300s 3 +#define bfd_mach_h8300hn 4 +#define bfd_mach_h8300sn 5 +#define bfd_mach_h8300sx 6 +#define bfd_mach_h8300sxn 7 + bfd_arch_pdp11, /* DEC PDP-11 */ + bfd_arch_powerpc, /* PowerPC */ +#define bfd_mach_ppc 32 +#define bfd_mach_ppc64 64 +#define bfd_mach_ppc_403 403 +#define bfd_mach_ppc_403gc 4030 +#define bfd_mach_ppc_505 505 +#define bfd_mach_ppc_601 601 +#define bfd_mach_ppc_602 602 +#define bfd_mach_ppc_603 603 +#define bfd_mach_ppc_ec603e 6031 +#define bfd_mach_ppc_604 604 +#define bfd_mach_ppc_620 620 +#define bfd_mach_ppc_630 630 +#define bfd_mach_ppc_750 750 +#define bfd_mach_ppc_860 860 +#define bfd_mach_ppc_a35 35 +#define bfd_mach_ppc_rs64ii 642 +#define bfd_mach_ppc_rs64iii 643 +#define bfd_mach_ppc_7400 7400 +#define bfd_mach_ppc_e500 500 + bfd_arch_rs6000, /* IBM RS/6000 */ +#define bfd_mach_rs6k 6000 +#define bfd_mach_rs6k_rs1 6001 +#define bfd_mach_rs6k_rsc 6003 +#define bfd_mach_rs6k_rs2 6002 + bfd_arch_hppa, /* HP PA RISC */ +#define bfd_mach_hppa10 10 +#define bfd_mach_hppa11 11 +#define bfd_mach_hppa20 20 +#define bfd_mach_hppa20w 25 + bfd_arch_d10v, /* Mitsubishi D10V */ +#define bfd_mach_d10v 1 +#define bfd_mach_d10v_ts2 2 +#define bfd_mach_d10v_ts3 3 + bfd_arch_d30v, /* Mitsubishi D30V */ + bfd_arch_dlx, /* DLX */ + bfd_arch_m68hc11, /* Motorola 68HC11 */ + bfd_arch_m68hc12, /* Motorola 68HC12 */ +#define bfd_mach_m6812_default 0 +#define bfd_mach_m6812 1 +#define bfd_mach_m6812s 2 + bfd_arch_z8k, /* Zilog Z8000 */ +#define bfd_mach_z8001 1 +#define bfd_mach_z8002 2 + bfd_arch_h8500, /* Renesas H8/500 (formerly Hitachi H8/500) */ + bfd_arch_sh, /* Renesas / SuperH SH (formerly Hitachi SH) */ +#define bfd_mach_sh 1 +#define bfd_mach_sh2 0x20 +#define bfd_mach_sh_dsp 0x2d +#define bfd_mach_sh2a 0x2a +#define bfd_mach_sh2a_nofpu 0x2b +#define bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu 0x2a1 +#define bfd_mach_sh2a_nofpu_or_sh3_nommu 0x2a2 +#define bfd_mach_sh2a_or_sh4 0x2a3 +#define bfd_mach_sh2a_or_sh3e 0x2a4 +#define bfd_mach_sh2e 0x2e +#define bfd_mach_sh3 0x30 +#define bfd_mach_sh3_nommu 0x31 +#define bfd_mach_sh3_dsp 0x3d +#define bfd_mach_sh3e 0x3e +#define bfd_mach_sh4 0x40 +#define bfd_mach_sh4_nofpu 0x41 +#define bfd_mach_sh4_nommu_nofpu 0x42 +#define bfd_mach_sh4a 0x4a +#define bfd_mach_sh4a_nofpu 0x4b +#define bfd_mach_sh4al_dsp 0x4d +#define bfd_mach_sh5 0x50 + bfd_arch_alpha, /* Dec Alpha */ +#define bfd_mach_alpha_ev4 0x10 +#define bfd_mach_alpha_ev5 0x20 +#define bfd_mach_alpha_ev6 0x30 + bfd_arch_arm, /* Advanced Risc Machines ARM. */ +#define bfd_mach_arm_unknown 0 +#define bfd_mach_arm_2 1 +#define bfd_mach_arm_2a 2 +#define bfd_mach_arm_3 3 +#define bfd_mach_arm_3M 4 +#define bfd_mach_arm_4 5 +#define bfd_mach_arm_4T 6 +#define bfd_mach_arm_5 7 +#define bfd_mach_arm_5T 8 +#define bfd_mach_arm_5TE 9 +#define bfd_mach_arm_XScale 10 +#define bfd_mach_arm_ep9312 11 +#define bfd_mach_arm_iWMMXt 12 +#define bfd_mach_arm_iWMMXt2 13 + bfd_arch_ns32k, /* National Semiconductors ns32000 */ + bfd_arch_w65, /* WDC 65816 */ + bfd_arch_tic30, /* Texas Instruments TMS320C30 */ + bfd_arch_tic4x, /* Texas Instruments TMS320C3X/4X */ +#define bfd_mach_tic3x 30 +#define bfd_mach_tic4x 40 + bfd_arch_tic54x, /* Texas Instruments TMS320C54X */ + bfd_arch_tic80, /* TI TMS320c80 (MVP) */ + bfd_arch_v850, /* NEC V850 */ +#define bfd_mach_v850 1 +#define bfd_mach_v850e 'E' +#define bfd_mach_v850e1 '1' + bfd_arch_arc, /* ARC Cores */ +#define bfd_mach_arc_5 5 +#define bfd_mach_arc_6 6 +#define bfd_mach_arc_7 7 +#define bfd_mach_arc_8 8 + bfd_arch_m32c, /* Renesas M16C/M32C. */ +#define bfd_mach_m16c 0x75 +#define bfd_mach_m32c 0x78 + bfd_arch_m32r, /* Renesas M32R (formerly Mitsubishi M32R/D) */ +#define bfd_mach_m32r 1 /* For backwards compatibility. */ +#define bfd_mach_m32rx 'x' +#define bfd_mach_m32r2 '2' + bfd_arch_mn10200, /* Matsushita MN10200 */ + bfd_arch_mn10300, /* Matsushita MN10300 */ +#define bfd_mach_mn10300 300 +#define bfd_mach_am33 330 +#define bfd_mach_am33_2 332 + bfd_arch_fr30, +#define bfd_mach_fr30 0x46523330 + bfd_arch_frv, +#define bfd_mach_frv 1 +#define bfd_mach_frvsimple 2 +#define bfd_mach_fr300 300 +#define bfd_mach_fr400 400 +#define bfd_mach_fr450 450 +#define bfd_mach_frvtomcat 499 /* fr500 prototype */ +#define bfd_mach_fr500 500 +#define bfd_mach_fr550 550 + bfd_arch_mcore, + bfd_arch_mep, +#define bfd_mach_mep 1 +#define bfd_mach_mep_h1 0x6831 + bfd_arch_ia64, /* HP/Intel ia64 */ +#define bfd_mach_ia64_elf64 64 +#define bfd_mach_ia64_elf32 32 + bfd_arch_ip2k, /* Ubicom IP2K microcontrollers. */ +#define bfd_mach_ip2022 1 +#define bfd_mach_ip2022ext 2 + bfd_arch_iq2000, /* Vitesse IQ2000. */ +#define bfd_mach_iq2000 1 +#define bfd_mach_iq10 2 + bfd_arch_mt, +#define bfd_mach_ms1 1 +#define bfd_mach_mrisc2 2 +#define bfd_mach_ms2 3 + bfd_arch_pj, + bfd_arch_avr, /* Atmel AVR microcontrollers. */ +#define bfd_mach_avr1 1 +#define bfd_mach_avr2 2 +#define bfd_mach_avr3 3 +#define bfd_mach_avr4 4 +#define bfd_mach_avr5 5 +#define bfd_mach_avr6 6 + bfd_arch_bfin, /* ADI Blackfin */ +#define bfd_mach_bfin 1 + bfd_arch_cr16, /* National Semiconductor CompactRISC (ie CR16). */ +#define bfd_mach_cr16 1 + bfd_arch_cr16c, /* National Semiconductor CompactRISC. */ +#define bfd_mach_cr16c 1 + bfd_arch_crx, /* National Semiconductor CRX. */ +#define bfd_mach_crx 1 + bfd_arch_cris, /* Axis CRIS */ +#define bfd_mach_cris_v0_v10 255 +#define bfd_mach_cris_v32 32 +#define bfd_mach_cris_v10_v32 1032 + bfd_arch_s390, /* IBM s390 */ +#define bfd_mach_s390_31 31 +#define bfd_mach_s390_64 64 + bfd_arch_score, /* Sunplus score */ + bfd_arch_openrisc, /* OpenRISC */ + bfd_arch_mmix, /* Donald Knuth's educational processor. */ + bfd_arch_xstormy16, +#define bfd_mach_xstormy16 1 + bfd_arch_msp430, /* Texas Instruments MSP430 architecture. */ +#define bfd_mach_msp11 11 +#define bfd_mach_msp110 110 +#define bfd_mach_msp12 12 +#define bfd_mach_msp13 13 +#define bfd_mach_msp14 14 +#define bfd_mach_msp15 15 +#define bfd_mach_msp16 16 +#define bfd_mach_msp21 21 +#define bfd_mach_msp31 31 +#define bfd_mach_msp32 32 +#define bfd_mach_msp33 33 +#define bfd_mach_msp41 41 +#define bfd_mach_msp42 42 +#define bfd_mach_msp43 43 +#define bfd_mach_msp44 44 + bfd_arch_xc16x, /* Infineon's XC16X Series. */ +#define bfd_mach_xc16x 1 +#define bfd_mach_xc16xl 2 +#define bfd_mach_xc16xs 3 + bfd_arch_xtensa, /* Tensilica's Xtensa cores. */ +#define bfd_mach_xtensa 1 + bfd_arch_maxq, /* Dallas MAXQ 10/20 */ +#define bfd_mach_maxq10 10 +#define bfd_mach_maxq20 20 + bfd_arch_z80, +#define bfd_mach_z80strict 1 /* No undocumented opcodes. */ +#define bfd_mach_z80 3 /* With ixl, ixh, iyl, and iyh. */ +#define bfd_mach_z80full 7 /* All undocumented instructions. */ +#define bfd_mach_r800 11 /* R800: successor with multiplication. */ + bfd_arch_last + }; + +typedef struct bfd_arch_info +{ + int bits_per_word; + int bits_per_address; + int bits_per_byte; + enum bfd_architecture arch; + unsigned long mach; + const char *arch_name; + const char *printable_name; + unsigned int section_align_power; + /* TRUE if this is the default machine for the architecture. + The default arch should be the first entry for an arch so that + all the entries for that arch can be accessed via <<next>>. */ + bfd_boolean the_default; + const struct bfd_arch_info * (*compatible) + (const struct bfd_arch_info *a, const struct bfd_arch_info *b); + + bfd_boolean (*scan) (const struct bfd_arch_info *, const char *); + + const struct bfd_arch_info *next; +} +bfd_arch_info_type; + +const char *bfd_printable_name (bfd *abfd); + +const bfd_arch_info_type *bfd_scan_arch (const char *string); + +const char **bfd_arch_list (void); + +const bfd_arch_info_type *bfd_arch_get_compatible + (const bfd *abfd, const bfd *bbfd, bfd_boolean accept_unknowns); + +void bfd_set_arch_info (bfd *abfd, const bfd_arch_info_type *arg); + +enum bfd_architecture bfd_get_arch (bfd *abfd); + +unsigned long bfd_get_mach (bfd *abfd); + +unsigned int bfd_arch_bits_per_byte (bfd *abfd); + +unsigned int bfd_arch_bits_per_address (bfd *abfd); + +const bfd_arch_info_type *bfd_get_arch_info (bfd *abfd); + +const bfd_arch_info_type *bfd_lookup_arch + (enum bfd_architecture arch, unsigned long machine); + +const char *bfd_printable_arch_mach + (enum bfd_architecture arch, unsigned long machine); + +unsigned int bfd_octets_per_byte (bfd *abfd); + +unsigned int bfd_arch_mach_octets_per_byte + (enum bfd_architecture arch, unsigned long machine); + +/* Extracted from reloc.c. */ +typedef enum bfd_reloc_status +{ + /* No errors detected. */ + bfd_reloc_ok, + + /* The relocation was performed, but there was an overflow. */ + bfd_reloc_overflow, + + /* The address to relocate was not within the section supplied. */ + bfd_reloc_outofrange, + + /* Used by special functions. */ + bfd_reloc_continue, + + /* Unsupported relocation size requested. */ + bfd_reloc_notsupported, + + /* Unused. */ + bfd_reloc_other, + + /* The symbol to relocate against was undefined. */ + bfd_reloc_undefined, + + /* The relocation was performed, but may not be ok - presently + generated only when linking i960 coff files with i960 b.out + symbols. If this type is returned, the error_message argument + to bfd_perform_relocation will be set. */ + bfd_reloc_dangerous + } + bfd_reloc_status_type; + + +typedef struct reloc_cache_entry +{ + /* A pointer into the canonical table of pointers. */ + struct bfd_symbol **sym_ptr_ptr; + + /* offset in section. */ + bfd_size_type address; + + /* addend for relocation value. */ + bfd_vma addend; + + /* Pointer to how to perform the required relocation. */ + reloc_howto_type *howto; + +} +arelent; + +enum complain_overflow +{ + /* Do not complain on overflow. */ + complain_overflow_dont, + + /* Complain if the value overflows when considered as a signed + number one bit larger than the field. ie. A bitfield of N bits + is allowed to represent -2**n to 2**n-1. */ + complain_overflow_bitfield, + + /* Complain if the value overflows when considered as a signed + number. */ + complain_overflow_signed, + + /* Complain if the value overflows when considered as an + unsigned number. */ + complain_overflow_unsigned +}; + +struct reloc_howto_struct +{ + /* The type field has mainly a documentary use - the back end can + do what it wants with it, though normally the back end's + external idea of what a reloc number is stored + in this field. For example, a PC relative word relocation + in a coff environment has the type 023 - because that's + what the outside world calls a R_PCRWORD reloc. */ + unsigned int type; + + /* The value the final relocation is shifted right by. This drops + unwanted data from the relocation. */ + unsigned int rightshift; + + /* The size of the item to be relocated. This is *not* a + power-of-two measure. To get the number of bytes operated + on by a type of relocation, use bfd_get_reloc_size. */ + int size; + + /* The number of bits in the item to be relocated. This is used + when doing overflow checking. */ + unsigned int bitsize; + + /* Notes that the relocation is relative to the location in the + data section of the addend. The relocation function will + subtract from the relocation value the address of the location + being relocated. */ + bfd_boolean pc_relative; + + /* The bit position of the reloc value in the destination. + The relocated value is left shifted by this amount. */ + unsigned int bitpos; + + /* What type of overflow error should be checked for when + relocating. */ + enum complain_overflow complain_on_overflow; + + /* If this field is non null, then the supplied function is + called rather than the normal function. This allows really + strange relocation methods to be accommodated (e.g., i960 callj + instructions). */ + bfd_reloc_status_type (*special_function) + (bfd *, arelent *, struct bfd_symbol *, void *, asection *, + bfd *, char **); + + /* The textual name of the relocation type. */ + char *name; + + /* Some formats record a relocation addend in the section contents + rather than with the relocation. For ELF formats this is the + distinction between USE_REL and USE_RELA (though the code checks + for USE_REL == 1/0). The value of this field is TRUE if the + addend is recorded with the section contents; when performing a + partial link (ld -r) the section contents (the data) will be + modified. The value of this field is FALSE if addends are + recorded with the relocation (in arelent.addend); when performing + a partial link the relocation will be modified. + All relocations for all ELF USE_RELA targets should set this field + to FALSE (values of TRUE should be looked on with suspicion). + However, the converse is not true: not all relocations of all ELF + USE_REL targets set this field to TRUE. Why this is so is peculiar + to each particular target. For relocs that aren't used in partial + links (e.g. GOT stuff) it doesn't matter what this is set to. */ + bfd_boolean partial_inplace; + + /* src_mask selects the part of the instruction (or data) to be used + in the relocation sum. If the target relocations don't have an + addend in the reloc, eg. ELF USE_REL, src_mask will normally equal + dst_mask to extract the addend from the section contents. If + relocations do have an addend in the reloc, eg. ELF USE_RELA, this + field should be zero. Non-zero values for ELF USE_RELA targets are + bogus as in those cases the value in the dst_mask part of the + section contents should be treated as garbage. */ + bfd_vma src_mask; + + /* dst_mask selects which parts of the instruction (or data) are + replaced with a relocated value. */ + bfd_vma dst_mask; + + /* When some formats create PC relative instructions, they leave + the value of the pc of the place being relocated in the offset + slot of the instruction, so that a PC relative relocation can + be made just by adding in an ordinary offset (e.g., sun3 a.out). + Some formats leave the displacement part of an instruction + empty (e.g., m88k bcs); this flag signals the fact. */ + bfd_boolean pcrel_offset; +}; + +#define HOWTO(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ + { (unsigned) C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC } +#define NEWHOWTO(FUNCTION, NAME, SIZE, REL, IN) \ + HOWTO (0, 0, SIZE, 0, REL, 0, complain_overflow_dont, FUNCTION, \ + NAME, FALSE, 0, 0, IN) + +#define EMPTY_HOWTO(C) \ + HOWTO ((C), 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, \ + NULL, FALSE, 0, 0, FALSE) + +#define HOWTO_PREPARE(relocation, symbol) \ + { \ + if (symbol != NULL) \ + { \ + if (bfd_is_com_section (symbol->section)) \ + { \ + relocation = 0; \ + } \ + else \ + { \ + relocation = symbol->value; \ + } \ + } \ + } + +unsigned int bfd_get_reloc_size (reloc_howto_type *); + +typedef struct relent_chain +{ + arelent relent; + struct relent_chain *next; +} +arelent_chain; + +bfd_reloc_status_type bfd_check_overflow + (enum complain_overflow how, + unsigned int bitsize, + unsigned int rightshift, + unsigned int addrsize, + bfd_vma relocation); + +bfd_reloc_status_type bfd_perform_relocation + (bfd *abfd, + arelent *reloc_entry, + void *data, + asection *input_section, + bfd *output_bfd, + char **error_message); + +bfd_reloc_status_type bfd_install_relocation + (bfd *abfd, + arelent *reloc_entry, + void *data, bfd_vma data_start, + asection *input_section, + char **error_message); + +enum bfd_reloc_code_real { + _dummy_first_bfd_reloc_code_real, + + +/* Basic absolute relocations of N bits. */ + BFD_RELOC_64, + BFD_RELOC_32, + BFD_RELOC_26, + BFD_RELOC_24, + BFD_RELOC_16, + BFD_RELOC_14, + BFD_RELOC_8, + +/* PC-relative relocations. Sometimes these are relative to the address +of the relocation itself; sometimes they are relative to the start of +the section containing the relocation. It depends on the specific target. + +The 24-bit relocation is used in some Intel 960 configurations. */ + BFD_RELOC_64_PCREL, + BFD_RELOC_32_PCREL, + BFD_RELOC_24_PCREL, + BFD_RELOC_16_PCREL, + BFD_RELOC_12_PCREL, + BFD_RELOC_8_PCREL, + +/* Section relative relocations. Some targets need this for DWARF2. */ + BFD_RELOC_32_SECREL, + +/* For ELF. */ + BFD_RELOC_32_GOT_PCREL, + BFD_RELOC_16_GOT_PCREL, + BFD_RELOC_8_GOT_PCREL, + BFD_RELOC_32_GOTOFF, + BFD_RELOC_16_GOTOFF, + BFD_RELOC_LO16_GOTOFF, + BFD_RELOC_HI16_GOTOFF, + BFD_RELOC_HI16_S_GOTOFF, + BFD_RELOC_8_GOTOFF, + BFD_RELOC_64_PLT_PCREL, + BFD_RELOC_32_PLT_PCREL, + BFD_RELOC_24_PLT_PCREL, + BFD_RELOC_16_PLT_PCREL, + BFD_RELOC_8_PLT_PCREL, + BFD_RELOC_64_PLTOFF, + BFD_RELOC_32_PLTOFF, + BFD_RELOC_16_PLTOFF, + BFD_RELOC_LO16_PLTOFF, + BFD_RELOC_HI16_PLTOFF, + BFD_RELOC_HI16_S_PLTOFF, + BFD_RELOC_8_PLTOFF, + +/* Relocations used by 68K ELF. */ + BFD_RELOC_68K_GLOB_DAT, + BFD_RELOC_68K_JMP_SLOT, + BFD_RELOC_68K_RELATIVE, + +/* Linkage-table relative. */ + BFD_RELOC_32_BASEREL, + BFD_RELOC_16_BASEREL, + BFD_RELOC_LO16_BASEREL, + BFD_RELOC_HI16_BASEREL, + BFD_RELOC_HI16_S_BASEREL, + BFD_RELOC_8_BASEREL, + BFD_RELOC_RVA, + +/* Absolute 8-bit relocation, but used to form an address like 0xFFnn. */ + BFD_RELOC_8_FFnn, + +/* These PC-relative relocations are stored as word displacements -- +i.e., byte displacements shifted right two bits. The 30-bit word +displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the +SPARC. (SPARC tools generally refer to this as <<WDISP30>>.) The +signed 16-bit displacement is used on the MIPS, and the 23-bit +displacement is used on the Alpha. */ + BFD_RELOC_32_PCREL_S2, + BFD_RELOC_16_PCREL_S2, + BFD_RELOC_23_PCREL_S2, + +/* High 22 bits and low 10 bits of 32-bit value, placed into lower bits of +the target word. These are used on the SPARC. */ + BFD_RELOC_HI22, + BFD_RELOC_LO10, + +/* For systems that allocate a Global Pointer register, these are +displacements off that register. These relocation types are +handled specially, because the value the register will have is +decided relatively late. */ + BFD_RELOC_GPREL16, + BFD_RELOC_GPREL32, + +/* Reloc types used for i960/b.out. */ + BFD_RELOC_I960_CALLJ, + +/* SPARC ELF relocations. There is probably some overlap with other +relocation types already defined. */ + BFD_RELOC_NONE, + BFD_RELOC_SPARC_WDISP22, + BFD_RELOC_SPARC22, + BFD_RELOC_SPARC13, + BFD_RELOC_SPARC_GOT10, + BFD_RELOC_SPARC_GOT13, + BFD_RELOC_SPARC_GOT22, + BFD_RELOC_SPARC_PC10, + BFD_RELOC_SPARC_PC22, + BFD_RELOC_SPARC_WPLT30, + BFD_RELOC_SPARC_COPY, + BFD_RELOC_SPARC_GLOB_DAT, + BFD_RELOC_SPARC_JMP_SLOT, + BFD_RELOC_SPARC_RELATIVE, + BFD_RELOC_SPARC_UA16, + BFD_RELOC_SPARC_UA32, + BFD_RELOC_SPARC_UA64, + +/* I think these are specific to SPARC a.out (e.g., Sun 4). */ + BFD_RELOC_SPARC_BASE13, + BFD_RELOC_SPARC_BASE22, + +/* SPARC64 relocations */ +#define BFD_RELOC_SPARC_64 BFD_RELOC_64 + BFD_RELOC_SPARC_10, + BFD_RELOC_SPARC_11, + BFD_RELOC_SPARC_OLO10, + BFD_RELOC_SPARC_HH22, + BFD_RELOC_SPARC_HM10, + BFD_RELOC_SPARC_LM22, + BFD_RELOC_SPARC_PC_HH22, + BFD_RELOC_SPARC_PC_HM10, + BFD_RELOC_SPARC_PC_LM22, + BFD_RELOC_SPARC_WDISP16, + BFD_RELOC_SPARC_WDISP19, + BFD_RELOC_SPARC_7, + BFD_RELOC_SPARC_6, + BFD_RELOC_SPARC_5, +#define BFD_RELOC_SPARC_DISP64 BFD_RELOC_64_PCREL + BFD_RELOC_SPARC_PLT32, + BFD_RELOC_SPARC_PLT64, + BFD_RELOC_SPARC_HIX22, + BFD_RELOC_SPARC_LOX10, + BFD_RELOC_SPARC_H44, + BFD_RELOC_SPARC_M44, + BFD_RELOC_SPARC_L44, + BFD_RELOC_SPARC_REGISTER, + +/* SPARC little endian relocation */ + BFD_RELOC_SPARC_REV32, + +/* SPARC TLS relocations */ + BFD_RELOC_SPARC_TLS_GD_HI22, + BFD_RELOC_SPARC_TLS_GD_LO10, + BFD_RELOC_SPARC_TLS_GD_ADD, + BFD_RELOC_SPARC_TLS_GD_CALL, + BFD_RELOC_SPARC_TLS_LDM_HI22, + BFD_RELOC_SPARC_TLS_LDM_LO10, + BFD_RELOC_SPARC_TLS_LDM_ADD, + BFD_RELOC_SPARC_TLS_LDM_CALL, + BFD_RELOC_SPARC_TLS_LDO_HIX22, + BFD_RELOC_SPARC_TLS_LDO_LOX10, + BFD_RELOC_SPARC_TLS_LDO_ADD, + BFD_RELOC_SPARC_TLS_IE_HI22, + BFD_RELOC_SPARC_TLS_IE_LO10, + BFD_RELOC_SPARC_TLS_IE_LD, + BFD_RELOC_SPARC_TLS_IE_LDX, + BFD_RELOC_SPARC_TLS_IE_ADD, + BFD_RELOC_SPARC_TLS_LE_HIX22, + BFD_RELOC_SPARC_TLS_LE_LOX10, + BFD_RELOC_SPARC_TLS_DTPMOD32, + BFD_RELOC_SPARC_TLS_DTPMOD64, + BFD_RELOC_SPARC_TLS_DTPOFF32, + BFD_RELOC_SPARC_TLS_DTPOFF64, + BFD_RELOC_SPARC_TLS_TPOFF32, + BFD_RELOC_SPARC_TLS_TPOFF64, + +/* SPU Relocations. */ + BFD_RELOC_SPU_IMM7, + BFD_RELOC_SPU_IMM8, + BFD_RELOC_SPU_IMM10, + BFD_RELOC_SPU_IMM10W, + BFD_RELOC_SPU_IMM16, + BFD_RELOC_SPU_IMM16W, + BFD_RELOC_SPU_IMM18, + BFD_RELOC_SPU_PCREL9a, + BFD_RELOC_SPU_PCREL9b, + BFD_RELOC_SPU_PCREL16, + BFD_RELOC_SPU_LO16, + BFD_RELOC_SPU_HI16, + BFD_RELOC_SPU_PPU32, + BFD_RELOC_SPU_PPU64, + +/* Alpha ECOFF and ELF relocations. Some of these treat the symbol or +"addend" in some special way. +For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when +writing; when reading, it will be the absolute section symbol. The +addend is the displacement in bytes of the "lda" instruction from +the "ldah" instruction (which is at the address of this reloc). */ + BFD_RELOC_ALPHA_GPDISP_HI16, + +/* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as +with GPDISP_HI16 relocs. The addend is ignored when writing the +relocations out, and is filled in with the file's GP value on +reading, for convenience. */ + BFD_RELOC_ALPHA_GPDISP_LO16, + +/* The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 +relocation except that there is no accompanying GPDISP_LO16 +relocation. */ + BFD_RELOC_ALPHA_GPDISP, + +/* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; +the assembler turns it into a LDQ instruction to load the address of +the symbol, and then fills in a register in the real instruction. + +The LITERAL reloc, at the LDQ instruction, refers to the .lita +section symbol. The addend is ignored when writing, but is filled +in with the file's GP value on reading, for convenience, as with the +GPDISP_LO16 reloc. + +The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. +It should refer to the symbol to be referenced, as with 16_GOTOFF, +but it generates output not based on the position within the .got +section, but relative to the GP value chosen for the file during the +final link stage. + +The LITUSE reloc, on the instruction using the loaded address, gives +information to the linker that it might be able to use to optimize +away some literal section references. The symbol is ignored (read +as the absolute section symbol), and the "addend" indicates the type +of instruction using the register: +1 - "memory" fmt insn +2 - byte-manipulation (byte offset reg) +3 - jsr (target of branch) */ + BFD_RELOC_ALPHA_LITERAL, + BFD_RELOC_ALPHA_ELF_LITERAL, + BFD_RELOC_ALPHA_LITUSE, + +/* The HINT relocation indicates a value that should be filled into the +"hint" field of a jmp/jsr/ret instruction, for possible branch- +prediction logic which may be provided on some processors. */ + BFD_RELOC_ALPHA_HINT, + +/* The LINKAGE relocation outputs a linkage pair in the object file, +which is filled by the linker. */ + BFD_RELOC_ALPHA_LINKAGE, + +/* The CODEADDR relocation outputs a STO_CA in the object file, +which is filled by the linker. */ + BFD_RELOC_ALPHA_CODEADDR, + +/* The GPREL_HI/LO relocations together form a 32-bit offset from the +GP register. */ + BFD_RELOC_ALPHA_GPREL_HI16, + BFD_RELOC_ALPHA_GPREL_LO16, + +/* Like BFD_RELOC_23_PCREL_S2, except that the source and target must +share a common GP, and the target address is adjusted for +STO_ALPHA_STD_GPLOAD. */ + BFD_RELOC_ALPHA_BRSGP, + +/* Alpha thread-local storage relocations. */ + BFD_RELOC_ALPHA_TLSGD, + BFD_RELOC_ALPHA_TLSLDM, + BFD_RELOC_ALPHA_DTPMOD64, + BFD_RELOC_ALPHA_GOTDTPREL16, + BFD_RELOC_ALPHA_DTPREL64, + BFD_RELOC_ALPHA_DTPREL_HI16, + BFD_RELOC_ALPHA_DTPREL_LO16, + BFD_RELOC_ALPHA_DTPREL16, + BFD_RELOC_ALPHA_GOTTPREL16, + BFD_RELOC_ALPHA_TPREL64, + BFD_RELOC_ALPHA_TPREL_HI16, + BFD_RELOC_ALPHA_TPREL_LO16, + BFD_RELOC_ALPHA_TPREL16, + +/* Bits 27..2 of the relocation address shifted right 2 bits; +simple reloc otherwise. */ + BFD_RELOC_MIPS_JMP, + +/* The MIPS16 jump instruction. */ + BFD_RELOC_MIPS16_JMP, + +/* MIPS16 GP relative reloc. */ + BFD_RELOC_MIPS16_GPREL, + +/* High 16 bits of 32-bit value; simple reloc. */ + BFD_RELOC_HI16, + +/* High 16 bits of 32-bit value but the low 16 bits will be sign +extended and added to form the final result. If the low 16 +bits form a negative number, we need to add one to the high value +to compensate for the borrow when the low bits are added. */ + BFD_RELOC_HI16_S, + +/* Low 16 bits. */ + BFD_RELOC_LO16, + +/* High 16 bits of 32-bit pc-relative value */ + BFD_RELOC_HI16_PCREL, + +/* High 16 bits of 32-bit pc-relative value, adjusted */ + BFD_RELOC_HI16_S_PCREL, + +/* Low 16 bits of pc-relative value */ + BFD_RELOC_LO16_PCREL, + +/* MIPS16 high 16 bits of 32-bit value. */ + BFD_RELOC_MIPS16_HI16, + +/* MIPS16 high 16 bits of 32-bit value but the low 16 bits will be sign +extended and added to form the final result. If the low 16 +bits form a negative number, we need to add one to the high value +to compensate for the borrow when the low bits are added. */ + BFD_RELOC_MIPS16_HI16_S, + +/* MIPS16 low 16 bits. */ + BFD_RELOC_MIPS16_LO16, + +/* Relocation against a MIPS literal section. */ + BFD_RELOC_MIPS_LITERAL, + +/* MIPS ELF relocations. */ + BFD_RELOC_MIPS_GOT16, + BFD_RELOC_MIPS_CALL16, + BFD_RELOC_MIPS_GOT_HI16, + BFD_RELOC_MIPS_GOT_LO16, + BFD_RELOC_MIPS_CALL_HI16, + BFD_RELOC_MIPS_CALL_LO16, + BFD_RELOC_MIPS_SUB, + BFD_RELOC_MIPS_GOT_PAGE, + BFD_RELOC_MIPS_GOT_OFST, + BFD_RELOC_MIPS_GOT_DISP, + BFD_RELOC_MIPS_SHIFT5, + BFD_RELOC_MIPS_SHIFT6, + BFD_RELOC_MIPS_INSERT_A, + BFD_RELOC_MIPS_INSERT_B, + BFD_RELOC_MIPS_DELETE, + BFD_RELOC_MIPS_HIGHEST, + BFD_RELOC_MIPS_HIGHER, + BFD_RELOC_MIPS_SCN_DISP, + BFD_RELOC_MIPS_REL16, + BFD_RELOC_MIPS_RELGOT, + BFD_RELOC_MIPS_JALR, + BFD_RELOC_MIPS_TLS_DTPMOD32, + BFD_RELOC_MIPS_TLS_DTPREL32, + BFD_RELOC_MIPS_TLS_DTPMOD64, + BFD_RELOC_MIPS_TLS_DTPREL64, + BFD_RELOC_MIPS_TLS_GD, + BFD_RELOC_MIPS_TLS_LDM, + BFD_RELOC_MIPS_TLS_DTPREL_HI16, + BFD_RELOC_MIPS_TLS_DTPREL_LO16, + BFD_RELOC_MIPS_TLS_GOTTPREL, + BFD_RELOC_MIPS_TLS_TPREL32, + BFD_RELOC_MIPS_TLS_TPREL64, + BFD_RELOC_MIPS_TLS_TPREL_HI16, + BFD_RELOC_MIPS_TLS_TPREL_LO16, + + +/* MIPS ELF relocations (VxWorks extensions). */ + BFD_RELOC_MIPS_COPY, + BFD_RELOC_MIPS_JUMP_SLOT, + + +/* Fujitsu Frv Relocations. */ + BFD_RELOC_FRV_LABEL16, + BFD_RELOC_FRV_LABEL24, + BFD_RELOC_FRV_LO16, + BFD_RELOC_FRV_HI16, + BFD_RELOC_FRV_GPREL12, + BFD_RELOC_FRV_GPRELU12, + BFD_RELOC_FRV_GPREL32, + BFD_RELOC_FRV_GPRELHI, + BFD_RELOC_FRV_GPRELLO, + BFD_RELOC_FRV_GOT12, + BFD_RELOC_FRV_GOTHI, + BFD_RELOC_FRV_GOTLO, + BFD_RELOC_FRV_FUNCDESC, + BFD_RELOC_FRV_FUNCDESC_GOT12, + BFD_RELOC_FRV_FUNCDESC_GOTHI, + BFD_RELOC_FRV_FUNCDESC_GOTLO, + BFD_RELOC_FRV_FUNCDESC_VALUE, + BFD_RELOC_FRV_FUNCDESC_GOTOFF12, + BFD_RELOC_FRV_FUNCDESC_GOTOFFHI, + BFD_RELOC_FRV_FUNCDESC_GOTOFFLO, + BFD_RELOC_FRV_GOTOFF12, + BFD_RELOC_FRV_GOTOFFHI, + BFD_RELOC_FRV_GOTOFFLO, + BFD_RELOC_FRV_GETTLSOFF, + BFD_RELOC_FRV_TLSDESC_VALUE, + BFD_RELOC_FRV_GOTTLSDESC12, + BFD_RELOC_FRV_GOTTLSDESCHI, + BFD_RELOC_FRV_GOTTLSDESCLO, + BFD_RELOC_FRV_TLSMOFF12, + BFD_RELOC_FRV_TLSMOFFHI, + BFD_RELOC_FRV_TLSMOFFLO, + BFD_RELOC_FRV_GOTTLSOFF12, + BFD_RELOC_FRV_GOTTLSOFFHI, + BFD_RELOC_FRV_GOTTLSOFFLO, + BFD_RELOC_FRV_TLSOFF, + BFD_RELOC_FRV_TLSDESC_RELAX, + BFD_RELOC_FRV_GETTLSOFF_RELAX, + BFD_RELOC_FRV_TLSOFF_RELAX, + BFD_RELOC_FRV_TLSMOFF, + + +/* This is a 24bit GOT-relative reloc for the mn10300. */ + BFD_RELOC_MN10300_GOTOFF24, + +/* This is a 32bit GOT-relative reloc for the mn10300, offset by two bytes +in the instruction. */ + BFD_RELOC_MN10300_GOT32, + +/* This is a 24bit GOT-relative reloc for the mn10300, offset by two bytes +in the instruction. */ + BFD_RELOC_MN10300_GOT24, + +/* This is a 16bit GOT-relative reloc for the mn10300, offset by two bytes +in the instruction. */ + BFD_RELOC_MN10300_GOT16, + +/* Copy symbol at runtime. */ + BFD_RELOC_MN10300_COPY, + +/* Create GOT entry. */ + BFD_RELOC_MN10300_GLOB_DAT, + +/* Create PLT entry. */ + BFD_RELOC_MN10300_JMP_SLOT, + +/* Adjust by program base. */ + BFD_RELOC_MN10300_RELATIVE, + + +/* i386/elf relocations */ + BFD_RELOC_386_GOT32, + BFD_RELOC_386_PLT32, + BFD_RELOC_386_COPY, + BFD_RELOC_386_GLOB_DAT, + BFD_RELOC_386_JUMP_SLOT, + BFD_RELOC_386_RELATIVE, + BFD_RELOC_386_GOTOFF, + BFD_RELOC_386_GOTPC, + BFD_RELOC_386_TLS_TPOFF, + BFD_RELOC_386_TLS_IE, + BFD_RELOC_386_TLS_GOTIE, + BFD_RELOC_386_TLS_LE, + BFD_RELOC_386_TLS_GD, + BFD_RELOC_386_TLS_LDM, + BFD_RELOC_386_TLS_LDO_32, + BFD_RELOC_386_TLS_IE_32, + BFD_RELOC_386_TLS_LE_32, + BFD_RELOC_386_TLS_DTPMOD32, + BFD_RELOC_386_TLS_DTPOFF32, + BFD_RELOC_386_TLS_TPOFF32, + BFD_RELOC_386_TLS_GOTDESC, + BFD_RELOC_386_TLS_DESC_CALL, + BFD_RELOC_386_TLS_DESC, + +/* x86-64/elf relocations */ + BFD_RELOC_X86_64_GOT32, + BFD_RELOC_X86_64_PLT32, + BFD_RELOC_X86_64_COPY, + BFD_RELOC_X86_64_GLOB_DAT, + BFD_RELOC_X86_64_JUMP_SLOT, + BFD_RELOC_X86_64_RELATIVE, + BFD_RELOC_X86_64_GOTPCREL, + BFD_RELOC_X86_64_32S, + BFD_RELOC_X86_64_DTPMOD64, + BFD_RELOC_X86_64_DTPOFF64, + BFD_RELOC_X86_64_TPOFF64, + BFD_RELOC_X86_64_TLSGD, + BFD_RELOC_X86_64_TLSLD, + BFD_RELOC_X86_64_DTPOFF32, + BFD_RELOC_X86_64_GOTTPOFF, + BFD_RELOC_X86_64_TPOFF32, + BFD_RELOC_X86_64_GOTOFF64, + BFD_RELOC_X86_64_GOTPC32, + BFD_RELOC_X86_64_GOT64, + BFD_RELOC_X86_64_GOTPCREL64, + BFD_RELOC_X86_64_GOTPC64, + BFD_RELOC_X86_64_GOTPLT64, + BFD_RELOC_X86_64_PLTOFF64, + BFD_RELOC_X86_64_GOTPC32_TLSDESC, + BFD_RELOC_X86_64_TLSDESC_CALL, + BFD_RELOC_X86_64_TLSDESC, + +/* ns32k relocations */ + BFD_RELOC_NS32K_IMM_8, + BFD_RELOC_NS32K_IMM_16, + BFD_RELOC_NS32K_IMM_32, + BFD_RELOC_NS32K_IMM_8_PCREL, + BFD_RELOC_NS32K_IMM_16_PCREL, + BFD_RELOC_NS32K_IMM_32_PCREL, + BFD_RELOC_NS32K_DISP_8, + BFD_RELOC_NS32K_DISP_16, + BFD_RELOC_NS32K_DISP_32, + BFD_RELOC_NS32K_DISP_8_PCREL, + BFD_RELOC_NS32K_DISP_16_PCREL, + BFD_RELOC_NS32K_DISP_32_PCREL, + +/* PDP11 relocations */ + BFD_RELOC_PDP11_DISP_8_PCREL, + BFD_RELOC_PDP11_DISP_6_PCREL, + +/* Picojava relocs. Not all of these appear in object files. */ + BFD_RELOC_PJ_CODE_HI16, + BFD_RELOC_PJ_CODE_LO16, + BFD_RELOC_PJ_CODE_DIR16, + BFD_RELOC_PJ_CODE_DIR32, + BFD_RELOC_PJ_CODE_REL16, + BFD_RELOC_PJ_CODE_REL32, + +/* Power(rs6000) and PowerPC relocations. */ + BFD_RELOC_PPC_B26, + BFD_RELOC_PPC_BA26, + BFD_RELOC_PPC_TOC16, + BFD_RELOC_PPC_B16, + BFD_RELOC_PPC_B16_BRTAKEN, + BFD_RELOC_PPC_B16_BRNTAKEN, + BFD_RELOC_PPC_BA16, + BFD_RELOC_PPC_BA16_BRTAKEN, + BFD_RELOC_PPC_BA16_BRNTAKEN, + BFD_RELOC_PPC_COPY, + BFD_RELOC_PPC_GLOB_DAT, + BFD_RELOC_PPC_JMP_SLOT, + BFD_RELOC_PPC_RELATIVE, + BFD_RELOC_PPC_LOCAL24PC, + BFD_RELOC_PPC_EMB_NADDR32, + BFD_RELOC_PPC_EMB_NADDR16, + BFD_RELOC_PPC_EMB_NADDR16_LO, + BFD_RELOC_PPC_EMB_NADDR16_HI, + BFD_RELOC_PPC_EMB_NADDR16_HA, + BFD_RELOC_PPC_EMB_SDAI16, + BFD_RELOC_PPC_EMB_SDA2I16, + BFD_RELOC_PPC_EMB_SDA2REL, + BFD_RELOC_PPC_EMB_SDA21, + BFD_RELOC_PPC_EMB_MRKREF, + BFD_RELOC_PPC_EMB_RELSEC16, + BFD_RELOC_PPC_EMB_RELST_LO, + BFD_RELOC_PPC_EMB_RELST_HI, + BFD_RELOC_PPC_EMB_RELST_HA, + BFD_RELOC_PPC_EMB_BIT_FLD, + BFD_RELOC_PPC_EMB_RELSDA, + BFD_RELOC_PPC64_HIGHER, + BFD_RELOC_PPC64_HIGHER_S, + BFD_RELOC_PPC64_HIGHEST, + BFD_RELOC_PPC64_HIGHEST_S, + BFD_RELOC_PPC64_TOC16_LO, + BFD_RELOC_PPC64_TOC16_HI, + BFD_RELOC_PPC64_TOC16_HA, + BFD_RELOC_PPC64_TOC, + BFD_RELOC_PPC64_PLTGOT16, + BFD_RELOC_PPC64_PLTGOT16_LO, + BFD_RELOC_PPC64_PLTGOT16_HI, + BFD_RELOC_PPC64_PLTGOT16_HA, + BFD_RELOC_PPC64_ADDR16_DS, + BFD_RELOC_PPC64_ADDR16_LO_DS, + BFD_RELOC_PPC64_GOT16_DS, + BFD_RELOC_PPC64_GOT16_LO_DS, + BFD_RELOC_PPC64_PLT16_LO_DS, + BFD_RELOC_PPC64_SECTOFF_DS, + BFD_RELOC_PPC64_SECTOFF_LO_DS, + BFD_RELOC_PPC64_TOC16_DS, + BFD_RELOC_PPC64_TOC16_LO_DS, + BFD_RELOC_PPC64_PLTGOT16_DS, + BFD_RELOC_PPC64_PLTGOT16_LO_DS, + +/* PowerPC and PowerPC64 thread-local storage relocations. */ + BFD_RELOC_PPC_TLS, + BFD_RELOC_PPC_TLSGD, + BFD_RELOC_PPC_TLSLD, + BFD_RELOC_PPC_DTPMOD, + BFD_RELOC_PPC_TPREL16, + BFD_RELOC_PPC_TPREL16_LO, + BFD_RELOC_PPC_TPREL16_HI, + BFD_RELOC_PPC_TPREL16_HA, + BFD_RELOC_PPC_TPREL, + BFD_RELOC_PPC_DTPREL16, + BFD_RELOC_PPC_DTPREL16_LO, + BFD_RELOC_PPC_DTPREL16_HI, + BFD_RELOC_PPC_DTPREL16_HA, + BFD_RELOC_PPC_DTPREL, + BFD_RELOC_PPC_GOT_TLSGD16, + BFD_RELOC_PPC_GOT_TLSGD16_LO, + BFD_RELOC_PPC_GOT_TLSGD16_HI, + BFD_RELOC_PPC_GOT_TLSGD16_HA, + BFD_RELOC_PPC_GOT_TLSLD16, + BFD_RELOC_PPC_GOT_TLSLD16_LO, + BFD_RELOC_PPC_GOT_TLSLD16_HI, + BFD_RELOC_PPC_GOT_TLSLD16_HA, + BFD_RELOC_PPC_GOT_TPREL16, + BFD_RELOC_PPC_GOT_TPREL16_LO, + BFD_RELOC_PPC_GOT_TPREL16_HI, + BFD_RELOC_PPC_GOT_TPREL16_HA, + BFD_RELOC_PPC_GOT_DTPREL16, + BFD_RELOC_PPC_GOT_DTPREL16_LO, + BFD_RELOC_PPC_GOT_DTPREL16_HI, + BFD_RELOC_PPC_GOT_DTPREL16_HA, + BFD_RELOC_PPC64_TPREL16_DS, + BFD_RELOC_PPC64_TPREL16_LO_DS, + BFD_RELOC_PPC64_TPREL16_HIGHER, + BFD_RELOC_PPC64_TPREL16_HIGHERA, + BFD_RELOC_PPC64_TPREL16_HIGHEST, + BFD_RELOC_PPC64_TPREL16_HIGHESTA, + BFD_RELOC_PPC64_DTPREL16_DS, + BFD_RELOC_PPC64_DTPREL16_LO_DS, + BFD_RELOC_PPC64_DTPREL16_HIGHER, + BFD_RELOC_PPC64_DTPREL16_HIGHERA, + BFD_RELOC_PPC64_DTPREL16_HIGHEST, + BFD_RELOC_PPC64_DTPREL16_HIGHESTA, + +/* IBM 370/390 relocations */ + BFD_RELOC_I370_D12, + +/* The type of reloc used to build a constructor table - at the moment +probably a 32 bit wide absolute relocation, but the target can choose. +It generally does map to one of the other relocation types. */ + BFD_RELOC_CTOR, + +/* ARM 26 bit pc-relative branch. The lowest two bits must be zero and are +not stored in the instruction. */ + BFD_RELOC_ARM_PCREL_BRANCH, + +/* ARM 26 bit pc-relative branch. The lowest bit must be zero and is +not stored in the instruction. The 2nd lowest bit comes from a 1 bit +field in the instruction. */ + BFD_RELOC_ARM_PCREL_BLX, + +/* Thumb 22 bit pc-relative branch. The lowest bit must be zero and is +not stored in the instruction. The 2nd lowest bit comes from a 1 bit +field in the instruction. */ + BFD_RELOC_THUMB_PCREL_BLX, + +/* ARM 26-bit pc-relative branch for an unconditional BL or BLX instruction. */ + BFD_RELOC_ARM_PCREL_CALL, + +/* ARM 26-bit pc-relative branch for B or conditional BL instruction. */ + BFD_RELOC_ARM_PCREL_JUMP, + +/* Thumb 7-, 9-, 12-, 20-, 23-, and 25-bit pc-relative branches. +The lowest bit must be zero and is not stored in the instruction. +Note that the corresponding ELF R_ARM_THM_JUMPnn constant has an +"nn" one smaller in all cases. Note further that BRANCH23 +corresponds to R_ARM_THM_CALL. */ + BFD_RELOC_THUMB_PCREL_BRANCH7, + BFD_RELOC_THUMB_PCREL_BRANCH9, + BFD_RELOC_THUMB_PCREL_BRANCH12, + BFD_RELOC_THUMB_PCREL_BRANCH20, + BFD_RELOC_THUMB_PCREL_BRANCH23, + BFD_RELOC_THUMB_PCREL_BRANCH25, + +/* 12-bit immediate offset, used in ARM-format ldr and str instructions. */ + BFD_RELOC_ARM_OFFSET_IMM, + +/* 5-bit immediate offset, used in Thumb-format ldr and str instructions. */ + BFD_RELOC_ARM_THUMB_OFFSET, + +/* Pc-relative or absolute relocation depending on target. Used for +entries in .init_array sections. */ + BFD_RELOC_ARM_TARGET1, + +/* Read-only segment base relative address. */ + BFD_RELOC_ARM_ROSEGREL32, + +/* Data segment base relative address. */ + BFD_RELOC_ARM_SBREL32, + +/* This reloc is used for references to RTTI data from exception handling +tables. The actual definition depends on the target. It may be a +pc-relative or some form of GOT-indirect relocation. */ + BFD_RELOC_ARM_TARGET2, + +/* 31-bit PC relative address. */ + BFD_RELOC_ARM_PREL31, + +/* Low and High halfword relocations for MOVW and MOVT instructions. */ + BFD_RELOC_ARM_MOVW, + BFD_RELOC_ARM_MOVT, + BFD_RELOC_ARM_MOVW_PCREL, + BFD_RELOC_ARM_MOVT_PCREL, + BFD_RELOC_ARM_THUMB_MOVW, + BFD_RELOC_ARM_THUMB_MOVT, + BFD_RELOC_ARM_THUMB_MOVW_PCREL, + BFD_RELOC_ARM_THUMB_MOVT_PCREL, + +/* Relocations for setting up GOTs and PLTs for shared libraries. */ + BFD_RELOC_ARM_JUMP_SLOT, + BFD_RELOC_ARM_GLOB_DAT, + BFD_RELOC_ARM_GOT32, + BFD_RELOC_ARM_PLT32, + BFD_RELOC_ARM_RELATIVE, + BFD_RELOC_ARM_GOTOFF, + BFD_RELOC_ARM_GOTPC, + +/* ARM thread-local storage relocations. */ + BFD_RELOC_ARM_TLS_GD32, + BFD_RELOC_ARM_TLS_LDO32, + BFD_RELOC_ARM_TLS_LDM32, + BFD_RELOC_ARM_TLS_DTPOFF32, + BFD_RELOC_ARM_TLS_DTPMOD32, + BFD_RELOC_ARM_TLS_TPOFF32, + BFD_RELOC_ARM_TLS_IE32, + BFD_RELOC_ARM_TLS_LE32, + +/* ARM group relocations. */ + BFD_RELOC_ARM_ALU_PC_G0_NC, + BFD_RELOC_ARM_ALU_PC_G0, + BFD_RELOC_ARM_ALU_PC_G1_NC, + BFD_RELOC_ARM_ALU_PC_G1, + BFD_RELOC_ARM_ALU_PC_G2, + BFD_RELOC_ARM_LDR_PC_G0, + BFD_RELOC_ARM_LDR_PC_G1, + BFD_RELOC_ARM_LDR_PC_G2, + BFD_RELOC_ARM_LDRS_PC_G0, + BFD_RELOC_ARM_LDRS_PC_G1, + BFD_RELOC_ARM_LDRS_PC_G2, + BFD_RELOC_ARM_LDC_PC_G0, + BFD_RELOC_ARM_LDC_PC_G1, + BFD_RELOC_ARM_LDC_PC_G2, + BFD_RELOC_ARM_ALU_SB_G0_NC, + BFD_RELOC_ARM_ALU_SB_G0, + BFD_RELOC_ARM_ALU_SB_G1_NC, + BFD_RELOC_ARM_ALU_SB_G1, + BFD_RELOC_ARM_ALU_SB_G2, + BFD_RELOC_ARM_LDR_SB_G0, + BFD_RELOC_ARM_LDR_SB_G1, + BFD_RELOC_ARM_LDR_SB_G2, + BFD_RELOC_ARM_LDRS_SB_G0, + BFD_RELOC_ARM_LDRS_SB_G1, + BFD_RELOC_ARM_LDRS_SB_G2, + BFD_RELOC_ARM_LDC_SB_G0, + BFD_RELOC_ARM_LDC_SB_G1, + BFD_RELOC_ARM_LDC_SB_G2, + +/* These relocs are only used within the ARM assembler. They are not +(at present) written to any object files. */ + BFD_RELOC_ARM_IMMEDIATE, + BFD_RELOC_ARM_ADRL_IMMEDIATE, + BFD_RELOC_ARM_T32_IMMEDIATE, + BFD_RELOC_ARM_T32_ADD_IMM, + BFD_RELOC_ARM_T32_IMM12, + BFD_RELOC_ARM_T32_ADD_PC12, + BFD_RELOC_ARM_SHIFT_IMM, + BFD_RELOC_ARM_SMC, + BFD_RELOC_ARM_SWI, + BFD_RELOC_ARM_MULTI, + BFD_RELOC_ARM_CP_OFF_IMM, + BFD_RELOC_ARM_CP_OFF_IMM_S2, + BFD_RELOC_ARM_T32_CP_OFF_IMM, + BFD_RELOC_ARM_T32_CP_OFF_IMM_S2, + BFD_RELOC_ARM_ADR_IMM, + BFD_RELOC_ARM_LDR_IMM, + BFD_RELOC_ARM_LITERAL, + BFD_RELOC_ARM_IN_POOL, + BFD_RELOC_ARM_OFFSET_IMM8, + BFD_RELOC_ARM_T32_OFFSET_U8, + BFD_RELOC_ARM_T32_OFFSET_IMM, + BFD_RELOC_ARM_HWLITERAL, + BFD_RELOC_ARM_THUMB_ADD, + BFD_RELOC_ARM_THUMB_IMM, + BFD_RELOC_ARM_THUMB_SHIFT, + +/* Renesas / SuperH SH relocs. Not all of these appear in object files. */ + BFD_RELOC_SH_PCDISP8BY2, + BFD_RELOC_SH_PCDISP12BY2, + BFD_RELOC_SH_IMM3, + BFD_RELOC_SH_IMM3U, + BFD_RELOC_SH_DISP12, + BFD_RELOC_SH_DISP12BY2, + BFD_RELOC_SH_DISP12BY4, + BFD_RELOC_SH_DISP12BY8, + BFD_RELOC_SH_DISP20, + BFD_RELOC_SH_DISP20BY8, + BFD_RELOC_SH_IMM4, + BFD_RELOC_SH_IMM4BY2, + BFD_RELOC_SH_IMM4BY4, + BFD_RELOC_SH_IMM8, + BFD_RELOC_SH_IMM8BY2, + BFD_RELOC_SH_IMM8BY4, + BFD_RELOC_SH_PCRELIMM8BY2, + BFD_RELOC_SH_PCRELIMM8BY4, + BFD_RELOC_SH_SWITCH16, + BFD_RELOC_SH_SWITCH32, + BFD_RELOC_SH_USES, + BFD_RELOC_SH_COUNT, + BFD_RELOC_SH_ALIGN, + BFD_RELOC_SH_CODE, + BFD_RELOC_SH_DATA, + BFD_RELOC_SH_LABEL, + BFD_RELOC_SH_LOOP_START, + BFD_RELOC_SH_LOOP_END, + BFD_RELOC_SH_COPY, + BFD_RELOC_SH_GLOB_DAT, + BFD_RELOC_SH_JMP_SLOT, + BFD_RELOC_SH_RELATIVE, + BFD_RELOC_SH_GOTPC, + BFD_RELOC_SH_GOT_LOW16, + BFD_RELOC_SH_GOT_MEDLOW16, + BFD_RELOC_SH_GOT_MEDHI16, + BFD_RELOC_SH_GOT_HI16, + BFD_RELOC_SH_GOTPLT_LOW16, + BFD_RELOC_SH_GOTPLT_MEDLOW16, + BFD_RELOC_SH_GOTPLT_MEDHI16, + BFD_RELOC_SH_GOTPLT_HI16, + BFD_RELOC_SH_PLT_LOW16, + BFD_RELOC_SH_PLT_MEDLOW16, + BFD_RELOC_SH_PLT_MEDHI16, + BFD_RELOC_SH_PLT_HI16, + BFD_RELOC_SH_GOTOFF_LOW16, + BFD_RELOC_SH_GOTOFF_MEDLOW16, + BFD_RELOC_SH_GOTOFF_MEDHI16, + BFD_RELOC_SH_GOTOFF_HI16, + BFD_RELOC_SH_GOTPC_LOW16, + BFD_RELOC_SH_GOTPC_MEDLOW16, + BFD_RELOC_SH_GOTPC_MEDHI16, + BFD_RELOC_SH_GOTPC_HI16, + BFD_RELOC_SH_COPY64, + BFD_RELOC_SH_GLOB_DAT64, + BFD_RELOC_SH_JMP_SLOT64, + BFD_RELOC_SH_RELATIVE64, + BFD_RELOC_SH_GOT10BY4, + BFD_RELOC_SH_GOT10BY8, + BFD_RELOC_SH_GOTPLT10BY4, + BFD_RELOC_SH_GOTPLT10BY8, + BFD_RELOC_SH_GOTPLT32, + BFD_RELOC_SH_SHMEDIA_CODE, + BFD_RELOC_SH_IMMU5, + BFD_RELOC_SH_IMMS6, + BFD_RELOC_SH_IMMS6BY32, + BFD_RELOC_SH_IMMU6, + BFD_RELOC_SH_IMMS10, + BFD_RELOC_SH_IMMS10BY2, + BFD_RELOC_SH_IMMS10BY4, + BFD_RELOC_SH_IMMS10BY8, + BFD_RELOC_SH_IMMS16, + BFD_RELOC_SH_IMMU16, + BFD_RELOC_SH_IMM_LOW16, + BFD_RELOC_SH_IMM_LOW16_PCREL, + BFD_RELOC_SH_IMM_MEDLOW16, + BFD_RELOC_SH_IMM_MEDLOW16_PCREL, + BFD_RELOC_SH_IMM_MEDHI16, + BFD_RELOC_SH_IMM_MEDHI16_PCREL, + BFD_RELOC_SH_IMM_HI16, + BFD_RELOC_SH_IMM_HI16_PCREL, + BFD_RELOC_SH_PT_16, + BFD_RELOC_SH_TLS_GD_32, + BFD_RELOC_SH_TLS_LD_32, + BFD_RELOC_SH_TLS_LDO_32, + BFD_RELOC_SH_TLS_IE_32, + BFD_RELOC_SH_TLS_LE_32, + BFD_RELOC_SH_TLS_DTPMOD32, + BFD_RELOC_SH_TLS_DTPOFF32, + BFD_RELOC_SH_TLS_TPOFF32, + +/* ARC Cores relocs. +ARC 22 bit pc-relative branch. The lowest two bits must be zero and are +not stored in the instruction. The high 20 bits are installed in bits 26 +through 7 of the instruction. */ + BFD_RELOC_ARC_B22_PCREL, + +/* ARC 26 bit absolute branch. The lowest two bits must be zero and are not +stored in the instruction. The high 24 bits are installed in bits 23 +through 0. */ + BFD_RELOC_ARC_B26, + +/* ADI Blackfin 16 bit immediate absolute reloc. */ + BFD_RELOC_BFIN_16_IMM, + +/* ADI Blackfin 16 bit immediate absolute reloc higher 16 bits. */ + BFD_RELOC_BFIN_16_HIGH, + +/* ADI Blackfin 'a' part of LSETUP. */ + BFD_RELOC_BFIN_4_PCREL, + +/* ADI Blackfin. */ + BFD_RELOC_BFIN_5_PCREL, + +/* ADI Blackfin 16 bit immediate absolute reloc lower 16 bits. */ + BFD_RELOC_BFIN_16_LOW, + +/* ADI Blackfin. */ + BFD_RELOC_BFIN_10_PCREL, + +/* ADI Blackfin 'b' part of LSETUP. */ + BFD_RELOC_BFIN_11_PCREL, + +/* ADI Blackfin. */ + BFD_RELOC_BFIN_12_PCREL_JUMP, + +/* ADI Blackfin Short jump, pcrel. */ + BFD_RELOC_BFIN_12_PCREL_JUMP_S, + +/* ADI Blackfin Call.x not implemented. */ + BFD_RELOC_BFIN_24_PCREL_CALL_X, + +/* ADI Blackfin Long Jump pcrel. */ + BFD_RELOC_BFIN_24_PCREL_JUMP_L, + +/* ADI Blackfin FD-PIC relocations. */ + BFD_RELOC_BFIN_GOT17M4, + BFD_RELOC_BFIN_GOTHI, + BFD_RELOC_BFIN_GOTLO, + BFD_RELOC_BFIN_FUNCDESC, + BFD_RELOC_BFIN_FUNCDESC_GOT17M4, + BFD_RELOC_BFIN_FUNCDESC_GOTHI, + BFD_RELOC_BFIN_FUNCDESC_GOTLO, + BFD_RELOC_BFIN_FUNCDESC_VALUE, + BFD_RELOC_BFIN_FUNCDESC_GOTOFF17M4, + BFD_RELOC_BFIN_FUNCDESC_GOTOFFHI, + BFD_RELOC_BFIN_FUNCDESC_GOTOFFLO, + BFD_RELOC_BFIN_GOTOFF17M4, + BFD_RELOC_BFIN_GOTOFFHI, + BFD_RELOC_BFIN_GOTOFFLO, + +/* ADI Blackfin GOT relocation. */ + BFD_RELOC_BFIN_GOT, + +/* ADI Blackfin PLTPC relocation. */ + BFD_RELOC_BFIN_PLTPC, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_PUSH, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_CONST, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_ADD, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_SUB, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_MULT, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_DIV, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_MOD, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_LSHIFT, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_RSHIFT, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_AND, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_OR, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_XOR, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_LAND, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_LOR, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_LEN, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_NEG, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_COMP, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_PAGE, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_HWPAGE, + +/* ADI Blackfin arithmetic relocation. */ + BFD_ARELOC_BFIN_ADDR, + +/* Mitsubishi D10V relocs. +This is a 10-bit reloc with the right 2 bits +assumed to be 0. */ + BFD_RELOC_D10V_10_PCREL_R, + +/* Mitsubishi D10V relocs. +This is a 10-bit reloc with the right 2 bits +assumed to be 0. This is the same as the previous reloc +except it is in the left container, i.e., +shifted left 15 bits. */ + BFD_RELOC_D10V_10_PCREL_L, + +/* This is an 18-bit reloc with the right 2 bits +assumed to be 0. */ + BFD_RELOC_D10V_18, + +/* This is an 18-bit reloc with the right 2 bits +assumed to be 0. */ + BFD_RELOC_D10V_18_PCREL, + +/* Mitsubishi D30V relocs. +This is a 6-bit absolute reloc. */ + BFD_RELOC_D30V_6, + +/* This is a 6-bit pc-relative reloc with +the right 3 bits assumed to be 0. */ + BFD_RELOC_D30V_9_PCREL, + +/* This is a 6-bit pc-relative reloc with +the right 3 bits assumed to be 0. Same +as the previous reloc but on the right side +of the container. */ + BFD_RELOC_D30V_9_PCREL_R, + +/* This is a 12-bit absolute reloc with the +right 3 bitsassumed to be 0. */ + BFD_RELOC_D30V_15, + +/* This is a 12-bit pc-relative reloc with +the right 3 bits assumed to be 0. */ + BFD_RELOC_D30V_15_PCREL, + +/* This is a 12-bit pc-relative reloc with +the right 3 bits assumed to be 0. Same +as the previous reloc but on the right side +of the container. */ + BFD_RELOC_D30V_15_PCREL_R, + +/* This is an 18-bit absolute reloc with +the right 3 bits assumed to be 0. */ + BFD_RELOC_D30V_21, + +/* This is an 18-bit pc-relative reloc with +the right 3 bits assumed to be 0. */ + BFD_RELOC_D30V_21_PCREL, + +/* This is an 18-bit pc-relative reloc with +the right 3 bits assumed to be 0. Same +as the previous reloc but on the right side +of the container. */ + BFD_RELOC_D30V_21_PCREL_R, + +/* This is a 32-bit absolute reloc. */ + BFD_RELOC_D30V_32, + +/* This is a 32-bit pc-relative reloc. */ + BFD_RELOC_D30V_32_PCREL, + +/* DLX relocs */ + BFD_RELOC_DLX_HI16_S, + +/* DLX relocs */ + BFD_RELOC_DLX_LO16, + +/* DLX relocs */ + BFD_RELOC_DLX_JMP26, + +/* Renesas M16C/M32C Relocations. */ + BFD_RELOC_M32C_HI8, + BFD_RELOC_M32C_RL_JUMP, + BFD_RELOC_M32C_RL_1ADDR, + BFD_RELOC_M32C_RL_2ADDR, + +/* Renesas M32R (formerly Mitsubishi M32R) relocs. +This is a 24 bit absolute address. */ + BFD_RELOC_M32R_24, + +/* This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_10_PCREL, + +/* This is an 18-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_18_PCREL, + +/* This is a 26-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_26_PCREL, + +/* This is a 16-bit reloc containing the high 16 bits of an address +used when the lower 16 bits are treated as unsigned. */ + BFD_RELOC_M32R_HI16_ULO, + +/* This is a 16-bit reloc containing the high 16 bits of an address +used when the lower 16 bits are treated as signed. */ + BFD_RELOC_M32R_HI16_SLO, + +/* This is a 16-bit reloc containing the lower 16 bits of an address. */ + BFD_RELOC_M32R_LO16, + +/* This is a 16-bit reloc containing the small data area offset for use in +add3, load, and store instructions. */ + BFD_RELOC_M32R_SDA16, + +/* For PIC. */ + BFD_RELOC_M32R_GOT24, + BFD_RELOC_M32R_26_PLTREL, + BFD_RELOC_M32R_COPY, + BFD_RELOC_M32R_GLOB_DAT, + BFD_RELOC_M32R_JMP_SLOT, + BFD_RELOC_M32R_RELATIVE, + BFD_RELOC_M32R_GOTOFF, + BFD_RELOC_M32R_GOTOFF_HI_ULO, + BFD_RELOC_M32R_GOTOFF_HI_SLO, + BFD_RELOC_M32R_GOTOFF_LO, + BFD_RELOC_M32R_GOTPC24, + BFD_RELOC_M32R_GOT16_HI_ULO, + BFD_RELOC_M32R_GOT16_HI_SLO, + BFD_RELOC_M32R_GOT16_LO, + BFD_RELOC_M32R_GOTPC_HI_ULO, + BFD_RELOC_M32R_GOTPC_HI_SLO, + BFD_RELOC_M32R_GOTPC_LO, + +/* This is a 9-bit reloc */ + BFD_RELOC_V850_9_PCREL, + +/* This is a 22-bit reloc */ + BFD_RELOC_V850_22_PCREL, + +/* This is a 16 bit offset from the short data area pointer. */ + BFD_RELOC_V850_SDA_16_16_OFFSET, + +/* This is a 16 bit offset (of which only 15 bits are used) from the +short data area pointer. */ + BFD_RELOC_V850_SDA_15_16_OFFSET, + +/* This is a 16 bit offset from the zero data area pointer. */ + BFD_RELOC_V850_ZDA_16_16_OFFSET, + +/* This is a 16 bit offset (of which only 15 bits are used) from the +zero data area pointer. */ + BFD_RELOC_V850_ZDA_15_16_OFFSET, + +/* This is an 8 bit offset (of which only 6 bits are used) from the +tiny data area pointer. */ + BFD_RELOC_V850_TDA_6_8_OFFSET, + +/* This is an 8bit offset (of which only 7 bits are used) from the tiny +data area pointer. */ + BFD_RELOC_V850_TDA_7_8_OFFSET, + +/* This is a 7 bit offset from the tiny data area pointer. */ + BFD_RELOC_V850_TDA_7_7_OFFSET, + +/* This is a 16 bit offset from the tiny data area pointer. */ + BFD_RELOC_V850_TDA_16_16_OFFSET, + +/* This is a 5 bit offset (of which only 4 bits are used) from the tiny +data area pointer. */ + BFD_RELOC_V850_TDA_4_5_OFFSET, + +/* This is a 4 bit offset from the tiny data area pointer. */ + BFD_RELOC_V850_TDA_4_4_OFFSET, + +/* This is a 16 bit offset from the short data area pointer, with the +bits placed non-contiguously in the instruction. */ + BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET, + +/* This is a 16 bit offset from the zero data area pointer, with the +bits placed non-contiguously in the instruction. */ + BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET, + +/* This is a 6 bit offset from the call table base pointer. */ + BFD_RELOC_V850_CALLT_6_7_OFFSET, + +/* This is a 16 bit offset from the call table base pointer. */ + BFD_RELOC_V850_CALLT_16_16_OFFSET, + +/* Used for relaxing indirect function calls. */ + BFD_RELOC_V850_LONGCALL, + +/* Used for relaxing indirect jumps. */ + BFD_RELOC_V850_LONGJUMP, + +/* Used to maintain alignment whilst relaxing. */ + BFD_RELOC_V850_ALIGN, + +/* This is a variation of BFD_RELOC_LO16 that can be used in v850e ld.bu +instructions. */ + BFD_RELOC_V850_LO16_SPLIT_OFFSET, + +/* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the +instruction. */ + BFD_RELOC_MN10300_32_PCREL, + +/* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the +instruction. */ + BFD_RELOC_MN10300_16_PCREL, + +/* This is a 8bit DP reloc for the tms320c30, where the most +significant 8 bits of a 24 bit word are placed into the least +significant 8 bits of the opcode. */ + BFD_RELOC_TIC30_LDP, + +/* This is a 7bit reloc for the tms320c54x, where the least +significant 7 bits of a 16 bit word are placed into the least +significant 7 bits of the opcode. */ + BFD_RELOC_TIC54X_PARTLS7, + +/* This is a 9bit DP reloc for the tms320c54x, where the most +significant 9 bits of a 16 bit word are placed into the least +significant 9 bits of the opcode. */ + BFD_RELOC_TIC54X_PARTMS9, + +/* This is an extended address 23-bit reloc for the tms320c54x. */ + BFD_RELOC_TIC54X_23, + +/* This is a 16-bit reloc for the tms320c54x, where the least +significant 16 bits of a 23-bit extended address are placed into +the opcode. */ + BFD_RELOC_TIC54X_16_OF_23, + +/* This is a reloc for the tms320c54x, where the most +significant 7 bits of a 23-bit extended address are placed into +the opcode. */ + BFD_RELOC_TIC54X_MS7_OF_23, + +/* This is a 48 bit reloc for the FR30 that stores 32 bits. */ + BFD_RELOC_FR30_48, + +/* This is a 32 bit reloc for the FR30 that stores 20 bits split up into +two sections. */ + BFD_RELOC_FR30_20, + +/* This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in +4 bits. */ + BFD_RELOC_FR30_6_IN_4, + +/* This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset +into 8 bits. */ + BFD_RELOC_FR30_8_IN_8, + +/* This is a 16 bit reloc for the FR30 that stores a 9 bit short offset +into 8 bits. */ + BFD_RELOC_FR30_9_IN_8, + +/* This is a 16 bit reloc for the FR30 that stores a 10 bit word offset +into 8 bits. */ + BFD_RELOC_FR30_10_IN_8, + +/* This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative +short offset into 8 bits. */ + BFD_RELOC_FR30_9_PCREL, + +/* This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative +short offset into 11 bits. */ + BFD_RELOC_FR30_12_PCREL, + +/* Motorola Mcore relocations. */ + BFD_RELOC_MCORE_PCREL_IMM8BY4, + BFD_RELOC_MCORE_PCREL_IMM11BY2, + BFD_RELOC_MCORE_PCREL_IMM4BY2, + BFD_RELOC_MCORE_PCREL_32, + BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2, + BFD_RELOC_MCORE_RVA, + +/* Toshiba Media Processor Relocations. */ + BFD_RELOC_MEP_8, + BFD_RELOC_MEP_16, + BFD_RELOC_MEP_32, + BFD_RELOC_MEP_PCREL8A2, + BFD_RELOC_MEP_PCREL12A2, + BFD_RELOC_MEP_PCREL17A2, + BFD_RELOC_MEP_PCREL24A2, + BFD_RELOC_MEP_PCABS24A2, + BFD_RELOC_MEP_LOW16, + BFD_RELOC_MEP_HI16U, + BFD_RELOC_MEP_HI16S, + BFD_RELOC_MEP_GPREL, + BFD_RELOC_MEP_TPREL, + BFD_RELOC_MEP_TPREL7, + BFD_RELOC_MEP_TPREL7A2, + BFD_RELOC_MEP_TPREL7A4, + BFD_RELOC_MEP_UIMM24, + BFD_RELOC_MEP_ADDR24A4, + BFD_RELOC_MEP_GNU_VTINHERIT, + BFD_RELOC_MEP_GNU_VTENTRY, + + +/* These are relocations for the GETA instruction. */ + BFD_RELOC_MMIX_GETA, + BFD_RELOC_MMIX_GETA_1, + BFD_RELOC_MMIX_GETA_2, + BFD_RELOC_MMIX_GETA_3, + +/* These are relocations for a conditional branch instruction. */ + BFD_RELOC_MMIX_CBRANCH, + BFD_RELOC_MMIX_CBRANCH_J, + BFD_RELOC_MMIX_CBRANCH_1, + BFD_RELOC_MMIX_CBRANCH_2, + BFD_RELOC_MMIX_CBRANCH_3, + +/* These are relocations for the PUSHJ instruction. */ + BFD_RELOC_MMIX_PUSHJ, + BFD_RELOC_MMIX_PUSHJ_1, + BFD_RELOC_MMIX_PUSHJ_2, + BFD_RELOC_MMIX_PUSHJ_3, + BFD_RELOC_MMIX_PUSHJ_STUBBABLE, + +/* These are relocations for the JMP instruction. */ + BFD_RELOC_MMIX_JMP, + BFD_RELOC_MMIX_JMP_1, + BFD_RELOC_MMIX_JMP_2, + BFD_RELOC_MMIX_JMP_3, + +/* This is a relocation for a relative address as in a GETA instruction or +a branch. */ + BFD_RELOC_MMIX_ADDR19, + +/* This is a relocation for a relative address as in a JMP instruction. */ + BFD_RELOC_MMIX_ADDR27, + +/* This is a relocation for an instruction field that may be a general +register or a value 0..255. */ + BFD_RELOC_MMIX_REG_OR_BYTE, + +/* This is a relocation for an instruction field that may be a general +register. */ + BFD_RELOC_MMIX_REG, + +/* This is a relocation for two instruction fields holding a register and +an offset, the equivalent of the relocation. */ + BFD_RELOC_MMIX_BASE_PLUS_OFFSET, + +/* This relocation is an assertion that the expression is not allocated as +a global register. It does not modify contents. */ + BFD_RELOC_MMIX_LOCAL, + +/* This is a 16 bit reloc for the AVR that stores 8 bit pc relative +short offset into 7 bits. */ + BFD_RELOC_AVR_7_PCREL, + +/* This is a 16 bit reloc for the AVR that stores 13 bit pc relative +short offset into 12 bits. */ + BFD_RELOC_AVR_13_PCREL, + +/* This is a 16 bit reloc for the AVR that stores 17 bit value (usually +program memory address) into 16 bits. */ + BFD_RELOC_AVR_16_PM, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually +data memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_LO8_LDI, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit +of data memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HI8_LDI, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit +of program memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HH8_LDI, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit +of 32 bit value) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_MS8_LDI, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(usually data memory address) into 8 bit immediate value of SUBI insn. */ + BFD_RELOC_AVR_LO8_LDI_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(high 8 bit of data memory address) into 8 bit immediate value of +SUBI insn. */ + BFD_RELOC_AVR_HI8_LDI_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(most high 8 bit of program memory address) into 8 bit immediate value +of LDI or SUBI insn. */ + BFD_RELOC_AVR_HH8_LDI_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value (msb +of 32 bit value) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_MS8_LDI_NEG, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually +command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_LO8_LDI_PM, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value +(command address) into 8 bit immediate value of LDI insn. If the address +is beyond the 128k boundary, the linker inserts a jump stub for this reloc +in the lower 128k. */ + BFD_RELOC_AVR_LO8_LDI_GS, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit +of command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HI8_LDI_PM, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit +of command address) into 8 bit immediate value of LDI insn. If the address +is beyond the 128k boundary, the linker inserts a jump stub for this reloc +below 128k. */ + BFD_RELOC_AVR_HI8_LDI_GS, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit +of command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HH8_LDI_PM, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(usually command address) into 8 bit immediate value of SUBI insn. */ + BFD_RELOC_AVR_LO8_LDI_PM_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(high 8 bit of 16 bit command address) into 8 bit immediate value +of SUBI insn. */ + BFD_RELOC_AVR_HI8_LDI_PM_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(high 6 bit of 22 bit command address) into 8 bit immediate +value of SUBI insn. */ + BFD_RELOC_AVR_HH8_LDI_PM_NEG, + +/* This is a 32 bit reloc for the AVR that stores 23 bit value +into 22 bits. */ + BFD_RELOC_AVR_CALL, + +/* This is a 16 bit reloc for the AVR that stores all needed bits +for absolute addressing with ldi with overflow check to linktime */ + BFD_RELOC_AVR_LDI, + +/* This is a 6 bit reloc for the AVR that stores offset for ldd/std +instructions */ + BFD_RELOC_AVR_6, + +/* This is a 6 bit reloc for the AVR that stores offset for adiw/sbiw +instructions */ + BFD_RELOC_AVR_6_ADIW, + +/* Direct 12 bit. */ + BFD_RELOC_390_12, + +/* 12 bit GOT offset. */ + BFD_RELOC_390_GOT12, + +/* 32 bit PC relative PLT address. */ + BFD_RELOC_390_PLT32, + +/* Copy symbol at runtime. */ + BFD_RELOC_390_COPY, + +/* Create GOT entry. */ + BFD_RELOC_390_GLOB_DAT, + +/* Create PLT entry. */ + BFD_RELOC_390_JMP_SLOT, + +/* Adjust by program base. */ + BFD_RELOC_390_RELATIVE, + +/* 32 bit PC relative offset to GOT. */ + BFD_RELOC_390_GOTPC, + +/* 16 bit GOT offset. */ + BFD_RELOC_390_GOT16, + +/* PC relative 16 bit shifted by 1. */ + BFD_RELOC_390_PC16DBL, + +/* 16 bit PC rel. PLT shifted by 1. */ + BFD_RELOC_390_PLT16DBL, + +/* PC relative 32 bit shifted by 1. */ + BFD_RELOC_390_PC32DBL, + +/* 32 bit PC rel. PLT shifted by 1. */ + BFD_RELOC_390_PLT32DBL, + +/* 32 bit PC rel. GOT shifted by 1. */ + BFD_RELOC_390_GOTPCDBL, + +/* 64 bit GOT offset. */ + BFD_RELOC_390_GOT64, + +/* 64 bit PC relative PLT address. */ + BFD_RELOC_390_PLT64, + +/* 32 bit rel. offset to GOT entry. */ + BFD_RELOC_390_GOTENT, + +/* 64 bit offset to GOT. */ + BFD_RELOC_390_GOTOFF64, + +/* 12-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_390_GOTPLT12, + +/* 16-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_390_GOTPLT16, + +/* 32-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_390_GOTPLT32, + +/* 64-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_390_GOTPLT64, + +/* 32-bit rel. offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_390_GOTPLTENT, + +/* 16-bit rel. offset from the GOT to a PLT entry. */ + BFD_RELOC_390_PLTOFF16, + +/* 32-bit rel. offset from the GOT to a PLT entry. */ + BFD_RELOC_390_PLTOFF32, + +/* 64-bit rel. offset from the GOT to a PLT entry. */ + BFD_RELOC_390_PLTOFF64, + +/* s390 tls relocations. */ + BFD_RELOC_390_TLS_LOAD, + BFD_RELOC_390_TLS_GDCALL, + BFD_RELOC_390_TLS_LDCALL, + BFD_RELOC_390_TLS_GD32, + BFD_RELOC_390_TLS_GD64, + BFD_RELOC_390_TLS_GOTIE12, + BFD_RELOC_390_TLS_GOTIE32, + BFD_RELOC_390_TLS_GOTIE64, + BFD_RELOC_390_TLS_LDM32, + BFD_RELOC_390_TLS_LDM64, + BFD_RELOC_390_TLS_IE32, + BFD_RELOC_390_TLS_IE64, + BFD_RELOC_390_TLS_IEENT, + BFD_RELOC_390_TLS_LE32, + BFD_RELOC_390_TLS_LE64, + BFD_RELOC_390_TLS_LDO32, + BFD_RELOC_390_TLS_LDO64, + BFD_RELOC_390_TLS_DTPMOD, + BFD_RELOC_390_TLS_DTPOFF, + BFD_RELOC_390_TLS_TPOFF, + +/* Long displacement extension. */ + BFD_RELOC_390_20, + BFD_RELOC_390_GOT20, + BFD_RELOC_390_GOTPLT20, + BFD_RELOC_390_TLS_GOTIE20, + +/* Score relocations */ + BFD_RELOC_SCORE_DUMMY1, + +/* Low 16 bit for load/store */ + BFD_RELOC_SCORE_GPREL15, + +/* This is a 24-bit reloc with the right 1 bit assumed to be 0 */ + BFD_RELOC_SCORE_DUMMY2, + BFD_RELOC_SCORE_JMP, + +/* This is a 19-bit reloc with the right 1 bit assumed to be 0 */ + BFD_RELOC_SCORE_BRANCH, + +/* This is a 11-bit reloc with the right 1 bit assumed to be 0 */ + BFD_RELOC_SCORE16_JMP, + +/* This is a 8-bit reloc with the right 1 bit assumed to be 0 */ + BFD_RELOC_SCORE16_BRANCH, + +/* Undocumented Score relocs */ + BFD_RELOC_SCORE_GOT15, + BFD_RELOC_SCORE_GOT_LO16, + BFD_RELOC_SCORE_CALL15, + BFD_RELOC_SCORE_DUMMY_HI16, + +/* Scenix IP2K - 9-bit register number / data address */ + BFD_RELOC_IP2K_FR9, + +/* Scenix IP2K - 4-bit register/data bank number */ + BFD_RELOC_IP2K_BANK, + +/* Scenix IP2K - low 13 bits of instruction word address */ + BFD_RELOC_IP2K_ADDR16CJP, + +/* Scenix IP2K - high 3 bits of instruction word address */ + BFD_RELOC_IP2K_PAGE3, + +/* Scenix IP2K - ext/low/high 8 bits of data address */ + BFD_RELOC_IP2K_LO8DATA, + BFD_RELOC_IP2K_HI8DATA, + BFD_RELOC_IP2K_EX8DATA, + +/* Scenix IP2K - low/high 8 bits of instruction word address */ + BFD_RELOC_IP2K_LO8INSN, + BFD_RELOC_IP2K_HI8INSN, + +/* Scenix IP2K - even/odd PC modifier to modify snb pcl.0 */ + BFD_RELOC_IP2K_PC_SKIP, + +/* Scenix IP2K - 16 bit word address in text section. */ + BFD_RELOC_IP2K_TEXT, + +/* Scenix IP2K - 7-bit sp or dp offset */ + BFD_RELOC_IP2K_FR_OFFSET, + +/* Scenix VPE4K coprocessor - data/insn-space addressing */ + BFD_RELOC_VPE4KMATH_DATA, + BFD_RELOC_VPE4KMATH_INSN, + +/* These two relocations are used by the linker to determine which of +the entries in a C++ virtual function table are actually used. When +the --gc-sections option is given, the linker will zero out the entries +that are not used, so that the code for those functions need not be +included in the output. + +VTABLE_INHERIT is a zero-space relocation used to describe to the +linker the inheritance tree of a C++ virtual function table. The +relocation's symbol should be the parent class' vtable, and the +relocation should be located at the child vtable. + +VTABLE_ENTRY is a zero-space relocation that describes the use of a +virtual function table entry. The reloc's symbol should refer to the +table of the class mentioned in the code. Off of that base, an offset +describes the entry that is being used. For Rela hosts, this offset +is stored in the reloc's addend. For Rel hosts, we are forced to put +this offset in the reloc's section offset. */ + BFD_RELOC_VTABLE_INHERIT, + BFD_RELOC_VTABLE_ENTRY, + +/* Intel IA64 Relocations. */ + BFD_RELOC_IA64_IMM14, + BFD_RELOC_IA64_IMM22, + BFD_RELOC_IA64_IMM64, + BFD_RELOC_IA64_DIR32MSB, + BFD_RELOC_IA64_DIR32LSB, + BFD_RELOC_IA64_DIR64MSB, + BFD_RELOC_IA64_DIR64LSB, + BFD_RELOC_IA64_GPREL22, + BFD_RELOC_IA64_GPREL64I, + BFD_RELOC_IA64_GPREL32MSB, + BFD_RELOC_IA64_GPREL32LSB, + BFD_RELOC_IA64_GPREL64MSB, + BFD_RELOC_IA64_GPREL64LSB, + BFD_RELOC_IA64_LTOFF22, + BFD_RELOC_IA64_LTOFF64I, + BFD_RELOC_IA64_PLTOFF22, + BFD_RELOC_IA64_PLTOFF64I, + BFD_RELOC_IA64_PLTOFF64MSB, + BFD_RELOC_IA64_PLTOFF64LSB, + BFD_RELOC_IA64_FPTR64I, + BFD_RELOC_IA64_FPTR32MSB, + BFD_RELOC_IA64_FPTR32LSB, + BFD_RELOC_IA64_FPTR64MSB, + BFD_RELOC_IA64_FPTR64LSB, + BFD_RELOC_IA64_PCREL21B, + BFD_RELOC_IA64_PCREL21BI, + BFD_RELOC_IA64_PCREL21M, + BFD_RELOC_IA64_PCREL21F, + BFD_RELOC_IA64_PCREL22, + BFD_RELOC_IA64_PCREL60B, + BFD_RELOC_IA64_PCREL64I, + BFD_RELOC_IA64_PCREL32MSB, + BFD_RELOC_IA64_PCREL32LSB, + BFD_RELOC_IA64_PCREL64MSB, + BFD_RELOC_IA64_PCREL64LSB, + BFD_RELOC_IA64_LTOFF_FPTR22, + BFD_RELOC_IA64_LTOFF_FPTR64I, + BFD_RELOC_IA64_LTOFF_FPTR32MSB, + BFD_RELOC_IA64_LTOFF_FPTR32LSB, + BFD_RELOC_IA64_LTOFF_FPTR64MSB, + BFD_RELOC_IA64_LTOFF_FPTR64LSB, + BFD_RELOC_IA64_SEGREL32MSB, + BFD_RELOC_IA64_SEGREL32LSB, + BFD_RELOC_IA64_SEGREL64MSB, + BFD_RELOC_IA64_SEGREL64LSB, + BFD_RELOC_IA64_SECREL32MSB, + BFD_RELOC_IA64_SECREL32LSB, + BFD_RELOC_IA64_SECREL64MSB, + BFD_RELOC_IA64_SECREL64LSB, + BFD_RELOC_IA64_REL32MSB, + BFD_RELOC_IA64_REL32LSB, + BFD_RELOC_IA64_REL64MSB, + BFD_RELOC_IA64_REL64LSB, + BFD_RELOC_IA64_LTV32MSB, + BFD_RELOC_IA64_LTV32LSB, + BFD_RELOC_IA64_LTV64MSB, + BFD_RELOC_IA64_LTV64LSB, + BFD_RELOC_IA64_IPLTMSB, + BFD_RELOC_IA64_IPLTLSB, + BFD_RELOC_IA64_COPY, + BFD_RELOC_IA64_LTOFF22X, + BFD_RELOC_IA64_LDXMOV, + BFD_RELOC_IA64_TPREL14, + BFD_RELOC_IA64_TPREL22, + BFD_RELOC_IA64_TPREL64I, + BFD_RELOC_IA64_TPREL64MSB, + BFD_RELOC_IA64_TPREL64LSB, + BFD_RELOC_IA64_LTOFF_TPREL22, + BFD_RELOC_IA64_DTPMOD64MSB, + BFD_RELOC_IA64_DTPMOD64LSB, + BFD_RELOC_IA64_LTOFF_DTPMOD22, + BFD_RELOC_IA64_DTPREL14, + BFD_RELOC_IA64_DTPREL22, + BFD_RELOC_IA64_DTPREL64I, + BFD_RELOC_IA64_DTPREL32MSB, + BFD_RELOC_IA64_DTPREL32LSB, + BFD_RELOC_IA64_DTPREL64MSB, + BFD_RELOC_IA64_DTPREL64LSB, + BFD_RELOC_IA64_LTOFF_DTPREL22, + +/* Motorola 68HC11 reloc. +This is the 8 bit high part of an absolute address. */ + BFD_RELOC_M68HC11_HI8, + +/* Motorola 68HC11 reloc. +This is the 8 bit low part of an absolute address. */ + BFD_RELOC_M68HC11_LO8, + +/* Motorola 68HC11 reloc. +This is the 3 bit of a value. */ + BFD_RELOC_M68HC11_3B, + +/* Motorola 68HC11 reloc. +This reloc marks the beginning of a jump/call instruction. +It is used for linker relaxation to correctly identify beginning +of instruction and change some branches to use PC-relative +addressing mode. */ + BFD_RELOC_M68HC11_RL_JUMP, + +/* Motorola 68HC11 reloc. +This reloc marks a group of several instructions that gcc generates +and for which the linker relaxation pass can modify and/or remove +some of them. */ + BFD_RELOC_M68HC11_RL_GROUP, + +/* Motorola 68HC11 reloc. +This is the 16-bit lower part of an address. It is used for 'call' +instruction to specify the symbol address without any special +transformation (due to memory bank window). */ + BFD_RELOC_M68HC11_LO16, + +/* Motorola 68HC11 reloc. +This is a 8-bit reloc that specifies the page number of an address. +It is used by 'call' instruction to specify the page number of +the symbol. */ + BFD_RELOC_M68HC11_PAGE, + +/* Motorola 68HC11 reloc. +This is a 24-bit reloc that represents the address with a 16-bit +value and a 8-bit page number. The symbol address is transformed +to follow the 16K memory bank of 68HC12 (seen as mapped in the window). */ + BFD_RELOC_M68HC11_24, + +/* Motorola 68HC12 reloc. +This is the 5 bits of a value. */ + BFD_RELOC_M68HC12_5B, + +/* NS CR16C Relocations. */ + BFD_RELOC_16C_NUM08, + BFD_RELOC_16C_NUM08_C, + BFD_RELOC_16C_NUM16, + BFD_RELOC_16C_NUM16_C, + BFD_RELOC_16C_NUM32, + BFD_RELOC_16C_NUM32_C, + BFD_RELOC_16C_DISP04, + BFD_RELOC_16C_DISP04_C, + BFD_RELOC_16C_DISP08, + BFD_RELOC_16C_DISP08_C, + BFD_RELOC_16C_DISP16, + BFD_RELOC_16C_DISP16_C, + BFD_RELOC_16C_DISP24, + BFD_RELOC_16C_DISP24_C, + BFD_RELOC_16C_DISP24a, + BFD_RELOC_16C_DISP24a_C, + BFD_RELOC_16C_REG04, + BFD_RELOC_16C_REG04_C, + BFD_RELOC_16C_REG04a, + BFD_RELOC_16C_REG04a_C, + BFD_RELOC_16C_REG14, + BFD_RELOC_16C_REG14_C, + BFD_RELOC_16C_REG16, + BFD_RELOC_16C_REG16_C, + BFD_RELOC_16C_REG20, + BFD_RELOC_16C_REG20_C, + BFD_RELOC_16C_ABS20, + BFD_RELOC_16C_ABS20_C, + BFD_RELOC_16C_ABS24, + BFD_RELOC_16C_ABS24_C, + BFD_RELOC_16C_IMM04, + BFD_RELOC_16C_IMM04_C, + BFD_RELOC_16C_IMM16, + BFD_RELOC_16C_IMM16_C, + BFD_RELOC_16C_IMM20, + BFD_RELOC_16C_IMM20_C, + BFD_RELOC_16C_IMM24, + BFD_RELOC_16C_IMM24_C, + BFD_RELOC_16C_IMM32, + BFD_RELOC_16C_IMM32_C, + +/* NS CR16 Relocations. */ + BFD_RELOC_CR16_NUM8, + BFD_RELOC_CR16_NUM16, + BFD_RELOC_CR16_NUM32, + BFD_RELOC_CR16_NUM32a, + BFD_RELOC_CR16_REGREL0, + BFD_RELOC_CR16_REGREL4, + BFD_RELOC_CR16_REGREL4a, + BFD_RELOC_CR16_REGREL14, + BFD_RELOC_CR16_REGREL14a, + BFD_RELOC_CR16_REGREL16, + BFD_RELOC_CR16_REGREL20, + BFD_RELOC_CR16_REGREL20a, + BFD_RELOC_CR16_ABS20, + BFD_RELOC_CR16_ABS24, + BFD_RELOC_CR16_IMM4, + BFD_RELOC_CR16_IMM8, + BFD_RELOC_CR16_IMM16, + BFD_RELOC_CR16_IMM20, + BFD_RELOC_CR16_IMM24, + BFD_RELOC_CR16_IMM32, + BFD_RELOC_CR16_IMM32a, + BFD_RELOC_CR16_DISP4, + BFD_RELOC_CR16_DISP8, + BFD_RELOC_CR16_DISP16, + BFD_RELOC_CR16_DISP20, + BFD_RELOC_CR16_DISP24, + BFD_RELOC_CR16_DISP24a, + +/* NS CRX Relocations. */ + BFD_RELOC_CRX_REL4, + BFD_RELOC_CRX_REL8, + BFD_RELOC_CRX_REL8_CMP, + BFD_RELOC_CRX_REL16, + BFD_RELOC_CRX_REL24, + BFD_RELOC_CRX_REL32, + BFD_RELOC_CRX_REGREL12, + BFD_RELOC_CRX_REGREL22, + BFD_RELOC_CRX_REGREL28, + BFD_RELOC_CRX_REGREL32, + BFD_RELOC_CRX_ABS16, + BFD_RELOC_CRX_ABS32, + BFD_RELOC_CRX_NUM8, + BFD_RELOC_CRX_NUM16, + BFD_RELOC_CRX_NUM32, + BFD_RELOC_CRX_IMM16, + BFD_RELOC_CRX_IMM32, + BFD_RELOC_CRX_SWITCH8, + BFD_RELOC_CRX_SWITCH16, + BFD_RELOC_CRX_SWITCH32, + +/* These relocs are only used within the CRIS assembler. They are not +(at present) written to any object files. */ + BFD_RELOC_CRIS_BDISP8, + BFD_RELOC_CRIS_UNSIGNED_5, + BFD_RELOC_CRIS_SIGNED_6, + BFD_RELOC_CRIS_UNSIGNED_6, + BFD_RELOC_CRIS_SIGNED_8, + BFD_RELOC_CRIS_UNSIGNED_8, + BFD_RELOC_CRIS_SIGNED_16, + BFD_RELOC_CRIS_UNSIGNED_16, + BFD_RELOC_CRIS_LAPCQ_OFFSET, + BFD_RELOC_CRIS_UNSIGNED_4, + +/* Relocs used in ELF shared libraries for CRIS. */ + BFD_RELOC_CRIS_COPY, + BFD_RELOC_CRIS_GLOB_DAT, + BFD_RELOC_CRIS_JUMP_SLOT, + BFD_RELOC_CRIS_RELATIVE, + +/* 32-bit offset to symbol-entry within GOT. */ + BFD_RELOC_CRIS_32_GOT, + +/* 16-bit offset to symbol-entry within GOT. */ + BFD_RELOC_CRIS_16_GOT, + +/* 32-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_CRIS_32_GOTPLT, + +/* 16-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_CRIS_16_GOTPLT, + +/* 32-bit offset to symbol, relative to GOT. */ + BFD_RELOC_CRIS_32_GOTREL, + +/* 32-bit offset to symbol with PLT entry, relative to GOT. */ + BFD_RELOC_CRIS_32_PLT_GOTREL, + +/* 32-bit offset to symbol with PLT entry, relative to this relocation. */ + BFD_RELOC_CRIS_32_PLT_PCREL, + +/* Intel i860 Relocations. */ + BFD_RELOC_860_COPY, + BFD_RELOC_860_GLOB_DAT, + BFD_RELOC_860_JUMP_SLOT, + BFD_RELOC_860_RELATIVE, + BFD_RELOC_860_PC26, + BFD_RELOC_860_PLT26, + BFD_RELOC_860_PC16, + BFD_RELOC_860_LOW0, + BFD_RELOC_860_SPLIT0, + BFD_RELOC_860_LOW1, + BFD_RELOC_860_SPLIT1, + BFD_RELOC_860_LOW2, + BFD_RELOC_860_SPLIT2, + BFD_RELOC_860_LOW3, + BFD_RELOC_860_LOGOT0, + BFD_RELOC_860_SPGOT0, + BFD_RELOC_860_LOGOT1, + BFD_RELOC_860_SPGOT1, + BFD_RELOC_860_LOGOTOFF0, + BFD_RELOC_860_SPGOTOFF0, + BFD_RELOC_860_LOGOTOFF1, + BFD_RELOC_860_SPGOTOFF1, + BFD_RELOC_860_LOGOTOFF2, + BFD_RELOC_860_LOGOTOFF3, + BFD_RELOC_860_LOPC, + BFD_RELOC_860_HIGHADJ, + BFD_RELOC_860_HAGOT, + BFD_RELOC_860_HAGOTOFF, + BFD_RELOC_860_HAPC, + BFD_RELOC_860_HIGH, + BFD_RELOC_860_HIGOT, + BFD_RELOC_860_HIGOTOFF, + +/* OpenRISC Relocations. */ + BFD_RELOC_OPENRISC_ABS_26, + BFD_RELOC_OPENRISC_REL_26, + +/* H8 elf Relocations. */ + BFD_RELOC_H8_DIR16A8, + BFD_RELOC_H8_DIR16R8, + BFD_RELOC_H8_DIR24A8, + BFD_RELOC_H8_DIR24R8, + BFD_RELOC_H8_DIR32A16, + +/* Sony Xstormy16 Relocations. */ + BFD_RELOC_XSTORMY16_REL_12, + BFD_RELOC_XSTORMY16_12, + BFD_RELOC_XSTORMY16_24, + BFD_RELOC_XSTORMY16_FPTR16, + +/* Self-describing complex relocations. */ + BFD_RELOC_RELC, + + +/* Infineon Relocations. */ + BFD_RELOC_XC16X_PAG, + BFD_RELOC_XC16X_POF, + BFD_RELOC_XC16X_SEG, + BFD_RELOC_XC16X_SOF, + +/* Relocations used by VAX ELF. */ + BFD_RELOC_VAX_GLOB_DAT, + BFD_RELOC_VAX_JMP_SLOT, + BFD_RELOC_VAX_RELATIVE, + +/* Morpho MT - 16 bit immediate relocation. */ + BFD_RELOC_MT_PC16, + +/* Morpho MT - Hi 16 bits of an address. */ + BFD_RELOC_MT_HI16, + +/* Morpho MT - Low 16 bits of an address. */ + BFD_RELOC_MT_LO16, + +/* Morpho MT - Used to tell the linker which vtable entries are used. */ + BFD_RELOC_MT_GNU_VTINHERIT, + +/* Morpho MT - Used to tell the linker which vtable entries are used. */ + BFD_RELOC_MT_GNU_VTENTRY, + +/* Morpho MT - 8 bit immediate relocation. */ + BFD_RELOC_MT_PCINSN8, + +/* msp430 specific relocation codes */ + BFD_RELOC_MSP430_10_PCREL, + BFD_RELOC_MSP430_16_PCREL, + BFD_RELOC_MSP430_16, + BFD_RELOC_MSP430_16_PCREL_BYTE, + BFD_RELOC_MSP430_16_BYTE, + BFD_RELOC_MSP430_2X_PCREL, + BFD_RELOC_MSP430_RL_PCREL, + +/* IQ2000 Relocations. */ + BFD_RELOC_IQ2000_OFFSET_16, + BFD_RELOC_IQ2000_OFFSET_21, + BFD_RELOC_IQ2000_UHI16, + +/* Special Xtensa relocation used only by PLT entries in ELF shared +objects to indicate that the runtime linker should set the value +to one of its own internal functions or data structures. */ + BFD_RELOC_XTENSA_RTLD, + +/* Xtensa relocations for ELF shared objects. */ + BFD_RELOC_XTENSA_GLOB_DAT, + BFD_RELOC_XTENSA_JMP_SLOT, + BFD_RELOC_XTENSA_RELATIVE, + +/* Xtensa relocation used in ELF object files for symbols that may require +PLT entries. Otherwise, this is just a generic 32-bit relocation. */ + BFD_RELOC_XTENSA_PLT, + +/* Xtensa relocations to mark the difference of two local symbols. +These are only needed to support linker relaxation and can be ignored +when not relaxing. The field is set to the value of the difference +assuming no relaxation. The relocation encodes the position of the +first symbol so the linker can determine whether to adjust the field +value. */ + BFD_RELOC_XTENSA_DIFF8, + BFD_RELOC_XTENSA_DIFF16, + BFD_RELOC_XTENSA_DIFF32, + +/* Generic Xtensa relocations for instruction operands. Only the slot +number is encoded in the relocation. The relocation applies to the +last PC-relative immediate operand, or if there are no PC-relative +immediates, to the last immediate operand. */ + BFD_RELOC_XTENSA_SLOT0_OP, + BFD_RELOC_XTENSA_SLOT1_OP, + BFD_RELOC_XTENSA_SLOT2_OP, + BFD_RELOC_XTENSA_SLOT3_OP, + BFD_RELOC_XTENSA_SLOT4_OP, + BFD_RELOC_XTENSA_SLOT5_OP, + BFD_RELOC_XTENSA_SLOT6_OP, + BFD_RELOC_XTENSA_SLOT7_OP, + BFD_RELOC_XTENSA_SLOT8_OP, + BFD_RELOC_XTENSA_SLOT9_OP, + BFD_RELOC_XTENSA_SLOT10_OP, + BFD_RELOC_XTENSA_SLOT11_OP, + BFD_RELOC_XTENSA_SLOT12_OP, + BFD_RELOC_XTENSA_SLOT13_OP, + BFD_RELOC_XTENSA_SLOT14_OP, + +/* Alternate Xtensa relocations. Only the slot is encoded in the +relocation. The meaning of these relocations is opcode-specific. */ + BFD_RELOC_XTENSA_SLOT0_ALT, + BFD_RELOC_XTENSA_SLOT1_ALT, + BFD_RELOC_XTENSA_SLOT2_ALT, + BFD_RELOC_XTENSA_SLOT3_ALT, + BFD_RELOC_XTENSA_SLOT4_ALT, + BFD_RELOC_XTENSA_SLOT5_ALT, + BFD_RELOC_XTENSA_SLOT6_ALT, + BFD_RELOC_XTENSA_SLOT7_ALT, + BFD_RELOC_XTENSA_SLOT8_ALT, + BFD_RELOC_XTENSA_SLOT9_ALT, + BFD_RELOC_XTENSA_SLOT10_ALT, + BFD_RELOC_XTENSA_SLOT11_ALT, + BFD_RELOC_XTENSA_SLOT12_ALT, + BFD_RELOC_XTENSA_SLOT13_ALT, + BFD_RELOC_XTENSA_SLOT14_ALT, + +/* Xtensa relocations for backward compatibility. These have all been +replaced by BFD_RELOC_XTENSA_SLOT0_OP. */ + BFD_RELOC_XTENSA_OP0, + BFD_RELOC_XTENSA_OP1, + BFD_RELOC_XTENSA_OP2, + +/* Xtensa relocation to mark that the assembler expanded the +instructions from an original target. The expansion size is +encoded in the reloc size. */ + BFD_RELOC_XTENSA_ASM_EXPAND, + +/* Xtensa relocation to mark that the linker should simplify +assembler-expanded instructions. This is commonly used +internally by the linker after analysis of a +BFD_RELOC_XTENSA_ASM_EXPAND. */ + BFD_RELOC_XTENSA_ASM_SIMPLIFY, + +/* 8 bit signed offset in (ix+d) or (iy+d). */ + BFD_RELOC_Z80_DISP8, + +/* DJNZ offset. */ + BFD_RELOC_Z8K_DISP7, + +/* CALR offset. */ + BFD_RELOC_Z8K_CALLR, + +/* 4 bit value. */ + BFD_RELOC_Z8K_IMM4L, + BFD_RELOC_UNUSED }; +typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; +reloc_howto_type *bfd_reloc_type_lookup + (bfd *abfd, bfd_reloc_code_real_type code); +reloc_howto_type *bfd_reloc_name_lookup + (bfd *abfd, const char *reloc_name); + +const char *bfd_get_reloc_code_name (bfd_reloc_code_real_type code); + +/* Extracted from syms.c. */ + +typedef struct bfd_symbol +{ + /* A pointer to the BFD which owns the symbol. This information + is necessary so that a back end can work out what additional + information (invisible to the application writer) is carried + with the symbol. + + This field is *almost* redundant, since you can use section->owner + instead, except that some symbols point to the global sections + bfd_{abs,com,und}_section. This could be fixed by making + these globals be per-bfd (or per-target-flavor). FIXME. */ + struct bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */ + + /* The text of the symbol. The name is left alone, and not copied; the + application may not alter it. */ + const char *name; + + /* The value of the symbol. This really should be a union of a + numeric value with a pointer, since some flags indicate that + a pointer to another symbol is stored here. */ + symvalue value; + + /* Attributes of a symbol. */ +#define BSF_NO_FLAGS 0x00 + + /* The symbol has local scope; <<static>> in <<C>>. The value + is the offset into the section of the data. */ +#define BSF_LOCAL 0x01 + + /* The symbol has global scope; initialized data in <<C>>. The + value is the offset into the section of the data. */ +#define BSF_GLOBAL 0x02 + + /* The symbol has global scope and is exported. The value is + the offset into the section of the data. */ +#define BSF_EXPORT BSF_GLOBAL /* No real difference. */ + + /* A normal C symbol would be one of: + <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or + <<BSF_GLOBAL>>. */ + + /* The symbol is a debugging record. The value has an arbitrary + meaning, unless BSF_DEBUGGING_RELOC is also set. */ +#define BSF_DEBUGGING 0x08 + + /* The symbol denotes a function entry point. Used in ELF, + perhaps others someday. */ +#define BSF_FUNCTION 0x10 + + /* Used by the linker. */ +#define BSF_KEEP 0x20 +#define BSF_KEEP_G 0x40 + + /* A weak global symbol, overridable without warnings by + a regular global symbol of the same name. */ +#define BSF_WEAK 0x80 + + /* This symbol was created to point to a section, e.g. ELF's + STT_SECTION symbols. */ +#define BSF_SECTION_SYM 0x100 + + /* The symbol used to be a common symbol, but now it is + allocated. */ +#define BSF_OLD_COMMON 0x200 + + /* The default value for common data. */ +#define BFD_FORT_COMM_DEFAULT_VALUE 0 + + /* In some files the type of a symbol sometimes alters its + location in an output file - ie in coff a <<ISFCN>> symbol + which is also <<C_EXT>> symbol appears where it was + declared and not at the end of a section. This bit is set + by the target BFD part to convey this information. */ +#define BSF_NOT_AT_END 0x400 + + /* Signal that the symbol is the label of constructor section. */ +#define BSF_CONSTRUCTOR 0x800 + + /* Signal that the symbol is a warning symbol. The name is a + warning. The name of the next symbol is the one to warn about; + if a reference is made to a symbol with the same name as the next + symbol, a warning is issued by the linker. */ +#define BSF_WARNING 0x1000 + + /* Signal that the symbol is indirect. This symbol is an indirect + pointer to the symbol with the same name as the next symbol. */ +#define BSF_INDIRECT 0x2000 + + /* BSF_FILE marks symbols that contain a file name. This is used + for ELF STT_FILE symbols. */ +#define BSF_FILE 0x4000 + + /* Symbol is from dynamic linking information. */ +#define BSF_DYNAMIC 0x8000 + + /* The symbol denotes a data object. Used in ELF, and perhaps + others someday. */ +#define BSF_OBJECT 0x10000 + + /* This symbol is a debugging symbol. The value is the offset + into the section of the data. BSF_DEBUGGING should be set + as well. */ +#define BSF_DEBUGGING_RELOC 0x20000 + + /* This symbol is thread local. Used in ELF. */ +#define BSF_THREAD_LOCAL 0x40000 + + /* This symbol represents a complex relocation expression, + with the expression tree serialized in the symbol name. */ +#define BSF_RELC 0x80000 + + /* This symbol represents a signed complex relocation expression, + with the expression tree serialized in the symbol name. */ +#define BSF_SRELC 0x100000 + + flagword flags; + + /* A pointer to the section to which this symbol is + relative. This will always be non NULL, there are special + sections for undefined and absolute symbols. */ + struct bfd_section *section; + + /* Back end special data. */ + union + { + void *p; + bfd_vma i; + } + udata; +} +asymbol; + +#define bfd_get_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) + +bfd_boolean bfd_is_local_label (bfd *abfd, asymbol *sym); + +bfd_boolean bfd_is_local_label_name (bfd *abfd, const char *name); + +#define bfd_is_local_label_name(abfd, name) \ + BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) + +bfd_boolean bfd_is_target_special_symbol (bfd *abfd, asymbol *sym); + +#define bfd_is_target_special_symbol(abfd, sym) \ + BFD_SEND (abfd, _bfd_is_target_special_symbol, (abfd, sym)) + +#define bfd_canonicalize_symtab(abfd, location) \ + BFD_SEND (abfd, _bfd_canonicalize_symtab, (abfd, location)) + +bfd_boolean bfd_set_symtab + (bfd *abfd, asymbol **location, unsigned int count); + +void bfd_print_symbol_vandf (bfd *abfd, void *file, asymbol *symbol); + +#define bfd_make_empty_symbol(abfd) \ + BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) + +asymbol *_bfd_generic_make_empty_symbol (bfd *); + +#define bfd_make_debug_symbol(abfd,ptr,size) \ + BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size)) + +int bfd_decode_symclass (asymbol *symbol); + +bfd_boolean bfd_is_undefined_symclass (int symclass); + +void bfd_symbol_info (asymbol *symbol, symbol_info *ret); + +bfd_boolean bfd_copy_private_symbol_data + (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym); + +#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \ + BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ + (ibfd, isymbol, obfd, osymbol)) + +/* Extracted from bfd.c. */ +struct bfd +{ + /* A unique identifier of the BFD */ + unsigned int id; + + /* The filename the application opened the BFD with. */ + const char *filename; + + /* A pointer to the target jump table. */ + const struct bfd_target *xvec; + + /* The IOSTREAM, and corresponding IO vector that provide access + to the file backing the BFD. */ + void *iostream; + const struct bfd_iovec *iovec; + + /* Is the file descriptor being cached? That is, can it be closed as + needed, and re-opened when accessed later? */ + bfd_boolean cacheable; + + /* Marks whether there was a default target specified when the + BFD was opened. This is used to select which matching algorithm + to use to choose the back end. */ + bfd_boolean target_defaulted; + + /* The caching routines use these to maintain a + least-recently-used list of BFDs. */ + struct bfd *lru_prev, *lru_next; + + /* When a file is closed by the caching routines, BFD retains + state information on the file here... */ + ufile_ptr where; + + /* ... and here: (``once'' means at least once). */ + bfd_boolean opened_once; + + /* Set if we have a locally maintained mtime value, rather than + getting it from the file each time. */ + bfd_boolean mtime_set; + + /* File modified time, if mtime_set is TRUE. */ + long mtime; + + /* Reserved for an unimplemented file locking extension. */ + int ifd; + + /* The format which belongs to the BFD. (object, core, etc.) */ + bfd_format format; + + /* The direction with which the BFD was opened. */ + enum bfd_direction + { + no_direction = 0, + read_direction = 1, + write_direction = 2, + both_direction = 3 + } + direction; + + /* Format_specific flags. */ + flagword flags; + + /* Currently my_archive is tested before adding origin to + anything. I believe that this can become always an add of + origin, with origin set to 0 for non archive files. */ + ufile_ptr origin; + + /* Remember when output has begun, to stop strange things + from happening. */ + bfd_boolean output_has_begun; + + /* A hash table for section names. */ + struct bfd_hash_table section_htab; + + /* Pointer to linked list of sections. */ + struct bfd_section *sections; + + /* The last section on the section list. */ + struct bfd_section *section_last; + + /* The number of sections. */ + unsigned int section_count; + + /* Stuff only useful for object files: + The start address. */ + bfd_vma start_address; + + /* Used for input and output. */ + unsigned int symcount; + + /* Symbol table for output BFD (with symcount entries). */ + struct bfd_symbol **outsymbols; + + /* Used for slurped dynamic symbol tables. */ + unsigned int dynsymcount; + + /* Pointer to structure which contains architecture information. */ + const struct bfd_arch_info *arch_info; + + /* Flag set if symbols from this BFD should not be exported. */ + bfd_boolean no_export; + + /* Stuff only useful for archives. */ + void *arelt_data; + struct bfd *my_archive; /* The containing archive BFD. */ + struct bfd *archive_next; /* The next BFD in the archive. */ + struct bfd *archive_head; /* The first BFD in the archive. */ + bfd_boolean has_armap; + + /* A chain of BFD structures involved in a link. */ + struct bfd *link_next; + + /* A field used by _bfd_generic_link_add_archive_symbols. This will + be used only for archive elements. */ + int archive_pass; + + /* Used by the back end to hold private data. */ + union + { + struct aout_data_struct *aout_data; + struct artdata *aout_ar_data; + struct _oasys_data *oasys_obj_data; + struct _oasys_ar_data *oasys_ar_data; + struct coff_tdata *coff_obj_data; + struct pe_tdata *pe_obj_data; + struct xcoff_tdata *xcoff_obj_data; + struct ecoff_tdata *ecoff_obj_data; + struct ieee_data_struct *ieee_data; + struct ieee_ar_data_struct *ieee_ar_data; + struct srec_data_struct *srec_data; + struct ihex_data_struct *ihex_data; + struct tekhex_data_struct *tekhex_data; + struct elf_obj_tdata *elf_obj_data; + struct nlm_obj_tdata *nlm_obj_data; + struct bout_data_struct *bout_data; + struct mmo_data_struct *mmo_data; + struct sun_core_struct *sun_core_data; + struct sco5_core_struct *sco5_core_data; + struct trad_core_struct *trad_core_data; + struct som_data_struct *som_data; + struct hpux_core_struct *hpux_core_data; + struct hppabsd_core_struct *hppabsd_core_data; + struct sgi_core_struct *sgi_core_data; + struct lynx_core_struct *lynx_core_data; + struct osf_core_struct *osf_core_data; + struct cisco_core_struct *cisco_core_data; + struct versados_data_struct *versados_data; + struct netbsd_core_struct *netbsd_core_data; + struct mach_o_data_struct *mach_o_data; + struct mach_o_fat_data_struct *mach_o_fat_data; + struct bfd_pef_data_struct *pef_data; + struct bfd_pef_xlib_data_struct *pef_xlib_data; + struct bfd_sym_data_struct *sym_data; + void *any; + } + tdata; + + /* Used by the application to hold private data. */ + void *usrdata; + + /* Where all the allocated stuff under this BFD goes. This is a + struct objalloc *, but we use void * to avoid requiring the inclusion + of objalloc.h. */ + void *memory; +}; + +typedef enum bfd_error +{ + bfd_error_no_error = 0, + bfd_error_system_call, + bfd_error_invalid_target, + bfd_error_wrong_format, + bfd_error_wrong_object_format, + bfd_error_invalid_operation, + bfd_error_no_memory, + bfd_error_no_symbols, + bfd_error_no_armap, + bfd_error_no_more_archived_files, + bfd_error_malformed_archive, + bfd_error_file_not_recognized, + bfd_error_file_ambiguously_recognized, + bfd_error_no_contents, + bfd_error_nonrepresentable_section, + bfd_error_no_debug_section, + bfd_error_bad_value, + bfd_error_file_truncated, + bfd_error_file_too_big, + bfd_error_on_input, + bfd_error_invalid_error_code +} +bfd_error_type; + +bfd_error_type bfd_get_error (void); + +void bfd_set_error (bfd_error_type error_tag, ...); + +const char *bfd_errmsg (bfd_error_type error_tag); + +void bfd_perror (const char *message); + +typedef void (*bfd_error_handler_type) (const char *, ...); + +bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type); + +void bfd_set_error_program_name (const char *); + +bfd_error_handler_type bfd_get_error_handler (void); + +long bfd_get_reloc_upper_bound (bfd *abfd, asection *sect); + +long bfd_canonicalize_reloc + (bfd *abfd, asection *sec, arelent **loc, asymbol **syms); + +void bfd_set_reloc + (bfd *abfd, asection *sec, arelent **rel, unsigned int count); + +bfd_boolean bfd_set_file_flags (bfd *abfd, flagword flags); + +int bfd_get_arch_size (bfd *abfd); + +int bfd_get_sign_extend_vma (bfd *abfd); + +bfd_boolean bfd_set_start_address (bfd *abfd, bfd_vma vma); + +unsigned int bfd_get_gp_size (bfd *abfd); + +void bfd_set_gp_size (bfd *abfd, unsigned int i); + +bfd_vma bfd_scan_vma (const char *string, const char **end, int base); + +bfd_boolean bfd_copy_private_header_data (bfd *ibfd, bfd *obfd); + +#define bfd_copy_private_header_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_copy_private_header_data, \ + (ibfd, obfd)) +bfd_boolean bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd); + +#define bfd_copy_private_bfd_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ + (ibfd, obfd)) +bfd_boolean bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd); + +#define bfd_merge_private_bfd_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_merge_private_bfd_data, \ + (ibfd, obfd)) +bfd_boolean bfd_set_private_flags (bfd *abfd, flagword flags); + +#define bfd_set_private_flags(abfd, flags) \ + BFD_SEND (abfd, _bfd_set_private_flags, (abfd, flags)) +#define bfd_sizeof_headers(abfd, info) \ + BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, info)) + +#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ + BFD_SEND (abfd, _bfd_find_nearest_line, \ + (abfd, sec, syms, off, file, func, line)) + +#define bfd_find_line(abfd, syms, sym, file, line) \ + BFD_SEND (abfd, _bfd_find_line, \ + (abfd, syms, sym, file, line)) + +#define bfd_find_inliner_info(abfd, file, func, line) \ + BFD_SEND (abfd, _bfd_find_inliner_info, \ + (abfd, file, func, line)) + +#define bfd_debug_info_start(abfd) \ + BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) + +#define bfd_debug_info_end(abfd) \ + BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) + +#define bfd_debug_info_accumulate(abfd, section) \ + BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) + +#define bfd_stat_arch_elt(abfd, stat) \ + BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) + +#define bfd_update_armap_timestamp(abfd) \ + BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd)) + +#define bfd_set_arch_mach(abfd, arch, mach)\ + BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) + +#define bfd_relax_section(abfd, section, link_info, again) \ + BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) + +#define bfd_gc_sections(abfd, link_info) \ + BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info)) + +#define bfd_merge_sections(abfd, link_info) \ + BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info)) + +#define bfd_is_group_section(abfd, sec) \ + BFD_SEND (abfd, _bfd_is_group_section, (abfd, sec)) + +#define bfd_discard_group(abfd, sec) \ + BFD_SEND (abfd, _bfd_discard_group, (abfd, sec)) + +#define bfd_link_hash_table_create(abfd) \ + BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) + +#define bfd_link_hash_table_free(abfd, hash) \ + BFD_SEND (abfd, _bfd_link_hash_table_free, (hash)) + +#define bfd_link_add_symbols(abfd, info) \ + BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) + +#define bfd_link_just_syms(abfd, sec, info) \ + BFD_SEND (abfd, _bfd_link_just_syms, (sec, info)) + +#define bfd_final_link(abfd, info) \ + BFD_SEND (abfd, _bfd_final_link, (abfd, info)) + +#define bfd_free_cached_info(abfd) \ + BFD_SEND (abfd, _bfd_free_cached_info, (abfd)) + +#define bfd_get_dynamic_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd)) + +#define bfd_print_private_bfd_data(abfd, file)\ + BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file)) + +#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \ + BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols)) + +#define bfd_get_synthetic_symtab(abfd, count, syms, dyncount, dynsyms, ret) \ + BFD_SEND (abfd, _bfd_get_synthetic_symtab, (abfd, count, syms, \ + dyncount, dynsyms, ret)) + +#define bfd_get_dynamic_reloc_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd)) + +#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \ + BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms)) + +extern bfd_byte *bfd_get_relocated_section_contents + (bfd *, struct bfd_link_info *, struct bfd_link_order *, bfd_byte *, + bfd_boolean, asymbol **); + +bfd_boolean bfd_alt_mach_code (bfd *abfd, int alternative); + +struct bfd_preserve +{ + void *marker; + void *tdata; + flagword flags; + const struct bfd_arch_info *arch_info; + struct bfd_section *sections; + struct bfd_section *section_last; + unsigned int section_count; + struct bfd_hash_table section_htab; +}; + +bfd_boolean bfd_preserve_save (bfd *, struct bfd_preserve *); + +void bfd_preserve_restore (bfd *, struct bfd_preserve *); + +void bfd_preserve_finish (bfd *, struct bfd_preserve *); + +bfd_vma bfd_emul_get_maxpagesize (const char *); + +void bfd_emul_set_maxpagesize (const char *, bfd_vma); + +bfd_vma bfd_emul_get_commonpagesize (const char *); + +void bfd_emul_set_commonpagesize (const char *, bfd_vma); + +char *bfd_demangle (bfd *, const char *, int); + +/* Extracted from archive.c. */ +symindex bfd_get_next_mapent + (bfd *abfd, symindex previous, carsym **sym); + +bfd_boolean bfd_set_archive_head (bfd *output, bfd *new_head); + +bfd *bfd_openr_next_archived_file (bfd *archive, bfd *previous); + +/* Extracted from corefile.c. */ +const char *bfd_core_file_failing_command (bfd *abfd); + +int bfd_core_file_failing_signal (bfd *abfd); + +bfd_boolean core_file_matches_executable_p + (bfd *core_bfd, bfd *exec_bfd); + +bfd_boolean generic_core_file_matches_executable_p + (bfd *core_bfd, bfd *exec_bfd); + +/* Extracted from targets.c. */ +#define BFD_SEND(bfd, message, arglist) \ + ((*((bfd)->xvec->message)) arglist) + +#ifdef DEBUG_BFD_SEND +#undef BFD_SEND +#define BFD_SEND(bfd, message, arglist) \ + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ + ((*((bfd)->xvec->message)) arglist) : \ + (bfd_assert (__FILE__,__LINE__), NULL)) +#endif +#define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) + +#ifdef DEBUG_BFD_SEND +#undef BFD_SEND_FMT +#define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ + (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \ + (bfd_assert (__FILE__,__LINE__), NULL)) +#endif + +enum bfd_flavour +{ + bfd_target_unknown_flavour, + bfd_target_aout_flavour, + bfd_target_coff_flavour, + bfd_target_ecoff_flavour, + bfd_target_xcoff_flavour, + bfd_target_elf_flavour, + bfd_target_ieee_flavour, + bfd_target_nlm_flavour, + bfd_target_oasys_flavour, + bfd_target_tekhex_flavour, + bfd_target_srec_flavour, + bfd_target_ihex_flavour, + bfd_target_som_flavour, + bfd_target_os9k_flavour, + bfd_target_versados_flavour, + bfd_target_msdos_flavour, + bfd_target_ovax_flavour, + bfd_target_evax_flavour, + bfd_target_mmo_flavour, + bfd_target_mach_o_flavour, + bfd_target_pef_flavour, + bfd_target_pef_xlib_flavour, + bfd_target_sym_flavour +}; + +enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN }; + +/* Forward declaration. */ +typedef struct bfd_link_info _bfd_link_info; + +typedef struct bfd_target +{ + /* Identifies the kind of target, e.g., SunOS4, Ultrix, etc. */ + char *name; + + /* The "flavour" of a back end is a general indication about + the contents of a file. */ + enum bfd_flavour flavour; + + /* The order of bytes within the data area of a file. */ + enum bfd_endian byteorder; + + /* The order of bytes within the header parts of a file. */ + enum bfd_endian header_byteorder; + + /* A mask of all the flags which an executable may have set - + from the set <<BFD_NO_FLAGS>>, <<HAS_RELOC>>, ...<<D_PAGED>>. */ + flagword object_flags; + + /* A mask of all the flags which a section may have set - from + the set <<SEC_NO_FLAGS>>, <<SEC_ALLOC>>, ...<<SET_NEVER_LOAD>>. */ + flagword section_flags; + + /* The character normally found at the front of a symbol. + (if any), perhaps `_'. */ + char symbol_leading_char; + + /* The pad character for file names within an archive header. */ + char ar_pad_char; + + /* The maximum number of characters in an archive header. */ + unsigned short ar_max_namelen; + + /* Entries for byte swapping for data. These are different from the + other entry points, since they don't take a BFD as the first argument. + Certain other handlers could do the same. */ + bfd_uint64_t (*bfd_getx64) (const void *); + bfd_int64_t (*bfd_getx_signed_64) (const void *); + void (*bfd_putx64) (bfd_uint64_t, void *); + bfd_vma (*bfd_getx32) (const void *); + bfd_signed_vma (*bfd_getx_signed_32) (const void *); + void (*bfd_putx32) (bfd_vma, void *); + bfd_vma (*bfd_getx16) (const void *); + bfd_signed_vma (*bfd_getx_signed_16) (const void *); + void (*bfd_putx16) (bfd_vma, void *); + + /* Byte swapping for the headers. */ + bfd_uint64_t (*bfd_h_getx64) (const void *); + bfd_int64_t (*bfd_h_getx_signed_64) (const void *); + void (*bfd_h_putx64) (bfd_uint64_t, void *); + bfd_vma (*bfd_h_getx32) (const void *); + bfd_signed_vma (*bfd_h_getx_signed_32) (const void *); + void (*bfd_h_putx32) (bfd_vma, void *); + bfd_vma (*bfd_h_getx16) (const void *); + bfd_signed_vma (*bfd_h_getx_signed_16) (const void *); + void (*bfd_h_putx16) (bfd_vma, void *); + + /* Format dependent routines: these are vectors of entry points + within the target vector structure, one for each format to check. */ + + /* Check the format of a file being read. Return a <<bfd_target *>> or zero. */ + const struct bfd_target *(*_bfd_check_format[bfd_type_end]) (bfd *); + + /* Set the format of a file being written. */ + bfd_boolean (*_bfd_set_format[bfd_type_end]) (bfd *); + + /* Write cached information into a file being written, at <<bfd_close>>. */ + bfd_boolean (*_bfd_write_contents[bfd_type_end]) (bfd *); + + + /* Generic entry points. */ +#define BFD_JUMP_TABLE_GENERIC(NAME) \ + NAME##_close_and_cleanup, \ + NAME##_bfd_free_cached_info, \ + NAME##_new_section_hook, \ + NAME##_get_section_contents, \ + NAME##_get_section_contents_in_window + + /* Called when the BFD is being closed to do any necessary cleanup. */ + bfd_boolean (*_close_and_cleanup) (bfd *); + /* Ask the BFD to free all cached information. */ + bfd_boolean (*_bfd_free_cached_info) (bfd *); + /* Called when a new section is created. */ + bfd_boolean (*_new_section_hook) (bfd *, sec_ptr); + /* Read the contents of a section. */ + bfd_boolean (*_bfd_get_section_contents) + (bfd *, sec_ptr, void *, file_ptr, bfd_size_type); + bfd_boolean (*_bfd_get_section_contents_in_window) + (bfd *, sec_ptr, bfd_window *, file_ptr, bfd_size_type); + + /* Entry points to copy private data. */ +#define BFD_JUMP_TABLE_COPY(NAME) \ + NAME##_bfd_copy_private_bfd_data, \ + NAME##_bfd_merge_private_bfd_data, \ + _bfd_generic_init_private_section_data, \ + NAME##_bfd_copy_private_section_data, \ + NAME##_bfd_copy_private_symbol_data, \ + NAME##_bfd_copy_private_header_data, \ + NAME##_bfd_set_private_flags, \ + NAME##_bfd_print_private_bfd_data + + /* Called to copy BFD general private data from one object file + to another. */ + bfd_boolean (*_bfd_copy_private_bfd_data) (bfd *, bfd *); + /* Called to merge BFD general private data from one object file + to a common output file when linking. */ + bfd_boolean (*_bfd_merge_private_bfd_data) (bfd *, bfd *); + /* Called to initialize BFD private section data from one object file + to another. */ +#define bfd_init_private_section_data(ibfd, isec, obfd, osec, link_info) \ + BFD_SEND (obfd, _bfd_init_private_section_data, (ibfd, isec, obfd, osec, link_info)) + bfd_boolean (*_bfd_init_private_section_data) + (bfd *, sec_ptr, bfd *, sec_ptr, struct bfd_link_info *); + /* Called to copy BFD private section data from one object file + to another. */ + bfd_boolean (*_bfd_copy_private_section_data) + (bfd *, sec_ptr, bfd *, sec_ptr); + /* Called to copy BFD private symbol data from one symbol + to another. */ + bfd_boolean (*_bfd_copy_private_symbol_data) + (bfd *, asymbol *, bfd *, asymbol *); + /* Called to copy BFD private header data from one object file + to another. */ + bfd_boolean (*_bfd_copy_private_header_data) + (bfd *, bfd *); + /* Called to set private backend flags. */ + bfd_boolean (*_bfd_set_private_flags) (bfd *, flagword); + + /* Called to print private BFD data. */ + bfd_boolean (*_bfd_print_private_bfd_data) (bfd *, void *); + + /* Core file entry points. */ +#define BFD_JUMP_TABLE_CORE(NAME) \ + NAME##_core_file_failing_command, \ + NAME##_core_file_failing_signal, \ + NAME##_core_file_matches_executable_p + + char * (*_core_file_failing_command) (bfd *); + int (*_core_file_failing_signal) (bfd *); + bfd_boolean (*_core_file_matches_executable_p) (bfd *, bfd *); + + /* Archive entry points. */ +#define BFD_JUMP_TABLE_ARCHIVE(NAME) \ + NAME##_slurp_armap, \ + NAME##_slurp_extended_name_table, \ + NAME##_construct_extended_name_table, \ + NAME##_truncate_arname, \ + NAME##_write_armap, \ + NAME##_read_ar_hdr, \ + NAME##_openr_next_archived_file, \ + NAME##_get_elt_at_index, \ + NAME##_generic_stat_arch_elt, \ + NAME##_update_armap_timestamp + + bfd_boolean (*_bfd_slurp_armap) (bfd *); + bfd_boolean (*_bfd_slurp_extended_name_table) (bfd *); + bfd_boolean (*_bfd_construct_extended_name_table) + (bfd *, char **, bfd_size_type *, const char **); + void (*_bfd_truncate_arname) (bfd *, const char *, char *); + bfd_boolean (*write_armap) + (bfd *, unsigned int, struct orl *, unsigned int, int); + void * (*_bfd_read_ar_hdr_fn) (bfd *); + bfd * (*openr_next_archived_file) (bfd *, bfd *); +#define bfd_get_elt_at_index(b,i) BFD_SEND (b, _bfd_get_elt_at_index, (b,i)) + bfd * (*_bfd_get_elt_at_index) (bfd *, symindex); + int (*_bfd_stat_arch_elt) (bfd *, struct stat *); + bfd_boolean (*_bfd_update_armap_timestamp) (bfd *); + + /* Entry points used for symbols. */ +#define BFD_JUMP_TABLE_SYMBOLS(NAME) \ + NAME##_get_symtab_upper_bound, \ + NAME##_canonicalize_symtab, \ + NAME##_make_empty_symbol, \ + NAME##_print_symbol, \ + NAME##_get_symbol_info, \ + NAME##_bfd_is_local_label_name, \ + NAME##_bfd_is_target_special_symbol, \ + NAME##_get_lineno, \ + NAME##_find_nearest_line, \ + _bfd_generic_find_line, \ + NAME##_find_inliner_info, \ + NAME##_bfd_make_debug_symbol, \ + NAME##_read_minisymbols, \ + NAME##_minisymbol_to_symbol + + long (*_bfd_get_symtab_upper_bound) (bfd *); + long (*_bfd_canonicalize_symtab) + (bfd *, struct bfd_symbol **); + struct bfd_symbol * + (*_bfd_make_empty_symbol) (bfd *); + void (*_bfd_print_symbol) + (bfd *, void *, struct bfd_symbol *, bfd_print_symbol_type); +#define bfd_print_symbol(b,p,s,e) BFD_SEND (b, _bfd_print_symbol, (b,p,s,e)) + void (*_bfd_get_symbol_info) + (bfd *, struct bfd_symbol *, symbol_info *); +#define bfd_get_symbol_info(b,p,e) BFD_SEND (b, _bfd_get_symbol_info, (b,p,e)) + bfd_boolean (*_bfd_is_local_label_name) (bfd *, const char *); + bfd_boolean (*_bfd_is_target_special_symbol) (bfd *, asymbol *); + alent * (*_get_lineno) (bfd *, struct bfd_symbol *); + bfd_boolean (*_bfd_find_nearest_line) + (bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma, + const char **, const char **, unsigned int *); + bfd_boolean (*_bfd_find_line) + (bfd *, struct bfd_symbol **, struct bfd_symbol *, + const char **, unsigned int *); + bfd_boolean (*_bfd_find_inliner_info) + (bfd *, const char **, const char **, unsigned int *); + /* Back-door to allow format-aware applications to create debug symbols + while using BFD for everything else. Currently used by the assembler + when creating COFF files. */ + asymbol * (*_bfd_make_debug_symbol) + (bfd *, void *, unsigned long size); +#define bfd_read_minisymbols(b, d, m, s) \ + BFD_SEND (b, _read_minisymbols, (b, d, m, s)) + long (*_read_minisymbols) + (bfd *, bfd_boolean, void **, unsigned int *); +#define bfd_minisymbol_to_symbol(b, d, m, f) \ + BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f)) + asymbol * (*_minisymbol_to_symbol) + (bfd *, bfd_boolean, const void *, asymbol *); + + /* Routines for relocs. */ +#define BFD_JUMP_TABLE_RELOCS(NAME) \ + NAME##_get_reloc_upper_bound, \ + NAME##_canonicalize_reloc, \ + NAME##_bfd_reloc_type_lookup, \ + NAME##_bfd_reloc_name_lookup + + long (*_get_reloc_upper_bound) (bfd *, sec_ptr); + long (*_bfd_canonicalize_reloc) + (bfd *, sec_ptr, arelent **, struct bfd_symbol **); + /* See documentation on reloc types. */ + reloc_howto_type * + (*reloc_type_lookup) (bfd *, bfd_reloc_code_real_type); + reloc_howto_type * + (*reloc_name_lookup) (bfd *, const char *); + + + /* Routines used when writing an object file. */ +#define BFD_JUMP_TABLE_WRITE(NAME) \ + NAME##_set_arch_mach, \ + NAME##_set_section_contents + + bfd_boolean (*_bfd_set_arch_mach) + (bfd *, enum bfd_architecture, unsigned long); + bfd_boolean (*_bfd_set_section_contents) + (bfd *, sec_ptr, const void *, file_ptr, bfd_size_type); + + /* Routines used by the linker. */ +#define BFD_JUMP_TABLE_LINK(NAME) \ + NAME##_sizeof_headers, \ + NAME##_bfd_get_relocated_section_contents, \ + NAME##_bfd_relax_section, \ + NAME##_bfd_link_hash_table_create, \ + NAME##_bfd_link_hash_table_free, \ + NAME##_bfd_link_add_symbols, \ + NAME##_bfd_link_just_syms, \ + NAME##_bfd_final_link, \ + NAME##_bfd_link_split_section, \ + NAME##_bfd_gc_sections, \ + NAME##_bfd_merge_sections, \ + NAME##_bfd_is_group_section, \ + NAME##_bfd_discard_group, \ + NAME##_section_already_linked \ + + int (*_bfd_sizeof_headers) (bfd *, struct bfd_link_info *); + bfd_byte * (*_bfd_get_relocated_section_contents) + (bfd *, struct bfd_link_info *, struct bfd_link_order *, + bfd_byte *, bfd_boolean, struct bfd_symbol **); + + bfd_boolean (*_bfd_relax_section) + (bfd *, struct bfd_section *, struct bfd_link_info *, bfd_boolean *); + + /* Create a hash table for the linker. Different backends store + different information in this table. */ + struct bfd_link_hash_table * + (*_bfd_link_hash_table_create) (bfd *); + + /* Release the memory associated with the linker hash table. */ + void (*_bfd_link_hash_table_free) (struct bfd_link_hash_table *); + + /* Add symbols from this object file into the hash table. */ + bfd_boolean (*_bfd_link_add_symbols) (bfd *, struct bfd_link_info *); + + /* Indicate that we are only retrieving symbol values from this section. */ + void (*_bfd_link_just_syms) (asection *, struct bfd_link_info *); + + /* Do a link based on the link_order structures attached to each + section of the BFD. */ + bfd_boolean (*_bfd_final_link) (bfd *, struct bfd_link_info *); + + /* Should this section be split up into smaller pieces during linking. */ + bfd_boolean (*_bfd_link_split_section) (bfd *, struct bfd_section *); + + /* Remove sections that are not referenced from the output. */ + bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *); + + /* Attempt to merge SEC_MERGE sections. */ + bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *); + + /* Is this section a member of a group? */ + bfd_boolean (*_bfd_is_group_section) (bfd *, const struct bfd_section *); + + /* Discard members of a group. */ + bfd_boolean (*_bfd_discard_group) (bfd *, struct bfd_section *); + + /* Check if SEC has been already linked during a reloceatable or + final link. */ + void (*_section_already_linked) (bfd *, struct bfd_section *, + struct bfd_link_info *); + + /* Routines to handle dynamic symbols and relocs. */ +#define BFD_JUMP_TABLE_DYNAMIC(NAME) \ + NAME##_get_dynamic_symtab_upper_bound, \ + NAME##_canonicalize_dynamic_symtab, \ + NAME##_get_synthetic_symtab, \ + NAME##_get_dynamic_reloc_upper_bound, \ + NAME##_canonicalize_dynamic_reloc + + /* Get the amount of memory required to hold the dynamic symbols. */ + long (*_bfd_get_dynamic_symtab_upper_bound) (bfd *); + /* Read in the dynamic symbols. */ + long (*_bfd_canonicalize_dynamic_symtab) + (bfd *, struct bfd_symbol **); + /* Create synthetized symbols. */ + long (*_bfd_get_synthetic_symtab) + (bfd *, long, struct bfd_symbol **, long, struct bfd_symbol **, + struct bfd_symbol **); + /* Get the amount of memory required to hold the dynamic relocs. */ + long (*_bfd_get_dynamic_reloc_upper_bound) (bfd *); + /* Read in the dynamic relocs. */ + long (*_bfd_canonicalize_dynamic_reloc) + (bfd *, arelent **, struct bfd_symbol **); + + /* Opposite endian version of this target. */ + const struct bfd_target * alternative_target; + + /* Data for use by back-end routines, which isn't + generic enough to belong in this structure. */ + const void *backend_data; + +} bfd_target; + +bfd_boolean bfd_set_default_target (const char *name); + +const bfd_target *bfd_find_target (const char *target_name, bfd *abfd); + +const char ** bfd_target_list (void); + +const bfd_target *bfd_search_for_target + (int (*search_func) (const bfd_target *, void *), + void *); + +/* Extracted from format.c. */ +bfd_boolean bfd_check_format (bfd *abfd, bfd_format format); + +bfd_boolean bfd_check_format_matches + (bfd *abfd, bfd_format format, char ***matching); + +bfd_boolean bfd_set_format (bfd *abfd, bfd_format format); + +const char *bfd_format_string (bfd_format format); + +/* Extracted from linker.c. */ +bfd_boolean bfd_link_split_section (bfd *abfd, asection *sec); + +#define bfd_link_split_section(abfd, sec) \ + BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec)) + +void bfd_section_already_linked (bfd *abfd, asection *sec, + struct bfd_link_info *info); + +#define bfd_section_already_linked(abfd, sec, info) \ + BFD_SEND (abfd, _section_already_linked, (abfd, sec, info)) + +/* Extracted from simple.c. */ +bfd_byte *bfd_simple_get_relocated_section_contents + (bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/gnu/usr.bin/binutils/libbfd/config.h.fbsd b/gnu/usr.bin/binutils/libbfd/config.h.fbsd new file mode 100644 index 000000000000..e1c1cf660f4f --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/config.h.fbsd @@ -0,0 +1,297 @@ +/* $FreeBSD$ */ + +/* config.h. Generated by configure. */ +/* config.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +/* #undef ENABLE_NLS */ + +/* Define to 1 if you have the declaration of `basename', and to 0 if you + don't. */ +#define HAVE_DECL_BASENAME 0 + +/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */ +#define HAVE_DECL_FFS 1 + +/* Define to 1 if you have the declaration of `free', and to 0 if you don't. + */ +#define HAVE_DECL_FREE 1 + +/* Define to 1 if you have the declaration of `fseeko', and to 0 if you don't. + */ +#define HAVE_DECL_FSEEKO 1 + +/* Define to 1 if you have the declaration of `fseeko64', and to 0 if you + don't. */ +#define HAVE_DECL_FSEEKO64 0 + +/* Define to 1 if you have the declaration of `ftello', and to 0 if you don't. + */ +#define HAVE_DECL_FTELLO 1 + +/* Define to 1 if you have the declaration of `ftello64', and to 0 if you + don't. */ +#define HAVE_DECL_FTELLO64 0 + +/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. + */ +#define HAVE_DECL_GETENV 1 + +/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't. + */ +#define HAVE_DECL_MALLOC 1 + +/* Define to 1 if you have the declaration of `realloc', and to 0 if you + don't. */ +#define HAVE_DECL_REALLOC 1 + +/* Define to 1 if you have the declaration of `snprintf', and to 0 if you + don't. */ +#define HAVE_DECL_SNPRINTF 1 + +/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't. + */ +#define HAVE_DECL_STPCPY 1 + +/* Define to 1 if you have the declaration of `strstr', and to 0 if you don't. + */ +#define HAVE_DECL_STRSTR 1 + +/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you + don't. */ +#define HAVE_DECL_VSNPRINTF 1 + +/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `fcntl' function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `fdopen' function. */ +#define HAVE_FDOPEN 1 + +/* Define to 1 if you have the `fopen64' function. */ +/* #undef HAVE_FOPEN64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fseeko64' function. */ +/* #undef HAVE_FSEEKO64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftello64' function. */ +/* #undef HAVE_FTELLO64 */ + +/* Define to 1 if you have the `getgid' function. */ +#define HAVE_GETGID 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getuid' function. */ +#define HAVE_GETUID 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define if <sys/procfs.h> has lwpstatus_t. */ +/* #undef HAVE_LWPSTATUS_T */ + +/* Define if <sys/procfs.h> has lwpstatus_t.pr_context. */ +/* #undef HAVE_LWPSTATUS_T_PR_CONTEXT */ + +/* Define if <sys/procfs.h> has lwpstatus_t.pr_reg. */ +/* #undef HAVE_LWPSTATUS_T_PR_REG */ + +/* Define if <sys/procfs.h> has lwpxstatus_t. */ +/* #undef HAVE_LWPXSTATUS_T */ + +/* Define to 1 if you have the `madvise' function. */ +#define HAVE_MADVISE 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mprotect' function. */ +#define HAVE_MPROTECT 1 + +/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define if <sys/procfs.h> has prpsinfo32_t. */ +/* #undef HAVE_PRPSINFO32_T */ + +/* Define if <sys/procfs.h> has prpsinfo_t. */ +#define HAVE_PRPSINFO_T 1 + +/* Define if <sys/procfs.h> has prstatus32_t. */ +/* #undef HAVE_PRSTATUS32_T */ + +/* Define if <sys/procfs.h> has prstatus32_t.pr_who. */ +/* #undef HAVE_PRSTATUS32_T_PR_WHO */ + +/* Define if <sys/procfs.h> has prstatus_t. */ +#define HAVE_PRSTATUS_T 1 + +/* Define if <sys/procfs.h> has prstatus_t.pr_who. */ +/* #undef HAVE_PRSTATUS_T_PR_WHO */ + +/* Define if <sys/procfs.h> has psinfo32_t. */ +/* #undef HAVE_PSINFO32_T */ + +/* Define if <sys/procfs.h> has psinfo_t. */ +/* #undef HAVE_PSINFO_T */ + +/* Define if <sys/procfs.h> has pstatus32_t. */ +/* #undef HAVE_PSTATUS32_T */ + +/* Define if <sys/procfs.h> has pstatus_t. */ +/* #undef HAVE_PSTATUS_T */ + +/* Define if <sys/procfs.h> has pxstatus_t. */ +/* #undef HAVE_PXSTATUS_T */ + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtoull' function. */ +#define HAVE_STRTOULL 1 + +/* Define if struct core_dumpx has member c_impl */ +/* #undef HAVE_ST_C_IMPL */ + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the <sys/procfs.h> header file. */ +#define HAVE_SYS_PROCFS_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if <sys/procfs.h> has win32_pstatus_t. */ +/* #undef HAVE_WIN32_PSTATUS_T */ + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "bfd" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* The size of a `char', as computed by sizeof. */ +/* #undef SIZEOF_CHAR */ + +/* The size of a `int', as computed by sizeof. */ +/* #undef SIZEOF_INT */ + +/* The size of a `long', as computed by sizeof. */ +/* #define SIZEOF_LONG 4 */ + +/* The size of a `long long', as computed by sizeof. */ +/* #define SIZEOF_LONG_LONG 8 */ + +/* The size of a `off_t', as computed by sizeof. */ +/* #define SIZEOF_OFF_T 8 */ + +/* The size of a `short', as computed by sizeof. */ +/* #undef SIZEOF_SHORT */ + +/* The size of a `void *', as computed by sizeof. */ +/* #undef SIZEOF_VOID_P */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both <string.h> and <strings.h>. */ +#define STRING_WITH_STRINGS 1 + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#define TIME_WITH_SYS_TIME 1 + +/* Name of host specific header file to include in trad-core.c. */ +#define TRAD_HEADER !!TRAD_HEADER!! + +/* Use b modifier when opening binary files? */ +/* #undef USE_BINARY_FOPEN */ + +/* Use mmap if it's available? */ +/* #undef USE_MMAP */ + +/* Define if we should default to creating read-only plt entries */ +/* #undef USE_SECUREPLT */ + +/* Version number of package */ +/* #define VERSION "2.17.50" */ + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif diff --git a/gnu/usr.bin/binutils/libbfd/elf-fbsd-brand.c b/gnu/usr.bin/binutils/libbfd/elf-fbsd-brand.c new file mode 100644 index 000000000000..b8ba60e5f7d9 --- /dev/null +++ b/gnu/usr.bin/binutils/libbfd/elf-fbsd-brand.c @@ -0,0 +1,30 @@ +/*- + * Copyright (c) 2002, 2003 David E. O'Brien + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#define ELF_OSABI ELFOSABI_FREEBSD +#define elf_backend_post_process_headers _bfd_elf_set_osabi diff --git a/gnu/usr.bin/binutils/libbinutils/Makefile b/gnu/usr.bin/binutils/libbinutils/Makefile new file mode 100644 index 000000000000..d6518a55be6c --- /dev/null +++ b/gnu/usr.bin/binutils/libbinutils/Makefile @@ -0,0 +1,33 @@ +# $FreeBSD$ + +.include "../Makefile.inc0" + +.PATH: ${SRCDIR}/binutils + +LIB= binutils +SRCS+= arlex.l \ + arparse.y \ + arsup.c \ + binemul.c \ + bucomm.c \ + debug.c \ + dwarf.c \ + emul_vanilla.c \ + filemode.c \ + ieee.c \ + rdcoff.c \ + rddbg.c \ + rename.c \ + stabs.c \ + unwind-ia64.c \ + version.c \ + wrstabs.c +CFLAGS+= -DTARGET=\"${TARGET_TUPLE}\" +CFLAGS+= -DBFD_VERSION_STRING=\"${VERSION}\" +CFLAGS+= -D_GNU_SOURCE +CFLAGS+= -DYY_NO_INPUT +CFLAGS+= -I${SRCDIR}/binutils +CFLAGS+= -I${SRCDIR}/bfd +INTERNALLIB= + +.include <bsd.lib.mk> diff --git a/gnu/usr.bin/binutils/libbinutils/Makefile.depend b/gnu/usr.bin/binutils/libbinutils/Makefile.depend new file mode 100644 index 000000000000..89b90452da80 --- /dev/null +++ b/gnu/usr.bin/binutils/libbinutils/Makefile.depend @@ -0,0 +1,15 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/usr.bin/binutils/libbfd \ + include \ + include/xlocale \ + usr.bin/yacc.host \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/libbinutils/config.h b/gnu/usr.bin/binutils/libbinutils/config.h new file mode 100644 index 000000000000..5c457f1eeaff --- /dev/null +++ b/gnu/usr.bin/binutils/libbinutils/config.h @@ -0,0 +1,215 @@ +/* $FreeBSD$ */ + +/* FreeBSD isn't any form of AIX. */ +#define bin_dummy_emulation bin_vanilla_emulation + +/* config.h. Generated by configure. */ +/* config.in. Generated from configure.in by autoheader. */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +/* #undef CRAY_STACKSEG_END */ + +/* Define to 1 if using `alloca.c'. */ +/* #undef C_ALLOCA */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +/* #undef ENABLE_NLS */ + +/* Suffix used for executables, if any. */ +#define EXECUTABLE_SUFFIX "" + +/* Define to 1 if you have `alloca', as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). + */ +/* #undef HAVE_ALLOCA_H */ + +/* Define to 1 if you have the declaration of `environ', and to 0 if you + don't. */ +#define HAVE_DECL_ENVIRON 0 + +/* Define to 1 if you have the declaration of `fprintf', and to 0 if you + don't. */ +#define HAVE_DECL_FPRINTF 1 + +/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you + don't. */ +#define HAVE_DECL_GETC_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. + */ +#define HAVE_DECL_GETENV 1 + +/* Is the prototype for getopt in <unistd.h> in the expected format? */ +#define HAVE_DECL_GETOPT 1 + +/* Define to 1 if you have the declaration of `sbrk', and to 0 if you don't. + */ +#define HAVE_DECL_SBRK 1 + +/* Define to 1 if you have the declaration of `snprintf', and to 0 if you + don't. */ +#define HAVE_DECL_SNPRINTF 1 + +/* Define to 1 if you have the declaration of `stpcpy', and to 0 if you don't. + */ +#define HAVE_DECL_STPCPY 1 + +/* Define to 1 if you have the declaration of `strstr', and to 0 if you don't. + */ +#define HAVE_DECL_STRSTR 1 + +/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you + don't. */ +#define HAVE_DECL_VSNPRINTF 1 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Does the platform use an executable suffix? */ +/* #undef HAVE_EXECUTABLE_SUFFIX */ + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Is fopen64 available? */ +/* #undef HAVE_FOPEN64 */ + +/* Define to 1 if you have the `getc_unlocked' function. */ +#define HAVE_GETC_UNLOCKED 1 + +/* Does <utime.h> define struct utimbuf? */ +#define HAVE_GOOD_UTIME_H 1 + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkdtemp' function. */ +#define HAVE_MKDTEMP 1 + +/* Define to 1 if you have the `mkstemp' function. */ +#define HAVE_MKSTEMP 1 + +/* Define to 1 if you have the `sbrk' function. */ +/* #undef HAVE_SBRK */ + +/* Define to 1 if you have the `setmode' function. */ +#define HAVE_SETMODE 1 + +/* Is stat64 available? */ +/* #undef HAVE_STAT64 */ + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strcoll' function. */ +#define HAVE_STRCOLL 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Is the type time_t defined in <time.h>? */ +#define HAVE_TIME_T_IN_TIME_H 1 + +/* Is the type time_t defined in <sys/types.h>? */ +#define HAVE_TIME_T_IN_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "binutils" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +/* #undef STACK_DIRECTION */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Configured target name. */ +/* #define TARGET "i386-unknown-freebsd9.0" */ + +/* Define to 1 if user symbol names have a leading underscore, 0 if not. */ +#define TARGET_PREPENDS_UNDERSCORE 0 + +/* Use b modifier when opening binary files? */ +/* #undef USE_BINARY_FOPEN */ + +/* Version number of package */ +/* #define VERSION "2.17.50" */ + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#define YYTEXT_POINTER 1 + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +/* Enable LFS */ +/* #undef _LARGEFILE64_SOURCE */ diff --git a/gnu/usr.bin/binutils/libiberty/Makefile b/gnu/usr.bin/binutils/libiberty/Makefile new file mode 100644 index 000000000000..973154718d4b --- /dev/null +++ b/gnu/usr.bin/binutils/libiberty/Makefile @@ -0,0 +1,42 @@ +# $FreeBSD$ + +.include "../Makefile.inc0" + +.PATH: ${SRCDIR}/libiberty + +LIB= iberty +SRCS= argv.c \ + concat.c \ + choose-temp.c \ + cp-demangle.c \ + cp-demint.c \ + cplus-dem.c \ + dyn-string.c \ + getpwd.c \ + getruntime.c \ + filename_cmp.c \ + floatformat.c \ + hashtab.c \ + hex.c \ + lbasename.c \ + lrealpath.c \ + make-relative-prefix.c \ + make-temp-file.c \ + objalloc.c \ + obstack.c \ + safe-ctype.c \ + unlink-if-ordinary.c \ + xatexit.c \ + xexit.c \ + xmalloc.c \ + xstrdup.c \ + xstrerror.c + +# The following files are needed by gdb(1) +SRCS+= splay-tree.c + +WARNS?= 2 +CFLAGS+= -DHAVE_CONFIG_H +INTERNALLIB= + +.include <bsd.lib.mk> diff --git a/gnu/usr.bin/binutils/libiberty/Makefile.depend b/gnu/usr.bin/binutils/libiberty/Makefile.depend new file mode 100644 index 000000000000..c210061155d2 --- /dev/null +++ b/gnu/usr.bin/binutils/libiberty/Makefile.depend @@ -0,0 +1,14 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + lib/msun \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/libiberty/config.h b/gnu/usr.bin/binutils/libiberty/config.h new file mode 100644 index 000000000000..4361330c7f1f --- /dev/null +++ b/gnu/usr.bin/binutils/libiberty/config.h @@ -0,0 +1,449 @@ +/* $FreeBSD$ */ + +/* config.h. Generated by configure. */ +/* config.in. Generated from configure.ac by autoheader. */ + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +/* #undef CRAY_STACKSEG_END */ + +/* Define to 1 if you have the <alloca.h> header file. */ +/* #undef HAVE_ALLOCA_H */ + +/* Define to 1 if you have the `asprintf' function. */ +#define HAVE_ASPRINTF 1 + +/* Define to 1 if you have the `atexit' function. */ +#define HAVE_ATEXIT 1 + +/* Define to 1 if you have the `basename' function. */ +#define HAVE_BASENAME 1 + +/* Define to 1 if you have the `bcmp' function. */ +#define HAVE_BCMP 1 + +/* Define to 1 if you have the `bcopy' function. */ +#define HAVE_BCOPY 1 + +/* Define to 1 if you have the `bsearch' function. */ +#define HAVE_BSEARCH 1 + +/* Define to 1 if you have the `bzero' function. */ +#define HAVE_BZERO 1 + +/* Define to 1 if you have the `calloc' function. */ +#define HAVE_CALLOC 1 + +/* Define to 1 if you have the `canonicalize_file_name' function. */ +/* #undef HAVE_CANONICALIZE_FILE_NAME */ + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the declaration of `asprintf', and to 0 if you + don't. */ +#define HAVE_DECL_ASPRINTF 1 + +/* Define to 1 if you have the declaration of `basename', and to 0 if you + don't. */ +#define HAVE_DECL_BASENAME 0 + +/* Define to 1 if you have the declaration of `calloc', and to 0 if you don't. + */ +#define HAVE_DECL_CALLOC 1 + +/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */ +#define HAVE_DECL_FFS 1 + +/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. + */ +#define HAVE_DECL_GETENV 1 + +/* Define to 1 if you have the declaration of `getopt', and to 0 if you don't. + */ +#define HAVE_DECL_GETOPT 1 + +/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't. + */ +#define HAVE_DECL_MALLOC 1 + +/* Define to 1 if you have the declaration of `realloc', and to 0 if you + don't. */ +#define HAVE_DECL_REALLOC 1 + +/* Define to 1 if you have the declaration of `sbrk', and to 0 if you don't. + */ +#define HAVE_DECL_SBRK 1 + +/* Define to 1 if you have the declaration of `snprintf', and to 0 if you + don't. */ +#define HAVE_DECL_SNPRINTF 1 + +/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you + don't. */ +#define HAVE_DECL_STRVERSCMP 0 + +/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you + don't. */ +#define HAVE_DECL_VASPRINTF 1 + +/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you + don't. */ +#define HAVE_DECL_VSNPRINTF 1 + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `ffs' function. */ +#define HAVE_FFS 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getrusage' function. */ +#define HAVE_GETRUSAGE 1 + +/* Define to 1 if you have the `getsysinfo' function. */ +/* #undef HAVE_GETSYSINFO */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `index' function. */ +#define HAVE_INDEX 1 + +/* Define to 1 if you have the `insque' function. */ +#define HAVE_INSQUE 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the <machine/hal_sysinfo.h> header file. */ +/* #undef HAVE_MACHINE_HAL_SYSINFO_H */ + +/* Define to 1 if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define to 1 if you have the `memchr' function. */ +#define HAVE_MEMCHR 1 + +/* Define to 1 if you have the `memcmp' function. */ +#define HAVE_MEMCMP 1 + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mempcpy' function. */ +/* #undef HAVE_MEMPCPY */ + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the `mkstemps' function. */ +#define HAVE_MKSTEMPS 1 + +/* Define to 1 if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `on_exit' function. */ +/* #undef HAVE_ON_EXIT */ + +/* Define to 1 if you have the `psignal' function. */ +#define HAVE_PSIGNAL 1 + +/* Define to 1 if you have the `pstat_getdynamic' function. */ +/* #undef HAVE_PSTAT_GETDYNAMIC */ + +/* Define to 1 if you have the `pstat_getstatic' function. */ +/* #undef HAVE_PSTAT_GETSTATIC */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `random' function. */ +#define HAVE_RANDOM 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `rename' function. */ +#define HAVE_RENAME 1 + +/* Define to 1 if you have the `rindex' function. */ +#define HAVE_RINDEX 1 + +/* Define to 1 if you have the `sbrk' function. */ +/* #undef HAVE_SBRK */ + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the `sigsetmask' function. */ +#define HAVE_SIGSETMASK 1 + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdio_ext.h> header file. */ +/* #undef HAVE_STDIO_EXT_H */ + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +#define HAVE_STPCPY 1 + +/* Define to 1 if you have the `stpncpy' function. */ +#define HAVE_STPNCPY 1 + +/* Define to 1 if you have the `strcasecmp' function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strncasecmp' function. */ +#define HAVE_STRNCASECMP 1 + +/* Define to 1 if you have the `strndup' function. */ +#define HAVE_STRNDUP 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if you have the `strsignal' function. */ +#define HAVE_STRSIGNAL 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the `strtod' function. */ +#define HAVE_STRTOD 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strverscmp' function. */ +/* #undef HAVE_STRVERSCMP */ + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the `sysctl' function. */ +#define HAVE_SYSCTL 1 + +/* Define to 1 if you have the `sysmp' function. */ +/* #undef HAVE_SYSMP */ + +/* Define if you have the sys_errlist variable. */ +#define HAVE_SYS_ERRLIST 1 + +/* Define to 1 if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the <sys/mman.h> header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define if you have the sys_nerr variable. */ +#define HAVE_SYS_NERR 1 + +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the <sys/pstat.h> header file. */ +/* #undef HAVE_SYS_PSTAT_H */ + +/* Define to 1 if you have the <sys/resource.h> header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define if you have the sys_siglist variable. */ +#define HAVE_SYS_SIGLIST 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/sysctl.h> header file. */ +#define HAVE_SYS_SYSCTL_H 1 + +/* Define to 1 if you have the <sys/sysinfo.h> header file. */ +/* #undef HAVE_SYS_SYSINFO_H */ + +/* Define to 1 if you have the <sys/sysmp.h> header file. */ +/* #undef HAVE_SYS_SYSMP_H */ + +/* Define to 1 if you have the <sys/systemcfg.h> header file. */ +/* #undef HAVE_SYS_SYSTEMCFG_H */ + +/* Define to 1 if you have the <sys/table.h> header file. */ +/* #undef HAVE_SYS_TABLE_H */ + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `table' function. */ +/* #undef HAVE_TABLE */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define if you have the \`uintptr_t' type. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `vasprintf' function. */ +#define HAVE_VASPRINTF 1 + +/* Define to 1 if you have the `vfork' function. */ +#define HAVE_VFORK 1 + +/* Define to 1 if you have the <vfork.h> header file. */ +/* #undef HAVE_VFORK_H */ + +/* Define to 1 if you have the `vfprintf' function. */ +#define HAVE_VFPRINTF 1 + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to 1 if you have the `vsprintf' function. */ +#define HAVE_VSPRINTF 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define to 1 if `fork' works. */ +#define HAVE_WORKING_FORK 1 + +/* Define to 1 if `vfork' works. */ +#define HAVE_WORKING_VFORK 1 + +/* Define to 1 if you have the `_doprnt' function. */ +/* #undef HAVE__DOPRNT */ + +/* Define if you have the _system_configuration variable. */ +/* #undef HAVE__SYSTEM_CONFIGURATION */ + +/* Define to 1 if you have the `__fsetlocking' function. */ +/* #undef HAVE___FSETLOCKING */ + +/* Define if canonicalize_file_name is not declared in system header files. */ +#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 + +/* Define if errno must be declared even when <errno.h> is included. */ +/* #undef NEED_DECLARATION_ERRNO */ + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +/* #define PACKAGE_VERSION "" */ + +/* The size of a `int', as computed by sizeof. */ +/* #define SIZEOF_INT 4 */ + +/* Define if you know the direction of stack growth for your system; otherwise + it will be automatically deduced at run-time. STACK_DIRECTION > 0 => grows + toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#define STACK_DIRECTION -1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to an unsigned 64-bit type available in the compiler. */ +#define UNSIGNED_64BIT_TYPE uint64_t + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#if defined(__powerpc__) || defined(__sparc64__) +# define WORDS_BIGENDIAN 1 +#endif + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `int' if <sys/types.h> does not define. */ +/* #undef pid_t */ + +/* Define to `unsigned long' if <sys/types.h> does not define. */ +/* #undef uintptr_t */ + +/* Define as `fork' if `vfork' does not work. */ +/* #undef vfork */ diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile b/gnu/usr.bin/binutils/libopcodes/Makefile new file mode 100644 index 000000000000..eb6f273bc80a --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/Makefile @@ -0,0 +1,22 @@ +# $FreeBSD$ + +.include "../Makefile.inc0" + +.PATH: ${SRCDIR}/opcodes + +LIB= opcodes +SRCS+= dis-buf.c dis-init.c disassemble.c i386-opc.c +CFLAGS+= -D_GNU_SOURCE +CFLAGS+= -I${SRCDIR}/opcodes -I${SRCDIR}/bfd +INTERNALLIB= + +# If set, BINUTILSDISTDIR is the path to a directory containing the full GNU +# binutils release. FreeBSD only distributes the bits that are required to +# build native architectures. BINUTILSDISTDIR is needed to build cross tools. +.if defined(BINUTILSDISTDIR) && exists(${BINUTILSDISTDIR}) +.PATH: ${BINUTILSDISTDIR}/bfd ${BINUTILSDISTDIR}/opcodes +CFLAGS+= -I${BINUTILSDISTDIR}/opcodes -I${BINUTILSDISTDIR}/bfd +CFLAGS+= -I${BINUTILSDISTDIR}/include +.endif + +.include <bsd.lib.mk> diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.amd64 b/gnu/usr.bin/binutils/libopcodes/Makefile.amd64 new file mode 100644 index 000000000000..5b1ce3a96896 --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/Makefile.amd64 @@ -0,0 +1,4 @@ +# $FreeBSD$ + +SRCS+= i386-dis.c +CFLAGS+= -DARCH_i386 diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.arm b/gnu/usr.bin/binutils/libopcodes/Makefile.arm new file mode 100644 index 000000000000..67bb751db477 --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/Makefile.arm @@ -0,0 +1,4 @@ +# $FreeBSD$ + +SRCS+= arm-dis.c +CFLAGS+= -DARCH_arm diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.depend b/gnu/usr.bin/binutils/libopcodes/Makefile.depend new file mode 100644 index 000000000000..18be76b0cb6f --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/Makefile.depend @@ -0,0 +1,13 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.i386 b/gnu/usr.bin/binutils/libopcodes/Makefile.i386 new file mode 100644 index 000000000000..5b1ce3a96896 --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/Makefile.i386 @@ -0,0 +1,4 @@ +# $FreeBSD$ + +SRCS+= i386-dis.c +CFLAGS+= -DARCH_i386 diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.m68k b/gnu/usr.bin/binutils/libopcodes/Makefile.m68k new file mode 100644 index 000000000000..927e2a1ea5cb --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/Makefile.m68k @@ -0,0 +1,6 @@ +# +# $FreeBSD$ +# + +SRCS+= m68k-dis.c m68k-opc.c +CFLAGS+= -DARCH_m68k diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.mips b/gnu/usr.bin/binutils/libopcodes/Makefile.mips new file mode 100644 index 000000000000..4265de008753 --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/Makefile.mips @@ -0,0 +1,4 @@ +# $FreeBSD$ + +SRCS+= mips-dis.c mips-opc.c mips16-opc.c +CFLAGS+= -DARCH_mips diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.powerpc b/gnu/usr.bin/binutils/libopcodes/Makefile.powerpc new file mode 100644 index 000000000000..cc010ec4a306 --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/Makefile.powerpc @@ -0,0 +1,4 @@ +# $FreeBSD$ + +SRCS+= ppc-dis.c ppc-opc.c +CFLAGS+= -DARCH_powerpc -DARCH_rs6000 diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.sparc b/gnu/usr.bin/binutils/libopcodes/Makefile.sparc new file mode 100644 index 000000000000..190b76621cc0 --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/Makefile.sparc @@ -0,0 +1,6 @@ +# +# $FreeBSD$ +# + +SRCS+= sparc-dis.c sparc-opc.c +CFLAGS+= -DARCH_sparc diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.sparc64 b/gnu/usr.bin/binutils/libopcodes/Makefile.sparc64 new file mode 100644 index 000000000000..e795ad494bba --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/Makefile.sparc64 @@ -0,0 +1,4 @@ +# $FreeBSD$ + +SRCS+= sparc-dis.c sparc-opc.c +CFLAGS+= -DARCH_sparc diff --git a/gnu/usr.bin/binutils/libopcodes/config.h b/gnu/usr.bin/binutils/libopcodes/config.h new file mode 100644 index 000000000000..f77d5e0a4256 --- /dev/null +++ b/gnu/usr.bin/binutils/libopcodes/config.h @@ -0,0 +1,70 @@ +/* $FreeBSD$ */ + +/* config.h. Generated by configure. */ +/* config.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +/* #undef ENABLE_NLS */ + +/* Define to 1 if you have the declaration of `basename', and to 0 if you + don't. */ +#define HAVE_DECL_BASENAME 0 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "opcodes" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +/* #define VERSION "2.17.50" */ diff --git a/gnu/usr.bin/binutils/objcopy/Makefile b/gnu/usr.bin/binutils/objcopy/Makefile new file mode 100644 index 000000000000..992649bc2864 --- /dev/null +++ b/gnu/usr.bin/binutils/objcopy/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +.include "../Makefile.inc0" + +.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc + +PROG= objcopy +SRCS= objcopy.c not-strip.c +CFLAGS+= -D_GNU_SOURCE +CFLAGS+= -I${.CURDIR}/${GNURELTOP}/libbinutils +CFLAGS+= -I${SRCDIR}/binutils -I${SRCDIR}/bfd +DPADD= ${GNURELTOP}/libbinutils/libbinutils.a +DPADD+= ${GNURELTOP}/libbfd/libbfd.a +DPADD+= ${GNURELTOP}/libiberty/libiberty.a +LDADD= ${DPADD} + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/binutils/objcopy/Makefile.depend b/gnu/usr.bin/binutils/objcopy/Makefile.depend new file mode 100644 index 000000000000..c27a80a48005 --- /dev/null +++ b/gnu/usr.bin/binutils/objcopy/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/usr.bin/binutils/libbfd \ + gnu/usr.bin/binutils/libbinutils \ + gnu/usr.bin/binutils/libiberty \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/objcopy/objcopy.1 b/gnu/usr.bin/binutils/objcopy/objcopy.1 new file mode 100644 index 000000000000..66f051d3b86f --- /dev/null +++ b/gnu/usr.bin/binutils/objcopy/objcopy.1 @@ -0,0 +1,858 @@ +.\" $FreeBSD$ +.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.ie \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.el \{\ +. de IX +.. +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "OBJCOPY 1" +.TH OBJCOPY 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +objcopy \- copy and translate object files +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +objcopy [\fB\-F\fR \fIbfdname\fR|\fB\-\-target=\fR\fIbfdname\fR] + [\fB\-I\fR \fIbfdname\fR|\fB\-\-input\-target=\fR\fIbfdname\fR] + [\fB\-O\fR \fIbfdname\fR|\fB\-\-output\-target=\fR\fIbfdname\fR] + [\fB\-B\fR \fIbfdarch\fR|\fB\-\-binary\-architecture=\fR\fIbfdarch\fR] + [\fB\-S\fR|\fB\-\-strip\-all\fR] + [\fB\-g\fR|\fB\-\-strip\-debug\fR] + [\fB\-K\fR \fIsymbolname\fR|\fB\-\-keep\-symbol=\fR\fIsymbolname\fR] + [\fB\-N\fR \fIsymbolname\fR|\fB\-\-strip\-symbol=\fR\fIsymbolname\fR] + [\fB\-\-strip\-unneeded\-symbol=\fR\fIsymbolname\fR] + [\fB\-G\fR \fIsymbolname\fR|\fB\-\-keep\-global\-symbol=\fR\fIsymbolname\fR] + [\fB\-\-localize\-hidden\fR] + [\fB\-L\fR \fIsymbolname\fR|\fB\-\-localize\-symbol=\fR\fIsymbolname\fR] + [\fB\-\-globalize\-symbol=\fR\fIsymbolname\fR] + [\fB\-W\fR \fIsymbolname\fR|\fB\-\-weaken\-symbol=\fR\fIsymbolname\fR] + [\fB\-w\fR|\fB\-\-wildcard\fR] + [\fB\-x\fR|\fB\-\-discard\-all\fR] + [\fB\-X\fR|\fB\-\-discard\-locals\fR] + [\fB\-b\fR \fIbyte\fR|\fB\-\-byte=\fR\fIbyte\fR] + [\fB\-i\fR \fIinterleave\fR|\fB\-\-interleave=\fR\fIinterleave\fR] + [\fB\-j\fR \fIsectionname\fR|\fB\-\-only\-section=\fR\fIsectionname\fR] + [\fB\-R\fR \fIsectionname\fR|\fB\-\-remove\-section=\fR\fIsectionname\fR] + [\fB\-p\fR|\fB\-\-preserve\-dates\fR] + [\fB\-\-debugging\fR] + [\fB\-\-gap\-fill=\fR\fIval\fR] + [\fB\-\-pad\-to=\fR\fIaddress\fR] + [\fB\-\-set\-start=\fR\fIval\fR] + [\fB\-\-adjust\-start=\fR\fIincr\fR] + [\fB\-\-change\-addresses=\fR\fIincr\fR] + [\fB\-\-change\-section\-address\fR \fIsection\fR{=,+,\-}\fIval\fR] + [\fB\-\-change\-section\-lma\fR \fIsection\fR{=,+,\-}\fIval\fR] + [\fB\-\-change\-section\-vma\fR \fIsection\fR{=,+,\-}\fIval\fR] + [\fB\-\-change\-warnings\fR] [\fB\-\-no\-change\-warnings\fR] + [\fB\-\-set\-section\-flags\fR \fIsection\fR=\fIflags\fR] + [\fB\-\-add\-section\fR \fIsectionname\fR=\fIfilename\fR] + [\fB\-\-rename\-section\fR \fIoldname\fR=\fInewname\fR[,\fIflags\fR]] + [\fB\-\-change\-leading\-char\fR] [\fB\-\-remove\-leading\-char\fR] + [\fB\-\-reverse\-bytes=\fR\fInum\fR] + [\fB\-\-srec\-len=\fR\fIival\fR] [\fB\-\-srec\-forceS3\fR] + [\fB\-\-redefine\-sym\fR \fIold\fR=\fInew\fR] + [\fB\-\-redefine\-syms=\fR\fIfilename\fR] + [\fB\-\-weaken\fR] + [\fB\-\-keep\-symbols=\fR\fIfilename\fR] + [\fB\-\-strip\-symbols=\fR\fIfilename\fR] + [\fB\-\-strip\-unneeded\-symbols=\fR\fIfilename\fR] + [\fB\-\-keep\-global\-symbols=\fR\fIfilename\fR] + [\fB\-\-localize\-symbols=\fR\fIfilename\fR] + [\fB\-\-globalize\-symbols=\fR\fIfilename\fR] + [\fB\-\-weaken\-symbols=\fR\fIfilename\fR] + [\fB\-\-alt\-machine\-code=\fR\fIindex\fR] + [\fB\-\-prefix\-symbols=\fR\fIstring\fR] + [\fB\-\-prefix\-sections=\fR\fIstring\fR] + [\fB\-\-prefix\-alloc\-sections=\fR\fIstring\fR] + [\fB\-\-add\-gnu\-debuglink=\fR\fIpath-to-file\fR] + [\fB\-\-keep\-file\-symbols\fR] + [\fB\-\-only\-keep\-debug\fR] + [\fB\-\-extract\-symbol\fR] + [\fB\-\-writable\-text\fR] + [\fB\-\-readonly\-text\fR] + [\fB\-\-pure\fR] + [\fB\-\-impure\fR] + [\fB\-v\fR|\fB\-\-verbose\fR] + [\fB\-V\fR|\fB\-\-version\fR] + [\fB\-\-help\fR] [\fB\-\-info\fR] + \fIinfile\fR [\fIoutfile\fR] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +The \s-1GNU\s0 \fBobjcopy\fR utility copies the contents of an object +file to another. \fBobjcopy\fR uses the \s-1GNU\s0 \s-1BFD\s0 Library to +read and write the object files. It can write the destination object +file in a format different from that of the source object file. The +exact behavior of \fBobjcopy\fR is controlled by command-line options. +Note that \fBobjcopy\fR should be able to copy a fully linked file +between any two formats. However, copying a relocatable object file +between any two formats may not work as expected. +.PP +\&\fBobjcopy\fR creates temporary files to do its translations and +deletes them afterward. \fBobjcopy\fR uses \s-1BFD\s0 to do all its +translation work; it has access to all the formats described in \s-1BFD\s0 +and thus is able to recognize most formats without being told +explicitly. +.PP +\&\fBobjcopy\fR can be used to generate S\-records by using an output +target of \fBsrec\fR (e.g., use \fB\-O srec\fR). +.PP +\&\fBobjcopy\fR can be used to generate a raw binary file by using an +output target of \fBbinary\fR (e.g., use \fB\-O binary\fR). When +\&\fBobjcopy\fR generates a raw binary file, it will essentially produce +a memory dump of the contents of the input object file. All symbols and +relocation information will be discarded. The memory dump will start at +the load address of the lowest section copied into the output file. +.PP +When generating an S\-record or a raw binary file, it may be helpful to +use \fB\-S\fR to remove sections containing debugging information. In +some cases \fB\-R\fR will be useful to remove sections which contain +information that is not needed by the binary file. +.PP +Note\-\-\-\fBobjcopy\fR is not able to change the endianness of its input +files. If the input format has an endianness (some formats do not), +\&\fBobjcopy\fR can only copy the inputs into file formats that have the +same endianness or which have no endianness (e.g., \fBsrec\fR). +(However, see the \fB\-\-reverse\-bytes\fR option.) +.SH "OPTIONS" +.IX Header "OPTIONS" +.IP "\fIinfile\fR" 4 +.IX Item "infile" +.PD 0 +.IP "\fIoutfile\fR" 4 +.IX Item "outfile" +.PD +The input and output files, respectively. +If you do not specify \fIoutfile\fR, \fBobjcopy\fR creates a +temporary file and destructively renames the result with +the name of \fIinfile\fR. +.IP "\fB\-I\fR \fIbfdname\fR" 4 +.IX Item "-I bfdname" +.PD 0 +.IP "\fB\-\-input\-target=\fR\fIbfdname\fR" 4 +.IX Item "--input-target=bfdname" +.PD +Consider the source file's object format to be \fIbfdname\fR, rather than +attempting to deduce it. +.IP "\fB\-O\fR \fIbfdname\fR" 4 +.IX Item "-O bfdname" +.PD 0 +.IP "\fB\-\-output\-target=\fR\fIbfdname\fR" 4 +.IX Item "--output-target=bfdname" +.PD +Write the output file using the object format \fIbfdname\fR. +.IP "\fB\-F\fR \fIbfdname\fR" 4 +.IX Item "-F bfdname" +.PD 0 +.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 +.IX Item "--target=bfdname" +.PD +Use \fIbfdname\fR as the object format for both the input and the output +file; i.e., simply transfer data from source to destination with no +translation. +.IP "\fB\-B\fR \fIbfdarch\fR" 4 +.IX Item "-B bfdarch" +.PD 0 +.IP "\fB\-\-binary\-architecture=\fR\fIbfdarch\fR" 4 +.IX Item "--binary-architecture=bfdarch" +.PD +Useful when transforming a raw binary input file into an object file. +In this case the output architecture can be set to \fIbfdarch\fR. This +option will be ignored if the input file has a known \fIbfdarch\fR. You +can access this binary data inside a program by referencing the special +symbols that are created by the conversion process. These symbols are +called _binary_\fIobjfile\fR_start, _binary_\fIobjfile\fR_end and +_binary_\fIobjfile\fR_size. e.g. you can transform a picture file into +an object file and then access it in your code using these symbols. +.IP "\fB\-j\fR \fIsectionname\fR" 4 +.IX Item "-j sectionname" +.PD 0 +.IP "\fB\-\-only\-section=\fR\fIsectionname\fR" 4 +.IX Item "--only-section=sectionname" +.PD +Copy only the named section from the input file to the output file. +This option may be given more than once. Note that using this option +inappropriately may make the output file unusable. +.IP "\fB\-R\fR \fIsectionname\fR" 4 +.IX Item "-R sectionname" +.PD 0 +.IP "\fB\-\-remove\-section=\fR\fIsectionname\fR" 4 +.IX Item "--remove-section=sectionname" +.PD +Remove any section named \fIsectionname\fR from the output file. This +option may be given more than once. Note that using this option +inappropriately may make the output file unusable. +.IP "\fB\-S\fR" 4 +.IX Item "-S" +.PD 0 +.IP "\fB\-\-strip\-all\fR" 4 +.IX Item "--strip-all" +.PD +Do not copy relocation and symbol information from the source file. +.IP "\fB\-g\fR" 4 +.IX Item "-g" +.PD 0 +.IP "\fB\-\-strip\-debug\fR" 4 +.IX Item "--strip-debug" +.PD +Do not copy debugging symbols or sections from the source file. +.IP "\fB\-\-strip\-unneeded\fR" 4 +.IX Item "--strip-unneeded" +Strip all symbols that are not needed for relocation processing. +.IP "\fB\-K\fR \fIsymbolname\fR" 4 +.IX Item "-K symbolname" +.PD 0 +.IP "\fB\-\-keep\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--keep-symbol=symbolname" +.PD +When stripping symbols, keep symbol \fIsymbolname\fR even if it would +normally be stripped. This option may be given more than once. +.IP "\fB\-N\fR \fIsymbolname\fR" 4 +.IX Item "-N symbolname" +.PD 0 +.IP "\fB\-\-strip\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--strip-symbol=symbolname" +.PD +Do not copy symbol \fIsymbolname\fR from the source file. This option +may be given more than once. +.IP "\fB\-\-strip\-unneeded\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--strip-unneeded-symbol=symbolname" +Do not copy symbol \fIsymbolname\fR from the source file unless it is needed +by a relocation. This option may be given more than once. +.IP "\fB\-G\fR \fIsymbolname\fR" 4 +.IX Item "-G symbolname" +.PD 0 +.IP "\fB\-\-keep\-global\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--keep-global-symbol=symbolname" +.PD +Keep only symbol \fIsymbolname\fR global. Make all other symbols local +to the file, so that they are not visible externally. This option may +be given more than once. +.IP "\fB\-\-localize\-hidden\fR" 4 +.IX Item "--localize-hidden" +In an \s-1ELF\s0 object, mark all symbols that have hidden or internal visibility +as local. This option applies on top of symbol-specific localization options +such as \fB\-L\fR. +.IP "\fB\-L\fR \fIsymbolname\fR" 4 +.IX Item "-L symbolname" +.PD 0 +.IP "\fB\-\-localize\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--localize-symbol=symbolname" +.PD +Make symbol \fIsymbolname\fR local to the file, so that it is not +visible externally. This option may be given more than once. +.IP "\fB\-W\fR \fIsymbolname\fR" 4 +.IX Item "-W symbolname" +.PD 0 +.IP "\fB\-\-weaken\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--weaken-symbol=symbolname" +.PD +Make symbol \fIsymbolname\fR weak. This option may be given more than once. +.IP "\fB\-\-globalize\-symbol=\fR\fIsymbolname\fR" 4 +.IX Item "--globalize-symbol=symbolname" +Give symbol \fIsymbolname\fR global scoping so that it is visible +outside of the file in which it is defined. This option may be given +more than once. +.IP "\fB\-w\fR" 4 +.IX Item "-w" +.PD 0 +.IP "\fB\-\-wildcard\fR" 4 +.IX Item "--wildcard" +.PD +Permit regular expressions in \fIsymbolname\fRs used in other command +line options. The question mark (?), asterisk (*), backslash (\e) and +square brackets ([]) operators can be used anywhere in the symbol +name. If the first character of the symbol name is the exclamation +point (!) then the sense of the switch is reversed for that symbol. +For example: +.Sp +.Vb 1 +\& \-w \-W !foo \-W fo* +.Ve +.Sp +would cause objcopy to weaken all symbols that start with \*(L"fo\*(R" +except for the symbol \*(L"foo\*(R". +.IP "\fB\-x\fR" 4 +.IX Item "-x" +.PD 0 +.IP "\fB\-\-discard\-all\fR" 4 +.IX Item "--discard-all" +.PD +Do not copy non-global symbols from the source file. +.IP "\fB\-X\fR" 4 +.IX Item "-X" +.PD 0 +.IP "\fB\-\-discard\-locals\fR" 4 +.IX Item "--discard-locals" +.PD +Do not copy compiler-generated local symbols. +(These usually start with \fBL\fR or \fB.\fR.) +.IP "\fB\-b\fR \fIbyte\fR" 4 +.IX Item "-b byte" +.PD 0 +.IP "\fB\-\-byte=\fR\fIbyte\fR" 4 +.IX Item "--byte=byte" +.PD +Keep only every \fIbyte\fRth byte of the input file (header data is not +affected). \fIbyte\fR can be in the range from 0 to \fIinterleave\fR\-1, +where \fIinterleave\fR is given by the \fB\-i\fR or \fB\-\-interleave\fR +option, or the default of 4. This option is useful for creating files +to program \s-1ROM\s0. It is typically used with an \f(CW\*(C`srec\*(C'\fR output +target. +.IP "\fB\-i\fR \fIinterleave\fR" 4 +.IX Item "-i interleave" +.PD 0 +.IP "\fB\-\-interleave=\fR\fIinterleave\fR" 4 +.IX Item "--interleave=interleave" +.PD +Only copy one out of every \fIinterleave\fR bytes. Select which byte to +copy with the \fB\-b\fR or \fB\-\-byte\fR option. The default is 4. +\&\fBobjcopy\fR ignores this option if you do not specify either \fB\-b\fR or +\&\fB\-\-byte\fR. +.IP "\fB\-p\fR" 4 +.IX Item "-p" +.PD 0 +.IP "\fB\-\-preserve\-dates\fR" 4 +.IX Item "--preserve-dates" +.PD +Set the access and modification dates of the output file to be the same +as those of the input file. +.IP "\fB\-\-debugging\fR" 4 +.IX Item "--debugging" +Convert debugging information, if possible. This is not the default +because only certain debugging formats are supported, and the +conversion process can be time consuming. +.IP "\fB\-\-gap\-fill\fR \fIval\fR" 4 +.IX Item "--gap-fill val" +Fill gaps between sections with \fIval\fR. This operation applies to +the \fIload address\fR (\s-1LMA\s0) of the sections. It is done by increasing +the size of the section with the lower address, and filling in the extra +space created with \fIval\fR. +.IP "\fB\-\-pad\-to\fR \fIaddress\fR" 4 +.IX Item "--pad-to address" +Pad the output file up to the load address \fIaddress\fR. This is +done by increasing the size of the last section. The extra space is +filled in with the value specified by \fB\-\-gap\-fill\fR (default zero). +.IP "\fB\-\-set\-start\fR \fIval\fR" 4 +.IX Item "--set-start val" +Set the start address of the new file to \fIval\fR. Not all object file +formats support setting the start address. +.IP "\fB\-\-change\-start\fR \fIincr\fR" 4 +.IX Item "--change-start incr" +.PD 0 +.IP "\fB\-\-adjust\-start\fR \fIincr\fR" 4 +.IX Item "--adjust-start incr" +.PD +Change the start address by adding \fIincr\fR. Not all object file +formats support setting the start address. +.IP "\fB\-\-change\-addresses\fR \fIincr\fR" 4 +.IX Item "--change-addresses incr" +.PD 0 +.IP "\fB\-\-adjust\-vma\fR \fIincr\fR" 4 +.IX Item "--adjust-vma incr" +.PD +Change the \s-1VMA\s0 and \s-1LMA\s0 addresses of all sections, as well as the start +address, by adding \fIincr\fR. Some object file formats do not permit +section addresses to be changed arbitrarily. Note that this does not +relocate the sections; if the program expects sections to be loaded at a +certain address, and this option is used to change the sections such +that they are loaded at a different address, the program may fail. +.IP "\fB\-\-change\-section\-address\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4 +.IX Item "--change-section-address section{=,+,-}val" +.PD 0 +.IP "\fB\-\-adjust\-section\-vma\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4 +.IX Item "--adjust-section-vma section{=,+,-}val" +.PD +Set or change both the \s-1VMA\s0 address and the \s-1LMA\s0 address of the named +\&\fIsection\fR. If \fB=\fR is used, the section address is set to +\&\fIval\fR. Otherwise, \fIval\fR is added to or subtracted from the +section address. See the comments under \fB\-\-change\-addresses\fR, +above. If \fIsection\fR does not exist in the input file, a warning will +be issued, unless \fB\-\-no\-change\-warnings\fR is used. +.IP "\fB\-\-change\-section\-lma\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4 +.IX Item "--change-section-lma section{=,+,-}val" +Set or change the \s-1LMA\s0 address of the named \fIsection\fR. The \s-1LMA\s0 +address is the address where the section will be loaded into memory at +program load time. Normally this is the same as the \s-1VMA\s0 address, which +is the address of the section at program run time, but on some systems, +especially those where a program is held in \s-1ROM\s0, the two can be +different. If \fB=\fR is used, the section address is set to +\&\fIval\fR. Otherwise, \fIval\fR is added to or subtracted from the +section address. See the comments under \fB\-\-change\-addresses\fR, +above. If \fIsection\fR does not exist in the input file, a warning +will be issued, unless \fB\-\-no\-change\-warnings\fR is used. +.IP "\fB\-\-change\-section\-vma\fR \fIsection\fR\fB{=,+,\-}\fR\fIval\fR" 4 +.IX Item "--change-section-vma section{=,+,-}val" +Set or change the \s-1VMA\s0 address of the named \fIsection\fR. The \s-1VMA\s0 +address is the address where the section will be located once the +program has started executing. Normally this is the same as the \s-1LMA\s0 +address, which is the address where the section will be loaded into +memory, but on some systems, especially those where a program is held in +\&\s-1ROM\s0, the two can be different. If \fB=\fR is used, the section address +is set to \fIval\fR. Otherwise, \fIval\fR is added to or subtracted +from the section address. See the comments under +\&\fB\-\-change\-addresses\fR, above. If \fIsection\fR does not exist in +the input file, a warning will be issued, unless +\&\fB\-\-no\-change\-warnings\fR is used. +.IP "\fB\-\-change\-warnings\fR" 4 +.IX Item "--change-warnings" +.PD 0 +.IP "\fB\-\-adjust\-warnings\fR" 4 +.IX Item "--adjust-warnings" +.PD +If \fB\-\-change\-section\-address\fR or \fB\-\-change\-section\-lma\fR or +\&\fB\-\-change\-section\-vma\fR is used, and the named section does not +exist, issue a warning. This is the default. +.IP "\fB\-\-no\-change\-warnings\fR" 4 +.IX Item "--no-change-warnings" +.PD 0 +.IP "\fB\-\-no\-adjust\-warnings\fR" 4 +.IX Item "--no-adjust-warnings" +.PD +Do not issue a warning if \fB\-\-change\-section\-address\fR or +\&\fB\-\-adjust\-section\-lma\fR or \fB\-\-adjust\-section\-vma\fR is used, even +if the named section does not exist. +.IP "\fB\-\-set\-section\-flags\fR \fIsection\fR\fB=\fR\fIflags\fR" 4 +.IX Item "--set-section-flags section=flags" +Set the flags for the named section. The \fIflags\fR argument is a +comma separated string of flag names. The recognized names are +\&\fBalloc\fR, \fBcontents\fR, \fBload\fR, \fBnoload\fR, +\&\fBreadonly\fR, \fBcode\fR, \fBdata\fR, \fBrom\fR, \fBshare\fR, and +\&\fBdebug\fR. You can set the \fBcontents\fR flag for a section which +does not have contents, but it is not meaningful to clear the +\&\fBcontents\fR flag of a section which does have contents\*(--just remove +the section instead. Not all flags are meaningful for all object file +formats. +.IP "\fB\-\-add\-section\fR \fIsectionname\fR\fB=\fR\fIfilename\fR" 4 +.IX Item "--add-section sectionname=filename" +Add a new section named \fIsectionname\fR while copying the file. The +contents of the new section are taken from the file \fIfilename\fR. The +size of the section will be the size of the file. This option only +works on file formats which can support sections with arbitrary names. +.IP "\fB\-\-rename\-section\fR \fIoldname\fR\fB=\fR\fInewname\fR\fB[,\fR\fIflags\fR\fB]\fR" 4 +.IX Item "--rename-section oldname=newname[,flags]" +Rename a section from \fIoldname\fR to \fInewname\fR, optionally +changing the section's flags to \fIflags\fR in the process. This has +the advantage over usng a linker script to perform the rename in that +the output stays as an object file and does not become a linked +executable. +.Sp +This option is particularly helpful when the input format is binary, +since this will always create a section called .data. If for example, +you wanted instead to create a section called .rodata containing binary +data you could use the following command line to achieve it: +.Sp +.Vb 3 +\& objcopy \-I binary \-O <output_format> \-B <architecture> \e +\& \-\-rename\-section .data=.rodata,alloc,load,readonly,data,contents \e +\& <input_binary_file> <output_object_file> +.Ve +.IP "\fB\-\-change\-leading\-char\fR" 4 +.IX Item "--change-leading-char" +Some object file formats use special characters at the start of +symbols. The most common such character is underscore, which compilers +often add before every symbol. This option tells \fBobjcopy\fR to +change the leading character of every symbol when it converts between +object file formats. If the object file formats use the same leading +character, this option has no effect. Otherwise, it will add a +character, or remove a character, or change a character, as +appropriate. +.IP "\fB\-\-remove\-leading\-char\fR" 4 +.IX Item "--remove-leading-char" +If the first character of a global symbol is a special symbol leading +character used by the object file format, remove the character. The +most common symbol leading character is underscore. This option will +remove a leading underscore from all global symbols. This can be useful +if you want to link together objects of different file formats with +different conventions for symbol names. This is different from +\&\fB\-\-change\-leading\-char\fR because it always changes the symbol name +when appropriate, regardless of the object file format of the output +file. +.IP "\fB\-\-reverse\-bytes=\fR\fInum\fR" 4 +.IX Item "--reverse-bytes=num" +Reverse the bytes in a section with output contents. A section length must +be evenly divisible by the value given in order for the swap to be able to +take place. Reversing takes place before the interleaving is performed. +.Sp +This option is used typically in generating \s-1ROM\s0 images for problematic +target systems. For example, on some target boards, the 32\-bit words +fetched from 8\-bit ROMs are re-assembled in little-endian byte order +regardless of the \s-1CPU\s0 byte order. Depending on the programming model, the +endianness of the \s-1ROM\s0 may need to be modified. +.Sp +Consider a simple file with a section containing the following eight +bytes: \f(CW12345678\fR. +.Sp +Using \fB\-\-reverse\-bytes=2\fR for the above example, the bytes in the +output file would be ordered \f(CW21436587\fR. +.Sp +Using \fB\-\-reverse\-bytes=4\fR for the above example, the bytes in the +output file would be ordered \f(CW43218765\fR. +.Sp +By using \fB\-\-reverse\-bytes=2\fR for the above example, followed by +\&\fB\-\-reverse\-bytes=4\fR on the output file, the bytes in the second +output file would be ordered \f(CW34127856\fR. +.IP "\fB\-\-srec\-len=\fR\fIival\fR" 4 +.IX Item "--srec-len=ival" +Meaningful only for srec output. Set the maximum length of the Srecords +being produced to \fIival\fR. This length covers both address, data and +crc fields. +.IP "\fB\-\-srec\-forceS3\fR" 4 +.IX Item "--srec-forceS3" +Meaningful only for srec output. Avoid generation of S1/S2 records, +creating S3\-only record format. +.IP "\fB\-\-redefine\-sym\fR \fIold\fR\fB=\fR\fInew\fR" 4 +.IX Item "--redefine-sym old=new" +Change the name of a symbol \fIold\fR, to \fInew\fR. This can be useful +when one is trying link two things together for which you have no +source, and there are name collisions. +.IP "\fB\-\-redefine\-syms=\fR\fIfilename\fR" 4 +.IX Item "--redefine-syms=filename" +Apply \fB\-\-redefine\-sym\fR to each symbol pair "\fIold\fR \fInew\fR" +listed in the file \fIfilename\fR. \fIfilename\fR is simply a flat file, +with one symbol pair per line. Line comments may be introduced by the hash +character. This option may be given more than once. +.IP "\fB\-\-weaken\fR" 4 +.IX Item "--weaken" +Change all global symbols in the file to be weak. This can be useful +when building an object which will be linked against other objects using +the \fB\-R\fR option to the linker. This option is only effective when +using an object file format which supports weak symbols. +.IP "\fB\-\-keep\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--keep-symbols=filename" +Apply \fB\-\-keep\-symbol\fR option to each symbol listed in the file +\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. +.IP "\fB\-\-strip\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--strip-symbols=filename" +Apply \fB\-\-strip\-symbol\fR option to each symbol listed in the file +\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. +.IP "\fB\-\-strip\-unneeded\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--strip-unneeded-symbols=filename" +Apply \fB\-\-strip\-unneeded\-symbol\fR option to each symbol listed in +the file \fIfilename\fR. \fIfilename\fR is simply a flat file, with one +symbol name per line. Line comments may be introduced by the hash +character. This option may be given more than once. +.IP "\fB\-\-keep\-global\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--keep-global-symbols=filename" +Apply \fB\-\-keep\-global\-symbol\fR option to each symbol listed in the +file \fIfilename\fR. \fIfilename\fR is simply a flat file, with one +symbol name per line. Line comments may be introduced by the hash +character. This option may be given more than once. +.IP "\fB\-\-localize\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--localize-symbols=filename" +Apply \fB\-\-localize\-symbol\fR option to each symbol listed in the file +\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. +.IP "\fB\-\-globalize\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--globalize-symbols=filename" +Apply \fB\-\-globalize\-symbol\fR option to each symbol listed in the file +\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. +.IP "\fB\-\-weaken\-symbols=\fR\fIfilename\fR" 4 +.IX Item "--weaken-symbols=filename" +Apply \fB\-\-weaken\-symbol\fR option to each symbol listed in the file +\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol +name per line. Line comments may be introduced by the hash character. +This option may be given more than once. +.IP "\fB\-\-alt\-machine\-code=\fR\fIindex\fR" 4 +.IX Item "--alt-machine-code=index" +If the output architecture has alternate machine codes, use the +\&\fIindex\fRth code instead of the default one. This is useful in case +a machine is assigned an official code and the tool-chain adopts the +new code, but other applications still depend on the original code +being used. For \s-1ELF\s0 based architectures if the \fIindex\fR +alternative does not exist then the value is treated as an absolute +number to be stored in the e_machine field of the \s-1ELF\s0 header. +.IP "\fB\-\-writable\-text\fR" 4 +.IX Item "--writable-text" +Mark the output text as writable. This option isn't meaningful for all +object file formats. +.IP "\fB\-\-readonly\-text\fR" 4 +.IX Item "--readonly-text" +Make the output text write protected. This option isn't meaningful for all +object file formats. +.IP "\fB\-\-pure\fR" 4 +.IX Item "--pure" +Mark the output file as demand paged. This option isn't meaningful for all +object file formats. +.IP "\fB\-\-impure\fR" 4 +.IX Item "--impure" +Mark the output file as impure. This option isn't meaningful for all +object file formats. +.IP "\fB\-\-prefix\-symbols=\fR\fIstring\fR" 4 +.IX Item "--prefix-symbols=string" +Prefix all symbols in the output file with \fIstring\fR. +.IP "\fB\-\-prefix\-sections=\fR\fIstring\fR" 4 +.IX Item "--prefix-sections=string" +Prefix all section names in the output file with \fIstring\fR. +.IP "\fB\-\-prefix\-alloc\-sections=\fR\fIstring\fR" 4 +.IX Item "--prefix-alloc-sections=string" +Prefix all the names of all allocated sections in the output file with +\&\fIstring\fR. +.IP "\fB\-\-add\-gnu\-debuglink=\fR\fIpath-to-file\fR" 4 +.IX Item "--add-gnu-debuglink=path-to-file" +Creates a .gnu_debuglink section which contains a reference to \fIpath-to-file\fR +and adds it to the output file. +.IP "\fB\-\-keep\-file\-symbols\fR" 4 +.IX Item "--keep-file-symbols" +When stripping a file, perhaps with \fB\-\-strip\-debug\fR or +\&\fB\-\-strip\-unneeded\fR, retain any symbols specifying source file names, +which would otherwise get stripped. +.IP "\fB\-\-only\-keep\-debug\fR" 4 +.IX Item "--only-keep-debug" +Strip a file, removing contents of any sections that would not be +stripped by \fB\-\-strip\-debug\fR and leaving the debugging sections +intact. In \s-1ELF\s0 files, this preserves all note sections in the output. +.Sp +The intention is that this option will be used in conjunction with +\&\fB\-\-add\-gnu\-debuglink\fR to create a two part executable. One a +stripped binary which will occupy less space in \s-1RAM\s0 and in a +distribution and the second a debugging information file which is only +needed if debugging abilities are required. The suggested procedure +to create these files is as follows: +.RS 4 +.IP "1.<Link the executable as normal. Assuming that it is called>" 4 +.IX Item "1.<Link the executable as normal. Assuming that it is called>" +\&\f(CW\*(C`foo\*(C'\fR then... +.ie n .IP "1.<Run ""objcopy \-\-only\-keep\-debug foo foo.dbg"" to>" 4 +.el .IP "1.<Run \f(CWobjcopy \-\-only\-keep\-debug foo foo.dbg\fR to>" 4 +.IX Item "1.<Run objcopy --only-keep-debug foo foo.dbg to>" +create a file containing the debugging info. +.ie n .IP "1.<Run ""objcopy \-\-strip\-debug foo"" to create a>" 4 +.el .IP "1.<Run \f(CWobjcopy \-\-strip\-debug foo\fR to create a>" 4 +.IX Item "1.<Run objcopy --strip-debug foo to create a>" +stripped executable. +.ie n .IP "1.<Run ""objcopy \-\-add\-gnu\-debuglink=foo.dbg foo"">" 4 +.el .IP "1.<Run \f(CWobjcopy \-\-add\-gnu\-debuglink=foo.dbg foo\fR>" 4 +.IX Item "1.<Run objcopy --add-gnu-debuglink=foo.dbg foo>" +to add a link to the debugging info into the stripped executable. +.RE +.RS 4 +.Sp +Note \- the choice of \f(CW\*(C`.dbg\*(C'\fR as an extension for the debug info +file is arbitrary. Also the \f(CW\*(C`\-\-only\-keep\-debug\*(C'\fR step is +optional. You could instead do this: +.IP "1.<Link the executable as normal.>" 4 +.IX Item "1.<Link the executable as normal.>" +.PD 0 +.ie n .IP "1.<Copy ""foo"" to ""foo.full"">" 4 +.el .IP "1.<Copy \f(CWfoo\fR to \f(CWfoo.full\fR>" 4 +.IX Item "1.<Copy foo to foo.full>" +.ie n .IP "1.<Run ""objcopy \-\-strip\-debug foo"">" 4 +.el .IP "1.<Run \f(CWobjcopy \-\-strip\-debug foo\fR>" 4 +.IX Item "1.<Run objcopy --strip-debug foo>" +.ie n .IP "1.<Run ""objcopy \-\-add\-gnu\-debuglink=foo.full foo"">" 4 +.el .IP "1.<Run \f(CWobjcopy \-\-add\-gnu\-debuglink=foo.full foo\fR>" 4 +.IX Item "1.<Run objcopy --add-gnu-debuglink=foo.full foo>" +.RE +.RS 4 +.PD +.Sp +i.e., the file pointed to by the \fB\-\-add\-gnu\-debuglink\fR can be the +full executable. It does not have to be a file created by the +\&\fB\-\-only\-keep\-debug\fR switch. +.Sp +Note \- this switch is only intended for use on fully linked files. It +does not make sense to use it on object files where the debugging +information may be incomplete. Besides the gnu_debuglink feature +currently only supports the presence of one filename containing +debugging information, not multiple filenames on a one-per-object-file +basis. +.RE +.IP "\fB\-\-extract\-symbol\fR" 4 +.IX Item "--extract-symbol" +Keep the file's section flags and symbols but remove all section data. +Specifically, the option: +.RS 4 +.IP "*<sets the virtual and load addresses of every section to zero;>" 4 +.IX Item "*<sets the virtual and load addresses of every section to zero;>" +.PD 0 +.IP "*<removes the contents of all sections;>" 4 +.IX Item "*<removes the contents of all sections;>" +.IP "*<sets the size of every section to zero; and>" 4 +.IX Item "*<sets the size of every section to zero; and>" +.IP "*<sets the file's start address to zero.>" 4 +.IX Item "*<sets the file's start address to zero.>" +.RE +.RS 4 +.PD +.Sp +This option is used to build a \fI.sym\fR file for a VxWorks kernel. +It can also be a useful way of reducing the size of a \fB\-\-just\-symbols\fR +linker input file. +.RE +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Show the version number of \fBobjcopy\fR. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +.PD 0 +.IP "\fB\-\-verbose\fR" 4 +.IX Item "--verbose" +.PD +Verbose output: list all object files modified. In the case of +archives, \fBobjcopy \-V\fR lists all members of the archive. +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +Show a summary of the options to \fBobjcopy\fR. +.IP "\fB\-\-info\fR" 4 +.IX Item "--info" +Display a list showing all architectures and object formats available. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIld\fR\|(1), \fIobjdump\fR\|(1), and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 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 included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/gnu/usr.bin/binutils/objdump/Makefile b/gnu/usr.bin/binutils/objdump/Makefile new file mode 100644 index 000000000000..c712af9bc42f --- /dev/null +++ b/gnu/usr.bin/binutils/objdump/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +.include "../Makefile.inc0" + +.PATH: ${SRCDIR}/binutils ${SRCDIR}/binutils/doc + +PROG= objdump +SRCS= objdump.c prdbg.c +CFLAGS+= -D_GNU_SOURCE +CFLAGS+= -I${.CURDIR}/${GNURELTOP}/libbinutils +CFLAGS+= -I${SRCDIR}/binutils +CFLAGS+= -DBFD_VERSION_STRING=\"${VERSION}\" +DPADD= ${GNURELTOP}/libbinutils/libbinutils.a +DPADD+= ${GNURELTOP}/libopcodes/libopcodes.a +DPADD+= ${GNURELTOP}/libbfd/libbfd.a +DPADD+= ${GNURELTOP}/libiberty/libiberty.a +LDADD= ${DPADD} + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/binutils/objdump/Makefile.depend b/gnu/usr.bin/binutils/objdump/Makefile.depend new file mode 100644 index 000000000000..38831ab06c3e --- /dev/null +++ b/gnu/usr.bin/binutils/objdump/Makefile.depend @@ -0,0 +1,21 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/usr.bin/binutils/libbfd \ + gnu/usr.bin/binutils/libbinutils \ + gnu/usr.bin/binutils/libiberty \ + gnu/usr.bin/binutils/libopcodes \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/binutils/objdump/objdump.1 b/gnu/usr.bin/binutils/objdump/objdump.1 new file mode 100644 index 000000000000..6190fac36660 --- /dev/null +++ b/gnu/usr.bin/binutils/objdump/objdump.1 @@ -0,0 +1,640 @@ +.\" $FreeBSD$ +.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.ie \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.el \{\ +. de IX +.. +.\} +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "OBJDUMP 1" +.TH OBJDUMP 1 "2010-10-30" "binutils-2.17.50" "GNU Development Tools" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +objdump \- display information from object files. +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +objdump [\fB\-a\fR|\fB\-\-archive\-headers\fR] + [\fB\-b\fR \fIbfdname\fR|\fB\-\-target=\fR\fIbfdname\fR] + [\fB\-C\fR|\fB\-\-demangle\fR[=\fIstyle\fR] ] + [\fB\-d\fR|\fB\-\-disassemble\fR] + [\fB\-D\fR|\fB\-\-disassemble\-all\fR] + [\fB\-z\fR|\fB\-\-disassemble\-zeroes\fR] + [\fB\-EB\fR|\fB\-EL\fR|\fB\-\-endian=\fR{big | little }] + [\fB\-f\fR|\fB\-\-file\-headers\fR] + [\fB\-\-file\-start\-context\fR] + [\fB\-g\fR|\fB\-\-debugging\fR] + [\fB\-e\fR|\fB\-\-debugging\-tags\fR] + [\fB\-h\fR|\fB\-\-section\-headers\fR|\fB\-\-headers\fR] + [\fB\-i\fR|\fB\-\-info\fR] + [\fB\-j\fR \fIsection\fR|\fB\-\-section=\fR\fIsection\fR] + [\fB\-l\fR|\fB\-\-line\-numbers\fR] + [\fB\-S\fR|\fB\-\-source\fR] + [\fB\-m\fR \fImachine\fR|\fB\-\-architecture=\fR\fImachine\fR] + [\fB\-M\fR \fIoptions\fR|\fB\-\-disassembler\-options=\fR\fIoptions\fR] + [\fB\-p\fR|\fB\-\-private\-headers\fR] + [\fB\-r\fR|\fB\-\-reloc\fR] + [\fB\-R\fR|\fB\-\-dynamic\-reloc\fR] + [\fB\-s\fR|\fB\-\-full\-contents\fR] + [\fB\-W\fR|\fB\-\-dwarf\fR] + [\fB\-G\fR|\fB\-\-stabs\fR] + [\fB\-t\fR|\fB\-\-syms\fR] + [\fB\-T\fR|\fB\-\-dynamic\-syms\fR] + [\fB\-x\fR|\fB\-\-all\-headers\fR] + [\fB\-w\fR|\fB\-\-wide\fR] + [\fB\-\-start\-address=\fR\fIaddress\fR] + [\fB\-\-stop\-address=\fR\fIaddress\fR] + [\fB\-\-prefix\-addresses\fR] + [\fB\-\-[no\-]show\-raw\-insn\fR] + [\fB\-\-adjust\-vma=\fR\fIoffset\fR] + [\fB\-\-special\-syms\fR] + [\fB\-V\fR|\fB\-\-version\fR] + [\fB\-H\fR|\fB\-\-help\fR] + \fIobjfile\fR... +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +\&\fBobjdump\fR displays information about one or more object files. +The options control what particular information to display. This +information is mostly useful to programmers who are working on the +compilation tools, as opposed to programmers who just want their +program to compile and work. +.PP +\&\fBobjdump\fR will be removed from a future version of the +FreeBSD base system. Users who require \&\fBobjdump\fR are advised +to install the binutils port or package. +.PP +\&\fIobjfile\fR... are the object files to be examined. When you +specify archives, \fBobjdump\fR shows information on each of the member +object files. +.SH "OPTIONS" +.IX Header "OPTIONS" +The long and short forms of options, shown here as alternatives, are +equivalent. At least one option from the list +\&\fB\-a,\-d,\-D,\-e,\-f,\-g,\-G,\-h,\-H,\-p,\-r,\-R,\-s,\-S,\-t,\-T,\-V,\-x\fR must be given. +.IP "\fB\-a\fR" 4 +.IX Item "-a" +.PD 0 +.IP "\fB\-\-archive\-header\fR" 4 +.IX Item "--archive-header" +.PD +If any of the \fIobjfile\fR files are archives, display the archive +header information (in a format similar to \fBls \-l\fR). Besides the +information you could list with \fBar tv\fR, \fBobjdump \-a\fR shows +the object file format of each archive member. +.IP "\fB\-\-adjust\-vma=\fR\fIoffset\fR" 4 +.IX Item "--adjust-vma=offset" +When dumping information, first add \fIoffset\fR to all the section +addresses. This is useful if the section addresses do not correspond to +the symbol table, which can happen when putting sections at particular +addresses when using a format which can not represent section addresses, +such as a.out. +.IP "\fB\-b\fR \fIbfdname\fR" 4 +.IX Item "-b bfdname" +.PD 0 +.IP "\fB\-\-target=\fR\fIbfdname\fR" 4 +.IX Item "--target=bfdname" +.PD +Specify that the object-code format for the object files is +\&\fIbfdname\fR. This option may not be necessary; \fIobjdump\fR can +automatically recognize many formats. +.Sp +For example, +.Sp +.Vb 1 +\& objdump \-b oasys \-m vax \-h fu.o +.Ve +.Sp +displays summary information from the section headers (\fB\-h\fR) of +\&\fIfu.o\fR, which is explicitly identified (\fB\-m\fR) as a \s-1VAX\s0 object +file in the format produced by Oasys compilers. You can list the +formats available with the \fB\-i\fR option. +.IP "\fB\-C\fR" 4 +.IX Item "-C" +.PD 0 +.IP "\fB\-\-demangle[=\fR\fIstyle\fR\fB]\fR" 4 +.IX Item "--demangle[=style]" +.PD +Decode (\fIdemangle\fR) low-level symbol names into user-level names. +Besides removing any initial underscore prepended by the system, this +makes \*(C+ function names readable. Different compilers have different +mangling styles. The optional demangling style argument can be used to +choose an appropriate demangling style for your compiler. +.IP "\fB\-g\fR" 4 +.IX Item "-g" +.PD 0 +.IP "\fB\-\-debugging\fR" 4 +.IX Item "--debugging" +.PD +Display debugging information. This attempts to parse debugging +information stored in the file and print it out using a C like syntax. +Only certain types of debugging information have been implemented. +Some other types are supported by \fBreadelf \-w\fR. +.IP "\fB\-e\fR" 4 +.IX Item "-e" +.PD 0 +.IP "\fB\-\-debugging\-tags\fR" 4 +.IX Item "--debugging-tags" +.PD +Like \fB\-g\fR, but the information is generated in a format compatible +with ctags tool. +.IP "\fB\-d\fR" 4 +.IX Item "-d" +.PD 0 +.IP "\fB\-\-disassemble\fR" 4 +.IX Item "--disassemble" +.PD +Display the assembler mnemonics for the machine instructions from +\&\fIobjfile\fR. This option only disassembles those sections which are +expected to contain instructions. +.IP "\fB\-D\fR" 4 +.IX Item "-D" +.PD 0 +.IP "\fB\-\-disassemble\-all\fR" 4 +.IX Item "--disassemble-all" +.PD +Like \fB\-d\fR, but disassemble the contents of all sections, not just +those expected to contain instructions. +.IP "\fB\-\-prefix\-addresses\fR" 4 +.IX Item "--prefix-addresses" +When disassembling, print the complete address on each line. This is +the older disassembly format. +.IP "\fB\-EB\fR" 4 +.IX Item "-EB" +.PD 0 +.IP "\fB\-EL\fR" 4 +.IX Item "-EL" +.IP "\fB\-\-endian={big|little}\fR" 4 +.IX Item "--endian={big|little}" +.PD +Specify the endianness of the object files. This only affects +disassembly. This can be useful when disassembling a file format which +does not describe endianness information, such as S\-records. +.IP "\fB\-f\fR" 4 +.IX Item "-f" +.PD 0 +.IP "\fB\-\-file\-headers\fR" 4 +.IX Item "--file-headers" +.PD +Display summary information from the overall header of +each of the \fIobjfile\fR files. +.IP "\fB\-\-file\-start\-context\fR" 4 +.IX Item "--file-start-context" +Specify that when displaying interlisted source code/disassembly +(assumes \fB\-S\fR) from a file that has not yet been displayed, extend the +context to the start of the file. +.IP "\fB\-h\fR" 4 +.IX Item "-h" +.PD 0 +.IP "\fB\-\-section\-headers\fR" 4 +.IX Item "--section-headers" +.IP "\fB\-\-headers\fR" 4 +.IX Item "--headers" +.PD +Display summary information from the section headers of the +object file. +.Sp +File segments may be relocated to nonstandard addresses, for example by +using the \fB\-Ttext\fR, \fB\-Tdata\fR, or \fB\-Tbss\fR options to +\&\fBld\fR. However, some object file formats, such as a.out, do not +store the starting address of the file segments. In those situations, +although \fBld\fR relocates the sections correctly, using \fBobjdump +\&\-h\fR to list the file section headers cannot show the correct addresses. +Instead, it shows the usual addresses, which are implicit for the +target. +.IP "\fB\-H\fR" 4 +.IX Item "-H" +.PD 0 +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD +Print a summary of the options to \fBobjdump\fR and exit. +.IP "\fB\-i\fR" 4 +.IX Item "-i" +.PD 0 +.IP "\fB\-\-info\fR" 4 +.IX Item "--info" +.PD +Display a list showing all architectures and object formats available +for specification with \fB\-b\fR or \fB\-m\fR. +.IP "\fB\-j\fR \fIname\fR" 4 +.IX Item "-j name" +.PD 0 +.IP "\fB\-\-section=\fR\fIname\fR" 4 +.IX Item "--section=name" +.PD +Display information only for section \fIname\fR. +.IP "\fB\-l\fR" 4 +.IX Item "-l" +.PD 0 +.IP "\fB\-\-line\-numbers\fR" 4 +.IX Item "--line-numbers" +.PD +Label the display (using debugging information) with the filename and +source line numbers corresponding to the object code or relocs shown. +Only useful with \fB\-d\fR, \fB\-D\fR, or \fB\-r\fR. +.IP "\fB\-m\fR \fImachine\fR" 4 +.IX Item "-m machine" +.PD 0 +.IP "\fB\-\-architecture=\fR\fImachine\fR" 4 +.IX Item "--architecture=machine" +.PD +Specify the architecture to use when disassembling object files. This +can be useful when disassembling object files which do not describe +architecture information, such as S\-records. You can list the available +architectures with the \fB\-i\fR option. +.IP "\fB\-M\fR \fIoptions\fR" 4 +.IX Item "-M options" +.PD 0 +.IP "\fB\-\-disassembler\-options=\fR\fIoptions\fR" 4 +.IX Item "--disassembler-options=options" +.PD +Pass target specific information to the disassembler. Only supported on +some targets. If it is necessary to specify more than one +disassembler option then multiple \fB\-M\fR options can be used or +can be placed together into a comma separated list. +.Sp +If the target is an \s-1ARM\s0 architecture then this switch can be used to +select which register name set is used during disassembler. Specifying +\&\fB\-M reg-names-std\fR (the default) will select the register names as +used in \s-1ARM\s0's instruction set documentation, but with register 13 called +\&'sp', register 14 called 'lr' and register 15 called 'pc'. Specifying +\&\fB\-M reg-names-apcs\fR will select the name set used by the \s-1ARM\s0 +Procedure Call Standard, whilst specifying \fB\-M reg-names-raw\fR will +just use \fBr\fR followed by the register number. +.Sp +There are also two variants on the \s-1APCS\s0 register naming scheme enabled +by \fB\-M reg-names-atpcs\fR and \fB\-M reg-names-special-atpcs\fR which +use the ARM/Thumb Procedure Call Standard naming conventions. (Either +with the normal register names or the special register names). +.Sp +This option can also be used for \s-1ARM\s0 architectures to force the +disassembler to interpret all instructions as Thumb instructions by +using the switch \fB\-\-disassembler\-options=force\-thumb\fR. This can be +useful when attempting to disassemble thumb code produced by other +compilers. +.Sp +For the x86, some of the options duplicate functions of the \fB\-m\fR +switch, but allow finer grained control. Multiple selections from the +following may be specified as a comma separated string. +\&\fBx86\-64\fR, \fBi386\fR and \fBi8086\fR select disassembly for +the given architecture. \fBintel\fR and \fBatt\fR select between +intel syntax mode and \s-1AT&T\s0 syntax mode. \fBaddr64\fR, \fBaddr32\fR, +\&\fBaddr16\fR, \fBdata32\fR and \fBdata16\fR specify the default +address size and operand size. These four options will be overridden if +\&\fBx86\-64\fR, \fBi386\fR or \fBi8086\fR appear later in the +option string. Lastly, \fBsuffix\fR, when in \s-1AT&T\s0 mode, +instructs the disassembler to print a mnemonic suffix even when the +suffix could be inferred by the operands. +.Sp +For \s-1PPC\s0, \fBbooke\fR, \fBbooke32\fR and \fBbooke64\fR select +disassembly of BookE instructions. \fB32\fR and \fB64\fR select +PowerPC and PowerPC64 disassembly, respectively. \fBe300\fR selects +disassembly for the e300 family. \fB440\fR selects disassembly for +the PowerPC 440. +.Sp +For \s-1MIPS\s0, this option controls the printing of instruction mnemonic +names and register names in disassembled instructions. Multiple +selections from the following may be specified as a comma separated +string, and invalid options are ignored: +.RS 4 +.ie n .IP """no\-aliases""" 4 +.el .IP "\f(CWno\-aliases\fR" 4 +.IX Item "no-aliases" +Print the 'raw' instruction mnemonic instead of some pseudo +instruction mnemonic. I.e., print 'daddu' or 'or' instead of 'move', +\&'sll' instead of 'nop', etc. +.ie n .IP """gpr\-names=\f(CIABI\f(CW""" 4 +.el .IP "\f(CWgpr\-names=\f(CIABI\f(CW\fR" 4 +.IX Item "gpr-names=ABI" +Print \s-1GPR\s0 (general-purpose register) names as appropriate +for the specified \s-1ABI\s0. By default, \s-1GPR\s0 names are selected according to +the \s-1ABI\s0 of the binary being disassembled. +.ie n .IP """fpr\-names=\f(CIABI\f(CW""" 4 +.el .IP "\f(CWfpr\-names=\f(CIABI\f(CW\fR" 4 +.IX Item "fpr-names=ABI" +Print \s-1FPR\s0 (floating-point register) names as +appropriate for the specified \s-1ABI\s0. By default, \s-1FPR\s0 numbers are printed +rather than names. +.ie n .IP """cp0\-names=\f(CIARCH\f(CW""" 4 +.el .IP "\f(CWcp0\-names=\f(CIARCH\f(CW\fR" 4 +.IX Item "cp0-names=ARCH" +Print \s-1CP0\s0 (system control coprocessor; coprocessor 0) register names +as appropriate for the \s-1CPU\s0 or architecture specified by +\&\fI\s-1ARCH\s0\fR. By default, \s-1CP0\s0 register names are selected according to +the architecture and \s-1CPU\s0 of the binary being disassembled. +.ie n .IP """hwr\-names=\f(CIARCH\f(CW""" 4 +.el .IP "\f(CWhwr\-names=\f(CIARCH\f(CW\fR" 4 +.IX Item "hwr-names=ARCH" +Print \s-1HWR\s0 (hardware register, used by the \f(CW\*(C`rdhwr\*(C'\fR instruction) names +as appropriate for the \s-1CPU\s0 or architecture specified by +\&\fI\s-1ARCH\s0\fR. By default, \s-1HWR\s0 names are selected according to +the architecture and \s-1CPU\s0 of the binary being disassembled. +.ie n .IP """reg\-names=\f(CIABI\f(CW""" 4 +.el .IP "\f(CWreg\-names=\f(CIABI\f(CW\fR" 4 +.IX Item "reg-names=ABI" +Print \s-1GPR\s0 and \s-1FPR\s0 names as appropriate for the selected \s-1ABI\s0. +.ie n .IP """reg\-names=\f(CIARCH\f(CW""" 4 +.el .IP "\f(CWreg\-names=\f(CIARCH\f(CW\fR" 4 +.IX Item "reg-names=ARCH" +Print CPU-specific register names (\s-1CP0\s0 register and \s-1HWR\s0 names) +as appropriate for the selected \s-1CPU\s0 or architecture. +.RE +.RS 4 +.Sp +For any of the options listed above, \fI\s-1ABI\s0\fR or +\&\fI\s-1ARCH\s0\fR may be specified as \fBnumeric\fR to have numbers printed +rather than names, for the selected types of registers. +You can list the available values of \fI\s-1ABI\s0\fR and \fI\s-1ARCH\s0\fR using +the \fB\-\-help\fR option. +.Sp +For \s-1VAX\s0, you can specify function entry addresses with \fB\-M +entry:0xf00ba\fR. You can use this multiple times to properly +disassemble \s-1VAX\s0 binary files that don't contain symbol tables (like +\&\s-1ROM\s0 dumps). In these cases, the function entry mask would otherwise +be decoded as \s-1VAX\s0 instructions, which would probably lead the rest +of the function being wrongly disassembled. +.RE +.IP "\fB\-p\fR" 4 +.IX Item "-p" +.PD 0 +.IP "\fB\-\-private\-headers\fR" 4 +.IX Item "--private-headers" +.PD +Print information that is specific to the object file format. The exact +information printed depends upon the object file format. For some +object file formats, no additional information is printed. +.IP "\fB\-r\fR" 4 +.IX Item "-r" +.PD 0 +.IP "\fB\-\-reloc\fR" 4 +.IX Item "--reloc" +.PD +Print the relocation entries of the file. If used with \fB\-d\fR or +\&\fB\-D\fR, the relocations are printed interspersed with the +disassembly. +.IP "\fB\-R\fR" 4 +.IX Item "-R" +.PD 0 +.IP "\fB\-\-dynamic\-reloc\fR" 4 +.IX Item "--dynamic-reloc" +.PD +Print the dynamic relocation entries of the file. This is only +meaningful for dynamic objects, such as certain types of shared +libraries. +.IP "\fB\-s\fR" 4 +.IX Item "-s" +.PD 0 +.IP "\fB\-\-full\-contents\fR" 4 +.IX Item "--full-contents" +.PD +Display the full contents of any sections requested. By default all +non-empty sections are displayed. +.IP "\fB\-S\fR" 4 +.IX Item "-S" +.PD 0 +.IP "\fB\-\-source\fR" 4 +.IX Item "--source" +.PD +Display source code intermixed with disassembly, if possible. Implies +\&\fB\-d\fR. +.IP "\fB\-\-show\-raw\-insn\fR" 4 +.IX Item "--show-raw-insn" +When disassembling instructions, print the instruction in hex as well as +in symbolic form. This is the default except when +\&\fB\-\-prefix\-addresses\fR is used. +.IP "\fB\-\-no\-show\-raw\-insn\fR" 4 +.IX Item "--no-show-raw-insn" +When disassembling instructions, do not print the instruction bytes. +This is the default when \fB\-\-prefix\-addresses\fR is used. +.IP "\fB\-W\fR" 4 +.IX Item "-W" +.PD 0 +.IP "\fB\-\-dwarf\fR" 4 +.IX Item "--dwarf" +.PD +Displays the contents of the \s-1DWARF\s0 debug sections in the file, if any +are present. +.IP "\fB\-G\fR" 4 +.IX Item "-G" +.PD 0 +.IP "\fB\-\-stabs\fR" 4 +.IX Item "--stabs" +.PD +Display the full contents of any sections requested. Display the +contents of the .stab and .stab.index and .stab.excl sections from an +\&\s-1ELF\s0 file. This is only useful on systems (such as Solaris 2.0) in which +\&\f(CW\*(C`.stab\*(C'\fR debugging symbol-table entries are carried in an \s-1ELF\s0 +section. In most other file formats, debugging symbol-table entries are +interleaved with linkage symbols, and are visible in the \fB\-\-syms\fR +output. +.IP "\fB\-\-start\-address=\fR\fIaddress\fR" 4 +.IX Item "--start-address=address" +Start displaying data at the specified address. This affects the output +of the \fB\-d\fR, \fB\-r\fR and \fB\-s\fR options. +.IP "\fB\-\-stop\-address=\fR\fIaddress\fR" 4 +.IX Item "--stop-address=address" +Stop displaying data at the specified address. This affects the output +of the \fB\-d\fR, \fB\-r\fR and \fB\-s\fR options. +.IP "\fB\-t\fR" 4 +.IX Item "-t" +.PD 0 +.IP "\fB\-\-syms\fR" 4 +.IX Item "--syms" +.PD +Print the symbol table entries of the file. +This is similar to the information provided by the \fBnm\fR program. +.IP "\fB\-T\fR" 4 +.IX Item "-T" +.PD 0 +.IP "\fB\-\-dynamic\-syms\fR" 4 +.IX Item "--dynamic-syms" +.PD +Print the dynamic symbol table entries of the file. This is only +meaningful for dynamic objects, such as certain types of shared +libraries. This is similar to the information provided by the \fBnm\fR +program when given the \fB\-D\fR (\fB\-\-dynamic\fR) option. +.IP "\fB\-\-special\-syms\fR" 4 +.IX Item "--special-syms" +When displaying symbols include those which the target considers to be +special in some way and which would not normally be of interest to the +user. +.IP "\fB\-V\fR" 4 +.IX Item "-V" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Print the version number of \fBobjdump\fR and exit. +.IP "\fB\-x\fR" 4 +.IX Item "-x" +.PD 0 +.IP "\fB\-\-all\-headers\fR" 4 +.IX Item "--all-headers" +.PD +Display all available header information, including the symbol table and +relocation entries. Using \fB\-x\fR is equivalent to specifying all of +\&\fB\-a \-f \-h \-p \-r \-t\fR. +.IP "\fB\-w\fR" 4 +.IX Item "-w" +.PD 0 +.IP "\fB\-\-wide\fR" 4 +.IX Item "--wide" +.PD +Format some lines for output devices that have more than 80 columns. +Also do not truncate symbol names when they are displayed. +.IP "\fB\-z\fR" 4 +.IX Item "-z" +.PD 0 +.IP "\fB\-\-disassemble\-zeroes\fR" 4 +.IX Item "--disassemble-zeroes" +.PD +Normally the disassembly output will skip blocks of zeroes. This +option directs the disassembler to disassemble those blocks, just like +any other data. +.IP "\fB@\fR\fIfile\fR" 4 +.IX Item "@file" +Read command-line options from \fIfile\fR. The options read are +inserted in place of the original @\fIfile\fR option. If \fIfile\fR +does not exist, or cannot be read, then the option will be treated +literally, and not removed. +.Sp +Options in \fIfile\fR are separated by whitespace. A whitespace +character may be included in an option by surrounding the entire +option in either single or double quotes. Any character (including a +backslash) may be included by prefixing the character to be included +with a backslash. The \fIfile\fR may itself contain additional +@\fIfile\fR options; any such options will be processed recursively. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fInm\fR\|(1), \fIreadelf\fR\|(1), and the Info entries for \fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 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 included in the +section entitled \*(L"\s-1GNU\s0 Free Documentation License\*(R". diff --git a/gnu/usr.bin/binutils/update.sh b/gnu/usr.bin/binutils/update.sh new file mode 100755 index 000000000000..976cf3ec61c6 --- /dev/null +++ b/gnu/usr.bin/binutils/update.sh @@ -0,0 +1,47 @@ +#! /bin/sh +# +# $FreeBSD$ +# +# This script installs the main files generated by the binutils +# "configure" scripts and makefiles. It can be used for upgrading to +# a new version of binutils. +# +# Don't forget to change the VERSION definition in the top level +# "Makefile.inc0". + +gnudir=$(pwd) +contribdir="${gnudir}/../../../contrib/binutils" +platform="`uname -m`" + +rm -rf build +mkdir build + +echo "binutils elf configuration for $platform" + +(cd build + ${contribdir}/configure $platform-unknown-freebsd || exit + (cd gas + echo "Updating as" + make config.h || exit + cp config.h ${gnudir}/as/$platform/config.h || exit + ) + (cd ld + echo "Updating ld" + make config.h ldemul-list.h || exit + cp config.h ${gnudir}/ld || exit + cp ldemul-list.h ${gnudir}/ld/$platform || exit + ) + (cd bfd + echo "Updating libbfd" + make bfd.h config.h || exit + cp bfd.h ${gnudir}/libbfd/$platform || exit + cp config.h ${gnudir}/libbfd/$platform || exit + ) + (cd binutils + echo "Updating libbinutils" + make config.h || exit + cp config.h ${gnudir}/libbinutils/config.h || exit + ) + ) + +rm -rf build diff --git a/gnu/usr.bin/cc/Makefile b/gnu/usr.bin/cc/Makefile new file mode 100644 index 000000000000..378ababfcde8 --- /dev/null +++ b/gnu/usr.bin/cc/Makefile @@ -0,0 +1,32 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +# The order of some of these are rather important. Some depend on previous +# subdirs. + +SUBDIR= cc_tools .WAIT \ + libiberty libcpp libdecnumber cc_int cc cc1 include + +.if ${MK_CPP} != "no" +SUBDIR+= cpp +.endif + +.if ${MK_CXX} != "no" +SUBDIR+= cc1plus c++ +.endif + +.if ${MK_GCOV} != "no" +SUBDIR+= gcov +.endif + +SUBDIR_DEPEND_c++:= libcpp libiberty +SUBDIR_DEPEND_cc= libcpp libiberty +SUBDIR_DEPEND_cpp= libcpp libiberty +SUBDIR_DEPEND_cc1plus= cc_int libcpp libdecnumber libiberty +SUBDIR_DEPEND_cc1= cc_int libcpp libdecnumber libiberty +SUBDIR_DEPEND_gcov= libiberty + +SUBDIR_PARALLEL= + +.include <bsd.subdir.mk> diff --git a/gnu/usr.bin/cc/Makefile.fe b/gnu/usr.bin/cc/Makefile.fe new file mode 100644 index 000000000000..a681510cf02e --- /dev/null +++ b/gnu/usr.bin/cc/Makefile.fe @@ -0,0 +1,29 @@ +# $FreeBSD$ + +# Front-end-only bits + +.include "Makefile.ver" + +# +# These were previously defined in gcc.c. Just copy previous values from +# there. We ifdef most of them out for FREEBSD_NATIVE builds anyway. +# gcc.c won't compile without them though. +DRIVER_DEFINES = -DGCC_DRIVER \ + -DDEFAULT_TARGET_VERSION=\"$(BASEVER)\" \ + -DDEFAULT_TARGET_MACHINE=\"$(GCC_TARGET)\" \ + -DENABLE_SHARED_LIBGCC + +CFLAGS+= ${DRIVER_DEFINES} + +.PATH: ../cc_tools ${GCCDIR} ${GCCDIR}/doc ${GCCDIR}/config/${GCC_CPU} + +SRCS= gcc.c opts-common.c options.c intl.c prefix.c version.c + +# Include -march=native support for native-ish compilers only +.if (${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64") && \ + ${GCC_CPU} == "i386" +SRCS+= driver-${GCC_CPU}.c +.endif + +DPADD= ${LIBCPP} ${LIBIBERTY} +LDADD= ${LIBCPP} ${LIBIBERTY} diff --git a/gnu/usr.bin/cc/Makefile.inc b/gnu/usr.bin/cc/Makefile.inc new file mode 100644 index 000000000000..1af7d46fa777 --- /dev/null +++ b/gnu/usr.bin/cc/Makefile.inc @@ -0,0 +1,115 @@ +# $FreeBSD$ + +.include <src.opts.mk> +.include "../Makefile.inc" + +# Sometimes this is .include'd several times... +.if !defined(__CC_MAKEFILE_INC__) +__CC_MAKEFILE_INC__= ${MFILE} + +GCCVER= 4.2 +GCCDIR= ${SRCTOP}/contrib/gcc +GCCLIB= ${SRCTOP}/contrib/gcclibs + +.include "Makefile.tgt" + +# Machine description. +MD_FILE= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.md +GCC_TARGET= ${TARGET_ARCH}-undermydesk-freebsd + +CFLAGS+= -DGCCVER=\"${GCCVER}\" +CFLAGS+= -DIN_GCC -DHAVE_CONFIG_H +CFLAGS+= -DPREFIX=\"${TOOLS_PREFIX}/usr\" +#CFLAGS+= -DWANT_COMPILER_INVARIANTS +CSTD?= gnu89 + +.if ${TARGET_ARCH} != ${MACHINE_ARCH} +CFLAGS+= -DCROSS_DIRECTORY_STRUCTURE +CFLAGS+= -DTARGET_SYSTEM_ROOT=\"${TOOLS_PREFIX}\" +.endif + +.if ${TARGET_CPUARCH} == "arm" +CFLAGS+= -DTARGET_ARM_EABI +.endif + +.if ${TARGET_ARCH:Marm*eb} != "" +CFLAGS += -DTARGET_ENDIAN_DEFAULT=MASK_BIG_END +.endif +.if ${TARGET_ARCH:Marmv6*} != "" +CFLAGS += -DFREEBSD_ARCH_armv6 +.endif +.if ${TARGET_ARCH:Marmv7*} != "" +CFLAGS += -DFREEBSD_ARCH_armv7 +.endif + +.if ${TARGET_CPUARCH} == "mips" +.if ${TARGET_ARCH:Mmips*el*} != "" +CFLAGS += -DTARGET_ENDIAN_DEFAULT=0 +.endif + +.if ${TARGET_ARCH:Mmips64*} != "" +MIPS_ABI_DEFAULT=ABI_64 +.elif ${TARGET_ARCH:Mmipsn32*} != "" +MIPS_ABI_DEFAULT=ABI_N32 +.else +MIPS_ABI_DEFAULT=ABI_32 +.endif +CFLAGS += -DMIPS_ABI_DEFAULT=${MIPS_ABI_DEFAULT} + +# If we are compiling for the O32 ABI, we need to default to MIPS-III rather +# than taking the ISA from the ABI requirements, since FreeBSD is built with +# a number of MIPS-III features/instructions and that is the minimum ISA we +# support, not the O32 default MIPS-I. +.if ${MIPS_ABI_DEFAULT} == "ABI_32" +TARGET_CPUTYPE?=mips3 +.endif + +# GCC by default takes the ISA from the ABI's requirements. If world is built +# with a superior ISA, since we lack multilib, we have to set the right +# default ISA to be able to link against what's in /usr/lib. Terrible stuff. +.if defined(TARGET_CPUTYPE) +CFLAGS += -DMIPS_CPU_STRING_DEFAULT=\"${TARGET_CPUTYPE}\" +.endif +.endif + +.if defined(WANT_FORCE_OPTIMIZATION_DOWNGRADE) +CFLAGS+= -DFORCE_OPTIMIZATION_DOWNGRADE=${WANT_FORCE_OPTIMIZATION_DOWNGRADE} +.endif + +.if exists(${.OBJDIR}/../cc_tools) +CFLAGS+= -I${.OBJDIR}/../cc_tools +.endif +CFLAGS+= -I${.CURDIR}/../cc_tools +# This must go after the -I for cc_tools to resolve ambiguities for hash.h +# correctly. +CFLAGS+= -I${GCCDIR} -I${GCCDIR}/config + +CFLAGS+= -I${GCCLIB}/include +CFLAGS+= -I${GCCLIB}/libcpp/include +CFLAGS+= -I${GCCLIB}/libdecnumber + +.if exists(${.OBJDIR}/../cc_int) +LIBBACKEND= ${.OBJDIR}/../cc_int/libbackend.a +.else +LIBBACKEND= ${.CURDIR}/../cc_int/libbackend.a +.endif + +.if exists(${.OBJDIR}/../libiberty) +LIBIBERTY= ${.OBJDIR}/../libiberty/libiberty.a +.else +LIBIBERTY= ${.CURDIR}/../libiberty/libiberty.a +.endif + +.if exists(${.OBJDIR}/../libcpp) +LIBCPP= ${.OBJDIR}/../libcpp/libcpp.a +.else +LIBCPP= ${.CURDIR}/../libcpp/libcpp.a +.endif + +.if exists(${.OBJDIR}/../libdecnumber) +LIBDECNUMBER= ${.OBJDIR}/../libdecnumber/libdecnumber.a +.else +LIBDECNUMBER= ${.CURDIR}/../libdecnumber/libdecnumber.a +.endif + +.endif # !__CC_MAKEFILE_INC__ diff --git a/gnu/usr.bin/cc/Makefile.tgt b/gnu/usr.bin/cc/Makefile.tgt new file mode 100644 index 000000000000..b1a7f1608c72 --- /dev/null +++ b/gnu/usr.bin/cc/Makefile.tgt @@ -0,0 +1,23 @@ +# $FreeBSD$ + +# These assignments duplicate much of the functionality of +# MACHINE_CPUARCH, but there's no easy way to export make functions... + +.if defined(TARGET_ARCH) +TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}} +.else +TARGET_CPUARCH=${MACHINE_CPUARCH} +.endif +TARGET_ARCH?= ${MACHINE_ARCH} +GCC_CPU=${TARGET_CPUARCH:C/amd64/i386/:C/powerpc/rs6000/:C/sparc64/sparc/} + +.if ${TARGET_ARCH} == "sparc64" +TARGET_CPU_DEFAULT= TARGET_CPU_ultrasparc +.endif +.if ${TARGET_ARCH:Marm*eb} != "" || \ + (${TARGET_CPUARCH} == "mips" && ${TARGET_ARCH:Mmips*el*} == "") +TARGET_BIG_ENDIAN=t +.endif +.if ${TARGET_ARCH} == "powerpc64" +TARGET_CPU_DEFAULT= \"powerpc64\" +.endif diff --git a/gnu/usr.bin/cc/Makefile.ver b/gnu/usr.bin/cc/Makefile.ver new file mode 100644 index 000000000000..c7f460560ff1 --- /dev/null +++ b/gnu/usr.bin/cc/Makefile.ver @@ -0,0 +1,10 @@ +# $FreeBSD$ + +BASEVER!= cat ${GCCDIR}/BASE-VER +DATESTAMP!= cat ${GCCDIR}/DATESTAMP +DEVPHASE!= cat ${GCCDIR}/DEV-PHASE + +version.o: version.c ${GCCDIR}/BASE-VER ${GCCDIR}/DATESTAMP ${GCCDIR}/DEV-PHASE + ${CC} ${CFLAGS} -DBASEVER=\"${BASEVER}\" \ + -DDATESTAMP=\"\ ${DATESTAMP}\" \ + -DDEVPHASE=\"\ ${DEVPHASE}\" -c ${.IMPSRC} diff --git a/gnu/usr.bin/cc/c++/Makefile b/gnu/usr.bin/cc/c++/Makefile new file mode 100644 index 000000000000..39f372b2d888 --- /dev/null +++ b/gnu/usr.bin/cc/c++/Makefile @@ -0,0 +1,22 @@ +# $FreeBSD$ + +MAN= +.include <src.opts.mk> + +.include "../Makefile.inc" +.include "../Makefile.fe" + +.PATH: ${GCCDIR}/cp + +PROG= g++ +SRCS+= g++spec.c + +DPADD= ${LIBCPP} ${LIBIBERTY} +LDADD= ${LIBCPP} ${LIBIBERTY} + +.if ${MK_CLANG_IS_CC} == "no" +LINKS= ${BINDIR}/g++ ${BINDIR}/c++ +LINKS+= ${BINDIR}/g++ ${BINDIR}/CC +.endif + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/cc/c++/Makefile.depend b/gnu/usr.bin/cc/c++/Makefile.depend new file mode 100644 index 000000000000..2bea3c0fa889 --- /dev/null +++ b/gnu/usr.bin/cc/c++/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/usr.bin/cc/cc_tools \ + gnu/usr.bin/cc/libcpp \ + gnu/usr.bin/cc/libiberty \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/cc/Makefile b/gnu/usr.bin/cc/cc/Makefile new file mode 100644 index 000000000000..0fd82e092db4 --- /dev/null +++ b/gnu/usr.bin/cc/cc/Makefile @@ -0,0 +1,22 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +.include "../Makefile.inc" +.include "../Makefile.fe" + +PROG= gcc +MAN= gcc.1 +SRCS+= gccspec.c + +.if ${MK_SHARED_TOOLCHAIN} == "no" +NO_SHARED?=yes +.endif + +MLINKS= gcc.1 g++.1 +.if ${MK_CLANG_IS_CC} == "no" +LINKS= ${BINDIR}/gcc ${BINDIR}/cc +MLINKS+= gcc.1 cc.1 gcc.1 c++.1 gcc.1 CC.1 +.endif + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/cc/cc/Makefile.depend b/gnu/usr.bin/cc/cc/Makefile.depend new file mode 100644 index 000000000000..2bea3c0fa889 --- /dev/null +++ b/gnu/usr.bin/cc/cc/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/usr.bin/cc/cc_tools \ + gnu/usr.bin/cc/libcpp \ + gnu/usr.bin/cc/libiberty \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/cc1/Makefile b/gnu/usr.bin/cc/cc1/Makefile new file mode 100644 index 000000000000..7b2ec040ecd7 --- /dev/null +++ b/gnu/usr.bin/cc/cc1/Makefile @@ -0,0 +1,30 @@ +# $FreeBSD$ + +MAN= +.include <src.opts.mk> + +.include "../Makefile.inc" + +.PATH: ${GCCDIR} + +PROG= cc1 +SRCS= main.c c-parser.c c-lang.c +BINDIR= ${LIBEXECDIR} +.if ${MK_SHARED_TOOLCHAIN} == "no" +NO_SHARED?=yes +.endif + +OBJS+= ${PROG}-checksum.o +DPADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY} +LDADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY} + +DOBJS+= ${SRCS:N*.h:R:S/$/.o/g} +${PROG}-dummy: ${DOBJS} + ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${DOBJS} ${LDADD} +CLEANFILES+= ${PROG}-dummy + +${PROG}-checksum.c: ${PROG}-dummy + ../cc_tools/genchecksum ${PROG}-dummy > ${.TARGET} +CLEANFILES+= ${PROG}-checksum.c + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/cc/cc1/Makefile.depend b/gnu/usr.bin/cc/cc1/Makefile.depend new file mode 100644 index 000000000000..54acaaf4b5b0 --- /dev/null +++ b/gnu/usr.bin/cc/cc1/Makefile.depend @@ -0,0 +1,22 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/usr.bin/cc/cc_int \ + gnu/usr.bin/cc/cc_tools \ + gnu/usr.bin/cc/libcpp \ + gnu/usr.bin/cc/libdecnumber \ + gnu/usr.bin/cc/libiberty \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/cc1plus/Makefile b/gnu/usr.bin/cc/cc1plus/Makefile new file mode 100644 index 000000000000..1d9287453125 --- /dev/null +++ b/gnu/usr.bin/cc/cc1plus/Makefile @@ -0,0 +1,45 @@ +# $FreeBSD$ + +MAN= +.include <src.opts.mk> + +.include "../Makefile.inc" + +.PATH: ${GCCDIR}/cp ${GCCDIR} + +PROG= cc1plus +SRCS= cfns.h +SRCS+= main.c cp-lang.c c-opts.c call.c class.c cvt.c cxx-pretty-print.c \ + decl.c decl2.c error.c except.c expr.c dump.c friend.c init.c lex.c \ + mangle.c method.c name-lookup.c parser.c pt.c ptree.c repo.c rtti.c \ + search.c semantics.c tree.c typeck.c typeck2.c optimize.c \ + cp-objcp-common.c cp-gimplify.c tree-mudflap.c + +BINDIR= ${LIBEXECDIR} +.if ${MK_SHARED_TOOLCHAIN} == "no" +NO_SHARED?=yes +.endif + +CFLAGS+= -I${GCCDIR}/cp -I. + +OBJS+= ${PROG}-checksum.o +DPADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY} +LDADD= ${LIBBACKEND} ${LIBCPP} ${LIBDECNUMBER} ${LIBIBERTY} + +#----------------------------------------------------------------------- +# C++ parser +cfns.h: cfns.gperf + gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' -L ANSI-C \ + ${.ALLSRC} > ${.TARGET} || (rm -f ${.TARGET}; false) +CLEANFILES= cfns.h + +DOBJS+= ${SRCS:N*.h:R:S/$/.o/g} +${PROG}-dummy: ${DOBJS} + ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${DOBJS} ${LDADD} +CLEANFILES+= ${PROG}-dummy + +${PROG}-checksum.c: ${PROG}-dummy + ../cc_tools/genchecksum ${PROG}-dummy > ${.TARGET} +CLEANFILES+= ${PROG}-checksum.c + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/cc/cc1plus/Makefile.depend b/gnu/usr.bin/cc/cc1plus/Makefile.depend new file mode 100644 index 000000000000..7615829e9d1c --- /dev/null +++ b/gnu/usr.bin/cc/cc1plus/Makefile.depend @@ -0,0 +1,23 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/usr.bin/cc/cc_int \ + gnu/usr.bin/cc/cc_tools \ + gnu/usr.bin/cc/libcpp \ + gnu/usr.bin/cc/libdecnumber \ + gnu/usr.bin/cc/libiberty \ + gnu/usr.bin/gperf.host \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/cc_int/Makefile b/gnu/usr.bin/cc/cc_int/Makefile new file mode 100644 index 000000000000..33808a53689e --- /dev/null +++ b/gnu/usr.bin/cc/cc_int/Makefile @@ -0,0 +1,107 @@ +# $FreeBSD$ + +.include <bsd.own.mk> + +.include "../Makefile.inc" +.include "../Makefile.ver" + +.PATH: ../cc_tools ${GCCDIR} ${GCCDIR}/config/${GCC_CPU} + +LIB= backend +INTERNALLIB= + +EXTRA_OBJS= +GGC= ggc-page.o +host_hook_obj= host-default.o + +# +# Most lists copied verbatim from GCC Makefiles. +# +OBJS-common = \ + double-int.o tree-chrec.o tree-scalar-evolution.o tree-data-ref.o \ + tree-cfg.o tree-dfa.o tree-eh.o tree-ssa.o tree-optimize.o tree-gimple.o \ + gimplify.o tree-pretty-print.o tree-into-ssa.o \ + tree-outof-ssa.o tree-ssa-ccp.o tree-vn.o tree-ssa-uncprop.o \ + tree-ssa-dce.o tree-ssa-copy.o tree-nrv.o tree-ssa-copyrename.o \ + tree-ssa-pre.o tree-ssa-live.o tree-ssa-operands.o tree-ssa-alias.o \ + tree-ssa-alias-warnings.o \ + tree-ssa-phiopt.o tree-ssa-forwprop.o tree-nested.o tree-ssa-dse.o \ + tree-ssa-dom.o domwalk.o tree-tailcall.o gimple-low.o tree-iterator.o \ + omp-low.o tree-phinodes.o tree-ssanames.o tree-sra.o tree-complex.o \ + tree-vect-generic.o tree-ssa-loop.o tree-ssa-loop-niter.o \ + tree-ssa-loop-manip.o tree-ssa-threadupdate.o tree-ssa-threadedge.o \ + tree-vectorizer.o tree-vect-analyze.o tree-vect-transform.o \ + tree-vect-patterns.o tree-ssa-loop-prefetch.o \ + tree-ssa-loop-ivcanon.o tree-ssa-propagate.o tree-ssa-address.o \ + tree-ssa-math-opts.o \ + tree-ssa-loop-ivopts.o tree-if-conv.o tree-ssa-loop-unswitch.o \ + alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o \ + cfg.o cfganal.o cfgbuild.o cfgcleanup.o cfglayout.o cfgloop.o \ + cfgloopanal.o cfgloopmanip.o loop-init.o loop-unswitch.o loop-unroll.o \ + cfgrtl.o combine.o conflict.o convert.o coverage.o cse.o cselib.o \ + dbxout.o ddg.o tree-ssa-loop-ch.o loop-invariant.o tree-ssa-loop-im.o \ + debug.o df-core.o df-problems.o df-scan.o dfp.o diagnostic.o dojump.o \ + dominance.o loop-doloop.o \ + dwarf2asm.o dwarf2out.o emit-rtl.o except.o explow.o loop-iv.o \ + expmed.o expr.o final.o flow.o fold-const.o function.o gcse.o \ + genrtl.o ggc-common.o global.o graph.o gtype-desc.o \ + haifa-sched.o hooks.o ifcvt.o insn-attrtab.o insn-emit.o insn-modes.o \ + insn-extract.o insn-opinit.o insn-output.o insn-peep.o insn-recog.o \ + integrate.o intl.o jump.o langhooks.o lcm.o lists.o local-alloc.o \ + mode-switching.o modulo-sched.o optabs.o options.o opts.o opts-common.o \ + params.o postreload.o postreload-gcse.o predict.o \ + insn-preds.o insn-automata.o pointer-set.o \ + print-rtl.o print-tree.o profile.o value-prof.o var-tracking.o \ + real.o recog.o reg-stack.o regclass.o regmove.o regrename.o \ + reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o \ + sbitmap.o sched-deps.o sched-ebb.o sched-rgn.o sched-vis.o sdbout.o \ + see.o simplify-rtx.o sreal.o stmt.o stor-layout.o stringpool.o \ + struct-equiv.o targhooks.o timevar.o toplev.o tracer.o tree.o tree-dump.o \ + varasm.o varray.o vec.o version.o vmsdbgout.o xcoffout.o alloc-pool.o \ + et-forest.o cfghooks.o bt-load.o pretty-print.o $(GGC) web.o passes.o \ + tree-profile.o rtlhooks.o cfgexpand.o lambda-mat.o \ + lambda-trans.o lambda-code.o tree-loop-linear.o tree-ssa-sink.o \ + tree-vrp.o tree-stdarg.o tree-cfgcleanup.o tree-ssa-reassoc.o \ + tree-ssa-structalias.o tree-object-size.o \ + rtl-factoring.o + +OBJS-archive= $(EXTRA_OBJS) $(host_hook_obj) tree-inline.o \ + cgraph.o cgraphunit.o tree-nomudflap.o ipa.o ipa-inline.o \ + ipa-utils.o ipa-reference.o ipa-pure-const.o ipa-type-escape.o \ + ipa-prop.o ipa-cp.o + +OBJS-md= ${GCC_CPU}.o +.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-c.c) +OBJS-md+= ${GCC_CPU}-c.o +.endif + +# Target specific, C specific object file +C_TARGET_OBJS= + +# Language-specific object files for C and Objective C. +C_AND_OBJC_OBJS = attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \ + c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o \ + c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o prefix.o \ + c-objc-common.o c-dump.o c-pch.o c-parser.o $(C_TARGET_OBJS) \ + c-gimplify.o tree-mudflap.o c-pretty-print.o c-omp.o + +# Language-specific object files for C. +C_OBJS = c-lang.o stub-objc.o $(C_AND_OBJC_OBJS) + +# Put objC stub objects in library. objc frontend will override it +# Put dummy checksum object in library too. It will be overridden +# by each indidual front-end binary as needed. +OBJS-dummy= stub-objc.o dummy-checksum.o + +OBJS-all= ${OBJS-common} ${OBJS-archive} ${OBJS-md} ${C_AND_OBJC_OBJS} \ + ${OBJS-dummy} + +SRCS+= ${OBJS-all:R:S/$/.c/g} + +toplev.o: toplev.c + ${CC} ${CFLAGS} -DTARGET_NAME=\"${GCC_TARGET}\" -c ${.IMPSRC} + +# make sure we don't find .o's in ../cc_tools/ +CLEANFILES+= ${OBJS-all} + +.include <bsd.lib.mk> diff --git a/gnu/usr.bin/cc/cc_int/Makefile.depend b/gnu/usr.bin/cc/cc_int/Makefile.depend new file mode 100644 index 000000000000..ea841fdbb8d9 --- /dev/null +++ b/gnu/usr.bin/cc/cc_int/Makefile.depend @@ -0,0 +1,14 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/usr.bin/cc/cc_tools \ + include \ + include/xlocale \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/cc_tools/Makefile b/gnu/usr.bin/cc/cc_tools/Makefile new file mode 100644 index 000000000000..2e5ff3884b14 --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/Makefile @@ -0,0 +1,445 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +CFLAGS+= -I. + +.include "../Makefile.inc" +# Some of the logic needed in here is defined in Makefile.hdrs as it is shared +# with gnu/lib. +.include "Makefile.hdrs" + +CFLAGS+= -g +CFLAGS+= -DGENERATOR_FILE -DHAVE_CONFIG_H + +# Override LIBIBERTY set by Makefile.inc, We use our own for +# build tools. +LIBIBERTY= libiberty.a + +.PATH: ${GCCDIR} ${GCCLIB}/libiberty + +#----------------------------------------------------------------------- +# Determine content of variables used by the target/host config files + +# +# The list of headers to go into tm.h +# +.for H in ${TARGET_INC} +.for D in ${GCCDIR}/config ${GCCDIR} ${.CURDIR} +.if exists($D/$H) +TARGET_INC_FILES+= $D/$H +.endif +.endfor +.endfor + +# +# gtyp includes. +# +srcdir= ${GCCDIR} +CPPLIB_H= ${GCCLIB}/libcpp/include/line-map.h \ + ${GCCLIB}/libcpp/include/cpplib.h +SYMTAB_H= ${GCCLIB}/libcpp/include/symtab.h +CPP_ID_DATA_H= ${CPPLIB_H} ${GCCLIB}/libcpp/include/cpp-id-data.h +HASHTAB_H= ${GCCLIB}/include/hashtab.h +SPLAY_TREE_H= ${GCCLIB}/include/splay-tree.h +out_file= ${srcdir}/config/${GCC_CPU}/${GCC_CPU}.c +tm_file_list= ${TARGET_INC_FILES} +host_xm_file_list= ${.CURDIR}/auto-host.h ${GCCLIB}/include/ansidecl.h +GTFILES_SRCDIR= ${srcdir} + +# Copied unchanged from gcc/Makefile.in +GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \ + $(CPP_ID_DATA_H) $(host_xm_file_list) \ + $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \ + $(srcdir)/coverage.c $(srcdir)/rtl.h \ + $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/function.h $(srcdir)/libfuncs.h $(SYMTAB_H) \ + $(srcdir)/real.h $(srcdir)/varray.h $(srcdir)/insn-addr.h $(srcdir)/hwint.h \ + $(srcdir)/ipa-reference.h $(srcdir)/output.h \ + $(srcdir)/cselib.h $(srcdir)/basic-block.h $(srcdir)/cgraph.h \ + $(srcdir)/c-common.h $(srcdir)/c-tree.h $(srcdir)/reload.h \ + $(srcdir)/alias.c $(srcdir)/bitmap.c $(srcdir)/cselib.c $(srcdir)/cgraph.c \ + $(srcdir)/ipa-prop.c $(srcdir)/ipa-cp.c $(srcdir)/ipa-inline.c \ + $(srcdir)/dbxout.c $(srcdir)/dwarf2out.c $(srcdir)/dwarf2asm.c \ + $(srcdir)/dojump.c $(srcdir)/tree-profile.c \ + $(srcdir)/emit-rtl.c $(srcdir)/except.c $(srcdir)/explow.c $(srcdir)/expr.c \ + $(srcdir)/function.c $(srcdir)/except.h \ + $(srcdir)/gcse.c $(srcdir)/integrate.c $(srcdir)/lists.c $(srcdir)/optabs.c \ + $(srcdir)/profile.c $(srcdir)/regclass.c \ + $(srcdir)/reg-stack.c $(srcdir)/cfglayout.c \ + $(srcdir)/sdbout.c $(srcdir)/stor-layout.c \ + $(srcdir)/stringpool.c $(srcdir)/tree.c $(srcdir)/varasm.c \ + $(srcdir)/tree-mudflap.c $(srcdir)/tree-flow.h \ + $(srcdir)/c-objc-common.c $(srcdir)/c-common.c $(srcdir)/c-parser.c \ + $(srcdir)/tree-ssanames.c $(srcdir)/tree-eh.c $(srcdir)/tree-ssa-address.c \ + $(srcdir)/tree-phinodes.c $(srcdir)/tree-cfg.c \ + $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \ + $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \ + $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \ + $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \ + $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \ + $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \ + $(srcdir)/tree-ssa-structalias.c \ + $(srcdir)/c-pragma.h $(srcdir)/omp-low.c \ + $(srcdir)/targhooks.c $(srcdir)/cgraphunit.c $(out_file) \ + +# The list of frontend directories to look into +GTFILES_LANG_DIR_NAMES= + +.if ${MK_CXX} != "no" +GTFILES_LANG_DIR_NAMES+= cp +.endif + +# The list of language specific files for gengtype +.for L in ${GTFILES_LANG_DIR_NAMES} c +.if exists(${GCCDIR}/$L-config-lang.in) +# Source the language config file +L_GTFILES!= sh -c '. ${GCCDIR}/$L-config-lang.in; echo $$gtfiles' +.else +L_GTFILES!= sh -c '. ${GCCDIR}/$L/config-lang.in; echo $$gtfiles' +.endif +.for F in ${L_GTFILES} +GTFILES_FILES+= $F +GTFILES_LANGS+= $L +.endfor +.endfor +GTFILES+= ${GTFILES_FILES} + +# +# Tree definition files. +# +TREE_DEF_FILES= + +.if ${MK_CXX} != "no" +TREE_DEF_FILES+= cp/cp-tree.def +.endif + +#----------------------------------------------------------------------- +# Build rules for header files and generator tools + +# Host config +config.h: + TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ + HEADERS="auto-host.h ansidecl.h" \ + DEFINES="" \ + /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} + +GENSRCS+= config.h +CLEANFILES+= cs-config.h + +# Build config +bconfig.h: + TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ + HEADERS="auto-host.h ansidecl.h" \ + DEFINES="" \ + /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} +.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) + echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} +.endif + +GENSRCS+= bconfig.h +CLEANFILES+= cs-bconfig.h + +# tconfig.h +GENSRCS+= tconfig.h +CLEANFILES+= cs-tconfig.h + +# Options +GENONLY+= optionlist options.h options.c + +# Target machine config +GENSRCS+= tm.h +CLEANFILES+= cs-tm.h + +# Target machine protos/preds. +tm_p.h: + TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ + HEADERS="${GCC_CPU}/${GCC_CPU}-protos.h tm-preds.h" \ + DEFINES="" \ + /bin/sh ${GCCDIR}/mkconfig.sh tm_p.h + +GENSRCS+= tm_p.h +CLEANFILES+= cs-tm_p.h + +# gencheck +gencheck.h: ${TREE_DEF_FILES} +.for F in ${TREE_DEF_FILES} + echo "#include \"$F\"" >> ${.TARGET} +.endfor + touch ${.TARGET} + +GENSRCS+= gencheck.h + + +# Source header for gtyp generator. +gtyp-gen.h: ${GTFILES} + echo "/* This file is machine generated. Do not edit. */" > ${.TARGET} + echo "static const char * const srcdir = " >> ${.TARGET} + echo "\"$(GTFILES_SRCDIR)\";" >> ${.TARGET} + echo "static const char * const lang_files[] = {" >> ${.TARGET} +.for F in ${GTFILES_FILES} + echo "\"$F\", " >> ${.TARGET} +.endfor + echo "NULL};" >> ${.TARGET} + echo "static const char * const langs_for_lang_files[] = {">> ${.TARGET} +.for F in ${GTFILES_LANGS} + echo "\"$F\", " >> ${.TARGET} +.endfor + echo "NULL};" >> ${.TARGET} + echo "static const char * const all_files[] = {" >> ${.TARGET} +.for F in ${GTFILES} + echo "\"$F\", " >> ${.TARGET} +.endfor + echo "NULL};" >> ${.TARGET} + echo "static const char * const lang_dir_names[] = {" >> ${.TARGET} +.for F in c ${GTFILES_LANG_DIR_NAMES} + echo "\"$F\", " >> ${.TARGET} +.endfor + echo "NULL};" >> ${.TARGET} + +GENSRCS+= gtyp-gen.h + +# Version header for gcov +GENSRCS+= gcov-iov.h + +# Multilib config file +multilib.h: +.if ${TARGET_ARCH} == "powerpc64" || ${TARGET_ARCH} == "amd64" + echo 'static const char *const multilib_raw[] = { \ + ". !m64 !m32;", \ + "64:../lib m64 !m32;", \ + "32:../lib32 !m64 m32;", NULL };' > ${.TARGET} + echo 'static const char *multilib_options = "m64/m32";' >> ${.TARGET} + echo 'static const char *const multilib_matches_raw[] = { \ + "m64 m64;", "m32 m32;", NULL };' >> ${.TARGET} +.else + echo 'static const char *const multilib_raw[] = { \ + ". ;", NULL };' > ${.TARGET} + echo 'static const char *multilib_options = "";' >> ${.TARGET} + echo 'static const char *const multilib_matches_raw[] = { \ + NULL };' >> ${.TARGET} +.endif + echo 'static const char *multilib_extra = "";' >> ${.TARGET} + echo 'static const char *const multilib_exclusions_raw[] = { \ + NULL };' >> ${.TARGET} + +GENSRCS+= multilib.h + +configargs.h: + echo 'static const char configuration_arguments[] =' > ${.TARGET} + echo ' "FreeBSD/${TARGET_ARCH} system compiler";' >> ${.TARGET} + echo 'static const char thread_model[] = "posix";' >> ${.TARGET} + echo 'static const struct {' >> ${.TARGET} + echo ' const char *name, *value;' >> ${.TARGET} + echo '} configure_default_options[] = {' >> ${.TARGET} + echo ' { "NULL", "NULL" } };' >> ${.TARGET} + +GENSRCS+= configargs.h + +# Language spec files +specs.h: + echo '#include "cp/lang-specs.h"' > ${.TARGET} + +GENSRCS+= specs.h + +gstdint.h: + echo '#include "sys/types.h"' > ${.TARGET} + echo '#include "sys/stdint.h"' >> ${.TARGET} + +GENSRCS+= gstdint.h + +# Linked headers +GENSRCS+= gthr-default.h + +GENSRCS+= unwind.h + +# +# gtype gunk +# +gengtype-lex.c: gengtype-lex.l + flex -ogengtype-lex.c ${.ALLSRC} + +gengtype-yacc.h: gengtype-yacc.y + yacc -d -o gengtype-yacc.c ${.ALLSRC} + +gengtype-yacc.c: gengtype-yacc.h .NOMETA + +gengtype-yacc+%DIKED.c: gengtype-yacc.c + cat ${.ALLSRC} > ${.TARGET} + sed -e "s/xmalloc/malloc/g" \ + -e "s/xrealloc/realloc/g" \ + -e "s/malloc/xmalloc/g" \ + -e "s/realloc/xrealloc/g" \ + ${.ALLSRC} > ${.TARGET} + +GENSRCS+= gengtype-lex.c gengtype-yacc.h gengtype-yacc+%DIKED.c +CLEANFILES+= gengtype-yacc.c + +gengtype: gengtype.o gengtype-yacc+%DIKED.o gengtype-lex.o errors.o \ + ${LIBIBERTY} + ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} + +gtype-desc.h: gengtype + ${BTOOLSPATH:U.}/gengtype + touch ${.TARGET} + +gtype-desc.c: gtype-desc.h + +GENONLY+= gtype-desc.c gtype-desc.h +CLEANFILES+= gt-*.h gtype-*.h + +# +# Generator tools. +# +.for F in check checksum genrtl modes +gen$F: gen$F.o errors.o ${LIBIBERTY} + ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} +.endfor + +.for F in attr attrtab automata codes conditions config constants emit \ + extract flags opinit output peep preds recog +gen$F: gen$F.o rtl.o read-rtl.o ggc-none.o vec.o min-insn-modes.o \ + gensupport.o print-rtl.o errors.o ${LIBIBERTY} + ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} -lm +.endfor + +gencondmd: gencondmd.o + ${CC:N${CCACHE_BIN}} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} + +# +# Generated .md files. +# +insn-conditions.md: gencondmd + ${BTOOLSPATH:U.}/gencondmd > ${.TARGET} +GENSRCS+= insn-conditions.md + +# +# Generated header files. +# + +.for F in constants +insn-$F.h: gen$F ${MD_FILE} + ${BTOOLSPATH:U.}/gen$F ${MD_FILE} > ${.TARGET} +GENSRCS+= insn-$F.h +.endfor + +.for F in attr codes config flags +insn-$F.h: gen$F ${MD_FILE} insn-conditions.md + ${BTOOLSPATH:U.}/gen$F ${MD_FILE} insn-conditions.md > ${.TARGET} +GENSRCS+= insn-$F.h +.endfor + +# Header files with irregular names. +genrtl.h: gengenrtl + ${BTOOLSPATH:U.}/gengenrtl -h > ${.TARGET} +GENSRCS+= genrtl.h + +tm-preds.h: genpreds + ${BTOOLSPATH:U.}/genpreds -h ${MD_FILE} > ${.TARGET} +GENSRCS+= tm-preds.h + +tm-constrs.h: genpreds + ${BTOOLSPATH:U.}/genpreds -c ${MD_FILE} > ${.TARGET} +GENSRCS+= tm-constrs.h + +tree-check.h: gencheck + ${BTOOLSPATH:U.}/gencheck > ${.TARGET} +GENSRCS+= tree-check.h + +insn-modes.h: genmodes + ${BTOOLSPATH:U.}/genmodes -h > ${.TARGET} +GENSRCS+= insn-modes.h + +# +# Generated source files. +# +.for F in attrtab automata emit extract opinit output peep preds recog +insn-$F.c: gen$F ${MD_FILE} insn-conditions.md + ${BTOOLSPATH:U.}/gen$F ${MD_FILE} insn-conditions.md > ${.TARGET} +GENONLY+= insn-$F.c +.endfor + +.for F in conditions +insn-$F.c: gen$F ${MD_FILE} + ${BTOOLSPATH:U.}/gen$F ${MD_FILE} > ${.TARGET} +GENSRCS+= insn-$F.c +.endfor + +# Source files with irregular names. +insn-modes.c: genmodes + ${BTOOLSPATH:U.}/genmodes > ${.TARGET} +GENONLY+= insn-modes.c + +min-insn-modes.c: genmodes + ${BTOOLSPATH:U.}/genmodes -m > ${.TARGET} +GENSRCS+= min-insn-modes.c + +genrtl.c: gengenrtl + ${BTOOLSPATH:U.}/gengenrtl > ${.TARGET} +GENONLY+= genrtl.c + +gencondmd.c: genconditions ${MD_FILE} + ${BTOOLSPATH:U.}/genconditions ${MD_FILE} > ${.TARGET} +GENSRCS+= gencondmd.c + +#----------------------------------------------------------------------- +# Build tools. + +GNTOOLS+= genattr genattrtab genautomata gencodes gencheck genchecksum \ + genconditions gencondmd genconfig genconstants genemit \ + genextract genflags gengenrtl gengtype genmodes genopinit \ + genoutput genpeep genpreds genrecog + +${GNTOOLS:C,$,.o,} ${GNTOOLS}: ${BUILD_TOOLS_META} +all: ${GNTOOLS} ${GENSRCS} ${GENONLY} +build-tools: all +beforedepend: ${GENONLY} + +# +#----------------------------------------------------------------------- +# Build 'pocket' libiberty exclusively for build tools use. + +LIBIBERTY_SRCS= choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \ + dyn-string.c fibheap.c fopen_unlocked.c getpwd.c getruntime.c \ + hashtab.c hex.c lbasename.c make-temp-file.c md5.c obstack.c \ + partition.c pex-unix.c physmem.c safe-ctype.c splay-tree.c xexit.c \ + xmalloc.c xmemdup.c xstrdup.c xstrerror.c +LIBIBERTY_OBJS= ${LIBIBERTY_SRCS:R:S/$/.o/g} + +.for _src in ${LIBIBERTY_SRCS} +${_src:R:S/$/.o/}: ${_src} ${BUILD_TOOLS_META} + ${CC} -c -I ${.CURDIR}/../libiberty ${CFLAGS} -o ${.TARGET} ${.IMPSRC} +.endfor + +${LIBIBERTY}: ${LIBIBERTY_OBJS} ${BUILD_TOOLS_META} + @rm -f ${.TARGET} + @${AR} ${ARFLAGS} ${.TARGET} `lorder ${LIBIBERTY_OBJS} | tsort -q` + ${RANLIB} ${.TARGET} +CLEANFILES+= ${LIBIBERTY} ${LIBIBERTY_OBJS} + + +#----------------------------------------------------------------------- +# Fixups. + +# Set OBJS the same as bsd.prog.mk would do if we defined PROG. We can't +# define PROG because we have multiple programs. +# +SRCS= errors.c genattr.c genattrtab.c \ + genautomata.c gencheck.c genchecksum.c gencodes.c \ + genconditions.c genconfig.c genconstants.c genemit.c \ + genextract.c genflags.c gengenrtl.c gengtype.c genmodes.c \ + genopinit.c genoutput.c genpeep.c genpreds.c genrecog.c \ + gensupport.c ggc-none.c print-rtl.c read-rtl.c rtl.c \ + vec.c + +SRCS+= ${GENSRCS} +OBJS+= ${SRCS:N*.h:R:S/$/.o/g} +GENOBJS+= ${GENSRCS:N*.h:R:S/$/.o/g} +${OBJS} ${GENOBJS}: ${BUILD_TOOLS_META} +CLEANFILES+= ${GENSRCS} ${GENONLY} ${GENOBJS} ${GNTOOLS} + +#----------------------------------------------------------------------- +# Manual dependencies. +.include "Makefile.dep" + +.include <bsd.prog.mk> +# DO NOT DELETE diff --git a/gnu/usr.bin/cc/cc_tools/Makefile.dep b/gnu/usr.bin/cc/cc_tools/Makefile.dep new file mode 100644 index 000000000000..a1a848b2413f --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/Makefile.dep @@ -0,0 +1,153 @@ +# $FreeBSD$ + +OBJS_DEPEND_GUESS.errors.o+= bconfig.h auto-host.h + +OBJS_DEPEND_GUESS.genattr.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genattrtab.o+= bconfig.h \ + auto-host.h \ + tm.h options.h \ + insn-modes.h \ + gtype-desc.h + +OBJS_DEPEND_GUESS.genautomata.o+= bconfig.h \ + auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.gencheck.o+= bconfig.h auto-host.h \ + tm.h options.h \ + gencheck.h + +OBJS_DEPEND_GUESS.genchecksum.o+= bconfig.h \ + auto-host.h + +OBJS_DEPEND_GUESS.gencodes.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genconditions.o+= bconfig.h \ + auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genconfig.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genconstants.o+= bconfig.h \ + auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genemit.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genextract.o+= bconfig.h \ + auto-host.h \ + tm.h options.h \ + insn-modes.h \ + insn-config.h + +OBJS_DEPEND_GUESS.genflags.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.gengenrtl.o+= bconfig.h auto-host.h + +OBJS_DEPEND_GUESS.gengtype.o+= bconfig.h auto-host.h \ + tm.h options.h \ + gtyp-gen.h + +OBJS_DEPEND_GUESS.genmddeps.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genmodes.o+= bconfig.h auto-host.h + +OBJS_DEPEND_GUESS.genopinit.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genoutput.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genpeep.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genpreds.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.genrecog.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.gensupport.o+= bconfig.h \ + auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.ggc-none.o+= bconfig.h auto-host.h \ + gtype-desc.h + +OBJS_DEPEND_GUESS.print-rtl.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.read-rtl.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.rtl.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-modes.h \ + gtype-desc.h + +OBJS_DEPEND_GUESS.insn-modes.o+= insn-modes.c config.h auto-host.h \ + tm.h options.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.min-insn-modes.o+= bconfig.h auto-host.h \ + insn-modes.h + +OBJS_DEPEND_GUESS.gengtype-lex.o+= \ + bconfig.h auto-host.h \ + gengtype-yacc.h + +OBJS_DEPEND_GUESS.gengtype-yacc+%DIKED.o+= \ + bconfig.h \ + auto-host.h \ + tm.h options.h \ + +OBJS_DEPEND_GUESS.insn-conditions.o+= insn-conditions.c bconfig.h auto-host.h \ + insn-constants.h \ + tm.h options.h \ + insn-modes.h \ + tm_p.h \ + tm-preds.h \ + options.h + +OBJS_DEPEND_GUESS.gencondmd.o+= \ + tm.h options.h tm_p.h \ + tm-preds.h tm-constrs.h tree-check.h \ + insn-constants.h + +OBJS_DEPEND_GUESS.gencondmd.o+= bconfig.h auto-host.h \ + tm.h options.h \ + insn-constants.h \ + insn-modes.h \ + tm_p.h \ + tm-preds.h \ + tree-check.h \ + tm-constrs.h + +OBJS_DEPEND_GUESS.vec.o+= bconfig.h auto-host.h \ + insn-modes.h \ + tree-check.h \ + gtype-desc.h diff --git a/gnu/usr.bin/cc/cc_tools/Makefile.depend b/gnu/usr.bin/cc/cc_tools/Makefile.depend new file mode 100644 index 000000000000..7e06312d1eb7 --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/Makefile.depend @@ -0,0 +1,19 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + lib/msun \ + usr.bin/yacc.host \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/cc_tools/Makefile.hdrs b/gnu/usr.bin/cc/cc_tools/Makefile.hdrs new file mode 100644 index 000000000000..f2576f7fdf0a --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/Makefile.hdrs @@ -0,0 +1,136 @@ +# $FreeBSD$ +# +# This is logic for common headers shared inside of gnu/lib. It used to +# live in gnu/usr.bin/cc/cc_tools/Makefile. + +.if !defined(TARGET_CPUARCH) || !defined(GCC_CPU) +.error ${.CURDIR}: Must include gnu/usr.bin/cc/Makefile.tgt first. +.endif + +# +# The list of headers to go into tm.h +# +TARGET_INC+= options.h +.if ${TARGET_CPUARCH} == "amd64" +TARGET_INC+= i386/biarch64.h +.endif +.if ${TARGET_CPUARCH} != "arm" +TARGET_INC+= ${GCC_CPU}/${GCC_CPU}.h +.endif +.if ${TARGET_CPUARCH} == "i386" || ${TARGET_CPUARCH} == "amd64" +TARGET_INC+= ${GCC_CPU}/unix.h +TARGET_INC+= ${GCC_CPU}/att.h +.endif +TARGET_INC+= dbxelf.h +TARGET_INC+= elfos-undef.h +TARGET_INC+= elfos.h +TARGET_INC+= freebsd-native.h +TARGET_INC+= freebsd-spec.h +TARGET_INC+= freebsd.h +.if ${TARGET_CPUARCH} != "i386" && ${TARGET_CPUARCH} != "amd64" +. if exists(${GCCDIR}/config/${GCC_CPU}/sysv4.h) +TARGET_INC+= ${GCC_CPU}/sysv4.h +. endif +.endif +.if ${TARGET_CPUARCH} == "amd64" +TARGET_INC+= ${GCC_CPU}/x86-64.h +.endif +.if ${TARGET_CPUARCH} == "arm" || ${TARGET_CPUARCH} == "mips" +TARGET_INC+= ${GCC_CPU}/elf.h +.endif +.if ${TARGET_CPUARCH} == "arm" +TARGET_INC+= ${GCC_CPU}/aout.h +TARGET_INC+= ${GCC_CPU}/bpabi.h +.endif +.if ${TARGET_ARCH} == "powerpc64" +TARGET_INC+= ${GCC_CPU}/biarch64.h +TARGET_INC+= ${GCC_CPU}/default64.h +.endif +.if ${TARGET_ARCH} == "powerpcspe" +TARGET_INC+= ${GCC_CPU}/freebsdspe.h +TARGET_INC+= ${GCC_CPU}/e500-double.h +.endif +TARGET_INC+= ${GCC_CPU}/freebsd.h +.if ${TARGET_CPUARCH} == "amd64" +TARGET_INC+= ${GCC_CPU}/freebsd64.h +.endif +.if ${TARGET_CPUARCH} == "arm" +TARGET_INC+= ${GCC_CPU}/arm.h +.endif +TARGET_INC+= defaults.h + +# +# Option files. +# +OPT_FILES= c.opt common.opt + +.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt) +OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}.opt +.endif + +.if exists(${.CURDIR}/${GCC_CPU}-freebsd.opt) +OPT_FILES+= ${.CURDIR}/${GCC_CPU}-freebsd.opt +.endif + +.if ${TARGET_CPUARCH} == "powerpc" +OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/sysv4.opt +.endif + +.if ${TARGET_CPUARCH} == "sparc64" +OPT_FILES+= ${GCCDIR}/config/${GCC_CPU}/long-double-switch.opt +.endif + +.if exists(${.CURDIR}/freebsd.opt) +OPT_FILES+= ${.CURDIR}/freebsd.opt +.endif + + +# Options +optionlist: ${OPT_FILES} + LC_ALL=C awk -f ${GCCDIR}/opt-gather.awk ${.ALLSRC} > ${.TARGET} + +options.h: optionlist + LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \ + -f ${GCCDIR}/opth-gen.awk \ + < ${.ALLSRC} > ${.TARGET} + +options.c: optionlist + LC_ALL=C awk -f ${GCCDIR}/opt-functions.awk \ + -f ${GCCDIR}/optc-gen.awk \ + -v header_name="config.h system.h coretypes.h tm.h" \ + < ${.ALLSRC} > ${.TARGET} + +# Target machine config +tm.h: + TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ + HEADERS="${TARGET_INC}" \ + DEFINES="" \ + /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} +.if exists(${GCCDIR}/config/${GCC_CPU}/${GCC_CPU}-modes.def) + echo '#define EXTRA_MODES_FILE "${GCC_CPU}/${GCC_CPU}-modes.def"' >> ${.TARGET} +.endif + +# tconfig.h +tconfig.h: + TARGET_CPU_DEFAULT="${TARGET_CPU_DEFAULT}" \ + HEADERS="auto-host.h ansidecl.h" \ + DEFINES="USED_FOR_TARGET" \ + /bin/sh ${GCCDIR}/mkconfig.sh ${.TARGET} + +# Version header for gcov +gcov-iov.h: + echo "#define GCOV_VERSION ((gcov_unsigned_t)0x34303270)" >> ${.TARGET} + +# Linked headers +gthr-default.h: ${GCCDIR}/gthr-posix.h .NOMETA + ln -sf ${.ALLSRC} ${.TARGET} + +.if ${TARGET_CPUARCH} == "arm" +unwind.h: ${GCCDIR}/config/arm/unwind-arm.h +.else +unwind.h: ${GCCDIR}/unwind-generic.h +.endif + +unwind.h: .NOMETA + ln -sf ${.ALLSRC} ${.TARGET} + diff --git a/gnu/usr.bin/cc/cc_tools/arm.md.diff b/gnu/usr.bin/cc/cc_tools/arm.md.diff new file mode 100644 index 000000000000..f395b20ba223 --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/arm.md.diff @@ -0,0 +1,41 @@ +$FreeBSD$ +Index: arm.md +=================================================================== +RCS file: /cognet/ncvs/src/contrib/gcc/config/arm/arm.md,v +retrieving revision 1.1.1.7 +diff -u -p -r1.1.1.7 arm.md +--- arm.md 3 Jun 2005 03:28:42 -0000 1.1.1.7 ++++ arm.md 6 Nov 2006 02:44:36 -0000 +@@ -8840,7 +8840,7 @@ + val2 = INTVAL (XEXP (XEXP (operands[3], 0), 1)); + arith[0] = operands[0]; + arith[3] = operands[1]; +- if (val1 < val2) ++ if (val1 <= val2) + { + arith[1] = ldm[1]; + arith[2] = ldm[2]; +@@ -8870,7 +8870,7 @@ + else + output_asm_insn (\"ldm%?ia\\t%0, {%1, %2}\", ldm); + } +- else ++ else if (val2) + { + ldm[0] = XEXP (operands[2], 0); + if (val1 < val2) +@@ -8878,6 +8878,14 @@ + else + output_asm_insn (\"ldm%?da\\t%0, {%1, %2}\", ldm); + } ++ else { ++ ldm[0] = operands[0]; ++ ldm[1] = XEXP(operands[2], 0); ++ output_asm_insn(\"ldr\\t%0, [%1]\", ldm); ++ ldm[0] = operands[4]; ++ ldm[1] = XEXP(operands[3], 0); ++ output_asm_insn(\"ldr\\t%0, [%1]\", ldm); ++ } + output_asm_insn (\"%I3%?\\t%0, %1, %2\", arith); + return \"\"; + }" diff --git a/gnu/usr.bin/cc/cc_tools/auto-host.h b/gnu/usr.bin/cc/cc_tools/auto-host.h new file mode 100644 index 000000000000..7b72ea9117e3 --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/auto-host.h @@ -0,0 +1,1411 @@ +/* auto-host.h. Generated by configure. */ +/* config.in. Generated from configure.ac by autoheader. */ +/* $FreeBSD$ */ + +/* Define as the number of bits in a byte, if \`limits.h' doesn't. */ +#ifndef USED_FOR_TARGET +/* #undef CHAR_BIT */ +#endif + + +/* Define 0/1 to force the choice for exception handling model. */ +#ifndef USED_FOR_TARGET +/* #undef CONFIG_SJLJ_EXCEPTIONS */ +#endif + + +/* Define to enable the use of a default assembler. */ +#ifndef USED_FOR_TARGET +/* #undef DEFAULT_ASSEMBLER */ +#endif + + +/* Define to enable the use of a default linker. */ +#ifndef USED_FOR_TARGET +/* #undef DEFAULT_LINKER */ +#endif + + +/* Define if you want to use __cxa_atexit, rather than atexit, to register C++ + destructors for local statics and global objects. This is essential for + fully standards-compliant handling of destructors, but requires + __cxa_atexit in libc. */ +#ifndef USED_FOR_TARGET +#define DEFAULT_USE_CXA_ATEXIT 1 +#endif + + +/* Define if you want assertions enabled. This is a cheap check. */ +#ifndef USED_FOR_TARGET +#define ENABLE_ASSERT_CHECKING 1 +#endif + + +/* Define if you want more run-time sanity checks. This one gets a grab bag of + miscellaneous but relatively cheap checks. */ +#ifndef USED_FOR_TARGET +/* #undef ENABLE_CHECKING */ +#endif + + +/* Define to 1 to enable decimal float extension to C. */ +#ifndef USED_FOR_TARGET +#define ENABLE_DECIMAL_FLOAT 0 +#endif + + +/* Define if you want fold checked that it never destructs its argument. This + is quite expensive. */ +#ifndef USED_FOR_TARGET +/* #undef ENABLE_FOLD_CHECKING */ +#endif + + +/* Define if you want the garbage collector to operate in maximally paranoid + mode, validating the entire heap and collecting garbage at every + opportunity. This is extremely expensive. */ +#ifndef USED_FOR_TARGET +/* #undef ENABLE_GC_ALWAYS_COLLECT */ +#endif + + +/* Define if you want the garbage collector to do object poisoning and other + memory allocation checks. This is quite expensive. */ +#ifndef USED_FOR_TARGET +/* #undef ENABLE_GC_CHECKING */ +#endif + + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#ifndef USED_FOR_TARGET +/* #undef ENABLE_NLS */ +#endif + + +/* Define if you want all operations on RTL (the basic data structure of the + optimizer and back end) to be checked for dynamic type safety at runtime. + This is quite expensive. */ +#ifndef USED_FOR_TARGET +/* #undef ENABLE_RTL_CHECKING */ +#endif + + +/* Define if you want RTL flag accesses to be checked against the RTL codes + that are supported for each access macro. This is relatively cheap. */ +#ifndef USED_FOR_TARGET +/* #undef ENABLE_RTL_FLAG_CHECKING */ +#endif + + +/* Define if you want runtime assertions enabled. This is a cheap check. */ +#define ENABLE_RUNTIME_CHECKING 1 + +/* Define if you want all operations on trees (the basic data structure of the + front ends) to be checked for dynamic type safety at runtime. This is + moderately expensive. The tree browser debugging routines will also be + enabled by this option. */ +#ifndef USED_FOR_TARGET +/* #undef ENABLE_TREE_CHECKING */ +#endif + + +/* Define if you want to run subprograms and generated programs through + valgrind (a memory checker). This is extremely expensive. */ +#ifndef USED_FOR_TARGET +/* #undef ENABLE_VALGRIND_CHECKING */ +#endif + + +/* Define to 1 if installation paths should be looked up in the Windows + Registry. Ignored on non-Windows hosts. */ +#ifndef USED_FOR_TARGET +/* #undef ENABLE_WIN32_REGISTRY */ +#endif + + +/* Define to the name of a file containing a list of extra machine modes for + this architecture. */ +#ifndef USED_FOR_TARGET +/* #undef EXTRA_MODES_FILE */ +#endif + + +/* Define to enable detailed memory allocation stats gathering. */ +#ifndef USED_FOR_TARGET +/* #undef GATHER_STATISTICS */ +#endif + + +/* Define to the type of elements in the array set by `getgroups'. Usually + this is either `int' or `gid_t'. */ +#ifndef USED_FOR_TARGET +#define GETGROUPS_T gid_t +#endif + + +/* Define if the zone collector is in use */ +#ifndef USED_FOR_TARGET +/* #undef GGC_ZONE */ +#endif + + +/* mcontext_t fields start with __ */ +#ifndef USED_FOR_TARGET +/* #undef HAS_MCONTEXT_T_UNDERSCORES */ +#endif + + +/* Define to 1 if you have the `alphasort' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_ALPHASORT 1 +#endif + + +/* Define if your assembler supports dwarf2 .file/.loc directives, and + preserves file table indices exactly as given. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_DWARF2_DEBUG_LINE 1 +#endif + + +/* Define if your assembler supports explicit relocations. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_AS_EXPLICIT_RELOCS */ +#endif + + +/* Define if your assembler supports fprnd. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_AS_FPRND */ +#endif + + +/* Define if your assembler supports the --gdwarf2 option. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_GDWARF2_DEBUG_FLAG 1 +#endif + + +/* Define true if the assembler supports '.long foo@GOTOFF'. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_GOTOFF_IN_DATA 1 +#endif + + +/* Define if your assembler supports the --gstabs option. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_GSTABS_DEBUG_FLAG 1 +#endif + + +/* Define if your assembler supports the Sun syntax for cmov. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_AS_IX86_CMOV_SUN_SYNTAX */ +#endif + + +/* Define if your assembler supports the ffreep mnemonic. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_IX86_FFREEP 1 +#endif + + +/* Define if your assembler supports the lituse_jsrdirect relocation. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_AS_JSRDIRECT_RELOCS */ +#endif + + +/* Define if your assembler supports .sleb128 and .uleb128. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_LEB128 1 +#endif + + +/* Define if your assembler supports ltoffx and ldxmov relocations. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_LTOFFX_LDXMOV_RELOCS 1 +#endif + + +/* Define if your assembler supports mfcr field. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_MFCRF 1 +#endif + + +/* Define if your assembler supports the -no-mul-bug-abort option. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_AS_NO_MUL_BUG_ABORT_OPTION */ +#endif + + +/* Define if your assembler supports offsetable %lo(). */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_OFFSETABLE_LO10 1 +#endif + + +/* Define if your assembler supports popcntb field. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_AS_POPCNTB */ +#endif + + +/* Define if your assembler supports .register. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_REGISTER_PSEUDO_OP 1 +#endif + + +/* Define if your assembler supports R_PPC_REL16 relocs. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_REL16 +#endif + + +/* Define if your assembler supports -relax option. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_RELAX_OPTION 1 +#endif + + +/* Define if your assembler and linker support unaligned PC relative relocs. + */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_SPARC_UA_PCREL 1 +#endif + + +/* Define if your assembler and linker support unaligned PC relative relocs + against hidden symbols. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_SPARC_UA_PCREL_HIDDEN 1 +#endif + + +/* Define if your assembler supports thread-local storage. */ +#ifndef USED_FOR_TARGET +#define HAVE_AS_TLS 1 +#endif + + +/* Define to 1 if you have the `atoll' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_ATOLL 1 +#endif + + +/* Define to 1 if you have the `atoq' function. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_ATOQ */ +#endif + + +/* Define to 1 if you have the `clearerr_unlocked' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_CLEARERR_UNLOCKED 1 +#endif + + +/* Define to 1 if you have the `clock' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_CLOCK 1 +#endif + + +/* Define if <time.h> defines clock_t. */ +#ifndef USED_FOR_TARGET +#define HAVE_CLOCK_T 1 +#endif + + +/* Define 0/1 if your assembler and linker support COMDAT groups. */ +#ifndef USED_FOR_TARGET +#define HAVE_COMDAT_GROUP 1 +#endif + + +/* Define to 1 if we found a declaration for 'abort', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_ABORT 1 +#endif + + +/* Define to 1 if we found a declaration for 'asprintf', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_ASPRINTF 1 +#endif + + +/* Define to 1 if we found a declaration for 'atof', otherwise define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_ATOF 1 +#endif + + +/* Define to 1 if we found a declaration for 'atol', otherwise define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_ATOL 1 +#endif + + +/* Define to 1 if we found a declaration for 'basename', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_BASENAME 0 +#endif + + +/* Define to 1 if we found a declaration for 'calloc', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_CALLOC 1 +#endif + + +/* Define to 1 if we found a declaration for 'clearerr_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_CLEARERR_UNLOCKED 1 +#endif + + +/* Define to 1 if we found a declaration for 'clock', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_CLOCK 1 +#endif + + +/* Define to 1 if we found a declaration for 'errno', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_ERRNO 1 +#endif + + +/* Define to 1 if we found a declaration for 'feof_unlocked', otherwise define + to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FEOF_UNLOCKED 1 +#endif + + +/* Define to 1 if we found a declaration for 'ferror_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FERROR_UNLOCKED 1 +#endif + + +/* Define to 1 if we found a declaration for 'fflush_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FFLUSH_UNLOCKED 0 +#endif + + +/* Define to 1 if we found a declaration for 'fgetc_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FGETC_UNLOCKED 0 +#endif + + +/* Define to 1 if we found a declaration for 'fgets_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FGETS_UNLOCKED 0 +#endif + + +/* Define to 1 if we found a declaration for 'fileno_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FILENO_UNLOCKED 1 +#endif + + +/* Define to 1 if we found a declaration for 'fprintf_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FPRINTF_UNLOCKED 0 +#endif + + +/* Define to 1 if we found a declaration for 'fputc_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FPUTC_UNLOCKED 0 +#endif + + +/* Define to 1 if we found a declaration for 'fputs_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FPUTS_UNLOCKED 0 +#endif + + +/* Define to 1 if we found a declaration for 'fread_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FREAD_UNLOCKED 0 +#endif + + +/* Define to 1 if we found a declaration for 'free', otherwise define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FREE 1 +#endif + + +/* Define to 1 if we found a declaration for 'fwrite_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_FWRITE_UNLOCKED 0 +#endif + + +/* Define to 1 if we found a declaration for 'getchar_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_GETCHAR_UNLOCKED 1 +#endif + + +/* Define to 1 if we found a declaration for 'getcwd', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_GETCWD 1 +#endif + + +/* Define to 1 if we found a declaration for 'getc_unlocked', otherwise define + to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_GETC_UNLOCKED 1 +#endif + + +/* Define to 1 if we found a declaration for 'getenv', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_GETENV 1 +#endif + + +/* Define to 1 if we found a declaration for 'getopt', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_GETOPT 1 +#endif + + +/* Define to 1 if we found a declaration for 'getpagesize', otherwise define + to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_GETPAGESIZE 1 +#endif + + +/* Define to 1 if we found a declaration for 'getrlimit', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_GETRLIMIT 1 +#endif + + +/* Define to 1 if we found a declaration for 'getrusage', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_GETRUSAGE 1 +#endif + + +/* Define to 1 if we found a declaration for 'getwd', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_GETWD 1 +#endif + + +/* Define to 1 if we found a declaration for 'ldgetname', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_LDGETNAME 0 +#endif + + +/* Define to 1 if we found a declaration for 'malloc', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_MALLOC 1 +#endif + + +/* Define to 1 if we found a declaration for 'putchar_unlocked', otherwise + define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_PUTCHAR_UNLOCKED 1 +#endif + + +/* Define to 1 if we found a declaration for 'putc_unlocked', otherwise define + to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_PUTC_UNLOCKED 1 +#endif + + +/* Define to 1 if we found a declaration for 'realloc', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_REALLOC 1 +#endif + + +/* Define to 1 if we found a declaration for 'sbrk', otherwise define to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_SBRK 1 +#endif + + +/* Define to 1 if we found a declaration for 'setrlimit', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_SETRLIMIT 1 +#endif + + +/* Define to 1 if we found a declaration for 'sigaltstack', otherwise define + to 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_SIGALTSTACK 1 +#endif + + +/* Define to 1 if we found a declaration for 'snprintf', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_SNPRINTF 1 +#endif + + +/* Define to 1 if we found a declaration for 'strsignal', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_STRSIGNAL 1 +#endif + + +/* Define to 1 if we found a declaration for 'strstr', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_STRSTR 1 +#endif + + +/* Define to 1 if we found a declaration for 'strverscmp', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_STRVERSCMP 0 +#endif + + +/* Define to 1 if we found a declaration for 'times', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_TIMES 1 +#endif + + +/* Define to 1 if we found a declaration for 'vasprintf', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_VASPRINTF 1 +#endif + + +/* Define to 1 if we found a declaration for 'vsnprintf', otherwise define to + 0. */ +#ifndef USED_FOR_TARGET +#define HAVE_DECL_VSNPRINTF 1 +#endif + + +/* Define to 1 if you have the <direct.h> header file. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_DIRECT_H */ +#endif + + +/* Define to 1 if you have the <fcntl.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_FCNTL_H 1 +#endif + + +/* Define to 1 if you have the `feof_unlocked' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_FEOF_UNLOCKED 1 +#endif + + +/* Define to 1 if you have the `ferror_unlocked' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_FERROR_UNLOCKED 1 +#endif + + +/* Define to 1 if you have the `fflush_unlocked' function. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_FFLUSH_UNLOCKED */ +#endif + + +/* Define to 1 if you have the `fgetc_unlocked' function. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_FGETC_UNLOCKED */ +#endif + + +/* Define to 1 if you have the `fgets_unlocked' function. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_FGETS_UNLOCKED */ +#endif + + +/* Define to 1 if you have the `fileno_unlocked' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_FILENO_UNLOCKED 1 +#endif + + +/* Define to 1 if you have the `fork' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_FORK 1 +#endif + + +/* Define to 1 if you have the `fprintf_unlocked' function. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_FPRINTF_UNLOCKED */ +#endif + + +/* Define to 1 if you have the `fputc_unlocked' function. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_FPUTC_UNLOCKED */ +#endif + + +/* Define to 1 if you have the `fputs_unlocked' function. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_FPUTS_UNLOCKED */ +#endif + + +/* Define to 1 if you have the `fread_unlocked' function. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_FREAD_UNLOCKED */ +#endif + + +/* Define to 1 if you have the `fwrite_unlocked' function. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_FWRITE_UNLOCKED */ +#endif + + +/* Define if your assembler supports .balign and .p2align. */ +#ifndef USED_FOR_TARGET +#define HAVE_GAS_BALIGN_AND_P2ALIGN 1 +#endif + + +/* Define if your assembler uses the new HImode fild and fist notation. */ +#ifndef USED_FOR_TARGET +#define HAVE_GAS_FILDS_FISTS 1 +#endif + + +/* Define if your assembler and linker support .hidden. */ +#define HAVE_GAS_HIDDEN 1 + +/* Define if your assembler supports specifying the maximum number of bytes to + skip when using the GAS .p2align command. */ +#ifndef USED_FOR_TARGET +#define HAVE_GAS_MAX_SKIP_P2ALIGN 1 +#endif + + +/* Define if your assembler supports .nsubspa comdat option. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_GAS_NSUBSPA_COMDAT */ +#endif + + +/* Define if your assembler and linker support 32-bit section relative relocs + via '.secrel32 label'. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_GAS_PE_SECREL32_RELOC */ +#endif + + +/* Define 0/1 if your assembler supports marking sections with SHF_MERGE flag. + */ +#ifndef USED_FOR_TARGET +#define HAVE_GAS_SHF_MERGE 1 +#endif + + +/* Define if your assembler supports .subsection and .subsection -1 starts + emitting at the beginning of your section. */ +#ifndef USED_FOR_TARGET +#define HAVE_GAS_SUBSECTION_ORDERING 1 +#endif + + +/* Define if your assembler supports .weak. */ +#ifndef USED_FOR_TARGET +#define HAVE_GAS_WEAK 1 +#endif + + +/* Define if your assembler supports .weakref. */ +#ifndef USED_FOR_TARGET +#define HAVE_GAS_WEAKREF 1 +#endif + + +/* Define to 1 if you have the `getchar_unlocked' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_GETCHAR_UNLOCKED 1 +#endif + + +/* Define to 1 if you have the `getc_unlocked' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_GETC_UNLOCKED 1 +#endif + + +/* Define to 1 if system unwind library has _Unwind_GetIPInfo. */ +#define HAVE_GETIPINFO 1 + +/* Define to 1 if you have the `getrlimit' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_GETRLIMIT 1 +#endif + + +/* Define to 1 if you have the `getrusage' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_GETRUSAGE 1 +#endif + + +/* Define to 1 if you have the `gettimeofday' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_GETTIMEOFDAY 1 +#endif + + +/* Define if you have the iconv() function. */ +#ifndef USED_FOR_TARGET +#define HAVE_ICONV 1 +#endif + + +/* Define to 1 if you have the <iconv.h> header file. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_ICONV_H */ +#endif + + +/* Define .init_array/.fini_array sections are available and working. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_INITFINI_ARRAY */ +#endif + + +/* Define if you have a working <inttypes.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_INTTYPES_H 1 +#endif + + +/* Define to 1 if you have the `kill' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_KILL 1 +#endif + + +/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */ +#ifndef USED_FOR_TARGET +#define HAVE_LANGINFO_CODESET 1 +#endif + + +/* Define to 1 if you have the <langinfo.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_LANGINFO_H 1 +#endif + + +/* Define if your <locale.h> file defines LC_MESSAGES. */ +#ifndef USED_FOR_TARGET +#define HAVE_LC_MESSAGES 1 +#endif + + +/* Define to 1 if you have the <ldfcn.h> header file. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_LDFCN_H */ +#endif + + +/* Define if your linker supports --as-needed and --no-as-needed options. */ +#ifndef USED_FOR_TARGET +#define HAVE_LD_AS_NEEDED 1 +#endif + + +/* Define if your linker supports --demangle option. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_LD_DEMANGLE */ +#endif + + +/* Define if your linker supports --eh-frame-hdr option. */ +#define HAVE_LD_EH_FRAME_HDR 1 + +/* Define if your PowerPC64 linker only needs function descriptor syms. */ +#ifndef USED_FOR_TARGET +#define HAVE_LD_NO_DOT_SYMS 1 +#endif + + +/* Define if your linker supports -pie option. */ +#ifndef USED_FOR_TARGET +#define HAVE_LD_PIE 1 +#endif + + +/* Define if your linker links a mix of read-only and read-write sections into + a read-write section. */ +#ifndef USED_FOR_TARGET +#define HAVE_LD_RO_RW_SECTION_MIXING 1 +#endif + + +/* Define if your linker supports -Bstatic/-Bdynamic option. */ +#ifndef USED_FOR_TARGET +#define HAVE_LD_STATIC_DYNAMIC 1 +#endif + + +/* Define if your linker supports --sysroot. */ +#ifndef USED_FOR_TARGET +#define HAVE_LD_SYSROOT 1 +#endif + + +/* Define to 1 if you have the <limits.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_LIMITS_H 1 +#endif + + +/* Define to 1 if you have the <locale.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_LOCALE_H 1 +#endif + + +/* Define to 1 if the system has the type `long long'. */ +#ifndef USED_FOR_TARGET +#define HAVE_LONG_LONG 1 +#endif + + +/* Define to 1 if you have the <malloc.h> header file. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_MALLOC_H */ +#endif + + +/* Define to 1 if you have the `mbstowcs' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_MBSTOWCS 1 +#endif + + +/* Define if valgrind's memcheck.h header is installed. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_MEMCHECK_H */ +#endif + + +/* Define to 1 if you have the <memory.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_MEMORY_H 1 +#endif + + +/* Define to 1 if you have the `mincore' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_MINCORE 1 +#endif + + +/* Define to 1 if you have the `mmap' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_MMAP 1 +#endif + + +/* Define if mmap with MAP_ANON(YMOUS) works. */ +#ifndef USED_FOR_TARGET +#define HAVE_MMAP_ANON 1 +#endif + + +/* Define if mmap of /dev/zero works. */ +#ifndef USED_FOR_TARGET +#define HAVE_MMAP_DEV_ZERO 1 +#endif + + +/* Define if read-only mmap of a plain file works. */ +#ifndef USED_FOR_TARGET +#define HAVE_MMAP_FILE 1 +#endif + + +/* Define to 1 if you have the `nl_langinfo' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_NL_LANGINFO 1 +#endif + + +/* Define to 1 if you have the `putchar_unlocked' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_PUTCHAR_UNLOCKED 1 +#endif + + +/* Define to 1 if you have the `putc_unlocked' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_PUTC_UNLOCKED 1 +#endif + + +/* Define to 1 if you have the `scandir' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_SCANDIR 1 +#endif + + +/* Define to 1 if you have the `setlocale' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_SETLOCALE 1 +#endif + + +/* Define to 1 if you have the `setrlimit' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_SETRLIMIT 1 +#endif + + +/* Define to 1 if you have the <stddef.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_STDDEF_H 1 +#endif + + +/* Define to 1 if you have the <stdint.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_STDINT_H 1 +#endif + + +/* Define to 1 if you have the <stdlib.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_STDLIB_H 1 +#endif + + +/* Define to 1 if you have the <strings.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_STRINGS_H 1 +#endif + + +/* Define to 1 if you have the <string.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_STRING_H 1 +#endif + + +/* Define to 1 if you have the `strsignal' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_STRSIGNAL 1 +#endif + + +/* Define if <sys/times.h> defines struct tms. */ +#ifndef USED_FOR_TARGET +#define HAVE_STRUCT_TMS 1 +#endif + + +/* Define to 1 if you have the `sysconf' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_SYSCONF 1 +#endif + + +/* Define to 1 if you have the <sys/file.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_SYS_FILE_H 1 +#endif + + +/* Define to 1 if you have the <sys/mman.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_SYS_MMAN_H 1 +#endif + + +/* Define to 1 if you have the <sys/param.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_SYS_PARAM_H 1 +#endif + + +/* Define to 1 if you have the <sys/resource.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_SYS_RESOURCE_H 1 +#endif + + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_SYS_STAT_H 1 +#endif + + +/* Define to 1 if you have the <sys/times.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_SYS_TIMES_H 1 +#endif + + +/* Define to 1 if you have the <sys/time.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_SYS_TIME_H 1 +#endif + + +/* Define to 1 if you have the <sys/types.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_SYS_TYPES_H 1 +#endif + + +/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */ +#ifndef USED_FOR_TARGET +#define HAVE_SYS_WAIT_H 1 +#endif + + +/* Define to 1 if you have the `times' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_TIMES 1 +#endif + + +/* Define to 1 if you have the <time.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_TIME_H 1 +#endif + + +/* Define to 1 if you have the <unistd.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_UNISTD_H 1 +#endif + + +/* Define if valgrind's valgrind/memcheck.h header is installed. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_VALGRIND_MEMCHECK_H */ +#endif + + +/* Define to 1 if you have the `vfork' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_VFORK 1 +#endif + + +/* Define to 1 if you have the <vfork.h> header file. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE_VFORK_H */ +#endif + + +/* Define to 1 if you have the <wchar.h> header file. */ +#ifndef USED_FOR_TARGET +#define HAVE_WCHAR_H 1 +#endif + + +/* Define to 1 if you have the `wcswidth' function. */ +#ifndef USED_FOR_TARGET +#define HAVE_WCSWIDTH 1 +#endif + + +/* Define to 1 if `fork' works. */ +#ifndef USED_FOR_TARGET +#define HAVE_WORKING_FORK 1 +#endif + + +/* Define this macro if mbstowcs does not crash when its first argument is + NULL. */ +#ifndef USED_FOR_TARGET +#define HAVE_WORKING_MBSTOWCS 1 +#endif + + +/* Define to 1 if `vfork' works. */ +#ifndef USED_FOR_TARGET +#define HAVE_WORKING_VFORK 1 +#endif + + +/* Define to 1 if the system has the type `__int64'. */ +#ifndef USED_FOR_TARGET +/* #undef HAVE___INT64 */ +#endif + + +/* Define as const if the declaration of iconv() needs const. */ +#ifndef USED_FOR_TARGET +#define ICONV_CONST const +#endif + + +/* Define if host mkdir takes a single argument. */ +#ifndef USED_FOR_TARGET +/* #undef MKDIR_TAKES_ONE_ARG */ +#endif + + +/* Define to 1 if HOST_WIDE_INT must be 64 bits wide (see hwint.h). */ +#ifndef USED_FOR_TARGET +#define NEED_64BIT_HOST_WIDE_INT 1 +#endif + + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#ifndef USED_FOR_TARGET +/* #undef NO_MINUS_C_MINUS_O */ +#endif + + +/* Define to the address where bug reports for this package should be sent. */ +#ifndef USED_FOR_TARGET +#define PACKAGE_BUGREPORT "" +#endif + + +/* Define to the full name of this package. */ +#ifndef USED_FOR_TARGET +#define PACKAGE_NAME "" +#endif + + +/* Define to the full name and version of this package. */ +#ifndef USED_FOR_TARGET +#define PACKAGE_STRING "" +#endif + + +/* Define to the one symbol short name of this package. */ +#ifndef USED_FOR_TARGET +#define PACKAGE_TARNAME "" +#endif + + +/* Define to the version of this package. */ +#ifndef USED_FOR_TARGET +#define PACKAGE_VERSION "" +#endif + + +/* Define to PREFIX/include if cpp should also search that directory. */ +#ifndef USED_FOR_TARGET +/* #undef PREFIX_INCLUDE_DIR */ +#endif + + +/* The size of a `int', as computed by sizeof. */ +#ifndef USED_FOR_TARGET +#define SIZEOF_INT 4 +#endif + + +/* The size of a `long', as computed by sizeof. */ +#ifndef USED_FOR_TARGET +#define SIZEOF_LONG 4 +#endif + + +/* The size of a `long long', as computed by sizeof. */ +#ifndef USED_FOR_TARGET +#define SIZEOF_LONG_LONG 8 +#endif + + +/* The size of a `short', as computed by sizeof. */ +#ifndef USED_FOR_TARGET +#define SIZEOF_SHORT 2 +#endif + + +/* The size of a `void *', as computed by sizeof. */ +#ifndef USED_FOR_TARGET +#define SIZEOF_VOID_P 4 +#endif + + +/* The size of a `__int64', as computed by sizeof. */ +#ifndef USED_FOR_TARGET +/* #undef SIZEOF___INT64 */ +#endif + + +/* Define to 1 if you have the ANSI C header files. */ +#ifndef USED_FOR_TARGET +#define STDC_HEADERS 1 +#endif + + +/* Define if you can safely include both <string.h> and <strings.h>. */ +#ifndef USED_FOR_TARGET +#define STRING_WITH_STRINGS 1 +#endif + + +/* Define if TFmode long double should be the default */ +#ifndef USED_FOR_TARGET +/* #undef TARGET_DEFAULT_LONG_DOUBLE_128 */ +#endif + + +/* Define if your target C library provides stack protector support */ +#ifndef USED_FOR_TARGET +#define TARGET_LIBC_PROVIDES_SSP 1 +#endif + + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#ifndef USED_FOR_TARGET +#define TIME_WITH_SYS_TIME 1 +#endif + + +/* Define if your assembler mis-optimizes .eh_frame data. */ +#ifndef USED_FOR_TARGET +/* #undef USE_AS_TRADITIONAL_FORMAT */ +#endif + + +/* Define to 1 if the 'long long' (or '__int64') is wider than 'long' but + still efficiently supported by the host hardware. */ +#ifndef USED_FOR_TARGET +/* #undef USE_LONG_LONG_FOR_WIDEST_FAST_INT */ +#endif + + +/* Define if location_t is fileline integer cookie. */ +#ifndef USED_FOR_TARGET +/* #undef USE_MAPPED_LOCATION */ +#endif + + +/* Define to be the last component of the Windows registry key under which to + look for installation paths. The full key used will be + HKEY_LOCAL_MACHINE/SOFTWARE/Free Software Foundation/{WIN32_REGISTRY_KEY}. + The default is the GCC version number. */ +#ifndef USED_FOR_TARGET +/* #undef WIN32_REGISTRY_KEY */ +#endif + + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#ifndef USED_FOR_TARGET +/* #undef WORDS_BIGENDIAN */ +#endif + + +/* Always define this when using the GNU C Library */ +#ifndef USED_FOR_TARGET +/* #undef _GNU_SOURCE */ +#endif + + +/* Define to `int' if <sys/types.h> doesn't define. */ +#ifndef USED_FOR_TARGET +/* #undef gid_t */ +#endif + + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `int' if <sys/types.h> does not define. */ +#ifndef USED_FOR_TARGET +/* #undef pid_t */ +#endif + + +/* Define to \`long' if <sys/resource.h> doesn't define. */ +#ifndef USED_FOR_TARGET +/* #undef rlim_t */ +#endif + + +/* Define to `int' if <sys/types.h> does not define. */ +#ifndef USED_FOR_TARGET +/* #undef ssize_t */ +#endif + + +/* Define to `int' if <sys/types.h> doesn't define. */ +#ifndef USED_FOR_TARGET +/* #undef uid_t */ +#endif + + +/* Define as `fork' if `vfork' does not work. */ +#ifndef USED_FOR_TARGET +/* #undef vfork */ +#endif + +/* Override SIZEOF_?? using proper values. */ +#include <size-host.h> diff --git a/gnu/usr.bin/cc/cc_tools/elfos-undef.h b/gnu/usr.bin/cc/cc_tools/elfos-undef.h new file mode 100644 index 000000000000..e889865e838a --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/elfos-undef.h @@ -0,0 +1,9 @@ +/* $FreeBSD$ */ + +/* This header exists to avoid editing contrib/gcc/config/elfos.h - which + isn't coded to be defensive as it should... */ + +#undef ASM_DECLARE_OBJECT_NAME +#undef ASM_OUTPUT_IDENT +#undef IDENT_ASM_OP +#undef READONLY_DATA_SECTION_ASM_OP diff --git a/gnu/usr.bin/cc/cc_tools/freebsd-native.h b/gnu/usr.bin/cc/cc_tools/freebsd-native.h new file mode 100644 index 000000000000..375c62f4aa28 --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/freebsd-native.h @@ -0,0 +1,60 @@ +/* $FreeBSD$ */ + +/* FREEBSD_NATIVE is defined when gcc is integrated into the FreeBSD + source tree so it can be configured appropriately without using + the GNU configure/build mechanism. */ + +#define FREEBSD_NATIVE 1 + +/* Fake out gcc/config/freebsd<version>.h. */ +#define FBSD_MAJOR 13 +#define FBSD_CC_VER 1300000 /* form like __FreeBSD_version */ + +#undef SYSTEM_INCLUDE_DIR /* We don't need one for now. */ +#undef TOOL_INCLUDE_DIR /* We don't need one for now. */ +#undef LOCAL_INCLUDE_DIR /* We don't wish to support one. */ + +/* Look for the include files in the system-defined places. */ +#define GPLUSPLUS_INCLUDE_DIR "/usr/include/c++/"GCCVER +#define GPLUSPLUS_BACKWARD_INCLUDE_DIR "/usr/include/c++/"GCCVER"/backward" +#define GCC_INCLUDE_DIR PREFIX"/include/gcc/"GCCVER +#define STANDARD_INCLUDE_DIR "/usr/include" + +/* Under FreeBSD, the normal location of the compiler back ends is the + /usr/libexec directory. + + ``cc --print-search-dirs'' gives: + install: STANDARD_EXEC_PREFIX/ + programs: STANDARD_EXEC_PREFIX:MD_EXEC_PREFIX + libraries: STANDARD_STARTFILE_PREFIX +*/ +#undef STANDARD_BINDIR_PREFIX /* We don't need one for now. */ +#define STANDARD_EXEC_PREFIX PREFIX"/libexec/" +#define STANDARD_LIBEXEC_PREFIX PREFIX"/libexec/" +#define TOOLDIR_BASE_PREFIX PREFIX +#undef MD_EXEC_PREFIX /* We don't want one. */ +#define FBSD_DATA_PREFIX PREFIX"/libdata/gcc/" + +/* Under FreeBSD, the normal location of the various *crt*.o files is the + /usr/lib directory. */ + +#undef MD_STARTFILE_PREFIX /* We don't need one for now. */ +#define STANDARD_STARTFILE_PREFIX "/usr/lib/" +#define STARTFILE_PREFIX_SPEC "/usr/lib/" + +#if 0 +#define LIBGCC_SPEC "%{shared: -lgcc_pic} \ + %{!shared: %{!pg: -lgcc} %{pg: -lgcc_p}}" +#endif +#define LIBSTDCXX_PROFILE "-lstdc++_p" +#define MATH_LIBRARY_PROFILE "-lm_p" +#define FORTRAN_LIBRARY_PROFILE "-lg2c_p" + +#define LIBGCC_SPEC "-lgcc" +/* For the native system compiler, we actually build libgcc in a profiled + version. So we should use it with -pg. */ +#define LIBGCC_STATIC_LIB_SPEC "%{pg: -lgcc_p;:-lgcc}" +#define LIBGCC_EH_STATIC_LIB_SPEC "%{pg: -lgcc_eh_p;:-lgcc_eh}" + +/* FreeBSD is 4.4BSD derived */ +#define bsd4_4 diff --git a/gnu/usr.bin/cc/cc_tools/freebsd.opt b/gnu/usr.bin/cc/cc_tools/freebsd.opt new file mode 100644 index 000000000000..f71a5058b9ec --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/freebsd.opt @@ -0,0 +1,6 @@ +; $FreeBSD$ + +fformat-extensions +Common Report Var(flag_format_extensions) Init(0) +Allow FreeBSD kernel-specific printf format specifiers. + diff --git a/gnu/usr.bin/cc/cc_tools/i386-freebsd.opt b/gnu/usr.bin/cc/cc_tools/i386-freebsd.opt new file mode 100644 index 000000000000..ca71a8bb5685 --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/i386-freebsd.opt @@ -0,0 +1,13 @@ +; $FreeBSD$ + +mno-align-long-strings +Target RejectNegative Report Mask(NO_ALIGN_LONG_STRINGS) +Do not align long strings specially + +malign-long-strings +Target RejectNegative Report InverseMask(NO_ALIGN_LONG_STRINGS, ALIGN_LONG_STRINGS) Undocumented + +mprofiler-epilogue +Target Report Mask(PROFILER_EPILOGUE) +Function profiler epilogue + diff --git a/gnu/usr.bin/cc/cc_tools/size-host.h b/gnu/usr.bin/cc/cc_tools/size-host.h new file mode 100644 index 000000000000..8d5136f65419 --- /dev/null +++ b/gnu/usr.bin/cc/cc_tools/size-host.h @@ -0,0 +1,47 @@ +/* $FreeBSD$ */ + +#ifdef SIZEOF_INT +# undef SIZEOF_INT +#endif + +#ifdef SIZEOF_SHORT +# undef SIZEOF_SHORT +#endif + +#ifdef SIZEOF_LONG +# undef SIZEOF_LONG +#endif + +#ifdef SIZEOF_VOID_P +# undef SIZEOF_VOID_P +#endif + +#ifdef SIZEOF_LONG_LONG +# undef SIZEOF_LONG_LONG +#endif + +#ifdef HOST_WIDE_INT +# undef HOST_WIDE_INT +#endif + +#define SIZEOF_INT 4 +#define SIZEOF_SHORT 2 +#define SIZEOF_LONG_LONG 8 + +#if __LP64__ +#define SIZEOF_LONG 8 +#define SIZEOF_VOID_P 8 +#define HOST_WIDE_INT long +#else +#define SIZEOF_LONG 4 +#define SIZEOF_VOID_P 4 +#define HOST_WIDE_INT long long +#endif + +#ifdef WORDS_BIGENDIAN +#undef WORDS_BIGENDIAN +#endif + +#if defined(__sparc64__) || defined(__ARMEB__) +#define WORDS_BIGENDIAN 1 +#endif diff --git a/gnu/usr.bin/cc/cpp/Makefile b/gnu/usr.bin/cc/cpp/Makefile new file mode 100644 index 000000000000..a3ac04b909e3 --- /dev/null +++ b/gnu/usr.bin/cc/cpp/Makefile @@ -0,0 +1,16 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +.include "../Makefile.inc" +.include "../Makefile.fe" + +PROG= gcpp +SRCS+= cppspec.c + +.if ${MK_CLANG_IS_CC} == "no" +LINKS= ${BINDIR}/gcpp ${BINDIR}/cpp +MLINKS= gcpp.1 cpp.1 +.endif + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/cc/cpp/Makefile.depend b/gnu/usr.bin/cc/cpp/Makefile.depend new file mode 100644 index 000000000000..2bea3c0fa889 --- /dev/null +++ b/gnu/usr.bin/cc/cpp/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/usr.bin/cc/cc_tools \ + gnu/usr.bin/cc/libcpp \ + gnu/usr.bin/cc/libiberty \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/cpp/gcpp.1 b/gnu/usr.bin/cc/cpp/gcpp.1 new file mode 100644 index 000000000000..3a1bc366c220 --- /dev/null +++ b/gnu/usr.bin/cc/cpp/gcpp.1 @@ -0,0 +1,929 @@ +.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14 +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sh \" Subsection heading +.br +.if t .Sp +.ne 5 +.PP +\fB\\$1\fR +.PP +.. +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. | will give a +.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to +.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' +.\" expand to `' in nroff, nothing in troff, for use with C<>. +.tr \(*W-|\(bv\*(Tr +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +'br\} +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.\" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.hy 0 +.if n .na +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "CPP 1" +.TH CPP 1 "2007-07-19" "gcc-4.2.1" "GNU" +.SH "NAME" +cpp \- The C Preprocessor +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +cpp [\fB\-D\fR\fImacro\fR[=\fIdefn\fR]...] [\fB\-U\fR\fImacro\fR] + [\fB\-I\fR\fIdir\fR...] [\fB\-iquote\fR\fIdir\fR...] + [\fB\-W\fR\fIwarn\fR...] + [\fB\-M\fR|\fB\-MM\fR] [\fB\-MG\fR] [\fB\-MF\fR \fIfilename\fR] + [\fB\-MP\fR] [\fB\-MQ\fR \fItarget\fR...] + [\fB\-MT\fR \fItarget\fR...] + [\fB\-P\fR] [\fB\-fno\-working\-directory\fR] + [\fB\-x\fR \fIlanguage\fR] [\fB\-std=\fR\fIstandard\fR] + \fIinfile\fR \fIoutfile\fR +.PP +Only the most useful options are listed here; see below for the remainder. +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +The C preprocessor, often known as \fIcpp\fR, is a \fImacro processor\fR +that is used automatically by the C compiler to transform your program +before compilation. It is called a macro processor because it allows +you to define \fImacros\fR, which are brief abbreviations for longer +constructs. +.PP +The C preprocessor is intended to be used only with C and \*(C+ source +code. In the past, it has been abused as a general text processor. It +will choke on input which does not obey C's lexical rules. For +example, apostrophes will be interpreted as the beginning of character +constants, and cause errors. Also, you cannot rely on it preserving +characteristics of the input which are not significant to C\-family +languages. If a Makefile is preprocessed, all the hard tabs will be +removed, and the Makefile will not work. +.PP +Having said that, you can often get away with using cpp on things which +are not C. Other Algol-ish programming languages are often safe +(Pascal, Ada, etc.) So is assembly, with caution. \fB\-traditional\-cpp\fR +mode preserves more white space, and is otherwise more permissive. Many +of the problems can be avoided by writing C or \*(C+ style comments +instead of native language comments, and keeping macros simple. +.PP +Wherever possible, you should use a preprocessor geared to the language +you are writing in. Modern versions of the \s-1GNU\s0 assembler have macro +facilities. Most high level programming languages have their own +conditional compilation and inclusion mechanism. If all else fails, +try a true general text processor, such as \s-1GNU\s0 M4. +.PP +C preprocessors vary in some details. This manual discusses the \s-1GNU\s0 C +preprocessor, which provides a small superset of the features of \s-1ISO\s0 +Standard C. In its default mode, the \s-1GNU\s0 C preprocessor does not do a +few things required by the standard. These are features which are +rarely, if ever, used, and may cause surprising changes to the meaning +of a program which does not expect them. To get strict \s-1ISO\s0 Standard C, +you should use the \fB\-std=c89\fR or \fB\-std=c99\fR options, depending +on which version of the standard you want. To get all the mandatory +diagnostics, you must also use \fB\-pedantic\fR. +.PP +This manual describes the behavior of the \s-1ISO\s0 preprocessor. To +minimize gratuitous differences, where the \s-1ISO\s0 preprocessor's +behavior does not conflict with traditional semantics, the +traditional preprocessor should behave the same way. The various +differences that do exist are detailed in the section \fBTraditional +Mode\fR. +.PP +For clarity, unless noted otherwise, references to \fB\s-1CPP\s0\fR in this +manual refer to \s-1GNU\s0 \s-1CPP\s0. +.SH "OPTIONS" +.IX Header "OPTIONS" +The C preprocessor expects two file names as arguments, \fIinfile\fR and +\&\fIoutfile\fR. The preprocessor reads \fIinfile\fR together with any +other files it specifies with \fB#include\fR. All the output generated +by the combined input files is written in \fIoutfile\fR. +.PP +Either \fIinfile\fR or \fIoutfile\fR may be \fB\-\fR, which as +\&\fIinfile\fR means to read from standard input and as \fIoutfile\fR +means to write to standard output. Also, if either file is omitted, it +means the same as if \fB\-\fR had been specified for that file. +.PP +Unless otherwise noted, or the option ends in \fB=\fR, all options +which take an argument may have that argument appear either immediately +after the option, or with a space between option and argument: +\&\fB\-Ifoo\fR and \fB\-I foo\fR have the same effect. +.PP +Many options have multi-letter names; therefore multiple single-letter +options may \fInot\fR be grouped: \fB\-dM\fR is very different from +\&\fB\-d\ \-M\fR. +.IP "\fB\-D\fR \fIname\fR" 4 +.IX Item "-D name" +Predefine \fIname\fR as a macro, with definition \f(CW1\fR. +.IP "\fB\-D\fR \fIname\fR\fB=\fR\fIdefinition\fR" 4 +.IX Item "-D name=definition" +The contents of \fIdefinition\fR are tokenized and processed as if +they appeared during translation phase three in a \fB#define\fR +directive. In particular, the definition will be truncated by +embedded newline characters. +.Sp +If you are invoking the preprocessor from a shell or shell-like +program you may need to use the shell's quoting syntax to protect +characters such as spaces that have a meaning in the shell syntax. +.Sp +If you wish to define a function-like macro on the command line, write +its argument list with surrounding parentheses before the equals sign +(if any). Parentheses are meaningful to most shells, so you will need +to quote the option. With \fBsh\fR and \fBcsh\fR, +\&\fB\-D'\fR\fIname\fR\fB(\fR\fIargs...\fR\fB)=\fR\fIdefinition\fR\fB'\fR works. +.Sp +\&\fB\-D\fR and \fB\-U\fR options are processed in the order they +are given on the command line. All \fB\-imacros\fR \fIfile\fR and +\&\fB\-include\fR \fIfile\fR options are processed after all +\&\fB\-D\fR and \fB\-U\fR options. +.IP "\fB\-U\fR \fIname\fR" 4 +.IX Item "-U name" +Cancel any previous definition of \fIname\fR, either built in or +provided with a \fB\-D\fR option. +.IP "\fB\-undef\fR" 4 +.IX Item "-undef" +Do not predefine any system-specific or GCC-specific macros. The +standard predefined macros remain defined. +.IP "\fB\-I\fR \fIdir\fR" 4 +.IX Item "-I dir" +Add the directory \fIdir\fR to the list of directories to be searched +for header files. +.Sp +Directories named by \fB\-I\fR are searched before the standard +system include directories. If the directory \fIdir\fR is a standard +system include directory, the option is ignored to ensure that the +default search order for system directories and the special treatment +of system headers are not defeated +\&. +.IP "\fB\-o\fR \fIfile\fR" 4 +.IX Item "-o file" +Write output to \fIfile\fR. This is the same as specifying \fIfile\fR +as the second non-option argument to \fBcpp\fR. \fBgcc\fR has a +different interpretation of a second non-option argument, so you must +use \fB\-o\fR to specify the output file. +.IP "\fB\-Wall\fR" 4 +.IX Item "-Wall" +Turns on all optional warnings which are desirable for normal code. +At present this is \fB\-Wcomment\fR, \fB\-Wtrigraphs\fR, +\&\fB\-Wmultichar\fR and a warning about integer promotion causing a +change of sign in \f(CW\*(C`#if\*(C'\fR expressions. Note that many of the +preprocessor's warnings are on by default and have no options to +control them. +.IP "\fB\-Wcomment\fR" 4 +.IX Item "-Wcomment" +.PD 0 +.IP "\fB\-Wcomments\fR" 4 +.IX Item "-Wcomments" +.PD +Warn whenever a comment-start sequence \fB/*\fR appears in a \fB/*\fR +comment, or whenever a backslash-newline appears in a \fB//\fR comment. +(Both forms have the same effect.) +.IP "\fB\-Wtrigraphs\fR" 4 +.IX Item "-Wtrigraphs" +Most trigraphs in comments cannot affect the meaning of the program. +However, a trigraph that would form an escaped newline (\fB??/\fR at +the end of a line) can, by changing where the comment begins or ends. +Therefore, only trigraphs that would form escaped newlines produce +warnings inside a comment. +.Sp +This option is implied by \fB\-Wall\fR. If \fB\-Wall\fR is not +given, this option is still enabled unless trigraphs are enabled. To +get trigraph conversion without warnings, but get the other +\&\fB\-Wall\fR warnings, use \fB\-trigraphs \-Wall \-Wno\-trigraphs\fR. +.IP "\fB\-Wtraditional\fR" 4 +.IX Item "-Wtraditional" +Warn about certain constructs that behave differently in traditional and +\&\s-1ISO\s0 C. Also warn about \s-1ISO\s0 C constructs that have no traditional C +equivalent, and problematic constructs which should be avoided. +.IP "\fB\-Wimport\fR" 4 +.IX Item "-Wimport" +Warn the first time \fB#import\fR is used. +.IP "\fB\-Wundef\fR" 4 +.IX Item "-Wundef" +Warn whenever an identifier which is not a macro is encountered in an +\&\fB#if\fR directive, outside of \fBdefined\fR. Such identifiers are +replaced with zero. +.IP "\fB\-Wunused\-macros\fR" 4 +.IX Item "-Wunused-macros" +Warn about macros defined in the main file that are unused. A macro +is \fIused\fR if it is expanded or tested for existence at least once. +The preprocessor will also warn if the macro has not been used at the +time it is redefined or undefined. +.Sp +Built-in macros, macros defined on the command line, and macros +defined in include files are not warned about. +.Sp +\&\fINote:\fR If a macro is actually used, but only used in skipped +conditional blocks, then \s-1CPP\s0 will report it as unused. To avoid the +warning in such a case, you might improve the scope of the macro's +definition by, for example, moving it into the first skipped block. +Alternatively, you could provide a dummy use with something like: +.Sp +.Vb 2 +\& #if defined the_macro_causing_the_warning +\& #endif +.Ve +.IP "\fB\-Wendif\-labels\fR" 4 +.IX Item "-Wendif-labels" +Warn whenever an \fB#else\fR or an \fB#endif\fR are followed by text. +This usually happens in code of the form +.Sp +.Vb 5 +\& #if FOO +\& ... +\& #else FOO +\& ... +\& #endif FOO +.Ve +.Sp +The second and third \f(CW\*(C`FOO\*(C'\fR should be in comments, but often are not +in older programs. This warning is on by default. +.IP "\fB\-Werror\fR" 4 +.IX Item "-Werror" +Make all warnings into hard errors. Source code which triggers warnings +will be rejected. +.IP "\fB\-Wsystem\-headers\fR" 4 +.IX Item "-Wsystem-headers" +Issue warnings for code in system headers. These are normally unhelpful +in finding bugs in your own code, therefore suppressed. If you are +responsible for the system library, you may want to see them. +.IP "\fB\-w\fR" 4 +.IX Item "-w" +Suppress all warnings, including those which \s-1GNU\s0 \s-1CPP\s0 issues by default. +.IP "\fB\-pedantic\fR" 4 +.IX Item "-pedantic" +Issue all the mandatory diagnostics listed in the C standard. Some of +them are left out by default, since they trigger frequently on harmless +code. +.IP "\fB\-pedantic\-errors\fR" 4 +.IX Item "-pedantic-errors" +Issue all the mandatory diagnostics, and make all mandatory diagnostics +into errors. This includes mandatory diagnostics that \s-1GCC\s0 issues +without \fB\-pedantic\fR but treats as warnings. +.IP "\fB\-M\fR" 4 +.IX Item "-M" +Instead of outputting the result of preprocessing, output a rule +suitable for \fBmake\fR describing the dependencies of the main +source file. The preprocessor outputs one \fBmake\fR rule containing +the object file name for that source file, a colon, and the names of all +the included files, including those coming from \fB\-include\fR or +\&\fB\-imacros\fR command line options. +.Sp +Unless specified explicitly (with \fB\-MT\fR or \fB\-MQ\fR), the +object file name consists of the basename of the source file with any +suffix replaced with object file suffix. If there are many included +files then the rule is split into several lines using \fB\e\fR\-newline. +The rule has no commands. +.Sp +This option does not suppress the preprocessor's debug output, such as +\&\fB\-dM\fR. To avoid mixing such debug output with the dependency +rules you should explicitly specify the dependency output file with +\&\fB\-MF\fR, or use an environment variable like +\&\fB\s-1DEPENDENCIES_OUTPUT\s0\fR. Debug output +will still be sent to the regular output stream as normal. +.Sp +Passing \fB\-M\fR to the driver implies \fB\-E\fR, and suppresses +warnings with an implicit \fB\-w\fR. +.IP "\fB\-MM\fR" 4 +.IX Item "-MM" +Like \fB\-M\fR but do not mention header files that are found in +system header directories, nor header files that are included, +directly or indirectly, from such a header. +.Sp +This implies that the choice of angle brackets or double quotes in an +\&\fB#include\fR directive does not in itself determine whether that +header will appear in \fB\-MM\fR dependency output. This is a +slight change in semantics from \s-1GCC\s0 versions 3.0 and earlier. +.IP "\fB\-MF\fR \fIfile\fR" 4 +.IX Item "-MF file" +When used with \fB\-M\fR or \fB\-MM\fR, specifies a +file to write the dependencies to. If no \fB\-MF\fR switch is given +the preprocessor sends the rules to the same place it would have sent +preprocessed output. +.Sp +When used with the driver options \fB\-MD\fR or \fB\-MMD\fR, +\&\fB\-MF\fR overrides the default dependency output file. +.IP "\fB\-MG\fR" 4 +.IX Item "-MG" +In conjunction with an option such as \fB\-M\fR requesting +dependency generation, \fB\-MG\fR assumes missing header files are +generated files and adds them to the dependency list without raising +an error. The dependency filename is taken directly from the +\&\f(CW\*(C`#include\*(C'\fR directive without prepending any path. \fB\-MG\fR +also suppresses preprocessed output, as a missing header file renders +this useless. +.Sp +This feature is used in automatic updating of makefiles. +.IP "\fB\-MP\fR" 4 +.IX Item "-MP" +This option instructs \s-1CPP\s0 to add a phony target for each dependency +other than the main file, causing each to depend on nothing. These +dummy rules work around errors \fBmake\fR gives if you remove header +files without updating the \fIMakefile\fR to match. +.Sp +This is typical output: +.Sp +.Vb 1 +\& test.o: test.c test.h +.Ve +.Sp +.Vb 1 +\& test.h: +.Ve +.IP "\fB\-MT\fR \fItarget\fR" 4 +.IX Item "-MT target" +Change the target of the rule emitted by dependency generation. By +default \s-1CPP\s0 takes the name of the main input file, including any path, +deletes any file suffix such as \fB.c\fR, and appends the platform's +usual object suffix. The result is the target. +.Sp +An \fB\-MT\fR option will set the target to be exactly the string you +specify. If you want multiple targets, you can specify them as a single +argument to \fB\-MT\fR, or use multiple \fB\-MT\fR options. +.Sp +For example, \fB\-MT\ '$(objpfx)foo.o'\fR might give +.Sp +.Vb 1 +\& $(objpfx)foo.o: foo.c +.Ve +.IP "\fB\-MQ\fR \fItarget\fR" 4 +.IX Item "-MQ target" +Same as \fB\-MT\fR, but it quotes any characters which are special to +Make. \fB\-MQ\ '$(objpfx)foo.o'\fR gives +.Sp +.Vb 1 +\& $$(objpfx)foo.o: foo.c +.Ve +.Sp +The default target is automatically quoted, as if it were given with +\&\fB\-MQ\fR. +.IP "\fB\-MD\fR" 4 +.IX Item "-MD" +\&\fB\-MD\fR is equivalent to \fB\-M \-MF\fR \fIfile\fR, except that +\&\fB\-E\fR is not implied. The driver determines \fIfile\fR based on +whether an \fB\-o\fR option is given. If it is, the driver uses its +argument but with a suffix of \fI.d\fR, otherwise it take the +basename of the input file and applies a \fI.d\fR suffix. +.Sp +If \fB\-MD\fR is used in conjunction with \fB\-E\fR, any +\&\fB\-o\fR switch is understood to specify the dependency output file, but if used without \fB\-E\fR, each \fB\-o\fR +is understood to specify a target object file. +.Sp +Since \fB\-E\fR is not implied, \fB\-MD\fR can be used to generate +a dependency output file as a side-effect of the compilation process. +.IP "\fB\-MMD\fR" 4 +.IX Item "-MMD" +Like \fB\-MD\fR except mention only user header files, not system +header files. +.IP "\fB\-x c\fR" 4 +.IX Item "-x c" +.PD 0 +.IP "\fB\-x c++\fR" 4 +.IX Item "-x c++" +.IP "\fB\-x assembler-with-cpp\fR" 4 +.IX Item "-x assembler-with-cpp" +.PD +Specify the source language: C, \*(C+, or assembly. This has nothing +to do with standards conformance or extensions; it merely selects which +base syntax to expect. If you give none of these options, cpp will +deduce the language from the extension of the source file: \&\fB.c\fR, +\fB.cc\fR, or \fB.S\fR. Some other common extensions for \*(C+ and +assembly are also recognized. If cpp does not recognize the extension, +it will treat the file as C; this is the most generic mode. +.Sp +\&\fINote:\fR Previous versions of cpp accepted a \fB\-lang\fR option +which selected both the language and the standards conformance level. +This option has been removed, because it conflicts with the \fB\-l\fR +option. +.IP "\fB\-std=\fR\fIstandard\fR" 4 +.IX Item "-std=standard" +.PD 0 +.IP "\fB\-ansi\fR" 4 +.IX Item "-ansi" +.PD +Specify the standard to which the code should conform. Currently \s-1CPP\s0 +knows about C and \*(C+ standards; others may be added in the future. +.Sp +\&\fIstandard\fR +may be one of: +.RS 4 +.ie n .IP """iso9899:1990""" 4 +.el .IP "\f(CWiso9899:1990\fR" 4 +.IX Item "iso9899:1990" +.PD 0 +.ie n .IP """c89""" 4 +.el .IP "\f(CWc89\fR" 4 +.IX Item "c89" +.PD +The \s-1ISO\s0 C standard from 1990. \fBc89\fR is the customary shorthand for +this version of the standard. +.Sp +The \fB\-ansi\fR option is equivalent to \fB\-std=c89\fR. +.ie n .IP """iso9899:199409""" 4 +.el .IP "\f(CWiso9899:199409\fR" 4 +.IX Item "iso9899:199409" +The 1990 C standard, as amended in 1994. +.ie n .IP """iso9899:1999""" 4 +.el .IP "\f(CWiso9899:1999\fR" 4 +.IX Item "iso9899:1999" +.PD 0 +.ie n .IP """c99""" 4 +.el .IP "\f(CWc99\fR" 4 +.IX Item "c99" +.ie n .IP """iso9899:199x""" 4 +.el .IP "\f(CWiso9899:199x\fR" 4 +.IX Item "iso9899:199x" +.ie n .IP """c9x""" 4 +.el .IP "\f(CWc9x\fR" 4 +.IX Item "c9x" +.PD +The revised \s-1ISO\s0 C standard, published in December 1999. Before +publication, this was known as C9X. +.ie n .IP """gnu89""" 4 +.el .IP "\f(CWgnu89\fR" 4 +.IX Item "gnu89" +The 1990 C standard plus \s-1GNU\s0 extensions. This is the default. +.ie n .IP """gnu99""" 4 +.el .IP "\f(CWgnu99\fR" 4 +.IX Item "gnu99" +.PD 0 +.ie n .IP """gnu9x""" 4 +.el .IP "\f(CWgnu9x\fR" 4 +.IX Item "gnu9x" +.PD +The 1999 C standard plus \s-1GNU\s0 extensions. +.ie n .IP """c++98""" 4 +.el .IP "\f(CWc++98\fR" 4 +.IX Item "c++98" +The 1998 \s-1ISO\s0 \*(C+ standard plus amendments. +.ie n .IP """gnu++98""" 4 +.el .IP "\f(CWgnu++98\fR" 4 +.IX Item "gnu++98" +The same as \fB\-std=c++98\fR plus \s-1GNU\s0 extensions. This is the +default for \*(C+ code. +.RE +.RS 4 +.RE +.IP "\fB\-I\-\fR" 4 +.IX Item "-I-" +Split the include path. Any directories specified with \fB\-I\fR +options before \fB\-I\-\fR are searched only for headers requested with +\&\f(CW\*(C`#include\ "\f(CIfile\f(CW"\*(C'\fR; they are not searched for +\&\f(CW\*(C`#include\ <\f(CIfile\f(CW>\*(C'\fR. If additional directories are +specified with \fB\-I\fR options after the \fB\-I\-\fR, those +directories are searched for all \fB#include\fR directives. +.Sp +In addition, \fB\-I\-\fR inhibits the use of the directory of the current +file directory as the first search directory for \f(CW\*(C`#include\ "\f(CIfile\f(CW"\*(C'\fR. +.Sp +This option has been deprecated. +.IP "\fB\-nostdinc\fR" 4 +.IX Item "-nostdinc" +Do not search the standard system directories for header files. +Only the directories you have specified with \fB\-I\fR options +(and the directory of the current file, if appropriate) are searched. +.IP "\fB\-nostdinc++\fR" 4 +.IX Item "-nostdinc++" +Do not search for header files in the \*(C+\-specific standard directories, +but do still search the other standard directories. (This option is +used when building the \*(C+ library.) +.IP "\fB\-include\fR \fIfile\fR" 4 +.IX Item "-include file" +Process \fIfile\fR as if \f(CW\*(C`#include "file"\*(C'\fR appeared as the first +line of the primary source file. However, the first directory searched +for \fIfile\fR is the preprocessor's working directory \fIinstead of\fR +the directory containing the main source file. If not found there, it +is searched for in the remainder of the \f(CW\*(C`#include "..."\*(C'\fR search +chain as normal. +.Sp +If multiple \fB\-include\fR options are given, the files are included +in the order they appear on the command line. +.IP "\fB\-imacros\fR \fIfile\fR" 4 +.IX Item "-imacros file" +Exactly like \fB\-include\fR, except that any output produced by +scanning \fIfile\fR is thrown away. Macros it defines remain defined. +This allows you to acquire all the macros from a header without also +processing its declarations. +.Sp +All files specified by \fB\-imacros\fR are processed before all files +specified by \fB\-include\fR. +.IP "\fB\-idirafter\fR \fIdir\fR" 4 +.IX Item "-idirafter dir" +Search \fIdir\fR for header files, but do it \fIafter\fR all +directories specified with \fB\-I\fR and the standard system directories +have been exhausted. \fIdir\fR is treated as a system include directory. +.IP "\fB\-iprefix\fR \fIprefix\fR" 4 +.IX Item "-iprefix prefix" +Specify \fIprefix\fR as the prefix for subsequent \fB\-iwithprefix\fR +options. If the prefix represents a directory, you should include the +final \fB/\fR. +.IP "\fB\-iwithprefix\fR \fIdir\fR" 4 +.IX Item "-iwithprefix dir" +.PD 0 +.IP "\fB\-iwithprefixbefore\fR \fIdir\fR" 4 +.IX Item "-iwithprefixbefore dir" +.PD +Append \fIdir\fR to the prefix specified previously with +\&\fB\-iprefix\fR, and add the resulting directory to the include search +path. \fB\-iwithprefixbefore\fR puts it in the same place \fB\-I\fR +would; \fB\-iwithprefix\fR puts it where \fB\-idirafter\fR would. +.IP "\fB\-isysroot\fR \fIdir\fR" 4 +.IX Item "-isysroot dir" +This option is like the \fB\-\-sysroot\fR option, but applies only to +header files. See the \fB\-\-sysroot\fR option for more information. +.IP "\fB\-imultilib\fR \fIdir\fR" 4 +.IX Item "-imultilib dir" +Use \fIdir\fR as a subdirectory of the directory containing +target-specific \*(C+ headers. +.IP "\fB\-isystem\fR \fIdir\fR" 4 +.IX Item "-isystem dir" +Search \fIdir\fR for header files, after all directories specified by +\&\fB\-I\fR but before the standard system directories. Mark it +as a system directory, so that it gets the same special treatment as +is applied to the standard system directories. +.IP "\fB\-iquote\fR \fIdir\fR" 4 +.IX Item "-iquote dir" +Search \fIdir\fR only for header files requested with +\&\f(CW\*(C`#include\ "\f(CIfile\f(CW"\*(C'\fR; they are not searched for +\&\f(CW\*(C`#include\ <\f(CIfile\f(CW>\*(C'\fR, before all directories specified by +\&\fB\-I\fR and before the standard system directories. +.IP "\fB\-fdollars\-in\-identifiers\fR" 4 +.IX Item "-fdollars-in-identifiers" +Accept \fB$\fR in identifiers. +.IP "\fB\-fextended\-identifiers\fR" 4 +.IX Item "-fextended-identifiers" +Accept universal character names in identifiers. This option is +experimental; in a future version of \s-1GCC\s0, it will be enabled by +default for C99 and \*(C+. +.IP "\fB\-fpreprocessed\fR" 4 +.IX Item "-fpreprocessed" +Indicate to the preprocessor that the input file has already been +preprocessed. This suppresses things like macro expansion, trigraph +conversion, escaped newline splicing, and processing of most directives. +The preprocessor still recognizes and removes comments, so that you can +pass a file preprocessed with \fB\-C\fR to the compiler without +problems. In this mode the integrated preprocessor is little more than +a tokenizer for the front ends. +.Sp +\&\fB\-fpreprocessed\fR is implicit if the input file has one of the +extensions \fB.i\fR, \fB.ii\fR or \fB.mi\fR. These are the +extensions that \s-1GCC\s0 uses for preprocessed files created by +\&\fB\-save\-temps\fR. +.IP "\fB\-ftabstop=\fR\fIwidth\fR" 4 +.IX Item "-ftabstop=width" +Set the distance between tab stops. This helps the preprocessor report +correct column numbers in warnings or errors, even if tabs appear on the +line. If the value is less than 1 or greater than 100, the option is +ignored. The default is 8. +.IP "\fB\-fexec\-charset=\fR\fIcharset\fR" 4 +.IX Item "-fexec-charset=charset" +Set the execution character set, used for string and character +constants. The default is \s-1UTF\-8\s0. \fIcharset\fR can be any encoding +supported by the system's \f(CW\*(C`iconv\*(C'\fR library routine. +.IP "\fB\-fwide\-exec\-charset=\fR\fIcharset\fR" 4 +.IX Item "-fwide-exec-charset=charset" +Set the wide execution character set, used for wide string and +character constants. The default is \s-1UTF\-32\s0 or \s-1UTF\-16\s0, whichever +corresponds to the width of \f(CW\*(C`wchar_t\*(C'\fR. As with +\&\fB\-fexec\-charset\fR, \fIcharset\fR can be any encoding supported +by the system's \f(CW\*(C`iconv\*(C'\fR library routine; however, you will have +problems with encodings that do not fit exactly in \f(CW\*(C`wchar_t\*(C'\fR. +.IP "\fB\-finput\-charset=\fR\fIcharset\fR" 4 +.IX Item "-finput-charset=charset" +Set the input character set, used for translation from the character +set of the input file to the source character set used by \s-1GCC\s0. If the +locale does not specify, or \s-1GCC\s0 cannot get this information from the +locale, the default is \s-1UTF\-8\s0. This can be overridden by either the locale +or this command line option. Currently the command line option takes +precedence if there's a conflict. \fIcharset\fR can be any encoding +supported by the system's \f(CW\*(C`iconv\*(C'\fR library routine. +.IP "\fB\-fworking\-directory\fR" 4 +.IX Item "-fworking-directory" +Enable generation of linemarkers in the preprocessor output that will +let the compiler know the current working directory at the time of +preprocessing. When this option is enabled, the preprocessor will +emit, after the initial linemarker, a second linemarker with the +current working directory followed by two slashes. \s-1GCC\s0 will use this +directory, when it's present in the preprocessed input, as the +directory emitted as the current working directory in some debugging +information formats. This option is implicitly enabled if debugging +information is enabled, but this can be inhibited with the negated +form \fB\-fno\-working\-directory\fR. If the \fB\-P\fR flag is +present in the command line, this option has no effect, since no +\&\f(CW\*(C`#line\*(C'\fR directives are emitted whatsoever. +.IP "\fB\-fno\-show\-column\fR" 4 +.IX Item "-fno-show-column" +Do not print column numbers in diagnostics. This may be necessary if +diagnostics are being scanned by a program that does not understand the +column numbers, such as \fBdejagnu\fR. +.IP "\fB\-A\fR \fIpredicate\fR\fB=\fR\fIanswer\fR" 4 +.IX Item "-A predicate=answer" +Make an assertion with the predicate \fIpredicate\fR and answer +\&\fIanswer\fR. This form is preferred to the older form \fB\-A\fR +\&\fIpredicate\fR\fB(\fR\fIanswer\fR\fB)\fR, which is still supported, because +it does not use shell special characters. +.IP "\fB\-A \-\fR\fIpredicate\fR\fB=\fR\fIanswer\fR" 4 +.IX Item "-A -predicate=answer" +Cancel an assertion with the predicate \fIpredicate\fR and answer +\&\fIanswer\fR. +.IP "\fB\-dCHARS\fR" 4 +.IX Item "-dCHARS" +\&\fI\s-1CHARS\s0\fR is a sequence of one or more of the following characters, +and must not be preceded by a space. Other characters are interpreted +by the compiler proper, or reserved for future versions of \s-1GCC\s0, and so +are silently ignored. If you specify characters whose behavior +conflicts, the result is undefined. +.RS 4 +.IP "\fBM\fR" 4 +.IX Item "M" +Instead of the normal output, generate a list of \fB#define\fR +directives for all the macros defined during the execution of the +preprocessor, including predefined macros. This gives you a way of +finding out what is predefined in your version of the preprocessor. +Assuming you have no file \fIfoo.h\fR, the command +.Sp +.Vb 1 +\& touch foo.h; cpp -dM foo.h +.Ve +.Sp +will show all the predefined macros. +.IP "\fBD\fR" 4 +.IX Item "D" +Like \fBM\fR except in two respects: it does \fInot\fR include the +predefined macros, and it outputs \fIboth\fR the \fB#define\fR +directives and the result of preprocessing. Both kinds of output go to +the standard output file. +.IP "\fBN\fR" 4 +.IX Item "N" +Like \fBD\fR, but emit only the macro names, not their expansions. +.IP "\fBI\fR" 4 +.IX Item "I" +Output \fB#include\fR directives in addition to the result of +preprocessing. +.RE +.RS 4 +.RE +.IP "\fB\-P\fR" 4 +.IX Item "-P" +Inhibit generation of linemarkers in the output from the preprocessor. +This might be useful when running the preprocessor on something that is +not C code, and will be sent to a program which might be confused by the +linemarkers. +.IP "\fB\-C\fR" 4 +.IX Item "-C" +Do not discard comments. All comments are passed through to the output +file, except for comments in processed directives, which are deleted +along with the directive. +.Sp +You should be prepared for side effects when using \fB\-C\fR; it +causes the preprocessor to treat comments as tokens in their own right. +For example, comments appearing at the start of what would be a +directive line have the effect of turning that line into an ordinary +source line, since the first token on the line is no longer a \fB#\fR. +.IP "\fB\-CC\fR" 4 +.IX Item "-CC" +Do not discard comments, including during macro expansion. This is +like \fB\-C\fR, except that comments contained within macros are +also passed through to the output file where the macro is expanded. +.Sp +In addition to the side-effects of the \fB\-C\fR option, the +\&\fB\-CC\fR option causes all \*(C+\-style comments inside a macro +to be converted to C\-style comments. This is to prevent later use +of that macro from inadvertently commenting out the remainder of +the source line. +.Sp +The \fB\-CC\fR option is generally used to support lint comments. +.IP "\fB\-traditional\-cpp\fR" 4 +.IX Item "-traditional-cpp" +Try to imitate the behavior of old-fashioned C preprocessors, as +opposed to \s-1ISO\s0 C preprocessors. +.IP "\fB\-trigraphs\fR" 4 +.IX Item "-trigraphs" +Process trigraph sequences. +.IP "\fB\-remap\fR" 4 +.IX Item "-remap" +Enable special code to work around file systems which only permit very +short file names, such as \s-1MS\-DOS\s0. +.IP "\fB\-\-help\fR" 4 +.IX Item "--help" +.PD 0 +.IP "\fB\-\-target\-help\fR" 4 +.IX Item "--target-help" +.PD +Print text describing all the command line options instead of +preprocessing anything. +.IP "\fB\-v\fR" 4 +.IX Item "-v" +Verbose mode. Print out \s-1GNU\s0 \s-1CPP\s0's version number at the beginning of +execution, and report the final form of the include path. +.IP "\fB\-H\fR" 4 +.IX Item "-H" +Print the name of each header file used, in addition to other normal +activities. Each name is indented to show how deep in the +\&\fB#include\fR stack it is. Precompiled header files are also +printed, even if they are found to be invalid; an invalid precompiled +header file is printed with \fB...x\fR and a valid one with \fB...!\fR . +.IP "\fB\-version\fR" 4 +.IX Item "-version" +.PD 0 +.IP "\fB\-\-version\fR" 4 +.IX Item "--version" +.PD +Print out \s-1GNU\s0 \s-1CPP\s0's version number. With one dash, proceed to +preprocess as normal. With two dashes, exit immediately. +.SH "ENVIRONMENT" +.IX Header "ENVIRONMENT" +This section describes the environment variables that affect how \s-1CPP\s0 +operates. You can use them to specify directories or prefixes to use +when searching for include files, or to control dependency output. +.PP +Note that you can also specify places to search using options such as +\&\fB\-I\fR, and control dependency output with options like +\&\fB\-M\fR. These take precedence over +environment variables, which in turn take precedence over the +configuration of \s-1GCC\s0. +.IP "\fB\s-1CPATH\s0\fR" 4 +.IX Item "CPATH" +.PD 0 +.IP "\fBC_INCLUDE_PATH\fR" 4 +.IX Item "C_INCLUDE_PATH" +.IP "\fB\s-1CPLUS_INCLUDE_PATH\s0\fR" 4 +.IX Item "CPLUS_INCLUDE_PATH" +.PD +Each variable's value is a list of directories separated by a special +character, much like \fB\s-1PATH\s0\fR, in which to look for header files. +The special character, \f(CW\*(C`PATH_SEPARATOR\*(C'\fR, is target-dependent and +determined at \s-1GCC\s0 build time. For Microsoft Windows-based targets it is a +semicolon, and for almost all other targets it is a colon. +.Sp +\&\fB\s-1CPATH\s0\fR specifies a list of directories to be searched as if +specified with \fB\-I\fR, but after any paths given with \fB\-I\fR +options on the command line. This environment variable is used +regardless of which language is being preprocessed. +.Sp +The remaining environment variables apply only when preprocessing the +particular language indicated. Each specifies a list of directories +to be searched as if specified with \fB\-isystem\fR, but after any +paths given with \fB\-isystem\fR options on the command line. +.Sp +In all these variables, an empty element instructs the compiler to +search its current working directory. Empty elements can appear at the +beginning or end of a path. For instance, if the value of +\&\fB\s-1CPATH\s0\fR is \f(CW\*(C`:/special/include\*(C'\fR, that has the same +effect as \fB\-I.\ \-I/special/include\fR. +.IP "\fB\s-1DEPENDENCIES_OUTPUT\s0\fR" 4 +.IX Item "DEPENDENCIES_OUTPUT" +If this variable is set, its value specifies how to output +dependencies for Make based on the non-system header files processed +by the compiler. System header files are ignored in the dependency +output. +.Sp +The value of \fB\s-1DEPENDENCIES_OUTPUT\s0\fR can be just a file name, in +which case the Make rules are written to that file, guessing the target +name from the source file name. Or the value can have the form +\&\fIfile\fR\fB \fR\fItarget\fR, in which case the rules are written to +file \fIfile\fR using \fItarget\fR as the target name. +.Sp +In other words, this environment variable is equivalent to combining +the options \fB\-MM\fR and \fB\-MF\fR, +with an optional \fB\-MT\fR switch too. +.IP "\fB\s-1SUNPRO_DEPENDENCIES\s0\fR" 4 +.IX Item "SUNPRO_DEPENDENCIES" +This variable is the same as \fB\s-1DEPENDENCIES_OUTPUT\s0\fR (see above), +except that system header files are not ignored, so it implies +\&\fB\-M\fR rather than \fB\-MM\fR. However, the dependence on the +main input file is omitted. +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIgpl\fR\|(7), \fIgfdl\fR\|(7), \fIfsf\-funding\fR\|(7), +\&\fIgcc\fR\|(1), \fIas\fR\|(1), \fIld\fR\|(1), and the Info entries for \fIcpp\fR, \fIgcc\fR, and +\&\fIbinutils\fR. +.SH "COPYRIGHT" +.IX Header "COPYRIGHT" +Copyright (c) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, +1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. +.PP +Permission is granted to copy, distribute and/or modify this document +under the terms of the \s-1GNU\s0 Free Documentation License, Version 1.1 or +any later version published by the Free Software Foundation. A copy of +the license is included in the +man page \fIgfdl\fR\|(7). +This manual contains no Invariant Sections. The Front-Cover Texts are +(a) (see below), and the Back-Cover Texts are (b) (see below). +.PP +(a) The \s-1FSF\s0's Front-Cover Text is: +.PP +.Vb 1 +\& A GNU Manual +.Ve +.PP +(b) The \s-1FSF\s0's Back-Cover Text is: +.PP +.Vb 3 +\& You have freedom to copy and modify this GNU Manual, like GNU +\& software. Copies published by the Free Software Foundation raise +\& funds for GNU development. +.Ve diff --git a/gnu/usr.bin/cc/gcov/Makefile b/gnu/usr.bin/cc/gcov/Makefile new file mode 100644 index 000000000000..9a87c028a31b --- /dev/null +++ b/gnu/usr.bin/cc/gcov/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +.include <bsd.own.mk> + +.include "../Makefile.inc" +.include "../Makefile.ver" + +.PATH: ${GCCDIR} ${GCCDIR}/doc + +PROG= gcov +SRCS= gcov.c version.c errors.c +MAN= gcov.1 + +DPADD= ${LIBIBERTY} +LDADD= ${LIBIBERTY} + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/cc/gcov/Makefile.depend b/gnu/usr.bin/cc/gcov/Makefile.depend new file mode 100644 index 000000000000..de48a531065e --- /dev/null +++ b/gnu/usr.bin/cc/gcov/Makefile.depend @@ -0,0 +1,19 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/usr.bin/cc/cc_tools \ + gnu/usr.bin/cc/libiberty \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/include/Makefile b/gnu/usr.bin/cc/include/Makefile new file mode 100644 index 000000000000..1d749b9ef374 --- /dev/null +++ b/gnu/usr.bin/cc/include/Makefile @@ -0,0 +1,27 @@ +# $FreeBSD$ + +.include <bsd.own.mk> + +.include "../Makefile.inc" + +INCSDIR=${INCLUDEDIR}/gcc/${GCCVER} + +.PATH: ${GCCDIR}/config/${GCC_CPU} ${SRCTOP}/contrib/llvm/tools/clang/lib/Headers + +.if ${TARGET_ARCH} == "i386" || ${TARGET_ARCH} == "amd64" +INCS= ammintrin.h emmintrin.h mmintrin.h mm3dnow.h pmmintrin.h \ + tmmintrin.h xmmintrin.h mm_malloc.h +INCS+= wmmintrin.h __wmmintrin_aes.h __wmmintrin_pclmul.h +.elif ${TARGET_ARCH} == "arm" +INCS= mmintrin.h +.elif ${TARGET_ARCH} == "powerpc" || ${TARGET_ARCH} == "powerpc64" || \ + ${TARGET_ARCH} == "powerpcspe" +INCS= ppc-asm.h altivec.h spe.h +.endif + +mm_malloc.h: pmm_malloc.h + @rm -rf ${.TARGET} + @cp ${.ALLSRC} ${.TARGET} +CLEANFILES+= mm_malloc.h + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/cc/include/Makefile.depend b/gnu/usr.bin/cc/include/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ b/gnu/usr.bin/cc/include/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/include/__wmmintrin_aes.h b/gnu/usr.bin/cc/include/__wmmintrin_aes.h new file mode 100644 index 000000000000..ff8a3457948c --- /dev/null +++ b/gnu/usr.bin/cc/include/__wmmintrin_aes.h @@ -0,0 +1,54 @@ +/*- + * Copyright 2013 John-Mark Gurney + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#ifndef _WMMINTRIN_AES_H_ +#define _WMMINTRIN_AES_H_ + +#include <emmintrin.h> + +#define MAKE_AES(name) \ +static __inline__ __m128i __attribute__((__always_inline__, __nodebug__)) \ +_mm_## name ##_si128(__m128i __V, __m128i __R) \ +{ \ + __m128i v = __V; \ + \ + __asm__ (#name " %2, %0": "=x" (v): "0" (v), "xm" (__R)); \ + \ + return v; \ +} + +MAKE_AES(aesimc) +MAKE_AES(aesenc) +MAKE_AES(aesenclast) +MAKE_AES(aesdec) +MAKE_AES(aesdeclast) + +#undef MAKE_AES + +#endif /* _WMMINTRIN_AES_H_ */ diff --git a/gnu/usr.bin/cc/include/__wmmintrin_pclmul.h b/gnu/usr.bin/cc/include/__wmmintrin_pclmul.h new file mode 100644 index 000000000000..5bebd81be261 --- /dev/null +++ b/gnu/usr.bin/cc/include/__wmmintrin_pclmul.h @@ -0,0 +1,53 @@ +/*- + * Copyright 2013 John-Mark Gurney + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#ifndef _WMMINTRIN_PCLMUL_H_ +#define _WMMINTRIN_PCLMUL_H_ + +#include <emmintrin.h> + +/* + * c selects which parts of a and b to multiple: + * 0x00: a[ 63: 0] * b[ 63: 0] + * 0x01: a[127:64] * b[ 63: 0] + * 0x10: a[ 63: 0] * b[127:64] + * 0x11: a[127:64] * b[127:64] + */ +#define _mm_clmulepi64_si128(a, b, c) \ +({ \ + __m128i _a = (a); \ + __m128i _b = (b); \ + \ + __asm__("pclmulqdq %3, %2, %0": "=x" (_a): "0" (_a), "xm" (_b), \ + "i" (c)); \ + \ + _a; \ +}) + +#endif /* _WMMINTRIN_PCLMUL_H_ */ diff --git a/gnu/usr.bin/cc/libcpp/Makefile b/gnu/usr.bin/cc/libcpp/Makefile new file mode 100644 index 000000000000..d21bd8352bce --- /dev/null +++ b/gnu/usr.bin/cc/libcpp/Makefile @@ -0,0 +1,25 @@ +# $FreeBSD$ + +.include <bsd.own.mk> + +# Use our headers in preference to ones from ../cc_tools. +CFLAGS+= -I${.CURDIR} -I. + +.include "../Makefile.inc" + +.PATH: ${GCCLIB}/libcpp + +LIB= cpp +SRCS= localedir.h +SRCS+= charset.c directives.c directives-only.c errors.c expr.c \ + files.c identifiers.c init.c lex.c line-map.c macro.c \ + mkdeps.c pch.c symtab.c traditional.c +INTERNALLIB= +WARNS?= 1 + +localedir.h: Makefile + echo '#define LOCALEDIR "/usr/share/locale"' > localedir.h +SRCS+= localedir.h +CLEANFILES+= localedir.h + +.include <bsd.lib.mk> diff --git a/gnu/usr.bin/cc/libcpp/Makefile.depend b/gnu/usr.bin/cc/libcpp/Makefile.depend new file mode 100644 index 000000000000..18be76b0cb6f --- /dev/null +++ b/gnu/usr.bin/cc/libcpp/Makefile.depend @@ -0,0 +1,13 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/libcpp/config.h b/gnu/usr.bin/cc/libcpp/config.h new file mode 100644 index 000000000000..5577f2840df3 --- /dev/null +++ b/gnu/usr.bin/cc/libcpp/config.h @@ -0,0 +1,292 @@ +/* config.h. Generated by configure. */ +/* config.in. Generated from configure.ac by autoheader. */ +/* $FreeBSD$ */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +/* #undef CRAY_STACKSEG_END */ + +/* Define to 1 if using `alloca.c'. */ +/* #undef C_ALLOCA */ + +/* Define if you want more run-time sanity checks. */ +/* #undef ENABLE_CHECKING */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +/* #undef ENABLE_NLS */ + +/* Define to 1 if you have `alloca', as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). + */ +/* #undef HAVE_ALLOCA_H */ + +/* Define to 1 if you have the `clearerr_unlocked' function. */ +#define HAVE_CLEARERR_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `abort', and to 0 if you don't. + */ +#define HAVE_DECL_ABORT 1 + +/* Define to 1 if you have the declaration of `asprintf', and to 0 if you + don't. */ +#define HAVE_DECL_ASPRINTF 1 + +/* Define to 1 if you have the declaration of `basename', and to 0 if you + don't. */ +#define HAVE_DECL_BASENAME 0 + +/* Define to 1 if you have the declaration of `clearerr_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_CLEARERR_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `errno', and to 0 if you don't. + */ +#define HAVE_DECL_ERRNO 0 + +/* Define to 1 if you have the declaration of `feof_unlocked', and to 0 if you + don't. */ +#define HAVE_DECL_FEOF_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `ferror_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FERROR_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `fflush_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FFLUSH_UNLOCKED 0 + +/* Define to 1 if you have the declaration of `fgetc_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FGETC_UNLOCKED 0 + +/* Define to 1 if you have the declaration of `fgets_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FGETS_UNLOCKED 0 + +/* Define to 1 if you have the declaration of `fileno_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FILENO_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `fprintf_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FPRINTF_UNLOCKED 0 + +/* Define to 1 if you have the declaration of `fputc_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FPUTC_UNLOCKED 0 + +/* Define to 1 if you have the declaration of `fputs_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FPUTS_UNLOCKED 0 + +/* Define to 1 if you have the declaration of `fread_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FREAD_UNLOCKED 0 + +/* Define to 1 if you have the declaration of `fwrite_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_FWRITE_UNLOCKED 0 + +/* Define to 1 if you have the declaration of `getchar_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_GETCHAR_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you + don't. */ +#define HAVE_DECL_GETC_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `getopt', and to 0 if you don't. + */ +#define HAVE_DECL_GETOPT 1 + +/* Define to 1 if you have the declaration of `putchar_unlocked', and to 0 if + you don't. */ +#define HAVE_DECL_PUTCHAR_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `putc_unlocked', and to 0 if you + don't. */ +#define HAVE_DECL_PUTC_UNLOCKED 1 + +/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you + don't. */ +#define HAVE_DECL_VASPRINTF 1 + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `feof_unlocked' function. */ +#define HAVE_FEOF_UNLOCKED 1 + +/* Define to 1 if you have the `ferror_unlocked' function. */ +#define HAVE_FERROR_UNLOCKED 1 + +/* Define to 1 if you have the `fflush_unlocked' function. */ +/* #undef HAVE_FFLUSH_UNLOCKED */ + +/* Define to 1 if you have the `fgetc_unlocked' function. */ +/* #undef HAVE_FGETC_UNLOCKED */ + +/* Define to 1 if you have the `fgets_unlocked' function. */ +/* #undef HAVE_FGETS_UNLOCKED */ + +/* Define to 1 if you have the `fileno_unlocked' function. */ +#define HAVE_FILENO_UNLOCKED 1 + +/* Define to 1 if you have the `fprintf_unlocked' function. */ +/* #undef HAVE_FPRINTF_UNLOCKED */ + +/* Define to 1 if you have the `fputc_unlocked' function. */ +/* #undef HAVE_FPUTC_UNLOCKED */ + +/* Define to 1 if you have the `fputs_unlocked' function. */ +/* #undef HAVE_FPUTS_UNLOCKED */ + +/* Define to 1 if you have the `fread_unlocked' function. */ +/* #undef HAVE_FREAD_UNLOCKED */ + +/* Define to 1 if you have the `fwrite_unlocked' function. */ +/* #undef HAVE_FWRITE_UNLOCKED */ + +/* Define to 1 if you have the `getchar_unlocked' function. */ +#define HAVE_GETCHAR_UNLOCKED 1 + +/* Define to 1 if you have the `getc_unlocked' function. */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define if you have the iconv() function. */ +#if XXXKAN +#define HAVE_ICONV 1 +#endif + +/* Define to 1 if you have the <iconv.h> header file. */ +/* #undef HAVE_ICONV_H */ + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */ +#define HAVE_LANGINFO_CODESET 1 + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if libc includes obstacks. */ +/* #undef HAVE_OBSTACK */ + +/* Define to 1 if you have the `putchar_unlocked' function. */ +#define HAVE_PUTCHAR_UNLOCKED 1 + +/* Define to 1 if you have the `putc_unlocked' function. */ +#define HAVE_PUTC_UNLOCKED 1 + +/* Define to 1 if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define if <sys/types.h> defines \`uchar'. */ +/* #undef HAVE_UCHAR */ + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the widest efficient host integer type at least as wide as the + target's size_t type. */ +#define HOST_WIDE_INT long + +#if XXXKAN +/* Define as const if the declaration of iconv() needs const. */ +#define ICONV_CONST const +#endif + +/* Define to the name of this package. */ +#define PACKAGE "cpplib" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "gcc-bugs@gcc.gnu.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "cpplib" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "cpplib " + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "cpplib" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION " " + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +/* #undef STACK_DIRECTION */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both <string.h> and <strings.h>. */ +#define STRING_WITH_STRINGS 1 + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your <sys/time.h> declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `long' if <sys/types.h> does not define. */ +/* #undef off_t */ + +/* Define to `unsigned' if <sys/types.h> does not define. */ +/* #undef size_t */ + +typedef unsigned char uchar; + +#include <size-host.h> diff --git a/gnu/usr.bin/cc/libdecnumber/Makefile b/gnu/usr.bin/cc/libdecnumber/Makefile new file mode 100644 index 000000000000..2987c1c89b1f --- /dev/null +++ b/gnu/usr.bin/cc/libdecnumber/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +.include <bsd.own.mk> + +# Use our headers in preference to ones from ../cc_tools. +CFLAGS+= -I${.CURDIR} -I. + +.include "../Makefile.inc" + +.PATH: ${GCCLIB}/libdecnumber + +LIB= decnumber +SRCS= decNumber.c decContext.c decUtility.c \ + decimal32.c decimal64.c decimal128.c + +INTERNALLIB= +WARNS?= 1 + +.include <bsd.lib.mk> diff --git a/gnu/usr.bin/cc/libdecnumber/Makefile.depend b/gnu/usr.bin/cc/libdecnumber/Makefile.depend new file mode 100644 index 000000000000..ea841fdbb8d9 --- /dev/null +++ b/gnu/usr.bin/cc/libdecnumber/Makefile.depend @@ -0,0 +1,14 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/usr.bin/cc/cc_tools \ + include \ + include/xlocale \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/libdecnumber/config.h b/gnu/usr.bin/cc/libdecnumber/config.h new file mode 100644 index 000000000000..53b586f254d7 --- /dev/null +++ b/gnu/usr.bin/cc/libdecnumber/config.h @@ -0,0 +1,80 @@ +/* config.h. Generated by configure. */ +/* config.in. Generated from configure.ac by autoheader. */ +/* $FreeBSD$ */ + +/* Define to 1 if you have the <ctype.h> header file. */ +#define HAVE_CTYPE_H 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdio.h> header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "gcc-bugs@gcc.gnu.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libdecnumber" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libdecnumber " + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libdecnumber" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION " " + +/* The size of a `char', as computed by sizeof. */ +/* #undef SIZEOF_CHAR */ + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of a `short', as computed by sizeof. */ +/* #undef SIZEOF_SHORT */ + +/* The size of a `void *', as computed by sizeof. */ +/* #undef SIZEOF_VOID_P */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `long' if <sys/types.h> does not define. */ +/* #undef off_t */ + +#include <size-host.h> diff --git a/gnu/usr.bin/cc/libiberty/Makefile b/gnu/usr.bin/cc/libiberty/Makefile new file mode 100644 index 000000000000..adaa12878790 --- /dev/null +++ b/gnu/usr.bin/cc/libiberty/Makefile @@ -0,0 +1,28 @@ +# $FreeBSD$ + +.include <bsd.own.mk> + +# +# Make sure we will pick up our config.h file first, not the one from +# cc_tools. +# +CFLAGS+= -I${.CURDIR} + +.include "../Makefile.inc" + +.PATH: ${GCCLIB}/libiberty + +LIB= iberty +SRCS= argv.c choose-temp.c concat.c cp-demangle.c cp-demint.c cplus-dem.c \ + dyn-string.c fibheap.c fopen_unlocked.c getpwd.c getruntime.c \ + hashtab.c hex.c lbasename.c make-temp-file.c md5.c obstack.c \ + partition.c pex-unix.c physmem.c safe-ctype.c splay-tree.c xexit.c \ + xmalloc.c xmemdup.c xstrdup.c xstrerror.c make-relative-prefix.c \ + pexecute.c pex-common.c pex-one.c lrealpath.c strverscmp.c \ + regex.c +INTERNALLIB= +WARNS?= 1 + +CFLAGS+= -UPREFIX + +.include <bsd.lib.mk> diff --git a/gnu/usr.bin/cc/libiberty/Makefile.depend b/gnu/usr.bin/cc/libiberty/Makefile.depend new file mode 100644 index 000000000000..18be76b0cb6f --- /dev/null +++ b/gnu/usr.bin/cc/libiberty/Makefile.depend @@ -0,0 +1,13 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/cc/libiberty/config.h b/gnu/usr.bin/cc/libiberty/config.h new file mode 100644 index 000000000000..5a99758f8635 --- /dev/null +++ b/gnu/usr.bin/cc/libiberty/config.h @@ -0,0 +1,448 @@ +/* config.h. Generated by configure. */ +/* config.in. Generated from configure.ac by autoheader. */ +/* $FreeBSD$ */ + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +/* #undef CRAY_STACKSEG_END */ + +/* Define to 1 if you have the <alloca.h> header file. */ +/* #undef HAVE_ALLOCA_H */ + +/* Define to 1 if you have the `asprintf' function. */ +#define HAVE_ASPRINTF 1 + +/* Define to 1 if you have the `atexit' function. */ +#define HAVE_ATEXIT 1 + +/* Define to 1 if you have the `basename' function. */ +#define HAVE_BASENAME 1 + +/* Define to 1 if you have the `bcmp' function. */ +#define HAVE_BCMP 1 + +/* Define to 1 if you have the `bcopy' function. */ +#define HAVE_BCOPY 1 + +/* Define to 1 if you have the `bsearch' function. */ +#define HAVE_BSEARCH 1 + +/* Define to 1 if you have the `bzero' function. */ +#define HAVE_BZERO 1 + +/* Define to 1 if you have the `calloc' function. */ +#define HAVE_CALLOC 1 + +/* Define to 1 if you have the `canonicalize_file_name' function. */ +/* #undef HAVE_CANONICALIZE_FILE_NAME */ + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the declaration of `asprintf', and to 0 if you + don't. */ +#define HAVE_DECL_ASPRINTF 1 + +/* Define to 1 if you have the declaration of `basename', and to 0 if you + don't. */ +#define HAVE_DECL_BASENAME 0 + +/* Define to 1 if you have the declaration of `calloc', and to 0 if you don't. + */ +#define HAVE_DECL_CALLOC 1 + +/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */ +#define HAVE_DECL_FFS 1 + +/* Define to 1 if you have the declaration of `getenv', and to 0 if you don't. + */ +#define HAVE_DECL_GETENV 1 + +/* Define to 1 if you have the declaration of `getopt', and to 0 if you don't. + */ +#define HAVE_DECL_GETOPT 1 + +/* Define to 1 if you have the declaration of `malloc', and to 0 if you don't. + */ +#define HAVE_DECL_MALLOC 1 + +/* Define to 1 if you have the declaration of `realloc', and to 0 if you + don't. */ +#define HAVE_DECL_REALLOC 1 + +/* Define to 1 if you have the declaration of `sbrk', and to 0 if you don't. + */ +#define HAVE_DECL_SBRK 1 + +/* Define to 1 if you have the declaration of `snprintf', and to 0 if you + don't. */ +#define HAVE_DECL_SNPRINTF 1 + +/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you + don't. */ +#define HAVE_DECL_STRVERSCMP 0 + +/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you + don't. */ +#define HAVE_DECL_VASPRINTF 1 + +/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you + don't. */ +#define HAVE_DECL_VSNPRINTF 1 + +/* Define to 1 if you have the <fcntl.h> header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `ffs' function. */ +#define HAVE_FFS 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getrusage' function. */ +#define HAVE_GETRUSAGE 1 + +/* Define to 1 if you have the `getsysinfo' function. */ +/* #undef HAVE_GETSYSINFO */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `index' function. */ +#define HAVE_INDEX 1 + +/* Define to 1 if you have the `insque' function. */ +#define HAVE_INSQUE 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the <machine/hal_sysinfo.h> header file. */ +/* #undef HAVE_MACHINE_HAL_SYSINFO_H */ + +/* Define to 1 if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define to 1 if you have the `memchr' function. */ +#define HAVE_MEMCHR 1 + +/* Define to 1 if you have the `memcmp' function. */ +#define HAVE_MEMCMP 1 + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mempcpy' function. */ +/* #undef HAVE_MEMPCPY */ + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the `mkstemps' function. */ +#define HAVE_MKSTEMPS 1 + +/* Define to 1 if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `on_exit' function. */ +/* #undef HAVE_ON_EXIT */ + +/* Define to 1 if you have the `psignal' function. */ +#define HAVE_PSIGNAL 1 + +/* Define to 1 if you have the `pstat_getdynamic' function. */ +/* #undef HAVE_PSTAT_GETDYNAMIC */ + +/* Define to 1 if you have the `pstat_getstatic' function. */ +/* #undef HAVE_PSTAT_GETSTATIC */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `random' function. */ +#define HAVE_RANDOM 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `rename' function. */ +#define HAVE_RENAME 1 + +/* Define to 1 if you have the `rindex' function. */ +#define HAVE_RINDEX 1 + +/* Define to 1 if you have the `sbrk' function. */ +/* #undef HAVE_SBRK */ + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the `sigsetmask' function. */ +#define HAVE_SIGSETMASK 1 + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdio_ext.h> header file. */ +/* #undef HAVE_STDIO_EXT_H */ + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +#define HAVE_STPCPY 1 + +/* Define to 1 if you have the `stpncpy' function. */ +/* #undef HAVE_STPNCPY */ + +/* Define to 1 if you have the `strcasecmp' function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strncasecmp' function. */ +#define HAVE_STRNCASECMP 1 + +/* Define to 1 if you have the `strndup' function. */ +#define HAVE_STRNDUP 1 + +/* Define to 1 if you have the `strrchr' function. */ +#define HAVE_STRRCHR 1 + +/* Define to 1 if you have the `strsignal' function. */ +#define HAVE_STRSIGNAL 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the `strtod' function. */ +#define HAVE_STRTOD 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strverscmp' function. */ +/* #undef HAVE_STRVERSCMP */ + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the `sysctl' function. */ +#define HAVE_SYSCTL 1 + +/* Define to 1 if you have the `sysmp' function. */ +/* #undef HAVE_SYSMP */ + +/* Define if you have the sys_errlist variable. */ +#define HAVE_SYS_ERRLIST 1 + +/* Define to 1 if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the <sys/mman.h> header file. */ +#define HAVE_SYS_MMAN_H 1 + +/* Define if you have the sys_nerr variable. */ +#define HAVE_SYS_NERR 1 + +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the <sys/pstat.h> header file. */ +/* #undef HAVE_SYS_PSTAT_H */ + +/* Define to 1 if you have the <sys/resource.h> header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define if you have the sys_siglist variable. */ +#define HAVE_SYS_SIGLIST 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/sysctl.h> header file. */ +#define HAVE_SYS_SYSCTL_H 1 + +/* Define to 1 if you have the <sys/sysinfo.h> header file. */ +/* #undef HAVE_SYS_SYSINFO_H */ + +/* Define to 1 if you have the <sys/sysmp.h> header file. */ +/* #undef HAVE_SYS_SYSMP_H */ + +/* Define to 1 if you have the <sys/systemcfg.h> header file. */ +/* #undef HAVE_SYS_SYSTEMCFG_H */ + +/* Define to 1 if you have the <sys/table.h> header file. */ +/* #undef HAVE_SYS_TABLE_H */ + +/* Define to 1 if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `table' function. */ +/* #undef HAVE_TABLE */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define if you have the \`uintptr_t' type. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `vasprintf' function. */ +#define HAVE_VASPRINTF 1 + +/* Define to 1 if you have the `vfork' function. */ +#define HAVE_VFORK 1 + +/* Define to 1 if you have the <vfork.h> header file. */ +/* #undef HAVE_VFORK_H */ + +/* Define to 1 if you have the `vfprintf' function. */ +#define HAVE_VFPRINTF 1 + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the `vsnprintf' function. */ +#define HAVE_VSNPRINTF 1 + +/* Define to 1 if you have the `vsprintf' function. */ +#define HAVE_VSPRINTF 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define to 1 if `fork' works. */ +#define HAVE_WORKING_FORK 1 + +/* Define to 1 if `vfork' works. */ +#define HAVE_WORKING_VFORK 1 + +/* Define to 1 if you have the `_doprnt' function. */ +/* #undef HAVE__DOPRNT */ + +/* Define if you have the _system_configuration variable. */ +/* #undef HAVE__SYSTEM_CONFIGURATION */ + +/* Define to 1 if you have the `__fsetlocking' function. */ +/* #undef HAVE___FSETLOCKING */ + +/* Define if canonicalize_file_name is not declared in system header files. */ +#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 + +/* Define if errno must be declared even when <errno.h> is included. */ +/* #undef NEED_DECLARATION_ERRNO */ + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +/* #undef NO_MINUS_C_MINUS_O */ + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* Define if you know the direction of stack growth for your system; otherwise + it will be automatically deduced at run-time. STACK_DIRECTION > 0 => grows + toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#define STACK_DIRECTION -1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to an unsigned 64-bit type available in the compiler. */ +#define UNSIGNED_64BIT_TYPE uint64_t + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef WORDS_BIGENDIAN */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `int' if <sys/types.h> does not define. */ +/* #undef pid_t */ + +/* Define to `unsigned long' if <sys/types.h> does not define. */ +/* #undef uintptr_t */ + +/* Define as `fork' if `vfork' does not work. */ +/* #undef vfork */ + +#include <size-host.h> diff --git a/gnu/usr.bin/dialog/Makefile b/gnu/usr.bin/dialog/Makefile new file mode 100644 index 000000000000..71496f774830 --- /dev/null +++ b/gnu/usr.bin/dialog/Makefile @@ -0,0 +1,10 @@ +# $FreeBSD$ + +DIALOG= ${SRCTOP}/contrib/dialog +PROG= dialog + +LIBADD= dialog ncursesw m +CFLAGS+= -I${.CURDIR} -I${DIALOG} +.PATH: ${DIALOG} + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/dialog/Makefile.depend b/gnu/usr.bin/dialog/Makefile.depend new file mode 100644 index 000000000000..87a30b89d0f0 --- /dev/null +++ b/gnu/usr.bin/dialog/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/lib/libdialog \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + lib/msun \ + lib/ncurses/ncursesw \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/diff3/Makefile b/gnu/usr.bin/diff3/Makefile new file mode 100644 index 000000000000..7e72487bed00 --- /dev/null +++ b/gnu/usr.bin/diff3/Makefile @@ -0,0 +1,27 @@ +# $FreeBSD$ + +DIFFSRC=${SRCTOP}/contrib/diff/src +.PATH: ${DIFFSRC} \ + ${SRCTOP}/contrib/diff/lib \ + ${SRCTOP}/contrib/diff/man + +PROG= diff3 +SRCS= diff3.c version-etc.c \ + xmalloc.c error.c c-stack.c exitfail.c cmpbuf.c + +# Important for ctype macros! +CFLAGS+=-funsigned-char + +CFLAGS+=-I${SRCTOP}/contrib/diff/ +CFLAGS+=-I${SRCTOP}/contrib/diff/src +CFLAGS+=-I${SRCTOP}/contrib/diff/lib +CFLAGS+=-DHAVE_CONFIG_H +CFLAGS+=-DDEFAULT_DIFF_PROGRAM=\"/usr/bin/diff\" + +.for f in diff3.c +${f}: ${DIFFSRC}/${f} ${.CURDIR}/${f}.diff + patch -s -o ${.TARGET} < ${.CURDIR}/${f}.diff ${DIFFSRC}/${f} +CLEANFILES+= ${f} +.endfor + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/diff3/Makefile.depend b/gnu/usr.bin/diff3/Makefile.depend new file mode 100644 index 000000000000..6cfaab1c3644 --- /dev/null +++ b/gnu/usr.bin/diff3/Makefile.depend @@ -0,0 +1,17 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/diff3/diff3.c.diff b/gnu/usr.bin/diff3/diff3.c.diff new file mode 100644 index 000000000000..153d6e88c6d4 --- /dev/null +++ b/gnu/usr.bin/diff3/diff3.c.diff @@ -0,0 +1,11 @@ +$FreeBSD$ +--- diff3.c.orig 2004-04-12 15:44:35.000000000 +0800 ++++ diff3.c 2007-06-15 14:49:23.903835977 +0800 +@@ -230,7 +230,6 @@ + initialize_main (&argc, &argv); + program_name = argv[0]; + setlocale (LC_ALL, ""); +- bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + c_stack_action (0); + diff --git a/gnu/usr.bin/dtc/Makefile b/gnu/usr.bin/dtc/Makefile new file mode 100644 index 000000000000..d9fcc6404a91 --- /dev/null +++ b/gnu/usr.bin/dtc/Makefile @@ -0,0 +1,51 @@ +# $FreeBSD$ + +.include <bsd.own.mk> + +DTCDIR= ${.CURDIR}/../../../contrib/dtc +_LIBFDTDIR= ${.CURDIR}/../../../sys/contrib/libfdt +.PATH: ${DTCDIR} ${_LIBFDTDIR} + +PROG= dtc + +SRCS= dtc.c checks.c fstree.c livetree.c treesource.c data.c \ + flattree.c srcpos.c util.c \ + fdt.c fdt_ro.c fdt_rw.c fdt_strerror.c \ + fdt_sw.c fdt_wip.c ${DTCVERSIONFILE} + +WARNS?= 2 +CFLAGS+= -I. -I${.CURDIR} -I${DTCDIR} -I${_LIBFDTDIR} + +VERSIONMAJ!= awk '/^VERSION =/ { print $$3 }' ${DTCDIR}/Makefile +VERSIONMIN!= awk '/^PATCHLEVEL =/ { print $$3 }' ${DTCDIR}/Makefile +VERSIONSUB!= awk '/^SUBLEVEL =/ { print $$3 }' ${DTCDIR}/Makefile +VERSIONEXTRA= + +DTCVERSION:= ${VERSIONMAJ}.${VERSIONMIN}.${VERSIONSUB}${VERSIONEXTRA} +DTCVERSIONFILE:= version_gen.h + +MAN= + +BISON= yacc +LEX= lex + +OBJS+= dtc-parser.tab.o dtc-lexer.lex.o + +CLEANFILES+= dtc-parser.tab.o dtc-lexer.lex.o dtc-parser.tab.c \ + dtc-parser.tab.h dtc-lexer.lex.c ${DTCVERSIONFILE} + +${DTCVERSIONFILE}: ${DTCDIR}/Makefile + @echo '#define DTC_VERSION "DTC ${DTCVERSION}"' > ${DTCVERSIONFILE} + +dtc-parser.tab.o: dtc-parser.tab.c dtc-parser.tab.h +dtc-lexer.lex.o: dtc-lexer.lex.c dtc-parser.tab.h + +dtc-parser.tab.c: dtc-parser.y + ${BISON} -o$@ -d ${DTCDIR}/dtc-parser.y + +dtc-parser.tab.h: dtc-parser.tab.c + +dtc-lexer.lex.c: dtc-lexer.l + ${LEX} -o$@ ${DTCDIR}/dtc-lexer.l + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/dtc/Makefile.depend b/gnu/usr.bin/dtc/Makefile.depend new file mode 100644 index 000000000000..d084433f911c --- /dev/null +++ b/gnu/usr.bin/dtc/Makefile.depend @@ -0,0 +1,18 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + usr.bin/yacc.host \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/gdb/Makefile b/gnu/usr.bin/gdb/Makefile new file mode 100644 index 000000000000..c9564c232a3c --- /dev/null +++ b/gnu/usr.bin/gdb/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +SUBDIR= libgdb gdb kgdb + +.if ${MK_GDB_LIBEXEC} == "no" +.if exists(${.CURDIR}/gdbserver/reg-${MACHINE_CPUARCH}.c) +SUBDIR+=gdbserver +.endif +.endif + +.include <bsd.subdir.mk> diff --git a/gnu/usr.bin/gdb/Makefile.inc b/gnu/usr.bin/gdb/Makefile.inc new file mode 100644 index 000000000000..ecead2e2e674 --- /dev/null +++ b/gnu/usr.bin/gdb/Makefile.inc @@ -0,0 +1,66 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +VERSION= "6.1.1 [FreeBSD]" +VENDOR= marcel + +PACKAGE= gdb + +BMAKE_GDB= ${.CURDIR:H} +BMAKE_ROOT= ${BMAKE_GDB:H} +BMAKE_BU= ${BMAKE_ROOT}/binutils + +CNTRB_BU= ${SRCTOP}/contrib/binutils +CNTRB_GDB= ${SRCTOP}/contrib/gdb + +OBJ_BU= ${OBJTOP}/gnu/usr.bin/binutils +OBJ_GDB= ${OBJTOP}/gnu/usr.bin/gdb + +# These assignments duplicate much of the functionality of +# MACHINE_CPUARCH, but there's no easy way to export make functions... + +.if defined(TARGET_ARCH) +TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}} +.else +TARGET_CPUARCH=${MACHINE_CPUARCH} +.endif +TARGET_ARCH?= ${MACHINE_ARCH} +TARGET_SUBDIR= ${BMAKE_GDB}/arch/${TARGET_CPUARCH} + +.if ${TARGET_ARCH} != ${MACHINE_ARCH} +GDB_CROSS_DEBUGGER= +.endif + +.PATH: ${CNTRB_GDB}/gdb ${CNTRB_GDB}/gdb/cli ${CNTRB_GDB}/gdb/mi \ + ${CNTRB_GDB}/gdb/signals ${CNTRB_GDB}/gdb/tui ${TARGET_SUBDIR} + +CFLAGS+= -DHAVE_CONFIG_H -DRL_NO_COMPAT -DMI_OUT=1 +CFLAGS+= -DDEBUGDIR=\"${DEBUGDIR}\" +CFLAGS+= -I. +CFLAGS+= -I${TARGET_SUBDIR} +CFLAGS+= -I${BMAKE_BU}/libbfd -I${BMAKE_BU}/libbfd/${TARGET_CPUARCH} +CFLAGS+= -I${CNTRB_GDB}/gdb +CFLAGS+= -I${CNTRB_GDB}/gdb/config +CFLAGS+= -I${CNTRB_BU}/include +CFLAGS+= -I${CNTRB_GDB}/include +CFLAGS+= -I${CNTRB_BU}/bfd +CFLAGS+= -I${SRCTOP}/lib/libedit/edit + +GENSRCS+= nm.h tm.h + +.if defined(GDB_CROSS_DEBUGGER) +CFLAGS+= -DCROSS_DEBUGGER -I${BMAKE_ROOT:H:H} +GDB_SUFFIX= -${TARGET_ARCH} +MAN= +.elif ${MK_GDB_LIBEXEC} != "no" +BINDIR?= /usr/libexec +MAN= +.endif + +.include "${TARGET_SUBDIR}/Makefile" + +SRCS+= ${GENSRCS} +CLEANFILES+= ${GENSRCS} + +.include "../Makefile.inc" diff --git a/gnu/usr.bin/gdb/arch/amd64/Makefile b/gnu/usr.bin/gdb/arch/amd64/Makefile new file mode 100644 index 000000000000..a43e894e749c --- /dev/null +++ b/gnu/usr.bin/gdb/arch/amd64/Makefile @@ -0,0 +1,24 @@ +# $FreeBSD$ + +GENSRCS+= xm.h +.if !defined(GDB_CROSS_DEBUGGER) +LIBSRCS+= fbsd-proc.c fbsd-threads.c gcore.c +LIBSRCS+= amd64-nat.c amd64bsd-nat.c amd64fbsd-nat.c +.endif +LIBSRCS+= solib.c solib-svr4.c +LIBSRCS+= amd64-tdep.c amd64fbsd-tdep.c i386-tdep.c i386bsd-tdep.c \ + i386fbsd-tdep-fixed.c i387-tdep.c + +nm.h: + echo '#include "i386/nm-fbsd64.h"' > ${.TARGET} + +tm.h: + echo '#include "i386/tm-fbsd.h"' > ${.TARGET} + +xm.h: + echo '#include "i386/xm-i386.h"' > ${.TARGET} + +# Fix source static/extern mismatch nits that GCC 4.2 warns about. +CLEANFILES+= i386fbsd-tdep-fixed.c +i386fbsd-tdep-fixed.c: i386fbsd-tdep.c + sed -e '48s/^static //' ${.ALLSRC} > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/amd64/config.h b/gnu/usr.bin/gdb/arch/amd64/config.h new file mode 100644 index 000000000000..6908c793ece9 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/amd64/config.h @@ -0,0 +1,550 @@ +/* $FreeBSD$ */ + +/* config.h. Generated automatically by configure. */ +/* config.in. Generated automatically from configure.in by autoheader. */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define if using alloca.c. */ +/* #undef C_ALLOCA */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +/* #undef CRAY_STACKSEG_END */ + +/* Define if you have alloca, as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define if you have <alloca.h> and it should be used (not on Ultrix). */ +/* #undef HAVE_ALLOCA_H */ + +/* Define if the `long double' type works. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define if you have <vfork.h>. */ +/* #undef HAVE_VFORK_H */ + +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + +/* Define to `long' if <sys/types.h> doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if <sys/types.h> doesn't define. */ +/* #undef pid_t */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define if the `setpgrp' function takes no argument. */ +/* #undef SETPGRP_VOID */ + +/* Define to `unsigned' if <sys/types.h> doesn't define. */ +/* #undef size_t */ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown + */ +/* #undef STACK_DIRECTION */ + +/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define vfork as fork if vfork does not work. */ +/* #undef vfork */ + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +/* Define if your struct reg has r_fs. */ +/* #undef HAVE_STRUCT_REG_R_FS */ + +/* Define if your struct stat has st_blocks. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define if your struct reg has r_gs. */ +/* #undef HAVE_STRUCT_REG_R_GS */ + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``l_'' prefix. (For Solaris, SVR4, and + SVR4-like systems.) */ +#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``lm_'' prefix. (For SunOS.) */ +/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ + +/* Define if <link.h> exists and defines a struct so_map which has + members with an ``som_'' prefix. (Found on older *BSD systems.) */ +/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ + +/* Define if <sys/link.h> has struct link_map32 */ +/* #undef HAVE_STRUCT_LINK_MAP32 */ + +/* Define if <sys/link.h> has link_map32 (solaris sparc-64 target) */ +/* #undef _SYSCALL32 */ + +/* Define if the prfpregset_t type is broken. */ +/* #undef PRFPREGSET_T_BROKEN */ + +/* Define if you want to use new multi-fd /proc interface + (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ +/* #undef NEW_PROC_API */ + +/* Define if ioctl argument PIOCSET is available. */ +/* #undef HAVE_PROCFS_PIOCSET */ + +/* Define if the `long long' type works. */ +#define CC_HAS_LONG_LONG 1 + +/* Define if the "ll" format works to print long long ints. */ +#define PRINTF_HAS_LONG_LONG 1 + +/* Define if the "%Lg" format works to print long doubles. */ +#define PRINTF_HAS_LONG_DOUBLE 1 + +/* Define if the "%Lg" format works to scan long doubles. */ +#define SCANF_HAS_LONG_DOUBLE 1 + +/* Define if using Solaris thread debugging. */ +/* #undef HAVE_THREAD_DB_LIB */ + +/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ +/* #undef START_INFERIOR_TRAPS_EXPECTED */ +/* #undef sys_quotactl */ + +/* Define if you have HPUX threads */ +/* #undef HAVE_HPUX_THREAD_SUPPORT */ + +/* Define if <proc_service.h> on solaris uses int instead of + size_t, and assorted other type changes. */ +/* #undef PROC_SERVICE_IS_OLD */ + +/* Define if the simulator is being linked in. */ +#define WITH_SIM 1 + +/* Set to true if the save_state_t structure is present */ +/* #undef HAVE_STRUCT_SAVE_STATE_T */ + +/* Set to true if the save_state_t structure has the ss_wide member */ +/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETREGS request. */ +/* #undef HAVE_PTRACE_GETREGS */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETFPXREGS request. */ +/* #undef HAVE_PTRACE_GETFPXREGS */ + +/* Define if <sys/ptrace.h> defines the PT_GETDBREGS request. */ +#define HAVE_PT_GETDBREGS 1 + +/* Define if <sys/ptrace.h> defines the PT_GETXMMREGS request. */ +/* #undef HAVE_PT_GETXMMREGS */ + +/* Define if libunwind library is being used. */ +/* #undef HAVE_LIBUNWIND */ + +/* hostfile */ +#define GDB_XM_FILE config/i386/xm-i386.h + +/* targetfile */ +#define GDB_TM_FILE config/i386/tm-fbsd.h + +/* nativefile */ +#ifndef CROSS_DEBUGGER +#define GDB_NM_FILE config/i386/nm-fbsd64.h +#endif + +/* Define to 1 so <sys/proc.h> gets a definition of anon_hdl. Works + around a <sys/proc.h> problem on IRIX 5. */ +#ifndef _KMEMUSER +/* #undef _KMEMUSER */ +#endif + +/* Define if you have the __argz_count function. */ +/* #undef HAVE___ARGZ_COUNT */ + +/* Define if you have the __argz_next function. */ +/* #undef HAVE___ARGZ_NEXT */ + +/* Define if you have the __argz_stringify function. */ +/* #undef HAVE___ARGZ_STRINGIFY */ + +/* Define if you have the _mcleanup function. */ +#define HAVE__MCLEANUP 1 + +/* Define if you have the canonicalize_file_name function. */ +/* #undef HAVE_CANONICALIZE_FILE_NAME */ + +/* Define if you have the dcgettext function. */ +/* #undef HAVE_DCGETTEXT */ + +/* Define if you have the getcwd function. */ +#define HAVE_GETCWD 1 + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the monstartup function. */ +#define HAVE_MONSTARTUP 1 + +/* Define if you have the munmap function. */ +#define HAVE_MUNMAP 1 + +/* Define if you have the poll function. */ +#define HAVE_POLL 1 + +/* Define if you have the pread64 function. */ +/* #undef HAVE_PREAD64 */ + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the realpath function. */ +#define HAVE_REALPATH 1 + +/* Define if you have the sbrk function. */ +/* #undef HAVE_SBRK */ + +/* Define if you have the setenv function. */ +#define HAVE_SETENV 1 + +/* Define if you have the setlocale function. */ +#define HAVE_SETLOCALE 1 + +/* Define if you have the setpgid function. */ +#define HAVE_SETPGID 1 + +/* Define if you have the setpgrp function. */ +#define HAVE_SETPGRP 1 + +/* Define if you have the sigaction function. */ +#define HAVE_SIGACTION 1 + +/* Define if you have the sigprocmask function. */ +#define HAVE_SIGPROCMASK 1 + +/* Define if you have the sigsetmask function. */ +#define HAVE_SIGSETMASK 1 + +/* Define if you have the socketpair function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define if you have the stpcpy function. */ +#define HAVE_STPCPY 1 + +/* Define if you have the strcasecmp function. */ +#define HAVE_STRCASECMP 1 + +/* Define if you have the strchr function. */ +#define HAVE_STRCHR 1 + +/* Define if you have the syscall function. */ +#define HAVE_SYSCALL 1 + +/* Define if you have the <argz.h> header file. */ +/* #undef HAVE_ARGZ_H */ + +/* Define if you have the <ctype.h> header file. */ +#define HAVE_CTYPE_H 1 + +/* Define if you have the <curses.h> header file. */ +#define HAVE_CURSES_H 1 + +/* Define if you have the <dirent.h> header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the <libunwind-ia64.h> header file. */ +/* #undef HAVE_LIBUNWIND_IA64_H */ + +/* Define if you have the <libunwind.h> header file. */ +/* #undef HAVE_LIBUNWIND_H */ + +/* Define if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the <link.h> header file. */ +#define HAVE_LINK_H 1 + +/* Define if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the <machine/reg.h> header file. */ +#define HAVE_MACHINE_REG_H 1 + +/* Define if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if you have the <ncurses.h> header file. */ +#define HAVE_NCURSES_H 1 + +/* Define if you have the <ndir.h> header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the <nl_types.h> header file. */ +#define HAVE_NL_TYPES_H 1 + +/* Define if you have the <nlist.h> header file. */ +#define HAVE_NLIST_H 1 + +/* Define if you have the <poll.h> header file. */ +#define HAVE_POLL_H 1 + +/* Define if you have the <proc_service.h> header file. */ +/* #undef HAVE_PROC_SERVICE_H */ + +/* Define if you have the <ptrace.h> header file. */ +/* #undef HAVE_PTRACE_H */ + +/* Define if you have the <sgtty.h> header file. */ +#define HAVE_SGTTY_H 1 + +/* Define if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define if you have the <sys/debugreg.h> header file. */ +/* #undef HAVE_SYS_DEBUGREG_H */ + +/* Define if you have the <sys/dir.h> header file. */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define if you have the <sys/fault.h> header file. */ +/* #undef HAVE_SYS_FAULT_H */ + +/* Define if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define if you have the <sys/filio.h> header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define if you have the <sys/ndir.h> header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the <sys/poll.h> header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define if you have the <sys/proc.h> header file. */ +#define HAVE_SYS_PROC_H 1 + +/* Define if you have the <sys/procfs.h> header file. */ +#define HAVE_SYS_PROCFS_H 1 + +/* Define if you have the <sys/ptrace.h> header file. */ +#define HAVE_SYS_PTRACE_H 1 + +/* Define if you have the <sys/reg.h> header file. */ +/* #undef HAVE_SYS_REG_H */ + +/* Define if you have the <sys/select.h> header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define if you have the <sys/syscall.h> header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define if you have the <sys/user.h> header file. */ +#define HAVE_SYS_USER_H 1 + +/* Define if you have the <sys/wait.h> header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the <term.h> header file. */ +#define HAVE_TERM_H 1 + +/* Define if you have the <termio.h> header file. */ +/* #undef HAVE_TERMIO_H */ + +/* Define if you have the <termios.h> header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define if you have the <thread_db.h> header file. */ +/* #undef HAVE_THREAD_DB_H */ + +/* Define if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the <values.h> header file. */ +/* #undef HAVE_VALUES_H */ + +/* Define if you have the <wait.h> header file. */ +/* #undef HAVE_WAIT_H */ + +/* Define if you have the dl library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define if you have the m library (-lm). */ +#define HAVE_LIBM 1 + +/* Define if you have the w library (-lw). */ +/* #undef HAVE_LIBW */ + +/* Define if you have the stpcpy function */ +#define HAVE_STPCPY 1 + +/* Define if your locale.h file contains LC_MESSAGES. */ +#define HAVE_LC_MESSAGES 1 + +/* Define to 1 if NLS is requested */ +/* #undef ENABLE_NLS */ + +/* Define as 1 if you have gettext and don't want to use GNU gettext. */ +/* #undef HAVE_GETTEXT */ + +/* Name of this package. */ +#define PACKAGE "gdb" + +/* Define to BFD's default architecture. */ +#define DEFAULT_BFD_ARCH bfd_i386_arch + +/* Define to BFD's default target vector. */ +#define DEFAULT_BFD_VEC bfd_elf64_x86_64_vec + +/* Define to 1 if your system has the _etext variable. */ +#define HAVE__ETEXT 1 + +/* Define to 1 to avoid a clash between <widec.h> and <wchar.h> on + Solaris 2.[78] when using GCC. */ +/* #undef _MSE_INT_H */ + +/* Define to 1 if we found this declaration otherwise define to 0. */ +#define HAVE_DECL_GETOPT 0 + +/* Define if sigsetjmp is available. */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if the regex included in libiberty should be used. */ +#define USE_INCLUDED_REGEX 1 + +/* Define to 1 if your system has struct reg in <machine/reg.h>. */ +#define HAVE_STRUCT_REG 1 + +/* Define if <stdint.h> provides the uintptr_t type. */ +#define HAVE_UINTPTR_T 1 + +/* Define if malloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_MALLOC */ + +/* Define if realloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_REALLOC */ + +/* Define if free is not declared in system header files. */ +/* #undef NEED_DECLARATION_FREE */ + +/* Define if strerror is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRERROR */ + +/* Define if strdup is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRDUP */ + +/* Define if strstr is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRSTR */ + +/* Define if canonicalize_file_name is not declared in system header files. */ +#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 + +/* Define if <sys/procfs.h> has pstatus_t. */ +/* #undef HAVE_PSTATUS_T */ + +/* Define if <sys/procfs.h> has prrun_t. */ +/* #undef HAVE_PRRUN_T */ + +/* Define if <sys/procfs.h> has gregset_t. */ +#define HAVE_GREGSET_T 1 + +/* Define if <sys/procfs.h> has fpregset_t. */ +#define HAVE_FPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset_t. */ +#define HAVE_PRGREGSET_T 1 + +/* Define if <sys/procfs.h> has prfpregset_t. */ +#define HAVE_PRFPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset32_t. */ +/* #undef HAVE_PRGREGSET32_T */ + +/* Define if <sys/procfs.h> has prfpregset32_t. */ +/* #undef HAVE_PRFPREGSET32_T */ + +/* Define if <sys/procfs.h> has lwpid_t. */ +#define HAVE_LWPID_T 1 + +/* Define if <sys/procfs.h> has psaddr_t. */ +#define HAVE_PSADDR_T 1 + +/* Define if <sys/procfs.h> has prsysent_t. */ +/* #undef HAVE_PRSYSENT_T */ + +/* Define if <sys/procfs.h> has pr_sigset_t. */ +/* #undef HAVE_PR_SIGSET_T */ + +/* Define if <sys/procfs.h> has pr_sigaction64_t. */ +/* #undef HAVE_PR_SIGACTION64_T */ + +/* Define if <sys/procfs.h> has pr_siginfo64_t. */ +/* #undef HAVE_PR_SIGINFO64_T */ + +/* Define if <thread_db.h> has the TD_NOTALLOC error code. */ +/* #undef THREAD_DB_HAS_TD_NOTALLOC */ + +/* Define if we can use the tkill syscall. */ +/* #undef HAVE_TKILL_SYSCALL */ + +/* Define to the default OS ABI for this configuration. */ +/* #undef GDB_OSABI_DEFAULT */ + +/* Define to be a string naming the default host character set. */ +#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + diff --git a/gnu/usr.bin/gdb/arch/amd64/init.c b/gnu/usr.bin/gdb/arch/amd64/init.c new file mode 100644 index 000000000000..1b296f4a9406 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/amd64/init.c @@ -0,0 +1,234 @@ +/* $FreeBSD$ */ + +/* Do not modify this file. */ +/* It is created automatically by the Makefile. */ +#include "defs.h" /* For initialize_file_ftype. */ +#include "call-cmds.h" /* For initialize_all_files. */ +extern initialize_file_ftype _initialize_gdbtypes; +extern initialize_file_ftype _initialize_amd64fbsd_tdep; +extern initialize_file_ftype _initialize_i386_tdep; +extern initialize_file_ftype _initialize_i386bsd_tdep; +extern initialize_file_ftype _initialize_i386fbsd_tdep; +extern initialize_file_ftype _initialize_corelow; +extern initialize_file_ftype _initialize_solib; +extern initialize_file_ftype _initialize_svr4_solib; +extern initialize_file_ftype _initialize_ser_hardwire; +extern initialize_file_ftype _initialize_ser_pipe; +extern initialize_file_ftype _initialize_ser_tcp; +extern initialize_file_ftype _initialize_kernel_u_addr; +extern initialize_file_ftype _initialize_infptrace; +extern initialize_file_ftype _initialize_inftarg; +extern initialize_file_ftype _initialize_amd64fbsd_nat; +extern initialize_file_ftype _initialize_gcore; +extern initialize_file_ftype _initialize_fbsd_proc; +extern initialize_file_ftype _initialize_remote; +extern initialize_file_ftype _initialize_dcache; +extern initialize_file_ftype _initialize_sr_support; +extern initialize_file_ftype _initialize_tracepoint; +extern initialize_file_ftype _initialize_ax_gdb; +extern initialize_file_ftype _initialize_annotate; +extern initialize_file_ftype _initialize_auxv; +extern initialize_file_ftype _initialize_breakpoint; +extern initialize_file_ftype _initialize_regcache; +extern initialize_file_ftype _initialize_charset; +extern initialize_file_ftype _initialize_dummy_frame; +extern initialize_file_ftype _initialize_source; +extern initialize_file_ftype _initialize_values; +extern initialize_file_ftype _initialize_valops; +extern initialize_file_ftype _initialize_valarith; +extern initialize_file_ftype _initialize_valprint; +extern initialize_file_ftype _initialize_printcmd; +extern initialize_file_ftype _initialize_symtab; +extern initialize_file_ftype _initialize_symfile; +extern initialize_file_ftype _initialize_symmisc; +extern initialize_file_ftype _initialize_infcall; +extern initialize_file_ftype _initialize_infcmd; +extern initialize_file_ftype _initialize_infrun; +extern initialize_file_ftype _initialize_stack; +extern initialize_file_ftype _initialize_thread; +extern initialize_file_ftype _initialize_interpreter; +extern initialize_file_ftype _initialize_macrocmd; +extern initialize_file_ftype _initialize_gdbarch; +extern initialize_file_ftype _initialize_gdbarch_utils; +extern initialize_file_ftype _initialize_gdb_osabi; +extern initialize_file_ftype _initialize_copying; +extern initialize_file_ftype _initialize_mem; +extern initialize_file_ftype _initialize_parse; +extern initialize_file_ftype _initialize_language; +extern initialize_file_ftype _initialize_frame_reg; +extern initialize_file_ftype _initialize_signals; +extern initialize_file_ftype _initialize_kod; +extern initialize_file_ftype _initialize_gdb_events; +extern initialize_file_ftype _initialize_exec; +extern initialize_file_ftype _initialize_maint_cmds; +extern initialize_file_ftype _initialize_demangler; +extern initialize_file_ftype _initialize_dbxread; +extern initialize_file_ftype _initialize_coffread; +extern initialize_file_ftype _initialize_elfread; +extern initialize_file_ftype _initialize_mipsread; +extern initialize_file_ftype _initialize_stabsread; +extern initialize_file_ftype _initialize_core; +extern initialize_file_ftype _initialize_dwarf2_frame; +extern initialize_file_ftype _initialize_c_language; +extern initialize_file_ftype _initialize_f_language; +extern initialize_file_ftype _initialize_objc_language; +extern initialize_file_ftype _initialize_ui_out; +extern initialize_file_ftype _initialize_cli_out; +extern initialize_file_ftype _initialize_varobj; +extern initialize_file_ftype _initialize_java_language; +extern initialize_file_ftype _initialize_m2_language; +extern initialize_file_ftype _initialize_pascal_language; +extern initialize_file_ftype _initialize_pascal_valprint; +extern initialize_file_ftype _initialize_scheme_language; +extern initialize_file_ftype _initialize_complaints; +extern initialize_file_ftype _initialize_typeprint; +extern initialize_file_ftype _initialize_cp_valprint; +extern initialize_file_ftype _initialize_f_valprint; +extern initialize_file_ftype _initialize_nlmread; +extern initialize_file_ftype _initialize_serial; +extern initialize_file_ftype _initialize_mdebugread; +extern initialize_file_ftype _initialize_user_regs; +extern initialize_file_ftype _initialize_frame; +extern initialize_file_ftype _initialize_frame_unwind; +extern initialize_file_ftype _initialize_frame_base; +extern initialize_file_ftype _initialize_gnu_v2_abi; +extern initialize_file_ftype _initialize_gnu_v3_abi; +extern initialize_file_ftype _initialize_hpacc_abi; +extern initialize_file_ftype _initialize_cp_abi; +extern initialize_file_ftype _initialize_cp_support; +extern initialize_file_ftype _initialize_cp_namespace; +extern initialize_file_ftype _initialize_reggroup; +extern initialize_file_ftype _initialize_inflow; +extern initialize_file_ftype _initialize_cli_dump; +extern initialize_file_ftype _initialize_cli_logging; +extern initialize_file_ftype _initialize_cli_interp; +extern initialize_file_ftype _initialize_mi_out; +extern initialize_file_ftype _initialize_mi_cmds; +extern initialize_file_ftype _initialize_mi_cmd_env; +extern initialize_file_ftype _initialize_mi_interp; +extern initialize_file_ftype _initialize_mi_main; +extern initialize_file_ftype _initialize_thread_db; +extern initialize_file_ftype _initialize_tui_hooks; +extern initialize_file_ftype _initialize_tui_interp; +extern initialize_file_ftype _initialize_tui_layout; +extern initialize_file_ftype _initialize_tui_out; +extern initialize_file_ftype _initialize_tui_regs; +extern initialize_file_ftype _initialize_tui_stack; +extern initialize_file_ftype _initialize_tui_win; +void +initialize_all_files (void) +{ + _initialize_gdbtypes (); + _initialize_amd64fbsd_tdep (); + _initialize_i386_tdep (); + _initialize_i386bsd_tdep (); + _initialize_i386fbsd_tdep (); + _initialize_corelow (); + _initialize_solib (); + _initialize_svr4_solib (); + _initialize_ser_hardwire (); + _initialize_ser_pipe (); + _initialize_ser_tcp (); +#ifndef CROSS_DEBUGGER + _initialize_kernel_u_addr (); + _initialize_infptrace (); + _initialize_inftarg (); + _initialize_amd64fbsd_nat (); + _initialize_gcore (); + _initialize_fbsd_proc (); + _initialize_thread_db (); +#endif + _initialize_remote (); + _initialize_dcache (); + _initialize_sr_support (); + _initialize_tracepoint (); + _initialize_ax_gdb (); + _initialize_annotate (); + _initialize_auxv (); + _initialize_breakpoint (); + _initialize_regcache (); + _initialize_charset (); + _initialize_dummy_frame (); + _initialize_source (); + _initialize_values (); + _initialize_valops (); + _initialize_valarith (); + _initialize_valprint (); + _initialize_printcmd (); + _initialize_symtab (); + _initialize_symfile (); + _initialize_symmisc (); + _initialize_infcall (); + _initialize_infcmd (); + _initialize_infrun (); + _initialize_stack (); + _initialize_thread (); + _initialize_interpreter (); + _initialize_macrocmd (); + _initialize_gdbarch (); + _initialize_gdbarch_utils (); + _initialize_gdb_osabi (); + _initialize_copying (); + _initialize_mem (); + _initialize_parse (); + _initialize_language (); + _initialize_frame_reg (); + _initialize_signals (); + _initialize_kod (); + _initialize_gdb_events (); + _initialize_exec (); + _initialize_maint_cmds (); + _initialize_demangler (); + _initialize_dbxread (); + _initialize_coffread (); + _initialize_elfread (); + _initialize_mipsread (); + _initialize_stabsread (); + _initialize_core (); + _initialize_dwarf2_frame (); + _initialize_c_language (); + _initialize_f_language (); + _initialize_objc_language (); + _initialize_ui_out (); + _initialize_cli_out (); + _initialize_varobj (); + _initialize_java_language (); + _initialize_m2_language (); + _initialize_pascal_language (); + _initialize_pascal_valprint (); + _initialize_scheme_language (); + _initialize_complaints (); + _initialize_typeprint (); + _initialize_cp_valprint (); + _initialize_f_valprint (); + _initialize_nlmread (); + _initialize_serial (); + _initialize_mdebugread (); + _initialize_user_regs (); + _initialize_frame (); + _initialize_frame_unwind (); + _initialize_frame_base (); + _initialize_gnu_v2_abi (); + _initialize_gnu_v3_abi (); + _initialize_hpacc_abi (); + _initialize_cp_abi (); + _initialize_cp_support (); + _initialize_cp_namespace (); + _initialize_reggroup (); + _initialize_inflow (); + _initialize_cli_dump (); + _initialize_cli_logging (); + _initialize_cli_interp (); + _initialize_mi_out (); + _initialize_mi_cmds (); + _initialize_mi_cmd_env (); + _initialize_mi_interp (); + _initialize_mi_main (); + _initialize_tui_hooks (); + _initialize_tui_interp (); + _initialize_tui_layout (); + _initialize_tui_out (); + _initialize_tui_regs (); + _initialize_tui_stack (); + _initialize_tui_win (); +} diff --git a/gnu/usr.bin/gdb/arch/arm/Makefile b/gnu/usr.bin/gdb/arch/arm/Makefile new file mode 100644 index 000000000000..22aee06a7bf4 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/arm/Makefile @@ -0,0 +1,20 @@ +# $FreeBSD$ + +GENSRCS+= xm.h +LIBSRCS+= armfbsd-nat.c +LIBSRCS+= arm-tdep.c armfbsd-tdep.c solib.c solib-svr4.c +.if !defined(GDB_CROSS_DEBUGGER) +LIBSRCS+= fbsd-threads.c +.endif + +nm.h: +#XXX this should be arm/nm-fbsd.h but won't until it's merged into the gdb repo + echo '#include "nm-fbsd.h"' > ${.TARGET} + +tm.h: +#XXX this should be arm/tm-fbsd.h + echo '#include "tm-fbsd.h"' > ${.TARGET} + +xm.h: +#XXX this should be arm/xm-fbsd.h + echo '#include "xm-fbsd.h"' > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/arm/armfbsd-nat.c b/gnu/usr.bin/gdb/arch/arm/armfbsd-nat.c new file mode 100644 index 000000000000..674deffaa3f5 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/arm/armfbsd-nat.c @@ -0,0 +1,552 @@ +/* $FreeBSD$ */ + + /* Native-dependent code for BSD Unix running on ARM's, for GDB. + Copyright 1988, 1989, 1991, 1992, 1994, 1996, 1999, 2002 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" + +#ifndef FETCH_INFERIOR_REGISTERS +#ifndef CROSS_DEBUGGER +#error Not FETCH_INFERIOR_REGISTERS +#endif +#endif /* !FETCH_INFERIOR_REGISTERS */ + +#include "arm-tdep.h" + +#include <sys/types.h> +#ifndef CROSS_DEBUGGER +#include <sys/ptrace.h> +#include <machine/reg.h> +#include <machine/frame.h> +#endif +#include "inferior.h" +#include "regcache.h" +#include "gdbcore.h" + +extern int arm_apcs_32; + +#ifdef CROSS_DEBUGGER +struct reg { + unsigned int r[13]; + unsigned int r_sp; + unsigned int r_lr; + unsigned int r_pc; + unsigned int r_cpsr; +}; + +typedef struct fp_extended_precision { + u_int32_t fp_exponent; + u_int32_t fp_mantissa_hi; + u_int32_t fp_mantissa_lo; +} fp_extended_precision_t; + +typedef struct fp_extended_precision fp_reg_t; + +struct fpreg { + unsigned int fpr_fpsr; + fp_reg_t fpr[8]; +}; +#endif + +void +supply_gregset (struct reg *gregset) +{ + int regno; + CORE_ADDR r_pc; + + /* Integer registers. */ + for (regno = ARM_A1_REGNUM; regno < ARM_SP_REGNUM; regno++) + supply_register (regno, (char *) &gregset->r[regno]); + + supply_register (ARM_SP_REGNUM, (char *) &gregset->r_sp); + supply_register (ARM_LR_REGNUM, (char *) &gregset->r_lr); + supply_register (ARM_PC_REGNUM, (char *) &gregset->r_pc); + + if (arm_apcs_32) + supply_register (ARM_PS_REGNUM, (char *) &gregset->r_cpsr); + else + supply_register (ARM_PS_REGNUM, (char *) &gregset->r_pc); +} + +/* Fill register REGNO (if it is a general-purpose register) in + *GREGSETPS with the value in GDB's register array. If REGNO is -1, + do this for all registers. */ + +void +fill_gregset (struct reg *gregset, int regno) +{ + int i; + + for (i = ARM_A1_REGNUM; i < ARM_SP_REGNUM; i++) + if ((regno == -1 || regno == i)) + regcache_collect (i, &gregset->r[i]); + if (regno == -1 || regno == ARM_SP_REGNUM) + regcache_collect (ARM_SP_REGNUM, &gregset->r_sp); + if (regno == -1 || regno == ARM_LR_REGNUM) + regcache_collect (ARM_LR_REGNUM, &gregset->r_lr); + if (regno == -1 || regno == ARM_PC_REGNUM) + regcache_collect (ARM_PC_REGNUM, &gregset->r_pc); + if (regno == -1 || regno == ARM_PS_REGNUM) + regcache_collect (ARM_PS_REGNUM, &gregset->r_cpsr); +} + +void +supply_fpregset (struct fpreg *fparegset) +{ + int regno; + + for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++) + supply_register + (regno, (char *) &fparegset->fpr[regno - ARM_F0_REGNUM]); + + supply_register (ARM_FPS_REGNUM, (char *) &fparegset->fpr_fpsr); +} + +void +fill_fpregset (struct fpreg *fparegset, int regno) +{ + int i; + + for (i = ARM_F0_REGNUM; i <= ARM_F7_REGNUM; i++) + if (regno == -1 || regno == i) + regcache_raw_supply(current_regcache, i, + &fparegset->fpr[i - ARM_F0_REGNUM]); + if (regno == -1 || regno == ARM_FPS_REGNUM) + regcache_raw_supply(current_regcache, ARM_FPS_REGNUM, + &fparegset->fpr_fpsr); +} + +static void +fetch_register (int regno) +{ + struct reg inferior_registers; +#ifndef CROSS_DEBUGGER + int ret; + + ret = ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &inferior_registers, 0); + + if (ret < 0) + { + warning ("unable to fetch general register"); + return; + } +#endif + + switch (regno) + { + case ARM_SP_REGNUM: + supply_register (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp); + break; + + case ARM_LR_REGNUM: + supply_register (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr); + break; + + case ARM_PC_REGNUM: + /* This is ok: we're running native... */ + inferior_registers.r_pc = ADDR_BITS_REMOVE (inferior_registers.r_pc); + supply_register (ARM_PC_REGNUM, (char *) &inferior_registers.r_pc); + break; + + case ARM_PS_REGNUM: + if (arm_apcs_32) + supply_register (ARM_PS_REGNUM, (char *) &inferior_registers.r_cpsr); + else + supply_register (ARM_PS_REGNUM, (char *) &inferior_registers.r_pc); + break; + + default: + supply_register (regno, (char *) &inferior_registers.r[regno]); + break; + } +} + +static void +fetch_regs (void) +{ + struct reg inferior_registers; +#ifndef CROSS_DEBUGGER + int ret; +#endif + int regno; + +#ifndef CROSS_DEBUGGER + ret = ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &inferior_registers, 0); + + if (ret < 0) + { + warning ("unable to fetch general registers"); + return; + } +#endif + + supply_gregset (&inferior_registers); +} + +static void +fetch_fp_register (int regno) +{ + struct fpreg inferior_fp_registers; +#ifndef CROSS_DEBUGGER + int ret; + + ret = ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); + + if (ret < 0) + { + warning ("unable to fetch floating-point register"); + return; + } +#endif + + switch (regno) + { + case ARM_FPS_REGNUM: + supply_register (ARM_FPS_REGNUM, + (char *) &inferior_fp_registers.fpr_fpsr); + break; + + default: + supply_register + (regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]); + break; + } +} + +static void +fetch_fp_regs (void) +{ + struct fpreg inferior_fp_registers; +#ifndef CROSS_DEBUGGER + int ret; +#endif + int regno; + +#ifndef CROSS_DEBUGGER + ret = ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); + + if (ret < 0) + { + warning ("unable to fetch general registers"); + return; + } +#endif + + supply_fpregset (&inferior_fp_registers); +} + +void +fetch_inferior_registers (int regno) +{ + if (regno >= 0) + { + if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM) + fetch_register (regno); + else + fetch_fp_register (regno); + } + else + { + fetch_regs (); + fetch_fp_regs (); + } +} + + +static void +store_register (int regno) +{ + struct reg inferior_registers; +#ifndef CROSS_DEBUGGER + int ret; + + ret = ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &inferior_registers, 0); + + if (ret < 0) + { + warning ("unable to fetch general registers"); + return; + } +#endif + + switch (regno) + { + case ARM_SP_REGNUM: + regcache_collect (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp); + break; + + case ARM_LR_REGNUM: + regcache_collect (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr); + break; + + case ARM_PC_REGNUM: + if (arm_apcs_32) + regcache_collect (ARM_PC_REGNUM, (char *) &inferior_registers.r_pc); + else + { + unsigned pc_val; + + regcache_collect (ARM_PC_REGNUM, (char *) &pc_val); + + pc_val = ADDR_BITS_REMOVE (pc_val); + inferior_registers.r_pc + ^= ADDR_BITS_REMOVE (inferior_registers.r_pc); + inferior_registers.r_pc |= pc_val; + } + break; + + case ARM_PS_REGNUM: + if (arm_apcs_32) + regcache_collect (ARM_PS_REGNUM, (char *) &inferior_registers.r_cpsr); + else + { + unsigned psr_val; + + regcache_collect (ARM_PS_REGNUM, (char *) &psr_val); + + psr_val ^= ADDR_BITS_REMOVE (psr_val); + inferior_registers.r_pc = ADDR_BITS_REMOVE (inferior_registers.r_pc); + inferior_registers.r_pc |= psr_val; + } + break; + + default: + regcache_collect (regno, (char *) &inferior_registers.r[regno]); + break; + } + +#ifndef CROSS_DEBUGGER + ret = ptrace (PT_SETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &inferior_registers, 0); + + if (ret < 0) + warning ("unable to write register %d to inferior", regno); +#endif +} + +static void +store_regs (void) +{ + struct reg inferior_registers; + int ret; + int regno; + + + for (regno = ARM_A1_REGNUM; regno < ARM_SP_REGNUM; regno++) + regcache_collect (regno, (char *) &inferior_registers.r[regno]); + + regcache_collect (ARM_SP_REGNUM, (char *) &inferior_registers.r_sp); + regcache_collect (ARM_LR_REGNUM, (char *) &inferior_registers.r_lr); + + if (arm_apcs_32) + { + regcache_collect (ARM_PC_REGNUM, (char *) &inferior_registers.r_pc); + regcache_collect (ARM_PS_REGNUM, (char *) &inferior_registers.r_cpsr); + } + else + { + unsigned pc_val; + unsigned psr_val; + + regcache_collect (ARM_PC_REGNUM, (char *) &pc_val); + regcache_collect (ARM_PS_REGNUM, (char *) &psr_val); + + pc_val = ADDR_BITS_REMOVE (pc_val); + psr_val ^= ADDR_BITS_REMOVE (psr_val); + + inferior_registers.r_pc = pc_val | psr_val; + } + +#ifndef CROSS_DEBUGGER + ret = ptrace (PT_SETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &inferior_registers, 0); + + if (ret < 0) + warning ("unable to store general registers"); +#endif +} + +static void +store_fp_register (int regno) +{ + struct fpreg inferior_fp_registers; +#ifndef CROSS_DEBUGGER + int ret; + + ret = ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); + + if (ret < 0) + { + warning ("unable to fetch floating-point registers"); + return; + } +#endif + + switch (regno) + { + case ARM_FPS_REGNUM: + regcache_collect (ARM_FPS_REGNUM, + (char *) &inferior_fp_registers.fpr_fpsr); + break; + + default: + regcache_collect + (regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]); + break; + } + +#ifndef CROSS_DEBUGGER + ret = ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); + + if (ret < 0) + warning ("unable to write register %d to inferior", regno); +#endif +} + +static void +store_fp_regs (void) +{ + struct fpreg inferior_fp_registers; + int ret; + int regno; + + + for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++) + regcache_collect + (regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]); + + regcache_collect (ARM_FPS_REGNUM, (char *) &inferior_fp_registers.fpr_fpsr); + +#ifndef CROSS_DEBUGGER + ret = ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); + + if (ret < 0) + warning ("unable to store floating-point registers"); +#endif +} + +void +store_inferior_registers (int regno) +{ + if (regno >= 0) + { + if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM) + store_register (regno); + else + store_fp_register (regno); + } + else + { + store_regs (); + store_fp_regs (); + } +} + + +struct md_core +{ + struct reg intreg; + struct fpreg freg; +}; + +static void +fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, + int which, CORE_ADDR ignore) +{ + struct md_core *core_reg = (struct md_core *) core_reg_sect; + int regno; + CORE_ADDR r_pc; + + supply_gregset (&core_reg->intreg); + supply_fpregset (&core_reg->freg); +} + +static void +fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, + int which, CORE_ADDR ignore) +{ + struct reg gregset; + struct fpreg fparegset; + + switch (which) + { + case 0: /* Integer registers. */ + if (core_reg_size != sizeof (struct reg)) + warning ("wrong size of register set in core file"); + else + { + /* The memcpy may be unnecessary, but we can't really be sure + of the alignment of the data in the core file. */ + memcpy (&gregset, core_reg_sect, sizeof (gregset)); + supply_gregset (&gregset); + } + break; + + case 2: + if (core_reg_size != sizeof (struct fpreg)) + warning ("wrong size of FPA register set in core file"); + else + { + /* The memcpy may be unnecessary, but we can't really be sure + of the alignment of the data in the core file. */ + memcpy (&fparegset, core_reg_sect, sizeof (fparegset)); + supply_fpregset (&fparegset); + } + break; + + default: + /* Don't know what kind of register request this is; just ignore it. */ + break; + } +} + +static struct core_fns arm_freebsd_core_fns = +{ + bfd_target_unknown_flavour, /* core_flovour. */ + default_check_format, /* check_format. */ + default_core_sniffer, /* core_sniffer. */ + fetch_core_registers, /* core_read_registers. */ + NULL +}; + +static struct core_fns arm_freebsd_elfcore_fns = +{ + bfd_target_elf_flavour, /* core_flovour. */ + default_check_format, /* check_format. */ + default_core_sniffer, /* core_sniffer. */ + fetch_elfcore_registers, /* core_read_registers. */ + NULL +}; + +void +_initialize_arm_fbsdnat (void) +{ + add_core_fns (&arm_freebsd_core_fns); + add_core_fns (&arm_freebsd_elfcore_fns); +} diff --git a/gnu/usr.bin/gdb/arch/arm/armfbsd-tdep.c b/gnu/usr.bin/gdb/arch/arm/armfbsd-tdep.c new file mode 100644 index 000000000000..785897dad344 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/arm/armfbsd-tdep.c @@ -0,0 +1,68 @@ +/* $FreeBSD$ */ + +/* Target-specific functions for ARM running under NetBSD. + Copyright 2002, 2003 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "defs.h" +#include "osabi.h" + +#include "arch-utils.h" +#include "arm-tdep.h" +#include "solib-svr4.h" + +/* Description of the longjmp buffer. */ +#define ARM_FBSD_JB_PC 24 +#define ARM_FBSD_JB_ELEMENT_SIZE INT_REGISTER_SIZE + +static void +arm_freebsd_init_abi_common (struct gdbarch_info info, + struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + tdep->lowest_pc = 0x8000; + + tdep->jb_pc = ARM_FBSD_JB_PC; + tdep->jb_elt_size = ARM_FBSD_JB_ELEMENT_SIZE; +} + +static void +arm_freebsd_elf_init_abi (struct gdbarch_info info, + struct gdbarch *gdbarch) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + + arm_freebsd_init_abi_common (info, gdbarch); + + /* FreeBSD ELF uses SVR4-style shared libraries. */ + set_gdbarch_in_solib_call_trampoline + (gdbarch, generic_in_solib_call_trampoline); + set_solib_svr4_fetch_link_map_offsets + (gdbarch, svr4_ilp32_fetch_link_map_offsets); + + tdep->fp_model = ARM_FLOAT_SOFT_VFP; +} + +void +_initialize_armfbsd_tdep (void) +{ + gdbarch_register_osabi (bfd_arch_arm, 0, GDB_OSABI_FREEBSD_ELF, + arm_freebsd_elf_init_abi); +} diff --git a/gnu/usr.bin/gdb/arch/arm/config.h b/gnu/usr.bin/gdb/arch/arm/config.h new file mode 100644 index 000000000000..863f2d9c701b --- /dev/null +++ b/gnu/usr.bin/gdb/arch/arm/config.h @@ -0,0 +1,562 @@ +/* $FreeBSD$ */ + +/* config.h. Generated automatically by configure. */ +/* config.in. Generated automatically from configure.in by autoheader. */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define if using alloca.c. */ +/* #undef C_ALLOCA */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +/* #undef CRAY_STACKSEG_END */ + +/* Define if you have alloca, as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define if you have <alloca.h> and it should be used (not on Ultrix). */ +/* #undef HAVE_ALLOCA_H */ + +/* Define if the `long double' type works. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define if you have <vfork.h>. */ +/* #undef HAVE_VFORK_H */ + +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + +/* Define to `long' if <sys/types.h> doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if <sys/types.h> doesn't define. */ +/* #undef pid_t */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define if the `setpgrp' function takes no argument. */ +/* #undef SETPGRP_VOID */ + +/* Define to `unsigned' if <sys/types.h> doesn't define. */ +/* #undef size_t */ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown + */ +/* #undef STACK_DIRECTION */ + +/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define vfork as fork if vfork does not work. */ +/* #undef vfork */ + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +/* Define if your struct reg has r_fs. */ +/* #define HAVE_STRUCT_REG_R_FS 1 */ + +/* Define if your struct stat has st_blocks. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define if your struct reg has r_gs. */ +/* #define HAVE_STRUCT_REG_R_GS 1 */ + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``l_'' prefix. (For Solaris, SVR4, and + SVR4-like systems.) */ +#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``lm_'' prefix. (For SunOS.) */ +/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ + +/* Define if <link.h> exists and defines a struct so_map which has + members with an ``som_'' prefix. (Found on older *BSD systems.) */ +/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ + +/* Define if <sys/link.h> has struct link_map32 */ +/* #undef HAVE_STRUCT_LINK_MAP32 */ + +/* Define if <sys/link.h> has link_map32 (solaris sparc-64 target) */ +/* #undef _SYSCALL32 */ + +/* Define if the prfpregset_t type is broken. */ +/* #undef PRFPREGSET_T_BROKEN */ + +/* Define if you want to use new multi-fd /proc interface + (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ +/* #undef NEW_PROC_API */ + +/* Define if ioctl argument PIOCSET is available. */ +/* #undef HAVE_PROCFS_PIOCSET */ + +/* Define if the `long long' type works. */ +#define CC_HAS_LONG_LONG 1 + +/* Define if the "ll" format works to print long long ints. */ +#define PRINTF_HAS_LONG_LONG 1 + +/* Define if the "%Lg" format works to print long doubles. */ +#define PRINTF_HAS_LONG_DOUBLE 1 + +/* Define if the "%Lg" format works to scan long doubles. */ +#define SCANF_HAS_LONG_DOUBLE 1 + +/* Define if using Solaris thread debugging. */ +/* #undef HAVE_THREAD_DB_LIB */ + +/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ +/* #undef START_INFERIOR_TRAPS_EXPECTED */ +/* #undef sys_quotactl */ + +/* Define if you have HPUX threads */ +/* #undef HAVE_HPUX_THREAD_SUPPORT */ + +/* Define if <proc_service.h> on solaris uses int instead of + size_t, and assorted other type changes. */ +/* #undef PROC_SERVICE_IS_OLD */ + +/* Define if the simulator is being linked in. */ +#define WITH_SIM 1 + +/* Set to true if the save_state_t structure is present */ +/* #undef HAVE_STRUCT_SAVE_STATE_T */ + +/* Set to true if the save_state_t structure has the ss_wide member */ +/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETREGS request. */ +/* #undef HAVE_PTRACE_GETREGS */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETFPXREGS request. */ +/* #undef HAVE_PTRACE_GETFPXREGS */ + +/* Define if <sys/ptrace.h> defines the PT_GETDBREGS request. */ +#define HAVE_PT_GETDBREGS 1 + +/* Define if <sys/ptrace.h> defines the PT_GETXMMREGS request. */ +/* #undef HAVE_PT_GETXMMREGS */ + +/* Define if libunwind library is being used. */ +/* #undef HAVE_LIBUNWIND */ + +/* hostfile */ +#if 0 +#define GDB_XM_FILE config/arm/xm-fbsd.h +#else +#define GDB_XM_FILE xm-fbsd.h +#endif + +/* targetfile */ +#if 0 +#define GDB_TM_FILE config/arm/tm-fbsd.h +#else +#define GDB_TM_FILE tm-fbsd.h +#endif + +/* nativefile */ +#ifndef CROSS_DEBUGGER +#if 0 +#define GDB_NM_FILE config/arm/nm-fbsd.h +#else +#define GDB_NM_FILE nm-fbsd.h +#endif +#endif + +/* Define to 1 so <sys/proc.h> gets a definition of anon_hdl. Works + around a <sys/proc.h> problem on IRIX 5. */ +#ifndef _KMEMUSER +/* #undef _KMEMUSER */ +#endif + +/* Define if you have the __argz_count function. */ +/* #undef HAVE___ARGZ_COUNT */ + +/* Define if you have the __argz_next function. */ +/* #undef HAVE___ARGZ_NEXT */ + +/* Define if you have the __argz_stringify function. */ +/* #undef HAVE___ARGZ_STRINGIFY */ + +/* Define if you have the _mcleanup function. */ +#define HAVE__MCLEANUP 1 + +/* Define if you have the canonicalize_file_name function. */ +/* #undef HAVE_CANONICALIZE_FILE_NAME */ + +/* Define if you have the dcgettext function. */ +/* #undef HAVE_DCGETTEXT */ + +/* Define if you have the getcwd function. */ +#define HAVE_GETCWD 1 + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the monstartup function. */ +#define HAVE_MONSTARTUP 1 + +/* Define if you have the munmap function. */ +#define HAVE_MUNMAP 1 + +/* Define if you have the poll function. */ +#define HAVE_POLL 1 + +/* Define if you have the pread64 function. */ +/* #undef HAVE_PREAD64 */ + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the realpath function. */ +#define HAVE_REALPATH 1 + +/* Define if you have the sbrk function. */ +/* #undef HAVE_SBRK */ + +/* Define if you have the setenv function. */ +#define HAVE_SETENV 1 + +/* Define if you have the setlocale function. */ +#define HAVE_SETLOCALE 1 + +/* Define if you have the setpgid function. */ +#define HAVE_SETPGID 1 + +/* Define if you have the setpgrp function. */ +#define HAVE_SETPGRP 1 + +/* Define if you have the sigaction function. */ +#define HAVE_SIGACTION 1 + +/* Define if you have the sigprocmask function. */ +#define HAVE_SIGPROCMASK 1 + +/* Define if you have the sigsetmask function. */ +#define HAVE_SIGSETMASK 1 + +/* Define if you have the socketpair function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define if you have the stpcpy function. */ +#define HAVE_STPCPY 1 + +/* Define if you have the strcasecmp function. */ +#define HAVE_STRCASECMP 1 + +/* Define if you have the strchr function. */ +#define HAVE_STRCHR 1 + +/* Define if you have the syscall function. */ +#define HAVE_SYSCALL 1 + +/* Define if you have the <argz.h> header file. */ +/* #undef HAVE_ARGZ_H */ + +/* Define if you have the <ctype.h> header file. */ +#define HAVE_CTYPE_H 1 + +/* Define if you have the <curses.h> header file. */ +#define HAVE_CURSES_H 1 + +/* Define if you have the <dirent.h> header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the <libunwind-ia64.h> header file. */ +/* #undef HAVE_LIBUNWIND_IA64_H */ + +/* Define if you have the <libunwind.h> header file. */ +/* #undef HAVE_LIBUNWIND_H */ + +/* Define if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the <link.h> header file. */ +#define HAVE_LINK_H 1 + +/* Define if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the <machine/reg.h> header file. */ +#define HAVE_MACHINE_REG_H 1 + +/* Define if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if you have the <ncurses.h> header file. */ +#define HAVE_NCURSES_H 1 + +/* Define if you have the <ndir.h> header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the <nl_types.h> header file. */ +#define HAVE_NL_TYPES_H 1 + +/* Define if you have the <nlist.h> header file. */ +#define HAVE_NLIST_H 1 + +/* Define if you have the <poll.h> header file. */ +#define HAVE_POLL_H 1 + +/* Define if you have the <proc_service.h> header file. */ +/* #undef HAVE_PROC_SERVICE_H */ + +/* Define if you have the <ptrace.h> header file. */ +/* #undef HAVE_PTRACE_H */ + +/* Define if you have the <sgtty.h> header file. */ +#define HAVE_SGTTY_H 1 + +/* Define if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define if you have the <sys/debugreg.h> header file. */ +/* #undef HAVE_SYS_DEBUGREG_H */ + +/* Define if you have the <sys/dir.h> header file. */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define if you have the <sys/fault.h> header file. */ +/* #undef HAVE_SYS_FAULT_H */ + +/* Define if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define if you have the <sys/filio.h> header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define if you have the <sys/ndir.h> header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the <sys/poll.h> header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define if you have the <sys/proc.h> header file. */ +#define HAVE_SYS_PROC_H 1 + +/* Define if you have the <sys/procfs.h> header file. */ +#define HAVE_SYS_PROCFS_H 1 + +/* Define if you have the <sys/ptrace.h> header file. */ +#define HAVE_SYS_PTRACE_H 1 + +/* Define if you have the <sys/reg.h> header file. */ +/* #undef HAVE_SYS_REG_H */ + +/* Define if you have the <sys/select.h> header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define if you have the <sys/syscall.h> header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define if you have the <sys/user.h> header file. */ +#define HAVE_SYS_USER_H 1 + +/* Define if you have the <sys/wait.h> header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the <term.h> header file. */ +#define HAVE_TERM_H 1 + +/* Define if you have the <termio.h> header file. */ +/* #undef HAVE_TERMIO_H */ + +/* Define if you have the <termios.h> header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define if you have the <thread_db.h> header file. */ +/* #undef HAVE_THREAD_DB_H */ + +/* Define if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the <values.h> header file. */ +/* #undef HAVE_VALUES_H */ + +/* Define if you have the <wait.h> header file. */ +/* #undef HAVE_WAIT_H */ + +/* Define if you have the dl library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define if you have the m library (-lm). */ +#define HAVE_LIBM 1 + +/* Define if you have the w library (-lw). */ +/* #undef HAVE_LIBW */ + +/* Define if you have the stpcpy function */ +#define HAVE_STPCPY 1 + +/* Define if your locale.h file contains LC_MESSAGES. */ +#define HAVE_LC_MESSAGES 1 + +/* Define to 1 if NLS is requested */ +/* #undef ENABLE_NLS */ + +/* Define as 1 if you have gettext and don't want to use GNU gettext. */ +/* #undef HAVE_GETTEXT */ + +/* Name of this package. */ +#define PACKAGE "gdb" + +/* Define to BFD's default architecture. */ +#define DEFAULT_BFD_ARCH bfd_arm_arch + +/* Define to BFD's default target vector. */ +#define DEFAULT_BFD_VEC bfd_elf32_littlearm_vec + +/* Define to 1 if your system has the _etext variable. */ +#define HAVE__ETEXT 1 + +/* Define to 1 to avoid a clash between <widec.h> and <wchar.h> on + Solaris 2.[78] when using GCC. */ +/* #undef _MSE_INT_H */ + +/* Define to 1 if we found this declaration otherwise define to 0. */ +#define HAVE_DECL_GETOPT 0 + +/* Define if sigsetjmp is available. */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if the regex included in libiberty should be used. */ +#define USE_INCLUDED_REGEX 1 + +/* Define to 1 if your system has struct reg in <machine/reg.h>. */ +#define HAVE_STRUCT_REG 1 + +/* Define if <stdint.h> provides the uintptr_t type. */ +#define HAVE_UINTPTR_T 1 + +/* Define if malloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_MALLOC */ + +/* Define if realloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_REALLOC */ + +/* Define if free is not declared in system header files. */ +/* #undef NEED_DECLARATION_FREE */ + +/* Define if strerror is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRERROR */ + +/* Define if strdup is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRDUP */ + +/* Define if strstr is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRSTR */ + +/* Define if canonicalize_file_name is not declared in system header files. */ +#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 + +/* Define if <sys/procfs.h> has pstatus_t. */ +/* #undef HAVE_PSTATUS_T */ + +/* Define if <sys/procfs.h> has prrun_t. */ +/* #undef HAVE_PRRUN_T */ + +/* Define if <sys/procfs.h> has gregset_t. */ +#define HAVE_GREGSET_T 1 + +/* Define if <sys/procfs.h> has fpregset_t. */ +#define HAVE_FPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset_t. */ +#define HAVE_PRGREGSET_T 1 + +/* Define if <sys/procfs.h> has prfpregset_t. */ +#define HAVE_PRFPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset32_t. */ +/* #undef HAVE_PRGREGSET32_T */ + +/* Define if <sys/procfs.h> has prfpregset32_t. */ +/* #undef HAVE_PRFPREGSET32_T */ + +/* Define if <sys/procfs.h> has lwpid_t. */ +#define HAVE_LWPID_T 1 + +/* Define if <sys/procfs.h> has psaddr_t. */ +#define HAVE_PSADDR_T 1 + +/* Define if <sys/procfs.h> has prsysent_t. */ +/* #undef HAVE_PRSYSENT_T */ + +/* Define if <sys/procfs.h> has pr_sigset_t. */ +/* #undef HAVE_PR_SIGSET_T */ + +/* Define if <sys/procfs.h> has pr_sigaction64_t. */ +/* #undef HAVE_PR_SIGACTION64_T */ + +/* Define if <sys/procfs.h> has pr_siginfo64_t. */ +/* #undef HAVE_PR_SIGINFO64_T */ + +/* Define if <thread_db.h> has the TD_NOTALLOC error code. */ +/* #undef THREAD_DB_HAS_TD_NOTALLOC */ + +/* Define if we can use the tkill syscall. */ +/* #undef HAVE_TKILL_SYSCALL */ + +/* Define to the default OS ABI for this configuration. */ +/* #undef GDB_OSABI_DEFAULT */ + +/* Define to be a string naming the default host character set. */ +#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + diff --git a/gnu/usr.bin/gdb/arch/arm/init.c b/gnu/usr.bin/gdb/arch/arm/init.c new file mode 100644 index 000000000000..d4064dadd4ab --- /dev/null +++ b/gnu/usr.bin/gdb/arch/arm/init.c @@ -0,0 +1,228 @@ +/* $FreeBSD$ */ + +/* Do not modify this file. */ +/* It is created automatically by the Makefile. */ +#include "defs.h" /* For initialize_file_ftype. */ +#include "call-cmds.h" /* For initialize_all_files. */ +extern initialize_file_ftype _initialize_gdbtypes; +extern initialize_file_ftype _initialize_arm_tdep; +extern initialize_file_ftype _initialize_armfbsd_tdep; +extern initialize_file_ftype _initialize_corelow; +extern initialize_file_ftype _initialize_solib; +extern initialize_file_ftype _initialize_svr4_solib; +extern initialize_file_ftype _initialize_ser_hardwire; +extern initialize_file_ftype _initialize_ser_pipe; +extern initialize_file_ftype _initialize_ser_tcp; +#ifndef CROSS_DEBUGGER +extern initialize_file_ftype _initialize_kernel_u_addr; +extern initialize_file_ftype _initialize_infptrace; +extern initialize_file_ftype _initialize_inftarg; +#endif +extern initialize_file_ftype _initialize_arm_fbsdnat; +extern initialize_file_ftype _initialize_remote; +extern initialize_file_ftype _initialize_dcache; +extern initialize_file_ftype _initialize_sr_support; +extern initialize_file_ftype _initialize_tracepoint; +extern initialize_file_ftype _initialize_ax_gdb; +extern initialize_file_ftype _initialize_annotate; +extern initialize_file_ftype _initialize_auxv; +extern initialize_file_ftype _initialize_breakpoint; +extern initialize_file_ftype _initialize_regcache; +extern initialize_file_ftype _initialize_charset; +extern initialize_file_ftype _initialize_dummy_frame; +extern initialize_file_ftype _initialize_source; +extern initialize_file_ftype _initialize_values; +extern initialize_file_ftype _initialize_valops; +extern initialize_file_ftype _initialize_valarith; +extern initialize_file_ftype _initialize_valprint; +extern initialize_file_ftype _initialize_printcmd; +extern initialize_file_ftype _initialize_symtab; +extern initialize_file_ftype _initialize_symfile; +extern initialize_file_ftype _initialize_symmisc; +extern initialize_file_ftype _initialize_infcall; +extern initialize_file_ftype _initialize_infcmd; +extern initialize_file_ftype _initialize_infrun; +extern initialize_file_ftype _initialize_stack; +extern initialize_file_ftype _initialize_thread; +extern initialize_file_ftype _initialize_interpreter; +extern initialize_file_ftype _initialize_macrocmd; +extern initialize_file_ftype _initialize_gdbarch; +extern initialize_file_ftype _initialize_gdbarch_utils; +extern initialize_file_ftype _initialize_gdb_osabi; +extern initialize_file_ftype _initialize_copying; +extern initialize_file_ftype _initialize_mem; +extern initialize_file_ftype _initialize_parse; +extern initialize_file_ftype _initialize_language; +extern initialize_file_ftype _initialize_frame_reg; +extern initialize_file_ftype _initialize_signals; +extern initialize_file_ftype _initialize_kod; +extern initialize_file_ftype _initialize_gdb_events; +extern initialize_file_ftype _initialize_exec; +extern initialize_file_ftype _initialize_maint_cmds; +extern initialize_file_ftype _initialize_demangler; +extern initialize_file_ftype _initialize_dbxread; +extern initialize_file_ftype _initialize_coffread; +extern initialize_file_ftype _initialize_elfread; +extern initialize_file_ftype _initialize_mipsread; +extern initialize_file_ftype _initialize_stabsread; +extern initialize_file_ftype _initialize_core; +extern initialize_file_ftype _initialize_dwarf2_frame; +extern initialize_file_ftype _initialize_c_language; +extern initialize_file_ftype _initialize_f_language; +extern initialize_file_ftype _initialize_objc_language; +extern initialize_file_ftype _initialize_ui_out; +extern initialize_file_ftype _initialize_cli_out; +extern initialize_file_ftype _initialize_varobj; +extern initialize_file_ftype _initialize_java_language; +extern initialize_file_ftype _initialize_m2_language; +extern initialize_file_ftype _initialize_pascal_language; +extern initialize_file_ftype _initialize_pascal_valprint; +extern initialize_file_ftype _initialize_scheme_language; +extern initialize_file_ftype _initialize_complaints; +extern initialize_file_ftype _initialize_typeprint; +extern initialize_file_ftype _initialize_cp_valprint; +extern initialize_file_ftype _initialize_f_valprint; +extern initialize_file_ftype _initialize_nlmread; +extern initialize_file_ftype _initialize_serial; +extern initialize_file_ftype _initialize_mdebugread; +extern initialize_file_ftype _initialize_user_regs; +extern initialize_file_ftype _initialize_frame; +extern initialize_file_ftype _initialize_frame_unwind; +extern initialize_file_ftype _initialize_frame_base; +extern initialize_file_ftype _initialize_gnu_v2_abi; +extern initialize_file_ftype _initialize_gnu_v3_abi; +extern initialize_file_ftype _initialize_hpacc_abi; +extern initialize_file_ftype _initialize_cp_abi; +extern initialize_file_ftype _initialize_cp_support; +extern initialize_file_ftype _initialize_cp_namespace; +extern initialize_file_ftype _initialize_reggroup; +extern initialize_file_ftype _initialize_inflow; +extern initialize_file_ftype _initialize_cli_dump; +extern initialize_file_ftype _initialize_cli_logging; +extern initialize_file_ftype _initialize_cli_interp; +extern initialize_file_ftype _initialize_mi_out; +extern initialize_file_ftype _initialize_mi_cmds; +extern initialize_file_ftype _initialize_mi_cmd_env; +extern initialize_file_ftype _initialize_mi_interp; +extern initialize_file_ftype _initialize_mi_main; +extern initialize_file_ftype _initialize_thread_db; +extern initialize_file_ftype _initialize_tui_hooks; +extern initialize_file_ftype _initialize_tui_interp; +extern initialize_file_ftype _initialize_tui_layout; +extern initialize_file_ftype _initialize_tui_out; +extern initialize_file_ftype _initialize_tui_regs; +extern initialize_file_ftype _initialize_tui_stack; +extern initialize_file_ftype _initialize_tui_win; +void +initialize_all_files (void) +{ + _initialize_gdbtypes (); + _initialize_arm_tdep (); + _initialize_armfbsd_tdep (); + _initialize_corelow (); + _initialize_solib (); + _initialize_svr4_solib (); + _initialize_ser_hardwire (); + _initialize_ser_pipe (); + _initialize_ser_tcp (); +#ifndef CROSS_DEBUGGER + _initialize_kernel_u_addr (); + _initialize_infptrace (); + _initialize_inftarg (); + _initialize_thread_db (); +#endif + _initialize_arm_fbsdnat (); + _initialize_remote (); + _initialize_dcache (); + _initialize_sr_support (); + _initialize_tracepoint (); + _initialize_ax_gdb (); + _initialize_annotate (); + _initialize_auxv (); + _initialize_breakpoint (); + _initialize_regcache (); + _initialize_charset (); + _initialize_dummy_frame (); + _initialize_source (); + _initialize_values (); + _initialize_valops (); + _initialize_valarith (); + _initialize_valprint (); + _initialize_printcmd (); + _initialize_symtab (); + _initialize_symfile (); + _initialize_symmisc (); + _initialize_infcall (); + _initialize_infcmd (); + _initialize_infrun (); + _initialize_stack (); + _initialize_thread (); + _initialize_interpreter (); + _initialize_macrocmd (); + _initialize_gdbarch (); + _initialize_gdbarch_utils (); + _initialize_gdb_osabi (); + _initialize_copying (); + _initialize_mem (); + _initialize_parse (); + _initialize_language (); + _initialize_frame_reg (); + _initialize_signals (); + _initialize_kod (); + _initialize_gdb_events (); + _initialize_exec (); + _initialize_maint_cmds (); + _initialize_demangler (); + _initialize_dbxread (); + _initialize_coffread (); + _initialize_elfread (); + _initialize_mipsread (); + _initialize_stabsread (); + _initialize_core (); + _initialize_dwarf2_frame (); + _initialize_c_language (); + _initialize_f_language (); + _initialize_objc_language (); + _initialize_ui_out (); + _initialize_cli_out (); + _initialize_varobj (); + _initialize_java_language (); + _initialize_m2_language (); + _initialize_pascal_language (); + _initialize_pascal_valprint (); + _initialize_scheme_language (); + _initialize_complaints (); + _initialize_typeprint (); + _initialize_cp_valprint (); + _initialize_f_valprint (); + _initialize_nlmread (); + _initialize_serial (); + _initialize_mdebugread (); + _initialize_user_regs (); + _initialize_frame (); + _initialize_frame_unwind (); + _initialize_frame_base (); + _initialize_gnu_v2_abi (); + _initialize_gnu_v3_abi (); + _initialize_hpacc_abi (); + _initialize_cp_abi (); + _initialize_cp_support (); + _initialize_cp_namespace (); + _initialize_reggroup (); + _initialize_inflow (); + _initialize_cli_dump (); + _initialize_cli_logging (); + _initialize_cli_interp (); + _initialize_mi_out (); + _initialize_mi_cmds (); + _initialize_mi_cmd_env (); + _initialize_mi_interp (); + _initialize_mi_main (); + _initialize_tui_hooks (); + _initialize_tui_interp (); + _initialize_tui_layout (); + _initialize_tui_out (); + _initialize_tui_regs (); + _initialize_tui_stack (); + _initialize_tui_win (); +} diff --git a/gnu/usr.bin/gdb/arch/arm/nm-fbsd.h b/gnu/usr.bin/gdb/arch/arm/nm-fbsd.h new file mode 100644 index 000000000000..8134b1a5d88c --- /dev/null +++ b/gnu/usr.bin/gdb/arch/arm/nm-fbsd.h @@ -0,0 +1,35 @@ +/* $FreeBSD$ */ + +/* Native-dependent definitions for ARM running NetBSD, for GDB. + Copyright 1986, 1987, 1989, 1992, 1994, 1999 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef NM_FBSD_H +#define NM_FBSD_H + +/* Type of the third argument to the `ptrace' system call. */ +#define PTRACE_ARG3_TYPE caddr_t + +/* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */ +#define FETCH_INFERIOR_REGISTERS + +/* We can attach and detach. */ +#define ATTACH_DETACH + +#endif /* NM_FBSD_H */ diff --git a/gnu/usr.bin/gdb/arch/arm/tm-fbsd.h b/gnu/usr.bin/gdb/arch/arm/tm-fbsd.h new file mode 100644 index 000000000000..b010a969acf8 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/arm/tm-fbsd.h @@ -0,0 +1,28 @@ +/* $FreeBSD$ */ + +/* Macro definitions for ARM running under NetBSD. + Copyright 2003 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef TM_FBSD_H +#define TM_FBSD_H + +#include "solib.h" + +#endif /* TM_FBSD_H */ diff --git a/gnu/usr.bin/gdb/arch/arm/xm-fbsd.h b/gnu/usr.bin/gdb/arch/arm/xm-fbsd.h new file mode 100644 index 000000000000..75f8077564c2 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/arm/xm-fbsd.h @@ -0,0 +1,22 @@ +/* $FreeBSD$ */ + +/* Parameters for execution on an ARM running NetBSD, for GDB. + Copyright 1994 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + diff --git a/gnu/usr.bin/gdb/arch/i386/Makefile b/gnu/usr.bin/gdb/arch/i386/Makefile new file mode 100644 index 000000000000..3d9627890827 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/i386/Makefile @@ -0,0 +1,23 @@ +# $FreeBSD$ + +GENSRCS+= xm.h +.if !defined(GDB_CROSS_DEBUGGER) +LIBSRCS+= fbsd-proc.c fbsd-threads.c gcore.c +LIBSRCS+= i386-nat.c i386bsd-nat.c i386fbsd-nat.c +.endif +LIBSRCS+= solib.c solib-svr4.c +LIBSRCS+= i386-tdep.c i386bsd-tdep.c i386fbsd-tdep-fixed.c i387-tdep.c + +nm.h: + echo '#include "i386/nm-fbsd.h"' > ${.TARGET} + +tm.h: + echo '#include "i386/tm-fbsd.h"' > ${.TARGET} + +xm.h: + echo '#include "i386/xm-i386.h"' > ${.TARGET} + +# Fix source static/extern mismatch nits that GCC 4.2 warns about. +CLEANFILES += i386fbsd-tdep-fixed.c +i386fbsd-tdep-fixed.c: i386fbsd-tdep.c + sed -e '48s/^static\ //' ${.ALLSRC} > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/i386/config.h b/gnu/usr.bin/gdb/arch/i386/config.h new file mode 100644 index 000000000000..3f7f579433d5 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/i386/config.h @@ -0,0 +1,550 @@ +/* $FreeBSD$ */ + +/* config.h. Generated automatically by configure. */ +/* config.in. Generated automatically from configure.in by autoheader. */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define if using alloca.c. */ +/* #undef C_ALLOCA */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +/* #undef CRAY_STACKSEG_END */ + +/* Define if you have alloca, as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define if you have <alloca.h> and it should be used (not on Ultrix). */ +/* #undef HAVE_ALLOCA_H */ + +/* Define if the `long double' type works. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define if you have <vfork.h>. */ +/* #undef HAVE_VFORK_H */ + +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + +/* Define to `long' if <sys/types.h> doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if <sys/types.h> doesn't define. */ +/* #undef pid_t */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define if the `setpgrp' function takes no argument. */ +/* #undef SETPGRP_VOID */ + +/* Define to `unsigned' if <sys/types.h> doesn't define. */ +/* #undef size_t */ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown + */ +/* #undef STACK_DIRECTION */ + +/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define vfork as fork if vfork does not work. */ +/* #undef vfork */ + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +/* Define if your struct reg has r_fs. */ +#define HAVE_STRUCT_REG_R_FS 1 + +/* Define if your struct stat has st_blocks. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define if your struct reg has r_gs. */ +#define HAVE_STRUCT_REG_R_GS 1 + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``l_'' prefix. (For Solaris, SVR4, and + SVR4-like systems.) */ +#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``lm_'' prefix. (For SunOS.) */ +/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ + +/* Define if <link.h> exists and defines a struct so_map which has + members with an ``som_'' prefix. (Found on older *BSD systems.) */ +/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ + +/* Define if <sys/link.h> has struct link_map32 */ +/* #undef HAVE_STRUCT_LINK_MAP32 */ + +/* Define if <sys/link.h> has link_map32 (solaris sparc-64 target) */ +/* #undef _SYSCALL32 */ + +/* Define if the prfpregset_t type is broken. */ +/* #undef PRFPREGSET_T_BROKEN */ + +/* Define if you want to use new multi-fd /proc interface + (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ +/* #undef NEW_PROC_API */ + +/* Define if ioctl argument PIOCSET is available. */ +/* #undef HAVE_PROCFS_PIOCSET */ + +/* Define if the `long long' type works. */ +#define CC_HAS_LONG_LONG 1 + +/* Define if the "ll" format works to print long long ints. */ +#define PRINTF_HAS_LONG_LONG 1 + +/* Define if the "%Lg" format works to print long doubles. */ +#define PRINTF_HAS_LONG_DOUBLE 1 + +/* Define if the "%Lg" format works to scan long doubles. */ +#define SCANF_HAS_LONG_DOUBLE 1 + +/* Define if using Solaris thread debugging. */ +/* #undef HAVE_THREAD_DB_LIB */ + +/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ +/* #undef START_INFERIOR_TRAPS_EXPECTED */ +/* #undef sys_quotactl */ + +/* Define if you have HPUX threads */ +/* #undef HAVE_HPUX_THREAD_SUPPORT */ + +/* Define if <proc_service.h> on solaris uses int instead of + size_t, and assorted other type changes. */ +/* #undef PROC_SERVICE_IS_OLD */ + +/* Define if the simulator is being linked in. */ +#define WITH_SIM 1 + +/* Set to true if the save_state_t structure is present */ +/* #undef HAVE_STRUCT_SAVE_STATE_T */ + +/* Set to true if the save_state_t structure has the ss_wide member */ +/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETREGS request. */ +/* #undef HAVE_PTRACE_GETREGS */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETFPXREGS request. */ +/* #undef HAVE_PTRACE_GETFPXREGS */ + +/* Define if <sys/ptrace.h> defines the PT_GETDBREGS request. */ +#define HAVE_PT_GETDBREGS 1 + +/* Define if <sys/ptrace.h> defines the PT_GETXMMREGS request. */ +#define HAVE_PT_GETXMMREGS + +/* Define if libunwind library is being used. */ +/* #undef HAVE_LIBUNWIND */ + +/* hostfile */ +#define GDB_XM_FILE config/i386/xm-i386.h + +/* targetfile */ +#define GDB_TM_FILE config/i386/tm-fbsd.h + +/* nativefile */ +#ifndef CROSS_DEBUGGER +#define GDB_NM_FILE config/i386/nm-fbsd.h +#endif + +/* Define to 1 so <sys/proc.h> gets a definition of anon_hdl. Works + around a <sys/proc.h> problem on IRIX 5. */ +#ifndef _KMEMUSER +/* #undef _KMEMUSER */ +#endif + +/* Define if you have the __argz_count function. */ +/* #undef HAVE___ARGZ_COUNT */ + +/* Define if you have the __argz_next function. */ +/* #undef HAVE___ARGZ_NEXT */ + +/* Define if you have the __argz_stringify function. */ +/* #undef HAVE___ARGZ_STRINGIFY */ + +/* Define if you have the _mcleanup function. */ +#define HAVE__MCLEANUP 1 + +/* Define if you have the canonicalize_file_name function. */ +/* #undef HAVE_CANONICALIZE_FILE_NAME */ + +/* Define if you have the dcgettext function. */ +/* #undef HAVE_DCGETTEXT */ + +/* Define if you have the getcwd function. */ +#define HAVE_GETCWD 1 + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the monstartup function. */ +#define HAVE_MONSTARTUP 1 + +/* Define if you have the munmap function. */ +#define HAVE_MUNMAP 1 + +/* Define if you have the poll function. */ +#define HAVE_POLL 1 + +/* Define if you have the pread64 function. */ +/* #undef HAVE_PREAD64 */ + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the realpath function. */ +#define HAVE_REALPATH 1 + +/* Define if you have the sbrk function. */ +/* #undef HAVE_SBRK */ + +/* Define if you have the setenv function. */ +#define HAVE_SETENV 1 + +/* Define if you have the setlocale function. */ +#define HAVE_SETLOCALE 1 + +/* Define if you have the setpgid function. */ +#define HAVE_SETPGID 1 + +/* Define if you have the setpgrp function. */ +#define HAVE_SETPGRP 1 + +/* Define if you have the sigaction function. */ +#define HAVE_SIGACTION 1 + +/* Define if you have the sigprocmask function. */ +#define HAVE_SIGPROCMASK 1 + +/* Define if you have the sigsetmask function. */ +#define HAVE_SIGSETMASK 1 + +/* Define if you have the socketpair function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define if you have the stpcpy function. */ +#define HAVE_STPCPY 1 + +/* Define if you have the strcasecmp function. */ +#define HAVE_STRCASECMP 1 + +/* Define if you have the strchr function. */ +#define HAVE_STRCHR 1 + +/* Define if you have the syscall function. */ +#define HAVE_SYSCALL 1 + +/* Define if you have the <argz.h> header file. */ +/* #undef HAVE_ARGZ_H */ + +/* Define if you have the <ctype.h> header file. */ +#define HAVE_CTYPE_H 1 + +/* Define if you have the <curses.h> header file. */ +#define HAVE_CURSES_H 1 + +/* Define if you have the <dirent.h> header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the <libunwind-ia64.h> header file. */ +/* #undef HAVE_LIBUNWIND_IA64_H */ + +/* Define if you have the <libunwind.h> header file. */ +/* #undef HAVE_LIBUNWIND_H */ + +/* Define if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the <link.h> header file. */ +#define HAVE_LINK_H 1 + +/* Define if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the <machine/reg.h> header file. */ +#define HAVE_MACHINE_REG_H 1 + +/* Define if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if you have the <ncurses.h> header file. */ +#define HAVE_NCURSES_H 1 + +/* Define if you have the <ndir.h> header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the <nl_types.h> header file. */ +#define HAVE_NL_TYPES_H 1 + +/* Define if you have the <nlist.h> header file. */ +#define HAVE_NLIST_H 1 + +/* Define if you have the <poll.h> header file. */ +#define HAVE_POLL_H 1 + +/* Define if you have the <proc_service.h> header file. */ +/* #undef HAVE_PROC_SERVICE_H */ + +/* Define if you have the <ptrace.h> header file. */ +/* #undef HAVE_PTRACE_H */ + +/* Define if you have the <sgtty.h> header file. */ +#define HAVE_SGTTY_H 1 + +/* Define if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define if you have the <sys/debugreg.h> header file. */ +/* #undef HAVE_SYS_DEBUGREG_H */ + +/* Define if you have the <sys/dir.h> header file. */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define if you have the <sys/fault.h> header file. */ +/* #undef HAVE_SYS_FAULT_H */ + +/* Define if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define if you have the <sys/filio.h> header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define if you have the <sys/ndir.h> header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the <sys/poll.h> header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define if you have the <sys/proc.h> header file. */ +#define HAVE_SYS_PROC_H 1 + +/* Define if you have the <sys/procfs.h> header file. */ +#define HAVE_SYS_PROCFS_H 1 + +/* Define if you have the <sys/ptrace.h> header file. */ +#define HAVE_SYS_PTRACE_H 1 + +/* Define if you have the <sys/reg.h> header file. */ +/* #undef HAVE_SYS_REG_H */ + +/* Define if you have the <sys/select.h> header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define if you have the <sys/syscall.h> header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define if you have the <sys/user.h> header file. */ +#define HAVE_SYS_USER_H 1 + +/* Define if you have the <sys/wait.h> header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the <term.h> header file. */ +#define HAVE_TERM_H 1 + +/* Define if you have the <termio.h> header file. */ +/* #undef HAVE_TERMIO_H */ + +/* Define if you have the <termios.h> header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define if you have the <thread_db.h> header file. */ +/* #undef HAVE_THREAD_DB_H */ + +/* Define if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the <values.h> header file. */ +/* #undef HAVE_VALUES_H */ + +/* Define if you have the <wait.h> header file. */ +/* #undef HAVE_WAIT_H */ + +/* Define if you have the dl library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define if you have the m library (-lm). */ +#define HAVE_LIBM 1 + +/* Define if you have the w library (-lw). */ +/* #undef HAVE_LIBW */ + +/* Define if you have the stpcpy function */ +#define HAVE_STPCPY 1 + +/* Define if your locale.h file contains LC_MESSAGES. */ +#define HAVE_LC_MESSAGES 1 + +/* Define to 1 if NLS is requested */ +/* #undef ENABLE_NLS */ + +/* Define as 1 if you have gettext and don't want to use GNU gettext. */ +/* #undef HAVE_GETTEXT */ + +/* Name of this package. */ +#define PACKAGE "gdb" + +/* Define to BFD's default architecture. */ +#define DEFAULT_BFD_ARCH bfd_i386_arch + +/* Define to BFD's default target vector. */ +#define DEFAULT_BFD_VEC bfd_elf32_i386_freebsd_vec + +/* Define to 1 if your system has the _etext variable. */ +#define HAVE__ETEXT 1 + +/* Define to 1 to avoid a clash between <widec.h> and <wchar.h> on + Solaris 2.[78] when using GCC. */ +/* #undef _MSE_INT_H */ + +/* Define to 1 if we found this declaration otherwise define to 0. */ +#define HAVE_DECL_GETOPT 0 + +/* Define if sigsetjmp is available. */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if the regex included in libiberty should be used. */ +#define USE_INCLUDED_REGEX 1 + +/* Define to 1 if your system has struct reg in <machine/reg.h>. */ +#define HAVE_STRUCT_REG 1 + +/* Define if <stdint.h> provides the uintptr_t type. */ +#define HAVE_UINTPTR_T 1 + +/* Define if malloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_MALLOC */ + +/* Define if realloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_REALLOC */ + +/* Define if free is not declared in system header files. */ +/* #undef NEED_DECLARATION_FREE */ + +/* Define if strerror is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRERROR */ + +/* Define if strdup is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRDUP */ + +/* Define if strstr is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRSTR */ + +/* Define if canonicalize_file_name is not declared in system header files. */ +#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 + +/* Define if <sys/procfs.h> has pstatus_t. */ +/* #undef HAVE_PSTATUS_T */ + +/* Define if <sys/procfs.h> has prrun_t. */ +/* #undef HAVE_PRRUN_T */ + +/* Define if <sys/procfs.h> has gregset_t. */ +#define HAVE_GREGSET_T 1 + +/* Define if <sys/procfs.h> has fpregset_t. */ +#define HAVE_FPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset_t. */ +#define HAVE_PRGREGSET_T 1 + +/* Define if <sys/procfs.h> has prfpregset_t. */ +#define HAVE_PRFPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset32_t. */ +/* #undef HAVE_PRGREGSET32_T */ + +/* Define if <sys/procfs.h> has prfpregset32_t. */ +/* #undef HAVE_PRFPREGSET32_T */ + +/* Define if <sys/procfs.h> has lwpid_t. */ +#define HAVE_LWPID_T 1 + +/* Define if <sys/procfs.h> has psaddr_t. */ +#define HAVE_PSADDR_T 1 + +/* Define if <sys/procfs.h> has prsysent_t. */ +/* #undef HAVE_PRSYSENT_T */ + +/* Define if <sys/procfs.h> has pr_sigset_t. */ +/* #undef HAVE_PR_SIGSET_T */ + +/* Define if <sys/procfs.h> has pr_sigaction64_t. */ +/* #undef HAVE_PR_SIGACTION64_T */ + +/* Define if <sys/procfs.h> has pr_siginfo64_t. */ +/* #undef HAVE_PR_SIGINFO64_T */ + +/* Define if <thread_db.h> has the TD_NOTALLOC error code. */ +/* #undef THREAD_DB_HAS_TD_NOTALLOC */ + +/* Define if we can use the tkill syscall. */ +/* #undef HAVE_TKILL_SYSCALL */ + +/* Define to the default OS ABI for this configuration. */ +/* #undef GDB_OSABI_DEFAULT */ + +/* Define to be a string naming the default host character set. */ +#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + diff --git a/gnu/usr.bin/gdb/arch/i386/init.c b/gnu/usr.bin/gdb/arch/i386/init.c new file mode 100644 index 000000000000..7675d8e688ce --- /dev/null +++ b/gnu/usr.bin/gdb/arch/i386/init.c @@ -0,0 +1,236 @@ +/* $FreeBSD$ */ + +/* Do not modify this file. */ +/* It is created automatically by the Makefile. */ +#include "defs.h" /* For initialize_file_ftype. */ +#include "call-cmds.h" /* For initialize_all_files. */ +extern initialize_file_ftype _initialize_gdbtypes; +extern initialize_file_ftype _initialize_i386_tdep; +extern initialize_file_ftype _initialize_i386bsd_tdep; +extern initialize_file_ftype _initialize_i386fbsd_tdep; +extern initialize_file_ftype _initialize_corelow; +extern initialize_file_ftype _initialize_solib; +extern initialize_file_ftype _initialize_svr4_solib; +extern initialize_file_ftype _initialize_ser_hardwire; +extern initialize_file_ftype _initialize_ser_pipe; +extern initialize_file_ftype _initialize_ser_tcp; +extern initialize_file_ftype _initialize_kernel_u_addr; +extern initialize_file_ftype _initialize_infptrace; +extern initialize_file_ftype _initialize_inftarg; +extern initialize_file_ftype _initialize_i386_nat; +extern initialize_file_ftype _initialize_i386bsd_nat; +extern initialize_file_ftype _initialize_i386fbsd_nat; +extern initialize_file_ftype _initialize_gcore; +extern initialize_file_ftype _initialize_fbsd_proc; +extern initialize_file_ftype _initialize_remote; +extern initialize_file_ftype _initialize_dcache; +extern initialize_file_ftype _initialize_sr_support; +extern initialize_file_ftype _initialize_tracepoint; +extern initialize_file_ftype _initialize_ax_gdb; +extern initialize_file_ftype _initialize_annotate; +extern initialize_file_ftype _initialize_auxv; +extern initialize_file_ftype _initialize_breakpoint; +extern initialize_file_ftype _initialize_regcache; +extern initialize_file_ftype _initialize_charset; +extern initialize_file_ftype _initialize_dummy_frame; +extern initialize_file_ftype _initialize_source; +extern initialize_file_ftype _initialize_values; +extern initialize_file_ftype _initialize_valops; +extern initialize_file_ftype _initialize_valarith; +extern initialize_file_ftype _initialize_valprint; +extern initialize_file_ftype _initialize_printcmd; +extern initialize_file_ftype _initialize_symtab; +extern initialize_file_ftype _initialize_symfile; +extern initialize_file_ftype _initialize_symmisc; +extern initialize_file_ftype _initialize_infcall; +extern initialize_file_ftype _initialize_infcmd; +extern initialize_file_ftype _initialize_infrun; +extern initialize_file_ftype _initialize_stack; +extern initialize_file_ftype _initialize_thread; +extern initialize_file_ftype _initialize_interpreter; +extern initialize_file_ftype _initialize_macrocmd; +extern initialize_file_ftype _initialize_gdbarch; +extern initialize_file_ftype _initialize_gdbarch_utils; +extern initialize_file_ftype _initialize_gdb_osabi; +extern initialize_file_ftype _initialize_copying; +extern initialize_file_ftype _initialize_mem; +extern initialize_file_ftype _initialize_parse; +extern initialize_file_ftype _initialize_language; +extern initialize_file_ftype _initialize_frame_reg; +extern initialize_file_ftype _initialize_signals; +extern initialize_file_ftype _initialize_kod; +extern initialize_file_ftype _initialize_gdb_events; +extern initialize_file_ftype _initialize_exec; +extern initialize_file_ftype _initialize_maint_cmds; +extern initialize_file_ftype _initialize_demangler; +extern initialize_file_ftype _initialize_dbxread; +extern initialize_file_ftype _initialize_coffread; +extern initialize_file_ftype _initialize_elfread; +extern initialize_file_ftype _initialize_mipsread; +extern initialize_file_ftype _initialize_stabsread; +extern initialize_file_ftype _initialize_core; +extern initialize_file_ftype _initialize_dwarf2_frame; +extern initialize_file_ftype _initialize_c_language; +extern initialize_file_ftype _initialize_f_language; +extern initialize_file_ftype _initialize_objc_language; +extern initialize_file_ftype _initialize_ui_out; +extern initialize_file_ftype _initialize_cli_out; +extern initialize_file_ftype _initialize_varobj; +extern initialize_file_ftype _initialize_java_language; +extern initialize_file_ftype _initialize_m2_language; +extern initialize_file_ftype _initialize_pascal_language; +extern initialize_file_ftype _initialize_pascal_valprint; +extern initialize_file_ftype _initialize_scheme_language; +extern initialize_file_ftype _initialize_complaints; +extern initialize_file_ftype _initialize_typeprint; +extern initialize_file_ftype _initialize_cp_valprint; +extern initialize_file_ftype _initialize_f_valprint; +extern initialize_file_ftype _initialize_nlmread; +extern initialize_file_ftype _initialize_serial; +extern initialize_file_ftype _initialize_mdebugread; +extern initialize_file_ftype _initialize_user_regs; +extern initialize_file_ftype _initialize_frame; +extern initialize_file_ftype _initialize_frame_unwind; +extern initialize_file_ftype _initialize_frame_base; +extern initialize_file_ftype _initialize_gnu_v2_abi; +extern initialize_file_ftype _initialize_gnu_v3_abi; +extern initialize_file_ftype _initialize_hpacc_abi; +extern initialize_file_ftype _initialize_cp_abi; +extern initialize_file_ftype _initialize_cp_support; +extern initialize_file_ftype _initialize_cp_namespace; +extern initialize_file_ftype _initialize_reggroup; +extern initialize_file_ftype _initialize_inflow; +extern initialize_file_ftype _initialize_cli_dump; +extern initialize_file_ftype _initialize_cli_logging; +extern initialize_file_ftype _initialize_cli_interp; +extern initialize_file_ftype _initialize_mi_out; +extern initialize_file_ftype _initialize_mi_cmds; +extern initialize_file_ftype _initialize_mi_cmd_env; +extern initialize_file_ftype _initialize_mi_interp; +extern initialize_file_ftype _initialize_mi_main; +extern initialize_file_ftype _initialize_thread_db; +extern initialize_file_ftype _initialize_tui_hooks; +extern initialize_file_ftype _initialize_tui_interp; +extern initialize_file_ftype _initialize_tui_layout; +extern initialize_file_ftype _initialize_tui_out; +extern initialize_file_ftype _initialize_tui_regs; +extern initialize_file_ftype _initialize_tui_stack; +extern initialize_file_ftype _initialize_tui_win; +void +initialize_all_files (void) +{ + _initialize_gdbtypes (); + _initialize_i386_tdep (); + _initialize_i386bsd_tdep (); + _initialize_i386fbsd_tdep (); + _initialize_corelow (); + _initialize_solib (); + _initialize_svr4_solib (); + _initialize_ser_hardwire (); + _initialize_ser_pipe (); + _initialize_ser_tcp (); +#ifndef CROSS_DEBUGGER + _initialize_kernel_u_addr (); + _initialize_infptrace (); + _initialize_inftarg (); + _initialize_i386_nat (); + _initialize_i386bsd_nat (); + _initialize_i386fbsd_nat (); + _initialize_gcore (); + _initialize_fbsd_proc (); + _initialize_thread_db (); +#endif + _initialize_remote (); + _initialize_dcache (); + _initialize_sr_support (); + _initialize_tracepoint (); + _initialize_ax_gdb (); + _initialize_annotate (); + _initialize_auxv (); + _initialize_breakpoint (); + _initialize_regcache (); + _initialize_charset (); + _initialize_dummy_frame (); + _initialize_source (); + _initialize_values (); + _initialize_valops (); + _initialize_valarith (); + _initialize_valprint (); + _initialize_printcmd (); + _initialize_symtab (); + _initialize_symfile (); + _initialize_symmisc (); + _initialize_infcall (); + _initialize_infcmd (); + _initialize_infrun (); + _initialize_stack (); + _initialize_thread (); + _initialize_interpreter (); + _initialize_macrocmd (); + _initialize_gdbarch (); + _initialize_gdbarch_utils (); + _initialize_gdb_osabi (); + _initialize_copying (); + _initialize_mem (); + _initialize_parse (); + _initialize_language (); + _initialize_frame_reg (); + _initialize_signals (); + _initialize_kod (); + _initialize_gdb_events (); + _initialize_exec (); + _initialize_maint_cmds (); + _initialize_demangler (); + _initialize_dbxread (); + _initialize_coffread (); + _initialize_elfread (); + _initialize_mipsread (); + _initialize_stabsread (); + _initialize_core (); + _initialize_dwarf2_frame (); + _initialize_c_language (); + _initialize_f_language (); + _initialize_objc_language (); + _initialize_ui_out (); + _initialize_cli_out (); + _initialize_varobj (); + _initialize_java_language (); + _initialize_m2_language (); + _initialize_pascal_language (); + _initialize_pascal_valprint (); + _initialize_scheme_language (); + _initialize_complaints (); + _initialize_typeprint (); + _initialize_cp_valprint (); + _initialize_f_valprint (); + _initialize_nlmread (); + _initialize_serial (); + _initialize_mdebugread (); + _initialize_user_regs (); + _initialize_frame (); + _initialize_frame_unwind (); + _initialize_frame_base (); + _initialize_gnu_v2_abi (); + _initialize_gnu_v3_abi (); + _initialize_hpacc_abi (); + _initialize_cp_abi (); + _initialize_cp_support (); + _initialize_cp_namespace (); + _initialize_reggroup (); + _initialize_inflow (); + _initialize_cli_dump (); + _initialize_cli_logging (); + _initialize_cli_interp (); + _initialize_mi_out (); + _initialize_mi_cmds (); + _initialize_mi_cmd_env (); + _initialize_mi_interp (); + _initialize_mi_main (); + _initialize_tui_hooks (); + _initialize_tui_interp (); + _initialize_tui_layout (); + _initialize_tui_out (); + _initialize_tui_regs (); + _initialize_tui_stack (); + _initialize_tui_win (); +} diff --git a/gnu/usr.bin/gdb/arch/mips/Makefile b/gnu/usr.bin/gdb/arch/mips/Makefile new file mode 100644 index 000000000000..24e9cfce25e5 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/mips/Makefile @@ -0,0 +1,16 @@ +# $FreeBSD$ + +# +# XXX Should set DEFAULT_BFD_VEC based on target. +# +.if !defined(GDB_CROSS_DEBUGGER) +LIBSRCS+= mipsfbsd-nat.c fbsd-threads.c +.endif +LIBSRCS+= solib.c solib-svr4.c +LIBSRCS+= mips-tdep.c mipsfbsd-tdep.c fbsd-proc.c + +nm.h: + echo '#include "mips/nm-fbsd.h"' > ${.TARGET} + +tm.h: + echo '#include "mips/tm-fbsd.h"' > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/mips/config.h b/gnu/usr.bin/gdb/arch/mips/config.h new file mode 100644 index 000000000000..c0b04cc5e550 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/mips/config.h @@ -0,0 +1,550 @@ +/* $FreeBSD$ */ + +/* config.h. Generated automatically by configure. */ +/* config.in. Generated automatically from configure.in by autoheader. */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define if using alloca.c. */ +/* #undef C_ALLOCA */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +/* #undef CRAY_STACKSEG_END */ + +/* Define if you have alloca, as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define if you have <alloca.h> and it should be used (not on Ultrix). */ +/* #undef HAVE_ALLOCA_H */ + +/* Define if the `long double' type works. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define if you have <vfork.h>. */ +/* #undef HAVE_VFORK_H */ + +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + +/* Define to `long' if <sys/types.h> doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if <sys/types.h> doesn't define. */ +/* #undef pid_t */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define if the `setpgrp' function takes no argument. */ +/* #undef SETPGRP_VOID */ + +/* Define to `unsigned' if <sys/types.h> doesn't define. */ +/* #undef size_t */ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown + */ +/* #undef STACK_DIRECTION */ + +/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define vfork as fork if vfork does not work. */ +/* #undef vfork */ + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +/* Define if your struct reg has r_fs. */ +/* #undef HAVE_STRUCT_REG_R_FS */ + +/* Define if your struct stat has st_blocks. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define if your struct reg has r_gs. */ +/* #undef HAVE_STRUCT_REG_R_GS */ + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``l_'' prefix. (For Solaris, SVR4, and + SVR4-like systems.) */ +#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``lm_'' prefix. (For SunOS.) */ +/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ + +/* Define if <link.h> exists and defines a struct so_map which has + members with an ``som_'' prefix. (Found on older *BSD systems.) */ +/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ + +/* Define if <sys/link.h> has struct link_map32 */ +/* #undef HAVE_STRUCT_LINK_MAP32 */ + +/* Define if <sys/link.h> has link_map32 (solaris sparc-64 target) */ +/* #undef _SYSCALL32 */ + +/* Define if the prfpregset_t type is broken. */ +/* #undef PRFPREGSET_T_BROKEN */ + +/* Define if you want to use new multi-fd /proc interface + (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ +/* #undef NEW_PROC_API */ + +/* Define if ioctl argument PIOCSET is available. */ +/* #undef HAVE_PROCFS_PIOCSET */ + +/* Define if the `long long' type works. */ +#define CC_HAS_LONG_LONG 1 + +/* Define if the "ll" format works to print long long ints. */ +#define PRINTF_HAS_LONG_LONG 1 + +/* Define if the "%Lg" format works to print long doubles. */ +#define PRINTF_HAS_LONG_DOUBLE 1 + +/* Define if the "%Lg" format works to scan long doubles. */ +#define SCANF_HAS_LONG_DOUBLE 1 + +/* Define if using Solaris thread debugging. */ +/* #undef HAVE_THREAD_DB_LIB */ + +/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ +/* #undef START_INFERIOR_TRAPS_EXPECTED */ +/* #undef sys_quotactl */ + +/* Define if you have HPUX threads */ +/* #undef HAVE_HPUX_THREAD_SUPPORT */ + +/* Define if <proc_service.h> on solaris uses int instead of + size_t, and assorted other type changes. */ +/* #undef PROC_SERVICE_IS_OLD */ + +/* Define if the simulator is being linked in. */ +#define WITH_SIM 1 + +/* Set to true if the save_state_t structure is present */ +/* #undef HAVE_STRUCT_SAVE_STATE_T */ + +/* Set to true if the save_state_t structure has the ss_wide member */ +/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETREGS request. */ +/* #undef HAVE_PTRACE_GETREGS */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETFPXREGS request. */ +/* #undef HAVE_PTRACE_GETFPXREGS */ + +/* Define if <sys/ptrace.h> defines the PT_GETDBREGS request. */ +#define HAVE_PT_GETDBREGS 1 + +/* Define if <sys/ptrace.h> defines the PT_GETXMMREGS request. */ +/* #undef HAVE_PT_GETXMMREGS */ + +/* Define if libunwind library is being used. */ +/* #undef HAVE_LIBUNWIND */ + +/* hostfile */ +/* #undef GDB_XM_FILE */ + +/* targetfile */ +#define GDB_TM_FILE config/mips/tm-fbsd.h + +/* nativefile */ +#ifndef CROSS_DEBUGGER +#define GDB_NM_FILE config/mips/nm-fbsd.h +#endif + +/* Define to 1 so <sys/proc.h> gets a definition of anon_hdl. Works + around a <sys/proc.h> problem on IRIX 5. */ +#ifndef _KMEMUSER +/* #undef _KMEMUSER */ +#endif + +/* Define if you have the __argz_count function. */ +/* #undef HAVE___ARGZ_COUNT */ + +/* Define if you have the __argz_next function. */ +/* #undef HAVE___ARGZ_NEXT */ + +/* Define if you have the __argz_stringify function. */ +/* #undef HAVE___ARGZ_STRINGIFY */ + +/* Define if you have the _mcleanup function. */ +#define HAVE__MCLEANUP 1 + +/* Define if you have the canonicalize_file_name function. */ +/* #undef HAVE_CANONICALIZE_FILE_NAME */ + +/* Define if you have the dcgettext function. */ +/* #undef HAVE_DCGETTEXT */ + +/* Define if you have the getcwd function. */ +#define HAVE_GETCWD 1 + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the monstartup function. */ +#define HAVE_MONSTARTUP 1 + +/* Define if you have the munmap function. */ +#define HAVE_MUNMAP 1 + +/* Define if you have the poll function. */ +#define HAVE_POLL 1 + +/* Define if you have the pread64 function. */ +/* #undef HAVE_PREAD64 */ + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the realpath function. */ +#define HAVE_REALPATH 1 + +/* Define if you have the sbrk function. */ +/* #undef HAVE_SBRK */ + +/* Define if you have the setenv function. */ +#define HAVE_SETENV 1 + +/* Define if you have the setlocale function. */ +#define HAVE_SETLOCALE 1 + +/* Define if you have the setpgid function. */ +#define HAVE_SETPGID 1 + +/* Define if you have the setpgrp function. */ +#define HAVE_SETPGRP 1 + +/* Define if you have the sigaction function. */ +#define HAVE_SIGACTION 1 + +/* Define if you have the sigprocmask function. */ +#define HAVE_SIGPROCMASK 1 + +/* Define if you have the sigsetmask function. */ +#define HAVE_SIGSETMASK 1 + +/* Define if you have the socketpair function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define if you have the stpcpy function. */ +#define HAVE_STPCPY 1 + +/* Define if you have the strcasecmp function. */ +#define HAVE_STRCASECMP 1 + +/* Define if you have the strchr function. */ +#define HAVE_STRCHR 1 + +/* Define if you have the syscall function. */ +#define HAVE_SYSCALL 1 + +/* Define if you have the <argz.h> header file. */ +/* #undef HAVE_ARGZ_H */ + +/* Define if you have the <ctype.h> header file. */ +#define HAVE_CTYPE_H 1 + +/* Define if you have the <curses.h> header file. */ +#define HAVE_CURSES_H 1 + +/* Define if you have the <dirent.h> header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the <libunwind-ia64.h> header file. */ +/* #undef HAVE_LIBUNWIND_IA64_H */ + +/* Define if you have the <libunwind.h> header file. */ +/* #undef HAVE_LIBUNWIND_H */ + +/* Define if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the <link.h> header file. */ +#define HAVE_LINK_H 1 + +/* Define if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the <machine/reg.h> header file. */ +#define HAVE_MACHINE_REG_H 1 + +/* Define if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if you have the <ncurses.h> header file. */ +#define HAVE_NCURSES_H 1 + +/* Define if you have the <ndir.h> header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the <nl_types.h> header file. */ +#define HAVE_NL_TYPES_H 1 + +/* Define if you have the <nlist.h> header file. */ +#define HAVE_NLIST_H 1 + +/* Define if you have the <poll.h> header file. */ +#define HAVE_POLL_H 1 + +/* Define if you have the <proc_service.h> header file. */ +/* #undef HAVE_PROC_SERVICE_H */ + +/* Define if you have the <ptrace.h> header file. */ +/* #undef HAVE_PTRACE_H */ + +/* Define if you have the <sgtty.h> header file. */ +#define HAVE_SGTTY_H 1 + +/* Define if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define if you have the <sys/debugreg.h> header file. */ +/* #undef HAVE_SYS_DEBUGREG_H */ + +/* Define if you have the <sys/dir.h> header file. */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define if you have the <sys/fault.h> header file. */ +/* #undef HAVE_SYS_FAULT_H */ + +/* Define if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define if you have the <sys/filio.h> header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define if you have the <sys/ndir.h> header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the <sys/poll.h> header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define if you have the <sys/proc.h> header file. */ +#define HAVE_SYS_PROC_H 1 + +/* Define if you have the <sys/procfs.h> header file. */ +#define HAVE_SYS_PROCFS_H 1 + +/* Define if you have the <sys/ptrace.h> header file. */ +#define HAVE_SYS_PTRACE_H 1 + +/* Define if you have the <sys/reg.h> header file. */ +/* #undef HAVE_SYS_REG_H */ + +/* Define if you have the <sys/select.h> header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define if you have the <sys/syscall.h> header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define if you have the <sys/user.h> header file. */ +#define HAVE_SYS_USER_H 1 + +/* Define if you have the <sys/wait.h> header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the <term.h> header file. */ +#define HAVE_TERM_H 1 + +/* Define if you have the <termio.h> header file. */ +/* #undef HAVE_TERMIO_H */ + +/* Define if you have the <termios.h> header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define if you have the <thread_db.h> header file. */ +/* #undef HAVE_THREAD_DB_H */ + +/* Define if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the <values.h> header file. */ +/* #undef HAVE_VALUES_H */ + +/* Define if you have the <wait.h> header file. */ +/* #undef HAVE_WAIT_H */ + +/* Define if you have the dl library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define if you have the m library (-lm). */ +#define HAVE_LIBM 1 + +/* Define if you have the w library (-lw). */ +/* #undef HAVE_LIBW */ + +/* Define if you have the stpcpy function */ +#define HAVE_STPCPY 1 + +/* Define if your locale.h file contains LC_MESSAGES. */ +#define HAVE_LC_MESSAGES 1 + +/* Define to 1 if NLS is requested */ +/* #undef ENABLE_NLS */ + +/* Define as 1 if you have gettext and don't want to use GNU gettext. */ +/* #undef HAVE_GETTEXT */ + +/* Name of this package. */ +#define PACKAGE "gdb" + +/* Define to BFD's default architecture. */ +#define DEFAULT_BFD_ARCH bfd_mips_arch + +/* Define to BFD's default target vector. */ +#define DEFAULT_BFD_VEC bfd_elf32_littlemips_vec + +/* Define to 1 if your system has the _etext variable. */ +#define HAVE__ETEXT 1 + +/* Define to 1 to avoid a clash between <widec.h> and <wchar.h> on + Solaris 2.[78] when using GCC. */ +/* #undef _MSE_INT_H */ + +/* Define to 1 if we found this declaration otherwise define to 0. */ +#define HAVE_DECL_GETOPT 0 + +/* Define if sigsetjmp is available. */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if the regex included in libiberty should be used. */ +#define USE_INCLUDED_REGEX 1 + +/* Define to 1 if your system has struct reg in <machine/reg.h>. */ +#define HAVE_STRUCT_REG 1 + +/* Define if <stdint.h> provides the uintptr_t type. */ +#define HAVE_UINTPTR_T 1 + +/* Define if malloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_MALLOC */ + +/* Define if realloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_REALLOC */ + +/* Define if free is not declared in system header files. */ +/* #undef NEED_DECLARATION_FREE */ + +/* Define if strerror is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRERROR */ + +/* Define if strdup is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRDUP */ + +/* Define if strstr is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRSTR */ + +/* Define if canonicalize_file_name is not declared in system header files. */ +#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 + +/* Define if <sys/procfs.h> has pstatus_t. */ +/* #undef HAVE_PSTATUS_T */ + +/* Define if <sys/procfs.h> has prrun_t. */ +/* #undef HAVE_PRRUN_T */ + +/* Define if <sys/procfs.h> has gregset_t. */ +#define HAVE_GREGSET_T 1 + +/* Define if <sys/procfs.h> has fpregset_t. */ +#define HAVE_FPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset_t. */ +#define HAVE_PRGREGSET_T 1 + +/* Define if <sys/procfs.h> has prfpregset_t. */ +#define HAVE_PRFPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset32_t. */ +/* #undef HAVE_PRGREGSET32_T */ + +/* Define if <sys/procfs.h> has prfpregset32_t. */ +/* #undef HAVE_PRFPREGSET32_T */ + +/* Define if <sys/procfs.h> has lwpid_t. */ +#define HAVE_LWPID_T 1 + +/* Define if <sys/procfs.h> has psaddr_t. */ +#define HAVE_PSADDR_T 1 + +/* Define if <sys/procfs.h> has prsysent_t. */ +/* #undef HAVE_PRSYSENT_T */ + +/* Define if <sys/procfs.h> has pr_sigset_t. */ +/* #undef HAVE_PR_SIGSET_T */ + +/* Define if <sys/procfs.h> has pr_sigaction64_t. */ +/* #undef HAVE_PR_SIGACTION64_T */ + +/* Define if <sys/procfs.h> has pr_siginfo64_t. */ +/* #undef HAVE_PR_SIGINFO64_T */ + +/* Define if <thread_db.h> has the TD_NOTALLOC error code. */ +/* #undef THREAD_DB_HAS_TD_NOTALLOC */ + +/* Define if we can use the tkill syscall. */ +/* #undef HAVE_TKILL_SYSCALL */ + +/* Define to the default OS ABI for this configuration. */ +/* #undef GDB_OSABI_DEFAULT */ + +/* Define to be a string naming the default host character set. */ +#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + diff --git a/gnu/usr.bin/gdb/arch/mips/init.c b/gnu/usr.bin/gdb/arch/mips/init.c new file mode 100644 index 000000000000..491b2b3ee396 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/mips/init.c @@ -0,0 +1,233 @@ +/* $FreeBSD$ */ + +/* Do not modify this file. */ +/* It is created automatically by the Makefile. */ +#include "defs.h" /* For initialize_file_ftype. */ +#include "call-cmds.h" /* For initialize_all_files. */ +extern initialize_file_ftype _initialize_gdbtypes; +extern initialize_file_ftype _initialize_mips_tdep; +extern initialize_file_ftype _initialize_mipsfbsd_tdep; +extern initialize_file_ftype _initialize_corelow; +extern initialize_file_ftype _initialize_ser_hardwire; +extern initialize_file_ftype _initialize_ser_pipe; +extern initialize_file_ftype _initialize_ser_tcp; +extern initialize_file_ftype _initialize_mipsfbsd_nat; +extern initialize_file_ftype _initialize_mips_nat; +extern initialize_file_ftype _initialize_kernel_u_addr; +extern initialize_file_ftype _initialize_infptrace; +extern initialize_file_ftype _initialize_inftarg; +extern initialize_file_ftype _initialize_solib; +extern initialize_file_ftype _initialize_svr4_solib; +extern initialize_file_ftype _initialize_svr4_lm; +extern initialize_file_ftype _initialize_remote; +extern initialize_file_ftype _initialize_dcache; +extern initialize_file_ftype _initialize_sr_support; +extern initialize_file_ftype _initialize_tracepoint; +extern initialize_file_ftype _initialize_ax_gdb; +extern initialize_file_ftype _initialize_annotate; +extern initialize_file_ftype _initialize_auxv; +extern initialize_file_ftype _initialize_breakpoint; +extern initialize_file_ftype _initialize_regcache; +extern initialize_file_ftype _initialize_charset; +extern initialize_file_ftype _initialize_dummy_frame; +extern initialize_file_ftype _initialize_source; +extern initialize_file_ftype _initialize_values; +extern initialize_file_ftype _initialize_valops; +extern initialize_file_ftype _initialize_valarith; +extern initialize_file_ftype _initialize_valprint; +extern initialize_file_ftype _initialize_printcmd; +extern initialize_file_ftype _initialize_symtab; +extern initialize_file_ftype _initialize_symfile; +extern initialize_file_ftype _initialize_symmisc; +extern initialize_file_ftype _initialize_infcall; +extern initialize_file_ftype _initialize_infcmd; +extern initialize_file_ftype _initialize_infrun; +extern initialize_file_ftype _initialize_stack; +extern initialize_file_ftype _initialize_thread; +extern initialize_file_ftype _initialize_interpreter; +extern initialize_file_ftype _initialize_macrocmd; +extern initialize_file_ftype _initialize_gdbarch; +extern initialize_file_ftype _initialize_gdbarch_utils; +extern initialize_file_ftype _initialize_gdb_osabi; +extern initialize_file_ftype _initialize_copying; +extern initialize_file_ftype _initialize_mem; +extern initialize_file_ftype _initialize_parse; +extern initialize_file_ftype _initialize_language; +extern initialize_file_ftype _initialize_frame_reg; +extern initialize_file_ftype _initialize_signals; +extern initialize_file_ftype _initialize_kod; +extern initialize_file_ftype _initialize_gdb_events; +extern initialize_file_ftype _initialize_exec; +extern initialize_file_ftype _initialize_maint_cmds; +extern initialize_file_ftype _initialize_demangler; +extern initialize_file_ftype _initialize_dbxread; +extern initialize_file_ftype _initialize_coffread; +extern initialize_file_ftype _initialize_elfread; +extern initialize_file_ftype _initialize_mipsread; +extern initialize_file_ftype _initialize_stabsread; +extern initialize_file_ftype _initialize_core; +extern initialize_file_ftype _initialize_dwarf2_frame; +extern initialize_file_ftype _initialize_c_language; +extern initialize_file_ftype _initialize_f_language; +extern initialize_file_ftype _initialize_objc_language; +extern initialize_file_ftype _initialize_ui_out; +extern initialize_file_ftype _initialize_cli_out; +extern initialize_file_ftype _initialize_varobj; +extern initialize_file_ftype _initialize_java_language; +extern initialize_file_ftype _initialize_m2_language; +extern initialize_file_ftype _initialize_pascal_language; +extern initialize_file_ftype _initialize_pascal_valprint; +extern initialize_file_ftype _initialize_scheme_language; +extern initialize_file_ftype _initialize_complaints; +extern initialize_file_ftype _initialize_typeprint; +extern initialize_file_ftype _initialize_cp_valprint; +extern initialize_file_ftype _initialize_f_valprint; +extern initialize_file_ftype _initialize_nlmread; +extern initialize_file_ftype _initialize_serial; +extern initialize_file_ftype _initialize_mdebugread; +extern initialize_file_ftype _initialize_user_regs; +extern initialize_file_ftype _initialize_frame; +extern initialize_file_ftype _initialize_frame_unwind; +extern initialize_file_ftype _initialize_frame_base; +extern initialize_file_ftype _initialize_gnu_v2_abi; +extern initialize_file_ftype _initialize_gnu_v3_abi; +extern initialize_file_ftype _initialize_hpacc_abi; +extern initialize_file_ftype _initialize_cp_abi; +extern initialize_file_ftype _initialize_cp_support; +extern initialize_file_ftype _initialize_cp_namespace; +extern initialize_file_ftype _initialize_reggroup; +extern initialize_file_ftype _initialize_inflow; +extern initialize_file_ftype _initialize_cli_dump; +extern initialize_file_ftype _initialize_cli_logging; +extern initialize_file_ftype _initialize_cli_interp; +extern initialize_file_ftype _initialize_mi_out; +extern initialize_file_ftype _initialize_mi_cmds; +extern initialize_file_ftype _initialize_mi_cmd_env; +extern initialize_file_ftype _initialize_mi_interp; +extern initialize_file_ftype _initialize_mi_main; +extern initialize_file_ftype _initialize_tui_hooks; +extern initialize_file_ftype _initialize_tui_interp; +extern initialize_file_ftype _initialize_tui_layout; +extern initialize_file_ftype _initialize_tui_out; +extern initialize_file_ftype _initialize_tui_regs; +extern initialize_file_ftype _initialize_tui_stack; +extern initialize_file_ftype _initialize_tui_win; +void +initialize_all_files (void) +{ + _initialize_gdbtypes (); + _initialize_mips_tdep (); + _initialize_mipsfbsd_tdep (); + _initialize_corelow (); + _initialize_solib (); + _initialize_svr4_solib (); + _initialize_ser_hardwire (); + _initialize_ser_pipe (); + _initialize_ser_tcp (); +#ifndef CROSS_DEBUGGER +#if 0 + _initialize_mipsfbsd_nat (); + _initialize_mips_nat (); +#endif + _initialize_kernel_u_addr (); + _initialize_infptrace (); + _initialize_inftarg (); + _initialize_thread_db (); +#if 0 + _initialize_svr4_lm (); +#endif +#endif + _initialize_remote (); + _initialize_dcache (); + _initialize_sr_support (); + _initialize_tracepoint (); + _initialize_ax_gdb (); + _initialize_annotate (); + _initialize_auxv (); + _initialize_breakpoint (); + _initialize_regcache (); + _initialize_charset (); + _initialize_dummy_frame (); + _initialize_source (); + _initialize_values (); + _initialize_valops (); + _initialize_valarith (); + _initialize_valprint (); + _initialize_printcmd (); + _initialize_symtab (); + _initialize_symfile (); + _initialize_symmisc (); + _initialize_infcall (); + _initialize_infcmd (); + _initialize_infrun (); + _initialize_stack (); + _initialize_thread (); + _initialize_interpreter (); + _initialize_macrocmd (); + _initialize_gdbarch (); + _initialize_gdbarch_utils (); + _initialize_gdb_osabi (); + _initialize_copying (); + _initialize_mem (); + _initialize_parse (); + _initialize_language (); + _initialize_frame_reg (); + _initialize_signals (); + _initialize_kod (); + _initialize_gdb_events (); + _initialize_exec (); + _initialize_maint_cmds (); + _initialize_demangler (); + _initialize_dbxread (); + _initialize_coffread (); + _initialize_elfread (); + _initialize_mipsread (); + _initialize_stabsread (); + _initialize_core (); + _initialize_dwarf2_frame (); + _initialize_c_language (); + _initialize_f_language (); + _initialize_objc_language (); + _initialize_ui_out (); + _initialize_cli_out (); + _initialize_varobj (); + _initialize_java_language (); + _initialize_m2_language (); + _initialize_pascal_language (); + _initialize_pascal_valprint (); + _initialize_scheme_language (); + _initialize_complaints (); + _initialize_typeprint (); + _initialize_cp_valprint (); + _initialize_f_valprint (); + _initialize_nlmread (); + _initialize_serial (); + _initialize_mdebugread (); + _initialize_user_regs (); + _initialize_frame (); + _initialize_frame_unwind (); + _initialize_frame_base (); + _initialize_gnu_v2_abi (); + _initialize_gnu_v3_abi (); + _initialize_hpacc_abi (); + _initialize_cp_abi (); + _initialize_cp_support (); + _initialize_cp_namespace (); + _initialize_reggroup (); + _initialize_inflow (); + _initialize_cli_dump (); + _initialize_cli_logging (); + _initialize_cli_interp (); + _initialize_mi_out (); + _initialize_mi_cmds (); + _initialize_mi_cmd_env (); + _initialize_mi_interp (); + _initialize_mi_main (); + _initialize_tui_hooks (); + _initialize_tui_interp (); + _initialize_tui_layout (); + _initialize_tui_out (); + _initialize_tui_regs (); + _initialize_tui_stack (); + _initialize_tui_win (); +} diff --git a/gnu/usr.bin/gdb/arch/powerpc/Makefile b/gnu/usr.bin/gdb/arch/powerpc/Makefile new file mode 100644 index 000000000000..fa41a237d1f7 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/powerpc/Makefile @@ -0,0 +1,14 @@ +# $FreeBSD$ + +.if !defined(GDB_CROSS_DEBUGGER) +LIBSRCS+= fbsd-proc.c fbsd-threads.c gcore.c +LIBSRCS+= ppcfbsd-nat.c +.endif +LIBSRCS+= solib.c solib-svr4.c +LIBSRCS+= ppc-sysv-tdep.c ppcfbsd-tdep.c rs6000-tdep.c + +nm.h: + echo '#include "powerpc/nm-fbsd.h"' > ${.TARGET} + +tm.h: + echo '#include "powerpc/tm-ppc-eabi.h"' > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/powerpc/config.h b/gnu/usr.bin/gdb/arch/powerpc/config.h new file mode 100644 index 000000000000..8686a99d1f56 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/powerpc/config.h @@ -0,0 +1,550 @@ +/* $FreeBSD$ */ + +/* config.h. Generated automatically by configure. */ +/* config.in. Generated automatically from configure.in by autoheader. */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define if using alloca.c. */ +/* #undef C_ALLOCA */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +/* #undef CRAY_STACKSEG_END */ + +/* Define if you have alloca, as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define if you have <alloca.h> and it should be used (not on Ultrix). */ +/* #undef HAVE_ALLOCA_H */ + +/* Define if the `long double' type works. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define if you have <vfork.h>. */ +/* #undef HAVE_VFORK_H */ + +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + +/* Define to `long' if <sys/types.h> doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if <sys/types.h> doesn't define. */ +/* #undef pid_t */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define if the `setpgrp' function takes no argument. */ +/* #undef SETPGRP_VOID */ + +/* Define to `unsigned' if <sys/types.h> doesn't define. */ +/* #undef size_t */ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown + */ +/* #undef STACK_DIRECTION */ + +/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define vfork as fork if vfork does not work. */ +/* #undef vfork */ + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +/* Define if your struct reg has r_fs. */ +/* #undef HAVE_STRUCT_REG_R_FS */ + +/* Define if your struct stat has st_blocks. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define if your struct reg has r_gs. */ +/* #undef HAVE_STRUCT_REG_R_GS */ + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``l_'' prefix. (For Solaris, SVR4, and + SVR4-like systems.) */ +#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``lm_'' prefix. (For SunOS.) */ +/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ + +/* Define if <link.h> exists and defines a struct so_map which has + members with an ``som_'' prefix. (Found on older *BSD systems.) */ +/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ + +/* Define if <sys/link.h> has struct link_map32 */ +/* #undef HAVE_STRUCT_LINK_MAP32 */ + +/* Define if <sys/link.h> has link_map32 (solaris sparc-64 target) */ +/* #undef _SYSCALL32 */ + +/* Define if the prfpregset_t type is broken. */ +/* #undef PRFPREGSET_T_BROKEN */ + +/* Define if you want to use new multi-fd /proc interface + (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ +/* #undef NEW_PROC_API */ + +/* Define if ioctl argument PIOCSET is available. */ +/* #undef HAVE_PROCFS_PIOCSET */ + +/* Define if the `long long' type works. */ +#define CC_HAS_LONG_LONG 1 + +/* Define if the "ll" format works to print long long ints. */ +#define PRINTF_HAS_LONG_LONG 1 + +/* Define if the "%Lg" format works to print long doubles. */ +#define PRINTF_HAS_LONG_DOUBLE 1 + +/* Define if the "%Lg" format works to scan long doubles. */ +#define SCANF_HAS_LONG_DOUBLE 1 + +/* Define if using Solaris thread debugging. */ +/* #undef HAVE_THREAD_DB_LIB */ + +/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ +/* #undef START_INFERIOR_TRAPS_EXPECTED */ +/* #undef sys_quotactl */ + +/* Define if you have HPUX threads */ +/* #undef HAVE_HPUX_THREAD_SUPPORT */ + +/* Define if <proc_service.h> on solaris uses int instead of + size_t, and assorted other type changes. */ +/* #undef PROC_SERVICE_IS_OLD */ + +/* Define if the simulator is being linked in. */ +#define WITH_SIM 1 + +/* Set to true if the save_state_t structure is present */ +/* #undef HAVE_STRUCT_SAVE_STATE_T */ + +/* Set to true if the save_state_t structure has the ss_wide member */ +/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETREGS request. */ +/* #undef HAVE_PTRACE_GETREGS */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETFPXREGS request. */ +/* #undef HAVE_PTRACE_GETFPXREGS */ + +/* Define if <sys/ptrace.h> defines the PT_GETDBREGS request. */ +#define HAVE_PT_GETDBREGS 1 + +/* Define if <sys/ptrace.h> defines the PT_GETXMMREGS request. */ +/* #undef HAVE_PT_GETXMMREGS */ + +/* Define if libunwind library is being used. */ +/* #undef HAVE_LIBUNWIND */ + +/* hostfile */ +/* #undef GDB_XM_FILE */ + +/* targetfile */ +#define GDB_TM_FILE config/powerpc/tm-ppc-eabi.h + +/* nativefile */ +#ifndef CROSS_DEBUGGER +#define GDB_NM_FILE config/powerpc/nm-fbsd.h +#endif + +/* Define to 1 so <sys/proc.h> gets a definition of anon_hdl. Works + around a <sys/proc.h> problem on IRIX 5. */ +#ifndef _KMEMUSER +/* #undef _KMEMUSER */ +#endif + +/* Define if you have the __argz_count function. */ +/* #undef HAVE___ARGZ_COUNT */ + +/* Define if you have the __argz_next function. */ +/* #undef HAVE___ARGZ_NEXT */ + +/* Define if you have the __argz_stringify function. */ +/* #undef HAVE___ARGZ_STRINGIFY */ + +/* Define if you have the _mcleanup function. */ +#define HAVE__MCLEANUP 1 + +/* Define if you have the canonicalize_file_name function. */ +/* #undef HAVE_CANONICALIZE_FILE_NAME */ + +/* Define if you have the dcgettext function. */ +/* #undef HAVE_DCGETTEXT */ + +/* Define if you have the getcwd function. */ +#define HAVE_GETCWD 1 + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the monstartup function. */ +#define HAVE_MONSTARTUP 1 + +/* Define if you have the munmap function. */ +#define HAVE_MUNMAP 1 + +/* Define if you have the poll function. */ +#define HAVE_POLL 1 + +/* Define if you have the pread64 function. */ +/* #undef HAVE_PREAD64 */ + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the realpath function. */ +#define HAVE_REALPATH 1 + +/* Define if you have the sbrk function. */ +/* #undef HAVE_SBRK */ + +/* Define if you have the setenv function. */ +#define HAVE_SETENV 1 + +/* Define if you have the setlocale function. */ +#define HAVE_SETLOCALE 1 + +/* Define if you have the setpgid function. */ +#define HAVE_SETPGID 1 + +/* Define if you have the setpgrp function. */ +#define HAVE_SETPGRP 1 + +/* Define if you have the sigaction function. */ +#define HAVE_SIGACTION 1 + +/* Define if you have the sigprocmask function. */ +#define HAVE_SIGPROCMASK 1 + +/* Define if you have the sigsetmask function. */ +#define HAVE_SIGSETMASK 1 + +/* Define if you have the socketpair function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define if you have the stpcpy function. */ +#define HAVE_STPCPY 1 + +/* Define if you have the strcasecmp function. */ +#define HAVE_STRCASECMP 1 + +/* Define if you have the strchr function. */ +#define HAVE_STRCHR 1 + +/* Define if you have the syscall function. */ +#define HAVE_SYSCALL 1 + +/* Define if you have the <argz.h> header file. */ +/* #undef HAVE_ARGZ_H */ + +/* Define if you have the <ctype.h> header file. */ +#define HAVE_CTYPE_H 1 + +/* Define if you have the <curses.h> header file. */ +#define HAVE_CURSES_H 1 + +/* Define if you have the <dirent.h> header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the <libunwind-ia64.h> header file. */ +/* #undef HAVE_LIBUNWIND_IA64_H */ + +/* Define if you have the <libunwind.h> header file. */ +/* #undef HAVE_LIBUNWIND_H */ + +/* Define if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the <link.h> header file. */ +#define HAVE_LINK_H 1 + +/* Define if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the <machine/reg.h> header file. */ +#define HAVE_MACHINE_REG_H 1 + +/* Define if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if you have the <ncurses.h> header file. */ +#define HAVE_NCURSES_H 1 + +/* Define if you have the <ndir.h> header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the <nl_types.h> header file. */ +#define HAVE_NL_TYPES_H 1 + +/* Define if you have the <nlist.h> header file. */ +#define HAVE_NLIST_H 1 + +/* Define if you have the <poll.h> header file. */ +#define HAVE_POLL_H 1 + +/* Define if you have the <proc_service.h> header file. */ +/* #undef HAVE_PROC_SERVICE_H */ + +/* Define if you have the <ptrace.h> header file. */ +/* #undef HAVE_PTRACE_H */ + +/* Define if you have the <sgtty.h> header file. */ +#define HAVE_SGTTY_H 1 + +/* Define if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define if you have the <sys/debugreg.h> header file. */ +/* #undef HAVE_SYS_DEBUGREG_H */ + +/* Define if you have the <sys/dir.h> header file. */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define if you have the <sys/fault.h> header file. */ +/* #undef HAVE_SYS_FAULT_H */ + +/* Define if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define if you have the <sys/filio.h> header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define if you have the <sys/ndir.h> header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the <sys/poll.h> header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define if you have the <sys/proc.h> header file. */ +#define HAVE_SYS_PROC_H 1 + +/* Define if you have the <sys/procfs.h> header file. */ +#define HAVE_SYS_PROCFS_H 1 + +/* Define if you have the <sys/ptrace.h> header file. */ +#define HAVE_SYS_PTRACE_H 1 + +/* Define if you have the <sys/reg.h> header file. */ +/* #undef HAVE_SYS_REG_H */ + +/* Define if you have the <sys/select.h> header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define if you have the <sys/syscall.h> header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define if you have the <sys/user.h> header file. */ +#define HAVE_SYS_USER_H 1 + +/* Define if you have the <sys/wait.h> header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the <term.h> header file. */ +#define HAVE_TERM_H 1 + +/* Define if you have the <termio.h> header file. */ +/* #undef HAVE_TERMIO_H */ + +/* Define if you have the <termios.h> header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define if you have the <thread_db.h> header file. */ +/* #undef HAVE_THREAD_DB_H */ + +/* Define if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the <values.h> header file. */ +/* #undef HAVE_VALUES_H */ + +/* Define if you have the <wait.h> header file. */ +/* #undef HAVE_WAIT_H */ + +/* Define if you have the dl library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define if you have the m library (-lm). */ +#define HAVE_LIBM 1 + +/* Define if you have the w library (-lw). */ +/* #undef HAVE_LIBW */ + +/* Define if you have the stpcpy function */ +#define HAVE_STPCPY 1 + +/* Define if your locale.h file contains LC_MESSAGES. */ +#define HAVE_LC_MESSAGES 1 + +/* Define to 1 if NLS is requested */ +/* #undef ENABLE_NLS */ + +/* Define as 1 if you have gettext and don't want to use GNU gettext. */ +/* #undef HAVE_GETTEXT */ + +/* Name of this package. */ +#define PACKAGE "gdb" + +/* Define to BFD's default architecture. */ +#define DEFAULT_BFD_ARCH bfd_rs6000_arch + +/* Define to BFD's default target vector. */ +#define DEFAULT_BFD_VEC bfd_elf32_powerpc_vec + +/* Define to 1 if your system has the _etext variable. */ +#define HAVE__ETEXT 1 + +/* Define to 1 to avoid a clash between <widec.h> and <wchar.h> on + Solaris 2.[78] when using GCC. */ +/* #undef _MSE_INT_H */ + +/* Define to 1 if we found this declaration otherwise define to 0. */ +#define HAVE_DECL_GETOPT 0 + +/* Define if sigsetjmp is available. */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if the regex included in libiberty should be used. */ +#define USE_INCLUDED_REGEX 1 + +/* Define to 1 if your system has struct reg in <machine/reg.h>. */ +#define HAVE_STRUCT_REG 1 + +/* Define if <stdint.h> provides the uintptr_t type. */ +#define HAVE_UINTPTR_T 1 + +/* Define if malloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_MALLOC */ + +/* Define if realloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_REALLOC */ + +/* Define if free is not declared in system header files. */ +/* #undef NEED_DECLARATION_FREE */ + +/* Define if strerror is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRERROR */ + +/* Define if strdup is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRDUP */ + +/* Define if strstr is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRSTR */ + +/* Define if canonicalize_file_name is not declared in system header files. */ +#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 + +/* Define if <sys/procfs.h> has pstatus_t. */ +/* #undef HAVE_PSTATUS_T */ + +/* Define if <sys/procfs.h> has prrun_t. */ +/* #undef HAVE_PRRUN_T */ + +/* Define if <sys/procfs.h> has gregset_t. */ +#define HAVE_GREGSET_T 1 + +/* Define if <sys/procfs.h> has fpregset_t. */ +#define HAVE_FPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset_t. */ +#define HAVE_PRGREGSET_T 1 + +/* Define if <sys/procfs.h> has prfpregset_t. */ +#define HAVE_PRFPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset32_t. */ +/* #undef HAVE_PRGREGSET32_T */ + +/* Define if <sys/procfs.h> has prfpregset32_t. */ +/* #undef HAVE_PRFPREGSET32_T */ + +/* Define if <sys/procfs.h> has lwpid_t. */ +#define HAVE_LWPID_T 1 + +/* Define if <sys/procfs.h> has psaddr_t. */ +#define HAVE_PSADDR_T 1 + +/* Define if <sys/procfs.h> has prsysent_t. */ +/* #undef HAVE_PRSYSENT_T */ + +/* Define if <sys/procfs.h> has pr_sigset_t. */ +/* #undef HAVE_PR_SIGSET_T */ + +/* Define if <sys/procfs.h> has pr_sigaction64_t. */ +/* #undef HAVE_PR_SIGACTION64_T */ + +/* Define if <sys/procfs.h> has pr_siginfo64_t. */ +/* #undef HAVE_PR_SIGINFO64_T */ + +/* Define if <thread_db.h> has the TD_NOTALLOC error code. */ +/* #undef THREAD_DB_HAS_TD_NOTALLOC */ + +/* Define if we can use the tkill syscall. */ +/* #undef HAVE_TKILL_SYSCALL */ + +/* Define to the default OS ABI for this configuration. */ +/* #undef GDB_OSABI_DEFAULT */ + +/* Define to be a string naming the default host character set. */ +#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + diff --git a/gnu/usr.bin/gdb/arch/powerpc/init.c b/gnu/usr.bin/gdb/arch/powerpc/init.c new file mode 100644 index 000000000000..5b96bd5137a2 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/powerpc/init.c @@ -0,0 +1,230 @@ +/* $FreeBSD$ */ + +/* Do not modify this file. */ +/* It is created automatically by the Makefile. */ +#include "defs.h" /* For initialize_file_ftype. */ +#include "call-cmds.h" /* For initialize_all_files. */ +extern initialize_file_ftype _initialize_gdbtypes; +extern initialize_file_ftype _initialize_rs6000_tdep; +extern initialize_file_ftype _initialize_ppcfbsd_tdep; +extern initialize_file_ftype _initialize_corelow; +extern initialize_file_ftype _initialize_solib; +extern initialize_file_ftype _initialize_svr4_solib; +extern initialize_file_ftype _initialize_ser_hardwire; +extern initialize_file_ftype _initialize_ser_pipe; +extern initialize_file_ftype _initialize_ser_tcp; +extern initialize_file_ftype _initialize_fbsd_proc; +extern initialize_file_ftype _initialize_gcore; +extern initialize_file_ftype _initialize_kernel_u_addr; +extern initialize_file_ftype _initialize_infptrace; +extern initialize_file_ftype _initialize_inftarg; +extern initialize_file_ftype _initialize_ppcfbsd_nat; +extern initialize_file_ftype _initialize_thread_db; +extern initialize_file_ftype _initialize_remote; +extern initialize_file_ftype _initialize_dcache; +extern initialize_file_ftype _initialize_sr_support; +extern initialize_file_ftype _initialize_tracepoint; +extern initialize_file_ftype _initialize_ax_gdb; +extern initialize_file_ftype _initialize_annotate; +extern initialize_file_ftype _initialize_auxv; +extern initialize_file_ftype _initialize_breakpoint; +extern initialize_file_ftype _initialize_regcache; +extern initialize_file_ftype _initialize_charset; +extern initialize_file_ftype _initialize_dummy_frame; +extern initialize_file_ftype _initialize_source; +extern initialize_file_ftype _initialize_values; +extern initialize_file_ftype _initialize_valops; +extern initialize_file_ftype _initialize_valarith; +extern initialize_file_ftype _initialize_valprint; +extern initialize_file_ftype _initialize_printcmd; +extern initialize_file_ftype _initialize_symtab; +extern initialize_file_ftype _initialize_symfile; +extern initialize_file_ftype _initialize_symmisc; +extern initialize_file_ftype _initialize_infcall; +extern initialize_file_ftype _initialize_infcmd; +extern initialize_file_ftype _initialize_infrun; +extern initialize_file_ftype _initialize_stack; +extern initialize_file_ftype _initialize_thread; +extern initialize_file_ftype _initialize_interpreter; +extern initialize_file_ftype _initialize_macrocmd; +extern initialize_file_ftype _initialize_gdbarch; +extern initialize_file_ftype _initialize_gdbarch_utils; +extern initialize_file_ftype _initialize_gdb_osabi; +extern initialize_file_ftype _initialize_copying; +extern initialize_file_ftype _initialize_mem; +extern initialize_file_ftype _initialize_parse; +extern initialize_file_ftype _initialize_language; +extern initialize_file_ftype _initialize_frame_reg; +extern initialize_file_ftype _initialize_signals; +extern initialize_file_ftype _initialize_kod; +extern initialize_file_ftype _initialize_gdb_events; +extern initialize_file_ftype _initialize_exec; +extern initialize_file_ftype _initialize_maint_cmds; +extern initialize_file_ftype _initialize_demangler; +extern initialize_file_ftype _initialize_dbxread; +extern initialize_file_ftype _initialize_coffread; +extern initialize_file_ftype _initialize_elfread; +extern initialize_file_ftype _initialize_mipsread; +extern initialize_file_ftype _initialize_stabsread; +extern initialize_file_ftype _initialize_core; +extern initialize_file_ftype _initialize_dwarf2_frame; +extern initialize_file_ftype _initialize_c_language; +extern initialize_file_ftype _initialize_f_language; +extern initialize_file_ftype _initialize_objc_language; +extern initialize_file_ftype _initialize_ui_out; +extern initialize_file_ftype _initialize_cli_out; +extern initialize_file_ftype _initialize_varobj; +extern initialize_file_ftype _initialize_java_language; +extern initialize_file_ftype _initialize_m2_language; +extern initialize_file_ftype _initialize_pascal_language; +extern initialize_file_ftype _initialize_pascal_valprint; +extern initialize_file_ftype _initialize_scheme_language; +extern initialize_file_ftype _initialize_complaints; +extern initialize_file_ftype _initialize_typeprint; +extern initialize_file_ftype _initialize_cp_valprint; +extern initialize_file_ftype _initialize_f_valprint; +extern initialize_file_ftype _initialize_nlmread; +extern initialize_file_ftype _initialize_serial; +extern initialize_file_ftype _initialize_mdebugread; +extern initialize_file_ftype _initialize_user_regs; +extern initialize_file_ftype _initialize_frame; +extern initialize_file_ftype _initialize_frame_unwind; +extern initialize_file_ftype _initialize_frame_base; +extern initialize_file_ftype _initialize_gnu_v2_abi; +extern initialize_file_ftype _initialize_gnu_v3_abi; +extern initialize_file_ftype _initialize_hpacc_abi; +extern initialize_file_ftype _initialize_cp_abi; +extern initialize_file_ftype _initialize_cp_support; +extern initialize_file_ftype _initialize_cp_namespace; +extern initialize_file_ftype _initialize_reggroup; +extern initialize_file_ftype _initialize_inflow; +extern initialize_file_ftype _initialize_cli_dump; +extern initialize_file_ftype _initialize_cli_logging; +extern initialize_file_ftype _initialize_cli_interp; +extern initialize_file_ftype _initialize_mi_out; +extern initialize_file_ftype _initialize_mi_cmds; +extern initialize_file_ftype _initialize_mi_cmd_env; +extern initialize_file_ftype _initialize_mi_interp; +extern initialize_file_ftype _initialize_mi_main; +extern initialize_file_ftype _initialize_tui_hooks; +extern initialize_file_ftype _initialize_tui_interp; +extern initialize_file_ftype _initialize_tui_layout; +extern initialize_file_ftype _initialize_tui_out; +extern initialize_file_ftype _initialize_tui_regs; +extern initialize_file_ftype _initialize_tui_stack; +extern initialize_file_ftype _initialize_tui_win; +void +initialize_all_files (void) +{ + _initialize_gdbtypes (); + _initialize_rs6000_tdep (); + _initialize_ppcfbsd_tdep (); + _initialize_corelow (); + _initialize_solib (); + _initialize_svr4_solib (); + _initialize_ser_hardwire (); + _initialize_ser_pipe (); + _initialize_ser_tcp (); +#ifndef CROSS_DEBUGGER + _initialize_fbsd_proc (); + _initialize_gcore (); + _initialize_kernel_u_addr (); + _initialize_infptrace (); + _initialize_inftarg (); + _initialize_ppcfbsd_nat (); + _initialize_thread_db (); +#endif + _initialize_remote (); + _initialize_dcache (); + _initialize_sr_support (); + _initialize_tracepoint (); + _initialize_ax_gdb (); + _initialize_annotate (); + _initialize_auxv (); + _initialize_breakpoint (); + _initialize_regcache (); + _initialize_charset (); + _initialize_dummy_frame (); + _initialize_source (); + _initialize_values (); + _initialize_valops (); + _initialize_valarith (); + _initialize_valprint (); + _initialize_printcmd (); + _initialize_symtab (); + _initialize_symfile (); + _initialize_symmisc (); + _initialize_infcall (); + _initialize_infcmd (); + _initialize_infrun (); + _initialize_stack (); + _initialize_thread (); + _initialize_interpreter (); + _initialize_macrocmd (); + _initialize_gdbarch (); + _initialize_gdbarch_utils (); + _initialize_gdb_osabi (); + _initialize_copying (); + _initialize_mem (); + _initialize_parse (); + _initialize_language (); + _initialize_frame_reg (); + _initialize_signals (); + _initialize_kod (); + _initialize_gdb_events (); + _initialize_exec (); + _initialize_maint_cmds (); + _initialize_demangler (); + _initialize_dbxread (); + _initialize_coffread (); + _initialize_elfread (); + _initialize_mipsread (); + _initialize_stabsread (); + _initialize_core (); + _initialize_dwarf2_frame (); + _initialize_c_language (); + _initialize_f_language (); + _initialize_objc_language (); + _initialize_ui_out (); + _initialize_cli_out (); + _initialize_varobj (); + _initialize_java_language (); + _initialize_m2_language (); + _initialize_pascal_language (); + _initialize_pascal_valprint (); + _initialize_scheme_language (); + _initialize_complaints (); + _initialize_typeprint (); + _initialize_cp_valprint (); + _initialize_f_valprint (); + _initialize_nlmread (); + _initialize_serial (); + _initialize_mdebugread (); + _initialize_user_regs (); + _initialize_frame (); + _initialize_frame_unwind (); + _initialize_frame_base (); + _initialize_gnu_v2_abi (); + _initialize_gnu_v3_abi (); + _initialize_hpacc_abi (); + _initialize_cp_abi (); + _initialize_cp_support (); + _initialize_cp_namespace (); + _initialize_reggroup (); + _initialize_inflow (); + _initialize_cli_dump (); + _initialize_cli_logging (); + _initialize_cli_interp (); + _initialize_mi_out (); + _initialize_mi_cmds (); + _initialize_mi_cmd_env (); + _initialize_mi_interp (); + _initialize_mi_main (); + _initialize_tui_hooks (); + _initialize_tui_interp (); + _initialize_tui_layout (); + _initialize_tui_out (); + _initialize_tui_regs (); + _initialize_tui_stack (); + _initialize_tui_win (); +} diff --git a/gnu/usr.bin/gdb/arch/powerpc64/Makefile b/gnu/usr.bin/gdb/arch/powerpc64/Makefile new file mode 100644 index 000000000000..fa41a237d1f7 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/powerpc64/Makefile @@ -0,0 +1,14 @@ +# $FreeBSD$ + +.if !defined(GDB_CROSS_DEBUGGER) +LIBSRCS+= fbsd-proc.c fbsd-threads.c gcore.c +LIBSRCS+= ppcfbsd-nat.c +.endif +LIBSRCS+= solib.c solib-svr4.c +LIBSRCS+= ppc-sysv-tdep.c ppcfbsd-tdep.c rs6000-tdep.c + +nm.h: + echo '#include "powerpc/nm-fbsd.h"' > ${.TARGET} + +tm.h: + echo '#include "powerpc/tm-ppc-eabi.h"' > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/powerpc64/config.h b/gnu/usr.bin/gdb/arch/powerpc64/config.h new file mode 100644 index 000000000000..6ec6560e4200 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/powerpc64/config.h @@ -0,0 +1,550 @@ +/* $FreeBSD$ */ + +/* config.h. Generated automatically by configure. */ +/* config.in. Generated automatically from configure.in by autoheader. */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define if using alloca.c. */ +/* #undef C_ALLOCA */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +/* #undef CRAY_STACKSEG_END */ + +/* Define if you have alloca, as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define if you have <alloca.h> and it should be used (not on Ultrix). */ +/* #undef HAVE_ALLOCA_H */ + +/* Define if the `long double' type works. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define if you have <vfork.h>. */ +/* #undef HAVE_VFORK_H */ + +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + +/* Define to `long' if <sys/types.h> doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if <sys/types.h> doesn't define. */ +/* #undef pid_t */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define if the `setpgrp' function takes no argument. */ +/* #undef SETPGRP_VOID */ + +/* Define to `unsigned' if <sys/types.h> doesn't define. */ +/* #undef size_t */ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown + */ +/* #undef STACK_DIRECTION */ + +/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define vfork as fork if vfork does not work. */ +/* #undef vfork */ + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +/* Define if your struct reg has r_fs. */ +/* #undef HAVE_STRUCT_REG_R_FS */ + +/* Define if your struct stat has st_blocks. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define if your struct reg has r_gs. */ +/* #undef HAVE_STRUCT_REG_R_GS */ + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``l_'' prefix. (For Solaris, SVR4, and + SVR4-like systems.) */ +#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``lm_'' prefix. (For SunOS.) */ +/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ + +/* Define if <link.h> exists and defines a struct so_map which has + members with an ``som_'' prefix. (Found on older *BSD systems.) */ +/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ + +/* Define if <sys/link.h> has struct link_map32 */ +/* #undef HAVE_STRUCT_LINK_MAP32 */ + +/* Define if <sys/link.h> has link_map32 (solaris sparc-64 target) */ +/* #undef _SYSCALL32 */ + +/* Define if the prfpregset_t type is broken. */ +/* #undef PRFPREGSET_T_BROKEN */ + +/* Define if you want to use new multi-fd /proc interface + (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ +/* #undef NEW_PROC_API */ + +/* Define if ioctl argument PIOCSET is available. */ +/* #undef HAVE_PROCFS_PIOCSET */ + +/* Define if the `long long' type works. */ +#define CC_HAS_LONG_LONG 1 + +/* Define if the "ll" format works to print long long ints. */ +#define PRINTF_HAS_LONG_LONG 1 + +/* Define if the "%Lg" format works to print long doubles. */ +#define PRINTF_HAS_LONG_DOUBLE 1 + +/* Define if the "%Lg" format works to scan long doubles. */ +#define SCANF_HAS_LONG_DOUBLE 1 + +/* Define if using Solaris thread debugging. */ +/* #undef HAVE_THREAD_DB_LIB */ + +/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ +/* #undef START_INFERIOR_TRAPS_EXPECTED */ +/* #undef sys_quotactl */ + +/* Define if you have HPUX threads */ +/* #undef HAVE_HPUX_THREAD_SUPPORT */ + +/* Define if <proc_service.h> on solaris uses int instead of + size_t, and assorted other type changes. */ +/* #undef PROC_SERVICE_IS_OLD */ + +/* Define if the simulator is being linked in. */ +#define WITH_SIM 1 + +/* Set to true if the save_state_t structure is present */ +/* #undef HAVE_STRUCT_SAVE_STATE_T */ + +/* Set to true if the save_state_t structure has the ss_wide member */ +/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETREGS request. */ +/* #undef HAVE_PTRACE_GETREGS */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETFPXREGS request. */ +/* #undef HAVE_PTRACE_GETFPXREGS */ + +/* Define if <sys/ptrace.h> defines the PT_GETDBREGS request. */ +#define HAVE_PT_GETDBREGS 1 + +/* Define if <sys/ptrace.h> defines the PT_GETXMMREGS request. */ +/* #undef HAVE_PT_GETXMMREGS */ + +/* Define if libunwind library is being used. */ +/* #undef HAVE_LIBUNWIND */ + +/* hostfile */ +/* #undef GDB_XM_FILE */ + +/* targetfile */ +#define GDB_TM_FILE config/powerpc/tm-ppc-eabi.h + +/* nativefile */ +#ifndef CROSS_DEBUGGER +#define GDB_NM_FILE config/ia64/nm-fbsd.h +#endif + +/* Define to 1 so <sys/proc.h> gets a definition of anon_hdl. Works + around a <sys/proc.h> problem on IRIX 5. */ +#ifndef _KMEMUSER +/* #undef _KMEMUSER */ +#endif + +/* Define if you have the __argz_count function. */ +/* #undef HAVE___ARGZ_COUNT */ + +/* Define if you have the __argz_next function. */ +/* #undef HAVE___ARGZ_NEXT */ + +/* Define if you have the __argz_stringify function. */ +/* #undef HAVE___ARGZ_STRINGIFY */ + +/* Define if you have the _mcleanup function. */ +#define HAVE__MCLEANUP 1 + +/* Define if you have the canonicalize_file_name function. */ +/* #undef HAVE_CANONICALIZE_FILE_NAME */ + +/* Define if you have the dcgettext function. */ +/* #undef HAVE_DCGETTEXT */ + +/* Define if you have the getcwd function. */ +#define HAVE_GETCWD 1 + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the monstartup function. */ +#define HAVE_MONSTARTUP 1 + +/* Define if you have the munmap function. */ +#define HAVE_MUNMAP 1 + +/* Define if you have the poll function. */ +#define HAVE_POLL 1 + +/* Define if you have the pread64 function. */ +/* #undef HAVE_PREAD64 */ + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the realpath function. */ +#define HAVE_REALPATH 1 + +/* Define if you have the sbrk function. */ +/* #undef HAVE_SBRK */ + +/* Define if you have the setenv function. */ +#define HAVE_SETENV 1 + +/* Define if you have the setlocale function. */ +#define HAVE_SETLOCALE 1 + +/* Define if you have the setpgid function. */ +#define HAVE_SETPGID 1 + +/* Define if you have the setpgrp function. */ +#define HAVE_SETPGRP 1 + +/* Define if you have the sigaction function. */ +#define HAVE_SIGACTION 1 + +/* Define if you have the sigprocmask function. */ +#define HAVE_SIGPROCMASK 1 + +/* Define if you have the sigsetmask function. */ +#define HAVE_SIGSETMASK 1 + +/* Define if you have the socketpair function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define if you have the stpcpy function. */ +#define HAVE_STPCPY 1 + +/* Define if you have the strcasecmp function. */ +#define HAVE_STRCASECMP 1 + +/* Define if you have the strchr function. */ +#define HAVE_STRCHR 1 + +/* Define if you have the syscall function. */ +#define HAVE_SYSCALL 1 + +/* Define if you have the <argz.h> header file. */ +/* #undef HAVE_ARGZ_H */ + +/* Define if you have the <ctype.h> header file. */ +#define HAVE_CTYPE_H 1 + +/* Define if you have the <curses.h> header file. */ +#define HAVE_CURSES_H 1 + +/* Define if you have the <dirent.h> header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the <libunwind-ia64.h> header file. */ +/* #undef HAVE_LIBUNWIND_IA64_H */ + +/* Define if you have the <libunwind.h> header file. */ +/* #undef HAVE_LIBUNWIND_H */ + +/* Define if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the <link.h> header file. */ +#define HAVE_LINK_H 1 + +/* Define if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the <machine/reg.h> header file. */ +#define HAVE_MACHINE_REG_H 1 + +/* Define if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if you have the <ncurses.h> header file. */ +#define HAVE_NCURSES_H 1 + +/* Define if you have the <ndir.h> header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the <nl_types.h> header file. */ +#define HAVE_NL_TYPES_H 1 + +/* Define if you have the <nlist.h> header file. */ +#define HAVE_NLIST_H 1 + +/* Define if you have the <poll.h> header file. */ +#define HAVE_POLL_H 1 + +/* Define if you have the <proc_service.h> header file. */ +/* #undef HAVE_PROC_SERVICE_H */ + +/* Define if you have the <ptrace.h> header file. */ +/* #undef HAVE_PTRACE_H */ + +/* Define if you have the <sgtty.h> header file. */ +#define HAVE_SGTTY_H 1 + +/* Define if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define if you have the <sys/debugreg.h> header file. */ +/* #undef HAVE_SYS_DEBUGREG_H */ + +/* Define if you have the <sys/dir.h> header file. */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define if you have the <sys/fault.h> header file. */ +/* #undef HAVE_SYS_FAULT_H */ + +/* Define if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define if you have the <sys/filio.h> header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define if you have the <sys/ndir.h> header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the <sys/poll.h> header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define if you have the <sys/proc.h> header file. */ +#define HAVE_SYS_PROC_H 1 + +/* Define if you have the <sys/procfs.h> header file. */ +#define HAVE_SYS_PROCFS_H 1 + +/* Define if you have the <sys/ptrace.h> header file. */ +#define HAVE_SYS_PTRACE_H 1 + +/* Define if you have the <sys/reg.h> header file. */ +/* #undef HAVE_SYS_REG_H */ + +/* Define if you have the <sys/select.h> header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define if you have the <sys/syscall.h> header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define if you have the <sys/user.h> header file. */ +#define HAVE_SYS_USER_H 1 + +/* Define if you have the <sys/wait.h> header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the <term.h> header file. */ +#define HAVE_TERM_H 1 + +/* Define if you have the <termio.h> header file. */ +/* #undef HAVE_TERMIO_H */ + +/* Define if you have the <termios.h> header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define if you have the <thread_db.h> header file. */ +/* #undef HAVE_THREAD_DB_H */ + +/* Define if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the <values.h> header file. */ +/* #undef HAVE_VALUES_H */ + +/* Define if you have the <wait.h> header file. */ +/* #undef HAVE_WAIT_H */ + +/* Define if you have the dl library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define if you have the m library (-lm). */ +#define HAVE_LIBM 1 + +/* Define if you have the w library (-lw). */ +/* #undef HAVE_LIBW */ + +/* Define if you have the stpcpy function */ +#define HAVE_STPCPY 1 + +/* Define if your locale.h file contains LC_MESSAGES. */ +#define HAVE_LC_MESSAGES 1 + +/* Define to 1 if NLS is requested */ +/* #undef ENABLE_NLS */ + +/* Define as 1 if you have gettext and don't want to use GNU gettext. */ +/* #undef HAVE_GETTEXT */ + +/* Name of this package. */ +#define PACKAGE "gdb" + +/* Define to BFD's default architecture. */ +#define DEFAULT_BFD_ARCH bfd_rs6000_arch + +/* Define to BFD's default target vector. */ +#define DEFAULT_BFD_VEC bfd_elf64_powerpc_vec + +/* Define to 1 if your system has the _etext variable. */ +#define HAVE__ETEXT 1 + +/* Define to 1 to avoid a clash between <widec.h> and <wchar.h> on + Solaris 2.[78] when using GCC. */ +/* #undef _MSE_INT_H */ + +/* Define to 1 if we found this declaration otherwise define to 0. */ +#define HAVE_DECL_GETOPT 0 + +/* Define if sigsetjmp is available. */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if the regex included in libiberty should be used. */ +#define USE_INCLUDED_REGEX 1 + +/* Define to 1 if your system has struct reg in <machine/reg.h>. */ +#define HAVE_STRUCT_REG 1 + +/* Define if <stdint.h> provides the uintptr_t type. */ +#define HAVE_UINTPTR_T 1 + +/* Define if malloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_MALLOC */ + +/* Define if realloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_REALLOC */ + +/* Define if free is not declared in system header files. */ +/* #undef NEED_DECLARATION_FREE */ + +/* Define if strerror is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRERROR */ + +/* Define if strdup is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRDUP */ + +/* Define if strstr is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRSTR */ + +/* Define if canonicalize_file_name is not declared in system header files. */ +#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 + +/* Define if <sys/procfs.h> has pstatus_t. */ +/* #undef HAVE_PSTATUS_T */ + +/* Define if <sys/procfs.h> has prrun_t. */ +/* #undef HAVE_PRRUN_T */ + +/* Define if <sys/procfs.h> has gregset_t. */ +#define HAVE_GREGSET_T 1 + +/* Define if <sys/procfs.h> has fpregset_t. */ +#define HAVE_FPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset_t. */ +#define HAVE_PRGREGSET_T 1 + +/* Define if <sys/procfs.h> has prfpregset_t. */ +#define HAVE_PRFPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset32_t. */ +/* #undef HAVE_PRGREGSET32_T */ + +/* Define if <sys/procfs.h> has prfpregset32_t. */ +/* #undef HAVE_PRFPREGSET32_T */ + +/* Define if <sys/procfs.h> has lwpid_t. */ +#define HAVE_LWPID_T 1 + +/* Define if <sys/procfs.h> has psaddr_t. */ +#define HAVE_PSADDR_T 1 + +/* Define if <sys/procfs.h> has prsysent_t. */ +/* #undef HAVE_PRSYSENT_T */ + +/* Define if <sys/procfs.h> has pr_sigset_t. */ +/* #undef HAVE_PR_SIGSET_T */ + +/* Define if <sys/procfs.h> has pr_sigaction64_t. */ +/* #undef HAVE_PR_SIGACTION64_T */ + +/* Define if <sys/procfs.h> has pr_siginfo64_t. */ +/* #undef HAVE_PR_SIGINFO64_T */ + +/* Define if <thread_db.h> has the TD_NOTALLOC error code. */ +/* #undef THREAD_DB_HAS_TD_NOTALLOC */ + +/* Define if we can use the tkill syscall. */ +/* #undef HAVE_TKILL_SYSCALL */ + +/* Define to the default OS ABI for this configuration. */ +/* #undef GDB_OSABI_DEFAULT */ + +/* Define to be a string naming the default host character set. */ +#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + diff --git a/gnu/usr.bin/gdb/arch/powerpc64/init.c b/gnu/usr.bin/gdb/arch/powerpc64/init.c new file mode 100644 index 000000000000..5b96bd5137a2 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/powerpc64/init.c @@ -0,0 +1,230 @@ +/* $FreeBSD$ */ + +/* Do not modify this file. */ +/* It is created automatically by the Makefile. */ +#include "defs.h" /* For initialize_file_ftype. */ +#include "call-cmds.h" /* For initialize_all_files. */ +extern initialize_file_ftype _initialize_gdbtypes; +extern initialize_file_ftype _initialize_rs6000_tdep; +extern initialize_file_ftype _initialize_ppcfbsd_tdep; +extern initialize_file_ftype _initialize_corelow; +extern initialize_file_ftype _initialize_solib; +extern initialize_file_ftype _initialize_svr4_solib; +extern initialize_file_ftype _initialize_ser_hardwire; +extern initialize_file_ftype _initialize_ser_pipe; +extern initialize_file_ftype _initialize_ser_tcp; +extern initialize_file_ftype _initialize_fbsd_proc; +extern initialize_file_ftype _initialize_gcore; +extern initialize_file_ftype _initialize_kernel_u_addr; +extern initialize_file_ftype _initialize_infptrace; +extern initialize_file_ftype _initialize_inftarg; +extern initialize_file_ftype _initialize_ppcfbsd_nat; +extern initialize_file_ftype _initialize_thread_db; +extern initialize_file_ftype _initialize_remote; +extern initialize_file_ftype _initialize_dcache; +extern initialize_file_ftype _initialize_sr_support; +extern initialize_file_ftype _initialize_tracepoint; +extern initialize_file_ftype _initialize_ax_gdb; +extern initialize_file_ftype _initialize_annotate; +extern initialize_file_ftype _initialize_auxv; +extern initialize_file_ftype _initialize_breakpoint; +extern initialize_file_ftype _initialize_regcache; +extern initialize_file_ftype _initialize_charset; +extern initialize_file_ftype _initialize_dummy_frame; +extern initialize_file_ftype _initialize_source; +extern initialize_file_ftype _initialize_values; +extern initialize_file_ftype _initialize_valops; +extern initialize_file_ftype _initialize_valarith; +extern initialize_file_ftype _initialize_valprint; +extern initialize_file_ftype _initialize_printcmd; +extern initialize_file_ftype _initialize_symtab; +extern initialize_file_ftype _initialize_symfile; +extern initialize_file_ftype _initialize_symmisc; +extern initialize_file_ftype _initialize_infcall; +extern initialize_file_ftype _initialize_infcmd; +extern initialize_file_ftype _initialize_infrun; +extern initialize_file_ftype _initialize_stack; +extern initialize_file_ftype _initialize_thread; +extern initialize_file_ftype _initialize_interpreter; +extern initialize_file_ftype _initialize_macrocmd; +extern initialize_file_ftype _initialize_gdbarch; +extern initialize_file_ftype _initialize_gdbarch_utils; +extern initialize_file_ftype _initialize_gdb_osabi; +extern initialize_file_ftype _initialize_copying; +extern initialize_file_ftype _initialize_mem; +extern initialize_file_ftype _initialize_parse; +extern initialize_file_ftype _initialize_language; +extern initialize_file_ftype _initialize_frame_reg; +extern initialize_file_ftype _initialize_signals; +extern initialize_file_ftype _initialize_kod; +extern initialize_file_ftype _initialize_gdb_events; +extern initialize_file_ftype _initialize_exec; +extern initialize_file_ftype _initialize_maint_cmds; +extern initialize_file_ftype _initialize_demangler; +extern initialize_file_ftype _initialize_dbxread; +extern initialize_file_ftype _initialize_coffread; +extern initialize_file_ftype _initialize_elfread; +extern initialize_file_ftype _initialize_mipsread; +extern initialize_file_ftype _initialize_stabsread; +extern initialize_file_ftype _initialize_core; +extern initialize_file_ftype _initialize_dwarf2_frame; +extern initialize_file_ftype _initialize_c_language; +extern initialize_file_ftype _initialize_f_language; +extern initialize_file_ftype _initialize_objc_language; +extern initialize_file_ftype _initialize_ui_out; +extern initialize_file_ftype _initialize_cli_out; +extern initialize_file_ftype _initialize_varobj; +extern initialize_file_ftype _initialize_java_language; +extern initialize_file_ftype _initialize_m2_language; +extern initialize_file_ftype _initialize_pascal_language; +extern initialize_file_ftype _initialize_pascal_valprint; +extern initialize_file_ftype _initialize_scheme_language; +extern initialize_file_ftype _initialize_complaints; +extern initialize_file_ftype _initialize_typeprint; +extern initialize_file_ftype _initialize_cp_valprint; +extern initialize_file_ftype _initialize_f_valprint; +extern initialize_file_ftype _initialize_nlmread; +extern initialize_file_ftype _initialize_serial; +extern initialize_file_ftype _initialize_mdebugread; +extern initialize_file_ftype _initialize_user_regs; +extern initialize_file_ftype _initialize_frame; +extern initialize_file_ftype _initialize_frame_unwind; +extern initialize_file_ftype _initialize_frame_base; +extern initialize_file_ftype _initialize_gnu_v2_abi; +extern initialize_file_ftype _initialize_gnu_v3_abi; +extern initialize_file_ftype _initialize_hpacc_abi; +extern initialize_file_ftype _initialize_cp_abi; +extern initialize_file_ftype _initialize_cp_support; +extern initialize_file_ftype _initialize_cp_namespace; +extern initialize_file_ftype _initialize_reggroup; +extern initialize_file_ftype _initialize_inflow; +extern initialize_file_ftype _initialize_cli_dump; +extern initialize_file_ftype _initialize_cli_logging; +extern initialize_file_ftype _initialize_cli_interp; +extern initialize_file_ftype _initialize_mi_out; +extern initialize_file_ftype _initialize_mi_cmds; +extern initialize_file_ftype _initialize_mi_cmd_env; +extern initialize_file_ftype _initialize_mi_interp; +extern initialize_file_ftype _initialize_mi_main; +extern initialize_file_ftype _initialize_tui_hooks; +extern initialize_file_ftype _initialize_tui_interp; +extern initialize_file_ftype _initialize_tui_layout; +extern initialize_file_ftype _initialize_tui_out; +extern initialize_file_ftype _initialize_tui_regs; +extern initialize_file_ftype _initialize_tui_stack; +extern initialize_file_ftype _initialize_tui_win; +void +initialize_all_files (void) +{ + _initialize_gdbtypes (); + _initialize_rs6000_tdep (); + _initialize_ppcfbsd_tdep (); + _initialize_corelow (); + _initialize_solib (); + _initialize_svr4_solib (); + _initialize_ser_hardwire (); + _initialize_ser_pipe (); + _initialize_ser_tcp (); +#ifndef CROSS_DEBUGGER + _initialize_fbsd_proc (); + _initialize_gcore (); + _initialize_kernel_u_addr (); + _initialize_infptrace (); + _initialize_inftarg (); + _initialize_ppcfbsd_nat (); + _initialize_thread_db (); +#endif + _initialize_remote (); + _initialize_dcache (); + _initialize_sr_support (); + _initialize_tracepoint (); + _initialize_ax_gdb (); + _initialize_annotate (); + _initialize_auxv (); + _initialize_breakpoint (); + _initialize_regcache (); + _initialize_charset (); + _initialize_dummy_frame (); + _initialize_source (); + _initialize_values (); + _initialize_valops (); + _initialize_valarith (); + _initialize_valprint (); + _initialize_printcmd (); + _initialize_symtab (); + _initialize_symfile (); + _initialize_symmisc (); + _initialize_infcall (); + _initialize_infcmd (); + _initialize_infrun (); + _initialize_stack (); + _initialize_thread (); + _initialize_interpreter (); + _initialize_macrocmd (); + _initialize_gdbarch (); + _initialize_gdbarch_utils (); + _initialize_gdb_osabi (); + _initialize_copying (); + _initialize_mem (); + _initialize_parse (); + _initialize_language (); + _initialize_frame_reg (); + _initialize_signals (); + _initialize_kod (); + _initialize_gdb_events (); + _initialize_exec (); + _initialize_maint_cmds (); + _initialize_demangler (); + _initialize_dbxread (); + _initialize_coffread (); + _initialize_elfread (); + _initialize_mipsread (); + _initialize_stabsread (); + _initialize_core (); + _initialize_dwarf2_frame (); + _initialize_c_language (); + _initialize_f_language (); + _initialize_objc_language (); + _initialize_ui_out (); + _initialize_cli_out (); + _initialize_varobj (); + _initialize_java_language (); + _initialize_m2_language (); + _initialize_pascal_language (); + _initialize_pascal_valprint (); + _initialize_scheme_language (); + _initialize_complaints (); + _initialize_typeprint (); + _initialize_cp_valprint (); + _initialize_f_valprint (); + _initialize_nlmread (); + _initialize_serial (); + _initialize_mdebugread (); + _initialize_user_regs (); + _initialize_frame (); + _initialize_frame_unwind (); + _initialize_frame_base (); + _initialize_gnu_v2_abi (); + _initialize_gnu_v3_abi (); + _initialize_hpacc_abi (); + _initialize_cp_abi (); + _initialize_cp_support (); + _initialize_cp_namespace (); + _initialize_reggroup (); + _initialize_inflow (); + _initialize_cli_dump (); + _initialize_cli_logging (); + _initialize_cli_interp (); + _initialize_mi_out (); + _initialize_mi_cmds (); + _initialize_mi_cmd_env (); + _initialize_mi_interp (); + _initialize_mi_main (); + _initialize_tui_hooks (); + _initialize_tui_interp (); + _initialize_tui_layout (); + _initialize_tui_out (); + _initialize_tui_regs (); + _initialize_tui_stack (); + _initialize_tui_win (); +} diff --git a/gnu/usr.bin/gdb/arch/sparc64/Makefile b/gnu/usr.bin/gdb/arch/sparc64/Makefile new file mode 100644 index 000000000000..9d771727e902 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/sparc64/Makefile @@ -0,0 +1,14 @@ +# $FreeBSD$ + +.if !defined(GDB_CROSS_DEBUGGER) +LIBSRCS+= fbsd-threads.c +LIBSRCS+= solib.c solib-legacy.c solib-svr4.c +LIBSRCS+= sparc-nat.c sparc64-nat.c sparc64fbsd-nat.c +.endif +LIBSRCS+= sparc-tdep.c sparc64-tdep.c sparc64fbsd-tdep.c + +nm.h: + echo '#include "sparc/nm-fbsd.h"' > ${.TARGET} + +tm.h: + echo '#include "sparc/tm-fbsd.h"' > ${.TARGET} diff --git a/gnu/usr.bin/gdb/arch/sparc64/config.h b/gnu/usr.bin/gdb/arch/sparc64/config.h new file mode 100644 index 000000000000..8bcfdb28c8f5 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/sparc64/config.h @@ -0,0 +1,550 @@ +/* $FreeBSD$ */ + +/* config.h. Generated automatically by configure. */ +/* config.in. Generated automatically from configure.in by autoheader. */ + +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + +/* Define if using alloca.c. */ +/* #undef C_ALLOCA */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +/* #undef CRAY_STACKSEG_END */ + +/* Define if you have alloca, as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define if you have <alloca.h> and it should be used (not on Ultrix). */ +/* #undef HAVE_ALLOCA_H */ + +/* Define if the `long double' type works. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define if you have <vfork.h>. */ +/* #undef HAVE_VFORK_H */ + +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + +/* Define to `long' if <sys/types.h> doesn't define. */ +/* #undef off_t */ + +/* Define to `int' if <sys/types.h> doesn't define. */ +/* #undef pid_t */ + +/* Define if you need to in order for stat and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define if the `setpgrp' function takes no argument. */ +/* #undef SETPGRP_VOID */ + +/* Define to `unsigned' if <sys/types.h> doesn't define. */ +/* #undef size_t */ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown + */ +/* #undef STACK_DIRECTION */ + +/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define vfork as fork if vfork does not work. */ +/* #undef vfork */ + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + +/* Define if your struct reg has r_fs. */ +/* #undef HAVE_STRUCT_REG_R_FS */ + +/* Define if your struct stat has st_blocks. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define if your struct reg has r_gs. */ +/* #undef HAVE_STRUCT_REG_R_GS */ + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``l_'' prefix. (For Solaris, SVR4, and + SVR4-like systems.) */ +#define HAVE_STRUCT_LINK_MAP_WITH_L_MEMBERS 1 + +/* Define if <link.h> exists and defines struct link_map which has + members with an ``lm_'' prefix. (For SunOS.) */ +/* #undef HAVE_STRUCT_LINK_MAP_WITH_LM_MEMBERS */ + +/* Define if <link.h> exists and defines a struct so_map which has + members with an ``som_'' prefix. (Found on older *BSD systems.) */ +/* #undef HAVE_STRUCT_SO_MAP_WITH_SOM_MEMBERS */ + +/* Define if <sys/link.h> has struct link_map32 */ +/* #undef HAVE_STRUCT_LINK_MAP32 */ + +/* Define if <sys/link.h> has link_map32 (solaris sparc-64 target) */ +/* #undef _SYSCALL32 */ + +/* Define if the prfpregset_t type is broken. */ +/* #undef PRFPREGSET_T_BROKEN */ + +/* Define if you want to use new multi-fd /proc interface + (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */ +/* #undef NEW_PROC_API */ + +/* Define if ioctl argument PIOCSET is available. */ +/* #undef HAVE_PROCFS_PIOCSET */ + +/* Define if the `long long' type works. */ +#define CC_HAS_LONG_LONG 1 + +/* Define if the "ll" format works to print long long ints. */ +#define PRINTF_HAS_LONG_LONG 1 + +/* Define if the "%Lg" format works to print long doubles. */ +#define PRINTF_HAS_LONG_DOUBLE 1 + +/* Define if the "%Lg" format works to scan long doubles. */ +#define SCANF_HAS_LONG_DOUBLE 1 + +/* Define if using Solaris thread debugging. */ +/* #undef HAVE_THREAD_DB_LIB */ + +/* Define on a GNU/Linux system to work around problems in sys/procfs.h. */ +/* #undef START_INFERIOR_TRAPS_EXPECTED */ +/* #undef sys_quotactl */ + +/* Define if you have HPUX threads */ +/* #undef HAVE_HPUX_THREAD_SUPPORT */ + +/* Define if <proc_service.h> on solaris uses int instead of + size_t, and assorted other type changes. */ +/* #undef PROC_SERVICE_IS_OLD */ + +/* Define if the simulator is being linked in. */ +#define WITH_SIM 1 + +/* Set to true if the save_state_t structure is present */ +/* #undef HAVE_STRUCT_SAVE_STATE_T */ + +/* Set to true if the save_state_t structure has the ss_wide member */ +/* #undef HAVE_STRUCT_MEMBER_SS_WIDE */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETREGS request. */ +/* #undef HAVE_PTRACE_GETREGS */ + +/* Define if <sys/ptrace.h> defines the PTRACE_GETFPXREGS request. */ +/* #undef HAVE_PTRACE_GETFPXREGS */ + +/* Define if <sys/ptrace.h> defines the PT_GETDBREGS request. */ +#define HAVE_PT_GETDBREGS 1 + +/* Define if <sys/ptrace.h> defines the PT_GETXMMREGS request. */ +/* #undef HAVE_PT_GETXMMREGS */ + +/* Define if libunwind library is being used. */ +/* #undef HAVE_LIBUNWIND */ + +/* hostfile */ +/* #undef GDB_XM_FILE */ + +/* targetfile */ +#define GDB_TM_FILE config/sparc/tm-fbsd.h + +/* nativefile */ +#ifndef CROSS_DEBUGGER +#define GDB_NM_FILE config/sparc/nm-fbsd.h +#endif + +/* Define to 1 so <sys/proc.h> gets a definition of anon_hdl. Works + around a <sys/proc.h> problem on IRIX 5. */ +#ifndef _KMEMUSER +/* #undef _KMEMUSER */ +#endif + +/* Define if you have the __argz_count function. */ +/* #undef HAVE___ARGZ_COUNT */ + +/* Define if you have the __argz_next function. */ +/* #undef HAVE___ARGZ_NEXT */ + +/* Define if you have the __argz_stringify function. */ +/* #undef HAVE___ARGZ_STRINGIFY */ + +/* Define if you have the _mcleanup function. */ +#define HAVE__MCLEANUP 1 + +/* Define if you have the canonicalize_file_name function. */ +/* #undef HAVE_CANONICALIZE_FILE_NAME */ + +/* Define if you have the dcgettext function. */ +/* #undef HAVE_DCGETTEXT */ + +/* Define if you have the getcwd function. */ +#define HAVE_GETCWD 1 + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the monstartup function. */ +#define HAVE_MONSTARTUP 1 + +/* Define if you have the munmap function. */ +#define HAVE_MUNMAP 1 + +/* Define if you have the poll function. */ +#define HAVE_POLL 1 + +/* Define if you have the pread64 function. */ +/* #undef HAVE_PREAD64 */ + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the realpath function. */ +#define HAVE_REALPATH 1 + +/* Define if you have the sbrk function. */ +/* #undef HAVE_SBRK */ + +/* Define if you have the setenv function. */ +#define HAVE_SETENV 1 + +/* Define if you have the setlocale function. */ +#define HAVE_SETLOCALE 1 + +/* Define if you have the setpgid function. */ +#define HAVE_SETPGID 1 + +/* Define if you have the setpgrp function. */ +#define HAVE_SETPGRP 1 + +/* Define if you have the sigaction function. */ +#define HAVE_SIGACTION 1 + +/* Define if you have the sigprocmask function. */ +#define HAVE_SIGPROCMASK 1 + +/* Define if you have the sigsetmask function. */ +#define HAVE_SIGSETMASK 1 + +/* Define if you have the socketpair function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define if you have the stpcpy function. */ +#define HAVE_STPCPY 1 + +/* Define if you have the strcasecmp function. */ +#define HAVE_STRCASECMP 1 + +/* Define if you have the strchr function. */ +#define HAVE_STRCHR 1 + +/* Define if you have the syscall function. */ +#define HAVE_SYSCALL 1 + +/* Define if you have the <argz.h> header file. */ +/* #undef HAVE_ARGZ_H */ + +/* Define if you have the <ctype.h> header file. */ +#define HAVE_CTYPE_H 1 + +/* Define if you have the <curses.h> header file. */ +#define HAVE_CURSES_H 1 + +/* Define if you have the <dirent.h> header file. */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the <libunwind-ia64.h> header file. */ +/* #undef HAVE_LIBUNWIND_IA64_H */ + +/* Define if you have the <libunwind.h> header file. */ +/* #undef HAVE_LIBUNWIND_H */ + +/* Define if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the <link.h> header file. */ +#define HAVE_LINK_H 1 + +/* Define if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define if you have the <machine/reg.h> header file. */ +#define HAVE_MACHINE_REG_H 1 + +/* Define if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if you have the <ncurses.h> header file. */ +#define HAVE_NCURSES_H 1 + +/* Define if you have the <ndir.h> header file. */ +/* #undef HAVE_NDIR_H */ + +/* Define if you have the <nl_types.h> header file. */ +#define HAVE_NL_TYPES_H 1 + +/* Define if you have the <nlist.h> header file. */ +#define HAVE_NLIST_H 1 + +/* Define if you have the <poll.h> header file. */ +#define HAVE_POLL_H 1 + +/* Define if you have the <proc_service.h> header file. */ +/* #undef HAVE_PROC_SERVICE_H */ + +/* Define if you have the <ptrace.h> header file. */ +/* #undef HAVE_PTRACE_H */ + +/* Define if you have the <sgtty.h> header file. */ +#define HAVE_SGTTY_H 1 + +/* Define if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define if you have the <sys/debugreg.h> header file. */ +/* #undef HAVE_SYS_DEBUGREG_H */ + +/* Define if you have the <sys/dir.h> header file. */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define if you have the <sys/fault.h> header file. */ +/* #undef HAVE_SYS_FAULT_H */ + +/* Define if you have the <sys/file.h> header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define if you have the <sys/filio.h> header file. */ +#define HAVE_SYS_FILIO_H 1 + +/* Define if you have the <sys/ioctl.h> header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define if you have the <sys/ndir.h> header file. */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the <sys/poll.h> header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define if you have the <sys/proc.h> header file. */ +#define HAVE_SYS_PROC_H 1 + +/* Define if you have the <sys/procfs.h> header file. */ +#define HAVE_SYS_PROCFS_H 1 + +/* Define if you have the <sys/ptrace.h> header file. */ +#define HAVE_SYS_PTRACE_H 1 + +/* Define if you have the <sys/reg.h> header file. */ +/* #undef HAVE_SYS_REG_H */ + +/* Define if you have the <sys/select.h> header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define if you have the <sys/syscall.h> header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define if you have the <sys/user.h> header file. */ +#define HAVE_SYS_USER_H 1 + +/* Define if you have the <sys/wait.h> header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the <term.h> header file. */ +#define HAVE_TERM_H 1 + +/* Define if you have the <termio.h> header file. */ +/* #undef HAVE_TERMIO_H */ + +/* Define if you have the <termios.h> header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define if you have the <thread_db.h> header file. */ +/* #undef HAVE_THREAD_DB_H */ + +/* Define if you have the <time.h> header file. */ +#define HAVE_TIME_H 1 + +/* Define if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the <values.h> header file. */ +/* #undef HAVE_VALUES_H */ + +/* Define if you have the <wait.h> header file. */ +/* #undef HAVE_WAIT_H */ + +/* Define if you have the dl library (-ldl). */ +/* #undef HAVE_LIBDL */ + +/* Define if you have the m library (-lm). */ +#define HAVE_LIBM 1 + +/* Define if you have the w library (-lw). */ +/* #undef HAVE_LIBW */ + +/* Define if you have the stpcpy function */ +#define HAVE_STPCPY 1 + +/* Define if your locale.h file contains LC_MESSAGES. */ +#define HAVE_LC_MESSAGES 1 + +/* Define to 1 if NLS is requested */ +/* #undef ENABLE_NLS */ + +/* Define as 1 if you have gettext and don't want to use GNU gettext. */ +/* #undef HAVE_GETTEXT */ + +/* Name of this package. */ +#define PACKAGE "gdb" + +/* Define to BFD's default architecture. */ +#define DEFAULT_BFD_ARCH bfd_sparc_arch + +/* Define to BFD's default target vector. */ +#define DEFAULT_BFD_VEC bfd_elf64_sparc_vec + +/* Define to 1 if your system has the _etext variable. */ +#define HAVE__ETEXT 1 + +/* Define to 1 to avoid a clash between <widec.h> and <wchar.h> on + Solaris 2.[78] when using GCC. */ +/* #undef _MSE_INT_H */ + +/* Define to 1 if we found this declaration otherwise define to 0. */ +#define HAVE_DECL_GETOPT 0 + +/* Define if sigsetjmp is available. */ +#define HAVE_SIGSETJMP 1 + +/* Define to 1 if the regex included in libiberty should be used. */ +#define USE_INCLUDED_REGEX 1 + +/* Define to 1 if your system has struct reg in <machine/reg.h>. */ +#define HAVE_STRUCT_REG 1 + +/* Define if <stdint.h> provides the uintptr_t type. */ +#define HAVE_UINTPTR_T 1 + +/* Define if malloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_MALLOC */ + +/* Define if realloc is not declared in system header files. */ +/* #undef NEED_DECLARATION_REALLOC */ + +/* Define if free is not declared in system header files. */ +/* #undef NEED_DECLARATION_FREE */ + +/* Define if strerror is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRERROR */ + +/* Define if strdup is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRDUP */ + +/* Define if strstr is not declared in system header files. */ +/* #undef NEED_DECLARATION_STRSTR */ + +/* Define if canonicalize_file_name is not declared in system header files. */ +#define NEED_DECLARATION_CANONICALIZE_FILE_NAME 1 + +/* Define if <sys/procfs.h> has pstatus_t. */ +/* #undef HAVE_PSTATUS_T */ + +/* Define if <sys/procfs.h> has prrun_t. */ +/* #undef HAVE_PRRUN_T */ + +/* Define if <sys/procfs.h> has gregset_t. */ +#define HAVE_GREGSET_T 1 + +/* Define if <sys/procfs.h> has fpregset_t. */ +#define HAVE_FPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset_t. */ +#define HAVE_PRGREGSET_T 1 + +/* Define if <sys/procfs.h> has prfpregset_t. */ +#define HAVE_PRFPREGSET_T 1 + +/* Define if <sys/procfs.h> has prgregset32_t. */ +/* #undef HAVE_PRGREGSET32_T */ + +/* Define if <sys/procfs.h> has prfpregset32_t. */ +/* #undef HAVE_PRFPREGSET32_T */ + +/* Define if <sys/procfs.h> has lwpid_t. */ +#define HAVE_LWPID_T 1 + +/* Define if <sys/procfs.h> has psaddr_t. */ +#define HAVE_PSADDR_T 1 + +/* Define if <sys/procfs.h> has prsysent_t. */ +/* #undef HAVE_PRSYSENT_T */ + +/* Define if <sys/procfs.h> has pr_sigset_t. */ +/* #undef HAVE_PR_SIGSET_T */ + +/* Define if <sys/procfs.h> has pr_sigaction64_t. */ +/* #undef HAVE_PR_SIGACTION64_T */ + +/* Define if <sys/procfs.h> has pr_siginfo64_t. */ +/* #undef HAVE_PR_SIGINFO64_T */ + +/* Define if <thread_db.h> has the TD_NOTALLOC error code. */ +/* #undef THREAD_DB_HAS_TD_NOTALLOC */ + +/* Define if we can use the tkill syscall. */ +/* #undef HAVE_TKILL_SYSCALL */ + +/* Define to the default OS ABI for this configuration. */ +/* #undef GDB_OSABI_DEFAULT */ + +/* Define to be a string naming the default host character set. */ +#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1" + +/* Define if you have the iconv() function. */ +/* #undef HAVE_ICONV */ + +/* Define as const if the declaration of iconv() needs const. */ +/* #undef ICONV_CONST */ + diff --git a/gnu/usr.bin/gdb/arch/sparc64/init.c b/gnu/usr.bin/gdb/arch/sparc64/init.c new file mode 100644 index 000000000000..d2cf24e98079 --- /dev/null +++ b/gnu/usr.bin/gdb/arch/sparc64/init.c @@ -0,0 +1,232 @@ +/* $FreeBSD$ */ + +/* Do not modify this file. */ +/* It is created automatically by the Makefile. */ +#include "defs.h" /* For initialize_file_ftype. */ +#include "call-cmds.h" /* For initialize_all_files. */ +extern initialize_file_ftype _initialize_gdbtypes; +extern initialize_file_ftype _initialize_sparc_tdep; +extern initialize_file_ftype _initialize_sparc64fbsd_tdep; +extern initialize_file_ftype _initialize_corelow; +extern initialize_file_ftype _initialize_ser_hardwire; +extern initialize_file_ftype _initialize_ser_pipe; +extern initialize_file_ftype _initialize_ser_tcp; +extern initialize_file_ftype _initialize_thread_db; +extern initialize_file_ftype _initialize_sparc64fbsd_nat; +extern initialize_file_ftype _initialize_sparc64_nat; +extern initialize_file_ftype _initialize_sparc_nat; +extern initialize_file_ftype _initialize_kernel_u_addr; +extern initialize_file_ftype _initialize_infptrace; +extern initialize_file_ftype _initialize_inftarg; +extern initialize_file_ftype _initialize_solib; +extern initialize_file_ftype _initialize_svr4_solib; +extern initialize_file_ftype _initialize_svr4_lm; +extern initialize_file_ftype _initialize_remote; +extern initialize_file_ftype _initialize_dcache; +extern initialize_file_ftype _initialize_sr_support; +extern initialize_file_ftype _initialize_tracepoint; +extern initialize_file_ftype _initialize_ax_gdb; +extern initialize_file_ftype _initialize_annotate; +extern initialize_file_ftype _initialize_auxv; +extern initialize_file_ftype _initialize_breakpoint; +extern initialize_file_ftype _initialize_regcache; +extern initialize_file_ftype _initialize_charset; +extern initialize_file_ftype _initialize_dummy_frame; +extern initialize_file_ftype _initialize_source; +extern initialize_file_ftype _initialize_values; +extern initialize_file_ftype _initialize_valops; +extern initialize_file_ftype _initialize_valarith; +extern initialize_file_ftype _initialize_valprint; +extern initialize_file_ftype _initialize_printcmd; +extern initialize_file_ftype _initialize_symtab; +extern initialize_file_ftype _initialize_symfile; +extern initialize_file_ftype _initialize_symmisc; +extern initialize_file_ftype _initialize_infcall; +extern initialize_file_ftype _initialize_infcmd; +extern initialize_file_ftype _initialize_infrun; +extern initialize_file_ftype _initialize_stack; +extern initialize_file_ftype _initialize_thread; +extern initialize_file_ftype _initialize_interpreter; +extern initialize_file_ftype _initialize_macrocmd; +extern initialize_file_ftype _initialize_gdbarch; +extern initialize_file_ftype _initialize_gdbarch_utils; +extern initialize_file_ftype _initialize_gdb_osabi; +extern initialize_file_ftype _initialize_copying; +extern initialize_file_ftype _initialize_mem; +extern initialize_file_ftype _initialize_parse; +extern initialize_file_ftype _initialize_language; +extern initialize_file_ftype _initialize_frame_reg; +extern initialize_file_ftype _initialize_signals; +extern initialize_file_ftype _initialize_kod; +extern initialize_file_ftype _initialize_gdb_events; +extern initialize_file_ftype _initialize_exec; +extern initialize_file_ftype _initialize_maint_cmds; +extern initialize_file_ftype _initialize_demangler; +extern initialize_file_ftype _initialize_dbxread; +extern initialize_file_ftype _initialize_coffread; +extern initialize_file_ftype _initialize_elfread; +extern initialize_file_ftype _initialize_mipsread; +extern initialize_file_ftype _initialize_stabsread; +extern initialize_file_ftype _initialize_core; +extern initialize_file_ftype _initialize_dwarf2_frame; +extern initialize_file_ftype _initialize_c_language; +extern initialize_file_ftype _initialize_f_language; +extern initialize_file_ftype _initialize_objc_language; +extern initialize_file_ftype _initialize_ui_out; +extern initialize_file_ftype _initialize_cli_out; +extern initialize_file_ftype _initialize_varobj; +extern initialize_file_ftype _initialize_java_language; +extern initialize_file_ftype _initialize_m2_language; +extern initialize_file_ftype _initialize_pascal_language; +extern initialize_file_ftype _initialize_pascal_valprint; +extern initialize_file_ftype _initialize_scheme_language; +extern initialize_file_ftype _initialize_complaints; +extern initialize_file_ftype _initialize_typeprint; +extern initialize_file_ftype _initialize_cp_valprint; +extern initialize_file_ftype _initialize_f_valprint; +extern initialize_file_ftype _initialize_nlmread; +extern initialize_file_ftype _initialize_serial; +extern initialize_file_ftype _initialize_mdebugread; +extern initialize_file_ftype _initialize_user_regs; +extern initialize_file_ftype _initialize_frame; +extern initialize_file_ftype _initialize_frame_unwind; +extern initialize_file_ftype _initialize_frame_base; +extern initialize_file_ftype _initialize_gnu_v2_abi; +extern initialize_file_ftype _initialize_gnu_v3_abi; +extern initialize_file_ftype _initialize_hpacc_abi; +extern initialize_file_ftype _initialize_cp_abi; +extern initialize_file_ftype _initialize_cp_support; +extern initialize_file_ftype _initialize_cp_namespace; +extern initialize_file_ftype _initialize_reggroup; +extern initialize_file_ftype _initialize_inflow; +extern initialize_file_ftype _initialize_cli_dump; +extern initialize_file_ftype _initialize_cli_logging; +extern initialize_file_ftype _initialize_cli_interp; +extern initialize_file_ftype _initialize_mi_out; +extern initialize_file_ftype _initialize_mi_cmds; +extern initialize_file_ftype _initialize_mi_cmd_env; +extern initialize_file_ftype _initialize_mi_interp; +extern initialize_file_ftype _initialize_mi_main; +extern initialize_file_ftype _initialize_tui_hooks; +extern initialize_file_ftype _initialize_tui_interp; +extern initialize_file_ftype _initialize_tui_layout; +extern initialize_file_ftype _initialize_tui_out; +extern initialize_file_ftype _initialize_tui_regs; +extern initialize_file_ftype _initialize_tui_stack; +extern initialize_file_ftype _initialize_tui_win; +void +initialize_all_files (void) +{ + _initialize_gdbtypes (); + _initialize_sparc_tdep (); + _initialize_sparc64fbsd_tdep (); + _initialize_corelow (); + _initialize_ser_hardwire (); + _initialize_ser_pipe (); + _initialize_ser_tcp (); +#ifndef CROSS_DEBUGGER + _initialize_thread_db (); + _initialize_sparc64fbsd_nat (); + _initialize_sparc64_nat (); + _initialize_sparc_nat (); + _initialize_kernel_u_addr (); + _initialize_infptrace (); + _initialize_inftarg (); + _initialize_solib (); + _initialize_svr4_solib (); + _initialize_svr4_lm (); +#endif + _initialize_remote (); + _initialize_dcache (); + _initialize_sr_support (); + _initialize_tracepoint (); + _initialize_ax_gdb (); + _initialize_annotate (); + _initialize_auxv (); + _initialize_breakpoint (); + _initialize_regcache (); + _initialize_charset (); + _initialize_dummy_frame (); + _initialize_source (); + _initialize_values (); + _initialize_valops (); + _initialize_valarith (); + _initialize_valprint (); + _initialize_printcmd (); + _initialize_symtab (); + _initialize_symfile (); + _initialize_symmisc (); + _initialize_infcall (); + _initialize_infcmd (); + _initialize_infrun (); + _initialize_stack (); + _initialize_thread (); + _initialize_interpreter (); + _initialize_macrocmd (); + _initialize_gdbarch (); + _initialize_gdbarch_utils (); + _initialize_gdb_osabi (); + _initialize_copying (); + _initialize_mem (); + _initialize_parse (); + _initialize_language (); + _initialize_frame_reg (); + _initialize_signals (); + _initialize_kod (); + _initialize_gdb_events (); + _initialize_exec (); + _initialize_maint_cmds (); + _initialize_demangler (); + _initialize_dbxread (); + _initialize_coffread (); + _initialize_elfread (); + _initialize_mipsread (); + _initialize_stabsread (); + _initialize_core (); + _initialize_dwarf2_frame (); + _initialize_c_language (); + _initialize_f_language (); + _initialize_objc_language (); + _initialize_ui_out (); + _initialize_cli_out (); + _initialize_varobj (); + _initialize_java_language (); + _initialize_m2_language (); + _initialize_pascal_language (); + _initialize_pascal_valprint (); + _initialize_scheme_language (); + _initialize_complaints (); + _initialize_typeprint (); + _initialize_cp_valprint (); + _initialize_f_valprint (); + _initialize_nlmread (); + _initialize_serial (); + _initialize_mdebugread (); + _initialize_user_regs (); + _initialize_frame (); + _initialize_frame_unwind (); + _initialize_frame_base (); + _initialize_gnu_v2_abi (); + _initialize_gnu_v3_abi (); + _initialize_hpacc_abi (); + _initialize_cp_abi (); + _initialize_cp_support (); + _initialize_cp_namespace (); + _initialize_reggroup (); + _initialize_inflow (); + _initialize_cli_dump (); + _initialize_cli_logging (); + _initialize_cli_interp (); + _initialize_mi_out (); + _initialize_mi_cmds (); + _initialize_mi_cmd_env (); + _initialize_mi_interp (); + _initialize_mi_main (); + _initialize_tui_hooks (); + _initialize_tui_interp (); + _initialize_tui_layout (); + _initialize_tui_out (); + _initialize_tui_regs (); + _initialize_tui_stack (); + _initialize_tui_win (); +} diff --git a/gnu/usr.bin/gdb/gdb/Makefile b/gnu/usr.bin/gdb/gdb/Makefile new file mode 100644 index 000000000000..5a6bba44c595 --- /dev/null +++ b/gnu/usr.bin/gdb/gdb/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +PROG= gdb${GDB_SUFFIX} +SRCS= gdb.c + +BULIBS= ${OBJ_BU}/libbfd/libbfd.a ${OBJ_BU}/libopcodes/libopcodes.a \ + ${OBJ_BU}/libiberty/libiberty.a +GDBLIBS= ${OBJ_GDB}/libgdb/libgdb.a + +# libthread_db.so calls back into gdb for the proc services. Make all the +# global symbols visible. +LDFLAGS+= -Wl,-E + +DPADD= ${GDBLIBS} ${BULIBS} +LDADD= ${GDBLIBS} ${BULIBS} +LIBADD+= m edit ncursesw gnuregex + +.include <bsd.prog.mk> +CFLAGS+= -DDEBUGDIR=\"${DEBUGDIR}\" diff --git a/gnu/usr.bin/gdb/gdb/Makefile.depend b/gnu/usr.bin/gdb/gdb/Makefile.depend new file mode 100644 index 000000000000..ee6269e741a7 --- /dev/null +++ b/gnu/usr.bin/gdb/gdb/Makefile.depend @@ -0,0 +1,25 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/lib/libreadline/readline \ + gnu/lib/libregex \ + gnu/usr.bin/binutils/libbfd \ + gnu/usr.bin/binutils/libiberty \ + gnu/usr.bin/binutils/libopcodes \ + gnu/usr.bin/gdb/libgdb \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + lib/msun \ + lib/ncurses/ncursesw \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/gdb/gdb/gdb.1 b/gnu/usr.bin/gdb/gdb/gdb.1 new file mode 100644 index 000000000000..635e5c311882 --- /dev/null +++ b/gnu/usr.bin/gdb/gdb/gdb.1 @@ -0,0 +1,376 @@ +.\" Copyright (c) 1991 Free Software Foundation +.\" See section COPYING for conditions for redistribution +.\" $FreeBSD$ +.TH gdb 1 "4nov1991" "GNU Tools" "GNU Tools" +.SH NAME +gdb \- The GNU Debugger +.SH SYNOPSIS +.na +.TP +.B gdb +.RB "[\|" \-help "\|]" +.RB "[\|" \-nx "\|]" +.RB "[\|" \-q "\|]" +.RB "[\|" \-batch "\|]" +.RB "[\|" \-cd=\c +.I dir\c +\|] +.RB "[\|" \-f "\|]" +.RB "[\|" "\-b\ "\c +.IR bps "\|]" +.RB "[\|" "\-tty="\c +.IR dev "\|]" +.RB "[\|" "\-s "\c +.I symfile\c +\&\|] +.RB "[\|" "\-e "\c +.I prog\c +\&\|] +.RB "[\|" "\-se "\c +.I prog\c +\&\|] +.RB "[\|" "\-c "\c +.I core\c +\&\|] +.RB "[\|" "\-x "\c +.I cmds\c +\&\|] +.RB "[\|" "\-d "\c +.I dir\c +\&\|] +.RB "[\|" \c +.I prog\c +.RB "[\|" \c +.IR core \||\| procID\c +\&\|]\&\|] +.ad b +.SH DEPRECATION NOTICE +This version of gdb is deprecated and will be removed from future versions +of the FreeBSD base system. +A newer version of gdb is available from ports or packages +(devel/gdb). +.SH DESCRIPTION +The purpose of a debugger such as GDB is to allow you to see what is +going on ``inside'' another program while it executes\(em\&or what another +program was doing at the moment it crashed. + +GDB can do four main kinds of things (plus other things in support of +these) to help you catch bugs in the act: + +.TP +\ \ \ \(bu +Start your program, specifying anything that might affect its behavior. + +.TP +\ \ \ \(bu +Make your program stop on specified conditions. + +.TP +\ \ \ \(bu +Examine what has happened, when your program has stopped. + +.TP +\ \ \ \(bu +Change things in your program, so you can experiment with correcting the +effects of one bug and go on to learn about another. +.PP + +You can use GDB to debug programs written in C, C++, and Modula-2. +Fortran support will be added when a GNU Fortran compiler is ready. + +GDB is invoked with the shell command \c +.B gdb\c +\&. Once started, it reads +commands from the terminal until you tell it to exit with the GDB +command \c +.B quit\c +\&. You can get online help from \c +.B gdb\c +\& itself +by using the command \c +.B help\c +\&. + +You can run \c +.B gdb\c +\& with no arguments or options; but the most +usual way to start GDB is with one argument or two, specifying an +executable program as the argument: +.sp +.br +gdb\ program +.br +.sp + +You can also start with both an executable program and a core file specified: +.sp +.br +gdb\ program\ core +.br +.sp + +You can, instead, specify a process ID as a second argument, if you want +to debug a running process: +.sp +.br +gdb\ program\ 1234 +.br +.sp + +would attach GDB to process \c +.B 1234\c +\& (unless you also have a file +named `\|\c +.B 1234\c +\&\|'; GDB does check for a core file first). + +Here are some of the most frequently needed GDB commands: +.TP +.B break \fR[\|\fIfile\fB:\fR\|]\fIfunction +\& +Set a breakpoint at \c +.I function\c +\& (in \c +.I file\c +\&). +.TP +.B run \fR[\|\fIarglist\fR\|] +Start your program (with \c +.I arglist\c +\&, if specified). +.TP +.B bt +Backtrace: display the program stack. +.TP +.BI print " expr"\c +\& +Display the value of an expression. +.TP +.B c +Continue running your program (after stopping, e.g. at a breakpoint). +.TP +.B next +Execute next program line (after stopping); step \c +.I over\c +\& any +function calls in the line. +.TP +.B step +Execute next program line (after stopping); step \c +.I into\c +\& any +function calls in the line. +.TP +.B help \fR[\|\fIname\fR\|] +Show information about GDB command \c +.I name\c +\&, or general information +about using GDB. +.TP +.B quit +Exit from GDB. +.PP +For full details on GDB, see \c +.I +Using GDB: A Guide to the GNU Source-Level Debugger\c +\&, by Richard M. Stallman and Roland H. Pesch. The same text is available online +as the \c +.B gdb\c +\& entry in the \c +.B info\c +\& program. +.SH OPTIONS +Any arguments other than options specify an executable +file and core file (or process ID); that is, the first argument +encountered with no +associated option flag is equivalent to a `\|\c +.B \-se\c +\&\|' option, and the +second, if any, is equivalent to a `\|\c +.B \-c\c +\&\|' option if it's the name of a file. Many options have +both long and short forms; both are shown here. The long forms are also +recognized if you truncate them, so long as enough of the option is +present to be unambiguous. (If you prefer, you can flag option +arguments with `\|\c +.B +\c +\&\|' rather than `\|\c +.B \-\c +\&\|', though we illustrate the +more usual convention.) + +All the options and command line arguments you give are processed +in sequential order. The order makes a difference when the +`\|\c +.B \-x\c +\&\|' option is used. + +.TP +.B \-help +.TP +.B \-h +List all options, with brief explanations. + +.TP +.BI "\-symbols=" "file"\c +.TP +.BI "\-s " "file"\c +\& +Read symbol table from file \c +.I file\c +\&. + +.TP +.BI "\-exec=" "file"\c +.TP +.BI "\-e " "file"\c +\& +Use file \c +.I file\c +\& as the executable file to execute when +appropriate, and for examining pure data in conjunction with a core +dump. + +.TP +.BI "\-se=" "file"\c +\& +Read symbol table from file \c +.I file\c +\& and use it as the executable +file. + +.TP +.BI "\-core=" "file"\c +.TP +.BI "\-c " "file"\c +\& +Use file \c +.I file\c +\& as a core dump to examine. + +.TP +.BI "\-command=" "file"\c +.TP +.BI "\-x " "file"\c +\& +Execute GDB commands from file \c +.I file\c +\&. + +.TP +.BI "\-directory=" "directory"\c +.TP +.BI "\-d " "directory"\c +\& +Add \c +.I directory\c +\& to the path to search for source files. +.PP + +.TP +.B \-nx +.TP +.B \-n +Do not execute commands from any `\|\c +.B .gdbinit\c +\&\|' initialization files. +Normally, the commands in these files are executed after all the +command options and arguments have been processed. + + +.TP +.B \-quiet +.TP +.B \-q +``Quiet''. Do not print the introductory and copyright messages. These +messages are also suppressed in batch mode. + +.TP +.B \-batch +Run in batch mode. Exit with status \c +.B 0\c +\& after processing all the command +files specified with `\|\c +.B \-x\c +\&\|' (and `\|\c +.B .gdbinit\c +\&\|', if not inhibited). +Exit with nonzero status if an error occurs in executing the GDB +commands in the command files. + +Batch mode may be useful for running GDB as a filter, for example to +download and run a program on another computer; in order to make this +more useful, the message +.sp +.br +Program\ exited\ normally. +.br +.sp + +(which is ordinarily issued whenever a program running under GDB control +terminates) is not issued when running in batch mode. + +.TP +.BI "\-cd=" "directory"\c +\& +Run GDB using \c +.I directory\c +\& as its working directory, +instead of the current directory. + +.TP +.B \-fullname +.TP +.B \-f +Emacs sets this option when it runs GDB as a subprocess. It tells GDB +to output the full file name and line number in a standard, +recognizable fashion each time a stack frame is displayed (which +includes each time the program stops). This recognizable format looks +like two `\|\c +.B \e032\c +\&\|' characters, followed by the file name, line number +and character position separated by colons, and a newline. The +Emacs-to-GDB interface program uses the two `\|\c +.B \e032\c +\&\|' characters as +a signal to display the source code for the frame. + +.TP +.BI "\-b " "bps"\c +\& +Set the line speed (baud rate or bits per second) of any serial +interface used by GDB for remote debugging. + +.TP +.BI "\-tty=" "device"\c +\& +Run using \c +.I device\c +\& for your program's standard input and output. +.PP + +.SH "SEE ALSO" +.RB "`\|" gdb "\|'" +entry in +.B info\c +\&; +.I +Using GDB: A Guide to the GNU Source-Level Debugger\c +, Richard M. Stallman and Roland H. Pesch, July 1991. +.SH COPYING +Copyright (c) 1991 Free Software Foundation, Inc. +.PP +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. +.PP +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. +.PP +Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be included in +translations approved by the Free Software Foundation instead of in +the original English. diff --git a/gnu/usr.bin/gdb/gdbserver/Makefile b/gnu/usr.bin/gdb/gdbserver/Makefile new file mode 100644 index 000000000000..fa46e6de14fa --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +# Not elf specific so don't install in /usr/libexec/elf +BINDIR=/usr/bin + +GDBDIR= ${SRCTOP}/contrib/gdb +.PATH: ${GDBDIR}/gdb/signals +.PATH: ${GDBDIR}/gdb/gdbserver +.PATH: ${GDBDIR}/gdb + +PROG= gdbserver + +SRCS= inferiors.c mem-break.c regcache.c remote-utils.c \ + server.c signals.c target.c utils.c +SRCS+= fbsd-low.c + +SRCS+= fbsd-${MACHINE_CPUARCH}-low.c reg-${MACHINE_CPUARCH}.c +.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" +SRCS+= i387-fp.c +.endif +#CFLAGS+= -I${.CURDIR}/../arch/${MACHINE_ARCH} +CFLAGS+= -I${GDBDIR}/gdb/gdbserver +CFLAGS+= -I${GDBDIR}/gdb/regformats +CFLAGS+= -DNO_MMALLOC -DGDBSERVER + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/gdb/gdbserver/Makefile.depend b/gnu/usr.bin/gdb/gdbserver/Makefile.depend new file mode 100644 index 000000000000..d5ed563ecfc8 --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/Makefile.depend @@ -0,0 +1,18 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/arpa \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-amd64-low.c b/gnu/usr.bin/gdb/gdbserver/fbsd-amd64-low.c new file mode 100644 index 000000000000..82a8c93f3dfb --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/fbsd-amd64-low.c @@ -0,0 +1,213 @@ +/* GNU/FreeBSD/amd64 specific low level interface, for the remote server for GDB. + Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "server.h" +#include "fbsd-low.h" +#include "i387-fp.h" + +#include <sys/stddef.h> +#include <sys/types.h> +#include <sys/ptrace.h> +#include <machine/reg.h> + +/* Mapping between the general-purpose registers in `struct user' + format and GDB's register array layout. */ +static int amd64_regmap[] = { + offsetof(struct reg, r_rax), + offsetof(struct reg, r_rbx), + offsetof(struct reg, r_rcx), + offsetof(struct reg, r_rdx), + offsetof(struct reg, r_rsi), + offsetof(struct reg, r_rdi), + offsetof(struct reg, r_rbp), + offsetof(struct reg, r_rsp), + offsetof(struct reg, r_r8), + offsetof(struct reg, r_r9), + offsetof(struct reg, r_r10), + offsetof(struct reg, r_r11), + offsetof(struct reg, r_r12), + offsetof(struct reg, r_r13), + offsetof(struct reg, r_r14), + offsetof(struct reg, r_r15), + offsetof(struct reg, r_rip), + offsetof(struct reg, r_rflags), /* XXX 64-bit */ + offsetof(struct reg, r_cs), + offsetof(struct reg, r_ss), + offsetof(struct reg, r_ds), + offsetof(struct reg, r_es), + offsetof(struct reg, r_fs), + offsetof(struct reg, r_gs), +}; +#define AMD64_NUM_REGS (sizeof(amd64_regmap) / sizeof(amd64_regmap[0])) + +static const char amd64_breakpoint[] = { 0xCC }; +#define AMD64_BP_LEN 1 + +extern int debug_threads; + +static int +amd64_cannot_store_register(int regno) +{ + + return (regno >= AMD64_NUM_REGS); +} + +static int +amd64_cannot_fetch_register(int regno) +{ + + return (regno >= AMD64_NUM_REGS); +} + +static void +amd64_fill_gregset(void *buf) +{ + int i; + + for (i = 0; i < AMD64_NUM_REGS; i++) + collect_register(i, ((char *)buf) + amd64_regmap[i]); +} + +static void +amd64_store_gregset(const void *buf) +{ + int i; + + for (i = 0; i < AMD64_NUM_REGS; i++) + supply_register(i, ((char *)buf) + amd64_regmap[i]); +} + +static void +amd64_fill_fpregset(void *buf) +{ + + i387_cache_to_fsave(buf); +} + +static void +amd64_store_fpregset(const void *buf) +{ + + i387_fsave_to_cache(buf); +} + +static void +amd64_fill_fpxregset(void *buf) +{ + + i387_cache_to_fxsave(buf); +} + +static void +amd64_store_fpxregset(const void *buf) +{ + + i387_fxsave_to_cache(buf); +} + + +struct regset_info target_regsets[] = { + { + PT_GETREGS, + PT_SETREGS, + sizeof(struct reg), + GENERAL_REGS, + amd64_fill_gregset, + amd64_store_gregset, + }, +#ifdef HAVE_PTRACE_GETFPXREGS + { + PTRACE_GETFPXREGS, + PTRACE_SETFPXREGS, + sizeof(elf_fpxregset_t), + EXTENDED_REGS, + amd64_fill_fpxregset, + amd64_store_fpxregset, + }, +#endif + { + PT_GETFPREGS, + PT_SETFPREGS, + sizeof(struct fpreg), + FP_REGS, + amd64_fill_fpregset, + amd64_store_fpregset, + }, + { + 0, + 0, + -1, + -1, + NULL, + NULL, + } +}; + +static CORE_ADDR +amd64_get_pc(void) +{ + unsigned long pc; + + collect_register_by_name("rip", &pc); + + if (debug_threads) + fprintf(stderr, "stop pc (before any decrement) is %016lx\n", pc); + + return (pc); +} + +static void +amd64_set_pc(CORE_ADDR newpc) +{ + + if (debug_threads) + fprintf(stderr, "set pc to %016lx\n", (long)newpc); + supply_register_by_name("rip", &newpc); +} + +static int +amd64_breakpoint_at(CORE_ADDR pc) +{ + unsigned char c; + + read_inferior_memory(pc, &c, 1); + if (c == 0xCC) + return (1); + + return (0); +} + +struct fbsd_target_ops the_low_target = { + AMD64_NUM_REGS, + amd64_regmap, + amd64_cannot_fetch_register, + amd64_cannot_store_register, + amd64_get_pc, + amd64_set_pc, + amd64_breakpoint, + AMD64_BP_LEN, + NULL, + 1, + amd64_breakpoint_at, +}; diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-arm-low.c b/gnu/usr.bin/gdb/gdbserver/fbsd-arm-low.c new file mode 100644 index 000000000000..faea705f94ff --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/fbsd-arm-low.c @@ -0,0 +1,146 @@ +/* FreeBSD/ARM specific low level interface, for the remote server for GDB. + Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "server.h" +#include "fbsd-low.h" + +#ifdef HAVE_SYS_REG_H +#include <sys/reg.h> +#endif + +#include <sys/procfs.h> +#include <sys/ptrace.h> + +#define arm_num_regs 26 + +static int arm_regmap[] = { + 0, 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 48, 52, 56, 60, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + 64 +}; + +static int +arm_cannot_store_register (int regno) +{ + return (regno >= arm_num_regs); +} + +static int +arm_cannot_fetch_register (int regno) +{ + return (regno >= arm_num_regs); +} + +extern int debug_threads; + +static CORE_ADDR +arm_get_pc () +{ + unsigned long pc; + collect_register_by_name ("pc", &pc); + if (debug_threads) + fprintf (stderr, "stop pc is %08lx\n", pc); + return pc; +} + +static void +arm_set_pc (CORE_ADDR pc) +{ + unsigned long newpc = pc; + supply_register_by_name ("pc", &newpc); +} + +/* Correct in either endianness. We do not support Thumb yet. */ +static const unsigned long arm_breakpoint = 0xef9f0001; +#define arm_breakpoint_len 4 + +static int +arm_breakpoint_at (CORE_ADDR where) +{ + unsigned long insn; + + (*the_target->read_memory) (where, (char *) &insn, 4); + if (insn == arm_breakpoint) + return 1; + + /* If necessary, recognize more trap instructions here. GDB only uses the + one. */ + return 0; +} + +/* We only place breakpoints in empty marker functions, and thread locking + is outside of the function. So rather than importing software single-step, + we can just run until exit. */ +static CORE_ADDR +arm_reinsert_addr () +{ + unsigned long pc; + collect_register_by_name ("lr", &pc); + return pc; +} + +static void +arm_fill_gregset (void *buf) +{ + int i; + + for (i = 0; i < arm_num_regs; i++) + if (arm_regmap[i] != -1) + collect_register (i, ((char *) buf) + arm_regmap[i]); + +} + +static void +arm_store_gregset (const void *buf) +{ + int i; + + for (i = 0; i < arm_num_regs; i++) + if (arm_regmap[i] != -1) + supply_register (i, ((char *) buf) + arm_regmap[i]); + +} + + +struct regset_info target_regsets[] = { + {PT_GETREGS, PT_SETREGS, sizeof (struct reg), + GENERAL_REGS, + arm_fill_gregset, arm_store_gregset }, + { 0, 0, -1, -1, NULL, NULL } +}; + +struct fbsd_target_ops the_low_target = { + arm_num_regs, + arm_regmap, + arm_cannot_fetch_register, + arm_cannot_store_register, + arm_get_pc, + arm_set_pc, + (const char *) &arm_breakpoint, + arm_breakpoint_len, + arm_reinsert_addr, + 0, + arm_breakpoint_at, +}; diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-i386-low.c b/gnu/usr.bin/gdb/gdbserver/fbsd-i386-low.c new file mode 100644 index 000000000000..cd296f9b6655 --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/fbsd-i386-low.c @@ -0,0 +1,176 @@ +/* GNU/Linux/i386 specific low level interface, for the remote server for GDB. + Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "server.h" +#include "fbsd-low.h" +#include "i387-fp.h" + +#ifdef HAVE_SYS_REG_H +#include <sys/reg.h> +#else +#include <machine/reg.h> +#endif + +/* This module only supports access to the general purpose registers. */ + +#define i386_num_regs 16 + +/* This stuff comes from i386-fbsd-nat.c. */ + +/* Mapping between the general-purpose registers in `struct user' + format and GDB's register array layout. */ +static int i386_regmap[] = +{ + tEAX * 4, tECX * 4, tEDX * 4, tEBX * 4, + tESP * 4, tEBP * 4, tESI * 4, tEDI * 4, + tEIP * 4, tEFLAGS * 4, tCS * 4, tSS * 4, + tDS * 4, tES * 4, tFS * 4, tGS * 4 +}; + +static int +i386_cannot_store_register (int regno) +{ + return (regno >= i386_num_regs); +} + +static int +i386_cannot_fetch_register (int regno) +{ + return (regno >= i386_num_regs); +} + + +#include <sys/procfs.h> +#include <sys/ptrace.h> + +static void +i386_fill_gregset (void *buf) +{ + int i; + + for (i = 0; i < i386_num_regs; i++) + collect_register (i, ((char *) buf) + i386_regmap[i]); + +} + +static void +i386_store_gregset (const void *buf) +{ + int i; + + for (i = 0; i < i386_num_regs; i++) + supply_register (i, ((char *) buf) + i386_regmap[i]); + +} + +static void +i386_fill_fpregset (void *buf) +{ + i387_cache_to_fsave (buf); +} + +static void +i386_store_fpregset (const void *buf) +{ + i387_fsave_to_cache (buf); +} + +static void +i386_fill_fpxregset (void *buf) +{ + i387_cache_to_fxsave (buf); +} + +static void +i386_store_fpxregset (const void *buf) +{ + i387_fxsave_to_cache (buf); +} + + +struct regset_info target_regsets[] = { + { PT_GETREGS, PT_SETREGS, sizeof (struct reg), + GENERAL_REGS, + i386_fill_gregset, i386_store_gregset }, +#ifdef HAVE_PTRACE_GETFPXREGS + { PTRACE_GETFPXREGS, PTRACE_SETFPXREGS, sizeof (elf_fpxregset_t), + EXTENDED_REGS, + i386_fill_fpxregset, i386_store_fpxregset }, +#endif + { PT_GETFPREGS, PT_SETFPREGS, sizeof (struct fpreg), + FP_REGS, + i386_fill_fpregset, i386_store_fpregset }, + { 0, 0, -1, -1, NULL, NULL } +}; + +static const char i386_breakpoint[] = { 0xCC }; +#define i386_breakpoint_len 1 + +extern int debug_threads; + +static CORE_ADDR +i386_get_pc () +{ + unsigned long pc; + + collect_register_by_name ("eip", &pc); + + if (debug_threads) + fprintf (stderr, "stop pc (before any decrement) is %08lx\n", pc); + return pc; +} + +static void +i386_set_pc (CORE_ADDR newpc) +{ + if (debug_threads) + fprintf (stderr, "set pc to %08lx\n", (long) newpc); + supply_register_by_name ("eip", &newpc); +} + +static int +i386_breakpoint_at (CORE_ADDR pc) +{ + unsigned char c; + + read_inferior_memory (pc, &c, 1); + if (c == 0xCC) + return 1; + + return 0; +} + +struct fbsd_target_ops the_low_target = { + i386_num_regs, + i386_regmap, + i386_cannot_fetch_register, + i386_cannot_store_register, + i386_get_pc, + i386_set_pc, + i386_breakpoint, + i386_breakpoint_len, + NULL, + 1, + i386_breakpoint_at, +}; diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-low.c b/gnu/usr.bin/gdb/gdbserver/fbsd-low.c new file mode 100644 index 000000000000..ab6ff2f30731 --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/fbsd-low.c @@ -0,0 +1,1265 @@ +/* Low level interface to ptrace, for the remote server for GDB. + Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "server.h" +#include "fbsd-low.h" + +#include <sys/wait.h> +#include <sys/param.h> +#include <sys/ptrace.h> +#include <sys/user.h> +#include <sys/ioctl.h> +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +/* ``all_threads'' is keyed by the LWP ID - it should be the thread ID instead, + however. This requires changing the ID in place when we go from !using_threads + to using_threads, immediately. + + ``all_processes'' is keyed by the process ID - which on Linux is (presently) + the same as the LWP ID. */ + +struct inferior_list all_processes; + +/* FIXME this is a bit of a hack, and could be removed. */ +int stopping_threads; + +/* FIXME make into a target method? */ +int using_threads; + +static void fbsd_resume_one_process (struct inferior_list_entry *entry, + int step, int signal); +static void fbsd_resume (struct thread_resume *resume_info); +static void stop_all_processes (void); +static int fbsd_wait_for_event (struct thread_info *child); + +struct pending_signals +{ + int signal; + struct pending_signals *prev; +}; + +#define PTRACE_ARG3_TYPE caddr_t +#define PTRACE_XFER_TYPE int + +int debug_threads = 0; + +#define pid_of(proc) ((proc)->head.id) + +/* FIXME: Delete eventually. */ +#define inferior_pid (pid_of (get_thread_process (current_inferior))) + +/* This function should only be called if the process got a SIGTRAP. + The SIGTRAP could mean several things. + + On i386, where decr_pc_after_break is non-zero: + If we were single-stepping this process using PT_STEP, + we will get only the one SIGTRAP (even if the instruction we + stepped over was a breakpoint). The value of $eip will be the + next instruction. + If we continue the process using PTRACE_CONT, we will get a + SIGTRAP when we hit a breakpoint. The value of $eip will be + the instruction after the breakpoint (i.e. needs to be + decremented). If we report the SIGTRAP to GDB, we must also + report the undecremented PC. If we cancel the SIGTRAP, we + must resume at the decremented PC. + + (Presumably, not yet tested) On a non-decr_pc_after_break machine + with hardware or kernel single-step: + If we single-step over a breakpoint instruction, our PC will + point at the following instruction. If we continue and hit a + breakpoint instruction, our PC will point at the breakpoint + instruction. */ + +static CORE_ADDR +get_stop_pc (void) +{ + CORE_ADDR stop_pc = (*the_low_target.get_pc) (); + + if (get_thread_process (current_inferior)->stepping) + return stop_pc; + else + return stop_pc - the_low_target.decr_pc_after_break; +} + +static void * +add_process (int pid) +{ + struct process_info *process; + + process = (struct process_info *) malloc (sizeof (*process)); + memset (process, 0, sizeof (*process)); + + process->head.id = pid; + + /* Default to tid == lwpid == pid. */ + process->tid = pid; + process->lwpid = pid; + + add_inferior_to_list (&all_processes, &process->head); + + return process; +} + +/* Start an inferior process and returns its pid. + ALLARGS is a vector of program-name and args. */ + +static int +fbsd_create_inferior (char *program, char **allargs) +{ + void *new_process; + int pid; + + pid = vfork (); + if (pid < 0) + perror_with_name ("vfork"); + + if (pid == 0) + { + ptrace (PT_TRACE_ME, 0, 0, 0); + + setpgid (0, 0); + + execv (program, allargs); + + fprintf (stderr, "Cannot exec %s: %s.\n", program, + strerror (errno)); + fflush (stderr); + _exit (0177); + } + + new_process = add_process (pid); + add_thread (pid, new_process); + + return pid; +} + +/* Attach to an inferior process. */ + +void +fbsd_attach_lwp (int pid, int tid) +{ + struct process_info *new_process; + + if (ptrace (PT_ATTACH, pid, 0, 0) != 0) + { + fprintf (stderr, "Cannot attach to process %d: %s (%d)\n", pid, + strerror (errno), errno); + fflush (stderr); + + /* If we fail to attach to an LWP, just return. */ + if (!using_threads) + _exit (0177); + return; + } + + new_process = (struct process_info *) add_process (pid); + add_thread (tid, new_process); + + /* The next time we wait for this LWP we'll see a SIGSTOP as PTRACE_ATTACH + brings it to a halt. We should ignore that SIGSTOP and resume the process + (unless this is the first process, in which case the flag will be cleared + in fbsd_attach). + + On the other hand, if we are currently trying to stop all threads, we + should treat the new thread as if we had sent it a SIGSTOP. This works + because we are guaranteed that add_process added us to the end of the + list, and so the new thread has not yet reached wait_for_sigstop (but + will). */ + if (! stopping_threads) + new_process->stop_expected = 1; +} + +int +fbsd_attach (int pid) +{ + struct process_info *process; + + fbsd_attach_lwp (pid, pid); + + /* Don't ignore the initial SIGSTOP if we just attached to this process. */ + process = (struct process_info *) find_inferior_id (&all_processes, pid); + process->stop_expected = 0; + + return 0; +} + +/* Kill the inferior process. Make us have no inferior. */ + +static void +fbsd_kill_one_process (struct inferior_list_entry *entry) +{ + struct thread_info *thread = (struct thread_info *) entry; + struct process_info *process = get_thread_process (thread); + int wstat; + + do + { + ptrace (PT_KILL, pid_of (process), 0, 0); + + /* Make sure it died. The loop is most likely unnecessary. */ + wstat = fbsd_wait_for_event (thread); + } while (WIFSTOPPED (wstat)); +} + +static void +fbsd_kill (void) +{ + for_each_inferior (&all_threads, fbsd_kill_one_process); +} + +static void +fbsd_detach_one_process (struct inferior_list_entry *entry) +{ + struct thread_info *thread = (struct thread_info *) entry; + struct process_info *process = get_thread_process (thread); + + ptrace (PT_DETACH, pid_of (process), 0, 0); +} + +static void +fbsd_detach (void) +{ + for_each_inferior (&all_threads, fbsd_detach_one_process); +} + +/* Return nonzero if the given thread is still alive. */ +static int +fbsd_thread_alive (int tid) +{ + if (find_inferior_id (&all_threads, tid) != NULL) + return 1; + else + return 0; +} + +/* Return nonzero if this process stopped at a breakpoint which + no longer appears to be inserted. Also adjust the PC + appropriately to resume where the breakpoint used to be. */ +static int +check_removed_breakpoint (struct process_info *event_child) +{ + CORE_ADDR stop_pc; + struct thread_info *saved_inferior; + + if (event_child->pending_is_breakpoint == 0) + return 0; + + if (debug_threads) + fprintf (stderr, "Checking for breakpoint.\n"); + + saved_inferior = current_inferior; + current_inferior = get_process_thread (event_child); + + stop_pc = get_stop_pc (); + + /* If the PC has changed since we stopped, then we shouldn't do + anything. This happens if, for instance, GDB handled the + decr_pc_after_break subtraction itself. */ + if (stop_pc != event_child->pending_stop_pc) + { + if (debug_threads) + fprintf (stderr, "Ignoring, PC was changed.\n"); + + event_child->pending_is_breakpoint = 0; + current_inferior = saved_inferior; + return 0; + } + + /* If the breakpoint is still there, we will report hitting it. */ + if ((*the_low_target.breakpoint_at) (stop_pc)) + { + if (debug_threads) + fprintf (stderr, "Ignoring, breakpoint is still present.\n"); + current_inferior = saved_inferior; + return 0; + } + + if (debug_threads) + fprintf (stderr, "Removed breakpoint.\n"); + + /* For decr_pc_after_break targets, here is where we perform the + decrement. We go immediately from this function to resuming, + and can not safely call get_stop_pc () again. */ + if (the_low_target.set_pc != NULL) + (*the_low_target.set_pc) (stop_pc); + + /* We consumed the pending SIGTRAP. */ + event_child->pending_is_breakpoint = 0; + event_child->status_pending_p = 0; + event_child->status_pending = 0; + + current_inferior = saved_inferior; + return 1; +} + +/* Return 1 if this process has an interesting status pending. This function + may silently resume an inferior process. */ +static int +status_pending_p (struct inferior_list_entry *entry, void *dummy) +{ + struct process_info *process = (struct process_info *) entry; + + if (process->status_pending_p) + if (check_removed_breakpoint (process)) + { + /* This thread was stopped at a breakpoint, and the breakpoint + is now gone. We were told to continue (or step...) all threads, + so GDB isn't trying to single-step past this breakpoint. + So instead of reporting the old SIGTRAP, pretend we got to + the breakpoint just after it was removed instead of just + before; resume the process. */ + fbsd_resume_one_process (&process->head, 0, 0); + return 0; + } + + return process->status_pending_p; +} + +static void +fbsd_wait_for_process (struct process_info **childp, int *wstatp) +{ + int ret; + int to_wait_for = -1; + + if (*childp != NULL) + to_wait_for = (*childp)->lwpid; + + while (1) + { + ret = waitpid (to_wait_for, wstatp, WNOHANG); + + if (ret == -1) + { + if (errno != ECHILD) + perror_with_name ("waitpid"); + } + else if (ret > 0) + break; + + usleep (1000); + } + + if (debug_threads + && (!WIFSTOPPED (*wstatp) + || (WSTOPSIG (*wstatp) != 32 + && WSTOPSIG (*wstatp) != 33))) + fprintf (stderr, "Got an event from %d (%x)\n", ret, *wstatp); + + if (to_wait_for == -1) + *childp = (struct process_info *) find_inferior_id (&all_processes, ret); + + (*childp)->stopped = 1; + (*childp)->pending_is_breakpoint = 0; + + if (debug_threads + && WIFSTOPPED (*wstatp)) + { + current_inferior = (struct thread_info *) + find_inferior_id (&all_threads, (*childp)->tid); + /* For testing only; i386_stop_pc prints out a diagnostic. */ + if (the_low_target.get_pc != NULL) + get_stop_pc (); + } +} + +static int +fbsd_wait_for_event (struct thread_info *child) +{ + CORE_ADDR stop_pc; + struct process_info *event_child; + int wstat; + + /* Check for a process with a pending status. */ + /* It is possible that the user changed the pending task's registers since + it stopped. We correctly handle the change of PC if we hit a breakpoint + (in check_removed_breakpoint); signals should be reported anyway. */ + if (child == NULL) + { + event_child = (struct process_info *) + find_inferior (&all_processes, status_pending_p, NULL); + if (debug_threads && event_child) + fprintf (stderr, "Got a pending child %d\n", event_child->lwpid); + } + else + { + event_child = get_thread_process (child); + if (event_child->status_pending_p + && check_removed_breakpoint (event_child)) + event_child = NULL; + } + + if (event_child != NULL) + { + if (event_child->status_pending_p) + { + if (debug_threads) + fprintf (stderr, "Got an event from pending child %d (%04x)\n", + event_child->lwpid, event_child->status_pending); + wstat = event_child->status_pending; + event_child->status_pending_p = 0; + event_child->status_pending = 0; + current_inferior = get_process_thread (event_child); + return wstat; + } + } + + /* We only enter this loop if no process has a pending wait status. Thus + any action taken in response to a wait status inside this loop is + responding as soon as we detect the status, not after any pending + events. */ + while (1) + { + if (child == NULL) + event_child = NULL; + else + event_child = get_thread_process (child); + + fbsd_wait_for_process (&event_child, &wstat); + + if (event_child == NULL) + error ("event from unknown child"); + + current_inferior = (struct thread_info *) + find_inferior_id (&all_threads, event_child->tid); + + if (using_threads) + { + /* Check for thread exit. */ + if (! WIFSTOPPED (wstat)) + { + if (debug_threads) + fprintf (stderr, "Thread %d (LWP %d) exiting\n", + event_child->tid, event_child->head.id); + + /* If the last thread is exiting, just return. */ + if (all_threads.head == all_threads.tail) + return wstat; + + dead_thread_notify (event_child->tid); + + remove_inferior (&all_processes, &event_child->head); + free (event_child); + remove_thread (current_inferior); + current_inferior = (struct thread_info *) all_threads.head; + + /* If we were waiting for this particular child to do something... + well, it did something. */ + if (child != NULL) + return wstat; + + /* Wait for a more interesting event. */ + continue; + } + + if (WIFSTOPPED (wstat) + && WSTOPSIG (wstat) == SIGSTOP + && event_child->stop_expected) + { + if (debug_threads) + fprintf (stderr, "Expected stop.\n"); + event_child->stop_expected = 0; + fbsd_resume_one_process (&event_child->head, + event_child->stepping, 0); + continue; + } + + /* FIXME drow/2002-06-09: Get signal numbers from the inferior's + thread library? */ + if (WIFSTOPPED (wstat)) + { + if (debug_threads) + fprintf (stderr, "Ignored signal %d for %d (LWP %d).\n", + WSTOPSIG (wstat), event_child->tid, + event_child->head.id); + fbsd_resume_one_process (&event_child->head, + event_child->stepping, + WSTOPSIG (wstat)); + continue; + } + } + + /* If this event was not handled above, and is not a SIGTRAP, report + it. */ + if (!WIFSTOPPED (wstat) || WSTOPSIG (wstat) != SIGTRAP) + return wstat; + + /* If this target does not support breakpoints, we simply report the + SIGTRAP; it's of no concern to us. */ + if (the_low_target.get_pc == NULL) + return wstat; + + stop_pc = get_stop_pc (); + + /* bp_reinsert will only be set if we were single-stepping. + Notice that we will resume the process after hitting + a gdbserver breakpoint; single-stepping to/over one + is not supported (yet). */ + if (event_child->bp_reinsert != 0) + { + if (debug_threads) + fprintf (stderr, "Reinserted breakpoint.\n"); + reinsert_breakpoint (event_child->bp_reinsert); + event_child->bp_reinsert = 0; + + /* Clear the single-stepping flag and SIGTRAP as we resume. */ + fbsd_resume_one_process (&event_child->head, 0, 0); + continue; + } + + if (debug_threads) + fprintf (stderr, "Hit a (non-reinsert) breakpoint.\n"); + + if (check_breakpoints (stop_pc) != 0) + { + /* We hit one of our own breakpoints. We mark it as a pending + breakpoint, so that check_removed_breakpoint () will do the PC + adjustment for us at the appropriate time. */ + event_child->pending_is_breakpoint = 1; + event_child->pending_stop_pc = stop_pc; + + /* Now we need to put the breakpoint back. We continue in the event + loop instead of simply replacing the breakpoint right away, + in order to not lose signals sent to the thread that hit the + breakpoint. Unfortunately this increases the window where another + thread could sneak past the removed breakpoint. For the current + use of server-side breakpoints (thread creation) this is + acceptable; but it needs to be considered before this breakpoint + mechanism can be used in more general ways. For some breakpoints + it may be necessary to stop all other threads, but that should + be avoided where possible. + + If breakpoint_reinsert_addr is NULL, that means that we can + use PT_STEP on this platform. Uninsert the breakpoint, + mark it for reinsertion, and single-step. + + Otherwise, call the target function to figure out where we need + our temporary breakpoint, create it, and continue executing this + process. */ + if (the_low_target.breakpoint_reinsert_addr == NULL) + { + event_child->bp_reinsert = stop_pc; + uninsert_breakpoint (stop_pc); + fbsd_resume_one_process (&event_child->head, 1, 0); + } + else + { + reinsert_breakpoint_by_bp + (stop_pc, (*the_low_target.breakpoint_reinsert_addr) ()); + fbsd_resume_one_process (&event_child->head, 0, 0); + } + + continue; + } + + /* If we were single-stepping, we definitely want to report the + SIGTRAP. The single-step operation has completed, so also + clear the stepping flag; in general this does not matter, + because the SIGTRAP will be reported to the client, which + will give us a new action for this thread, but clear it for + consistency anyway. It's safe to clear the stepping flag + because the only consumer of get_stop_pc () after this point + is check_removed_breakpoint, and pending_is_breakpoint is not + set. It might be wiser to use a step_completed flag instead. */ + if (event_child->stepping) + { + event_child->stepping = 0; + return wstat; + } + + /* A SIGTRAP that we can't explain. It may have been a breakpoint. + Check if it is a breakpoint, and if so mark the process information + accordingly. This will handle both the necessary fiddling with the + PC on decr_pc_after_break targets and suppressing extra threads + hitting a breakpoint if two hit it at once and then GDB removes it + after the first is reported. Arguably it would be better to report + multiple threads hitting breakpoints simultaneously, but the current + remote protocol does not allow this. */ + if ((*the_low_target.breakpoint_at) (stop_pc)) + { + event_child->pending_is_breakpoint = 1; + event_child->pending_stop_pc = stop_pc; + } + + return wstat; + } + + /* NOTREACHED */ + return 0; +} + +/* Wait for process, returns status. */ + +static unsigned char +fbsd_wait (char *status) +{ + int w; + struct thread_info *child = NULL; + +retry: + /* If we were only supposed to resume one thread, only wait for + that thread - if it's still alive. If it died, however - which + can happen if we're coming from the thread death case below - + then we need to make sure we restart the other threads. We could + pick a thread at random or restart all; restarting all is less + arbitrary. */ + if (cont_thread > 0) + { + child = (struct thread_info *) find_inferior_id (&all_threads, + cont_thread); + + /* No stepping, no signal - unless one is pending already, of course. */ + if (child == NULL) + { + struct thread_resume resume_info; + resume_info.thread = -1; + resume_info.step = resume_info.sig = resume_info.leave_stopped = 0; + fbsd_resume (&resume_info); + } + } + + enable_async_io (); + unblock_async_io (); + w = fbsd_wait_for_event (child); + stop_all_processes (); + disable_async_io (); + + /* If we are waiting for a particular child, and it exited, + fbsd_wait_for_event will return its exit status. Similarly if + the last child exited. If this is not the last child, however, + do not report it as exited until there is a 'thread exited' response + available in the remote protocol. Instead, just wait for another event. + This should be safe, because if the thread crashed we will already + have reported the termination signal to GDB; that should stop any + in-progress stepping operations, etc. + + Report the exit status of the last thread to exit. This matches + LinuxThreads' behavior. */ + + if (all_threads.head == all_threads.tail) + { + if (WIFEXITED (w)) + { + fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w)); + *status = 'W'; + clear_inferiors (); + free (all_processes.head); + all_processes.head = all_processes.tail = NULL; + return ((unsigned char) WEXITSTATUS (w)); + } + else if (!WIFSTOPPED (w)) + { + fprintf (stderr, "\nChild terminated with signal = %x \n", WTERMSIG (w)); + *status = 'X'; + clear_inferiors (); + free (all_processes.head); + all_processes.head = all_processes.tail = NULL; + return ((unsigned char) WTERMSIG (w)); + } + } + else + { + if (!WIFSTOPPED (w)) + goto retry; + } + + *status = 'T'; + return ((unsigned char) WSTOPSIG (w)); +} + +static void +send_sigstop (struct inferior_list_entry *entry) +{ + struct process_info *process = (struct process_info *) entry; + + if (process->stopped) + return; + + /* If we already have a pending stop signal for this process, don't + send another. */ + if (process->stop_expected) + { + process->stop_expected = 0; + return; + } + + if (debug_threads) + fprintf (stderr, "Sending sigstop to process %d\n", process->head.id); + + kill (process->head.id, SIGSTOP); + process->sigstop_sent = 1; +} + +static void +wait_for_sigstop (struct inferior_list_entry *entry) +{ + struct process_info *process = (struct process_info *) entry; + struct thread_info *saved_inferior, *thread; + int wstat, saved_tid; + + if (process->stopped) + return; + + saved_inferior = current_inferior; + saved_tid = ((struct inferior_list_entry *) saved_inferior)->id; + thread = (struct thread_info *) find_inferior_id (&all_threads, + process->tid); + wstat = fbsd_wait_for_event (thread); + + /* If we stopped with a non-SIGSTOP signal, save it for later + and record the pending SIGSTOP. If the process exited, just + return. */ + if (WIFSTOPPED (wstat) + && WSTOPSIG (wstat) != SIGSTOP) + { + if (debug_threads) + fprintf (stderr, "Stopped with non-sigstop signal\n"); + process->status_pending_p = 1; + process->status_pending = wstat; + process->stop_expected = 1; + } + + if (fbsd_thread_alive (saved_tid)) + current_inferior = saved_inferior; + else + { + if (debug_threads) + fprintf (stderr, "Previously current thread died.\n"); + + /* Set a valid thread as current. */ + set_desired_inferior (0); + } +} + +static void +stop_all_processes (void) +{ + stopping_threads = 1; + for_each_inferior (&all_processes, send_sigstop); + for_each_inferior (&all_processes, wait_for_sigstop); + stopping_threads = 0; +} + +/* Resume execution of the inferior process. + If STEP is nonzero, single-step it. + If SIGNAL is nonzero, give it that signal. */ + +static void +fbsd_resume_one_process (struct inferior_list_entry *entry, + int step, int signal) +{ + struct process_info *process = (struct process_info *) entry; + struct thread_info *saved_inferior; + + if (process->stopped == 0) + return; + + /* If we have pending signals or status, and a new signal, enqueue the + signal. Also enqueue the signal if we are waiting to reinsert a + breakpoint; it will be picked up again below. */ + if (signal != 0 + && (process->status_pending_p || process->pending_signals != NULL + || process->bp_reinsert != 0)) + { + struct pending_signals *p_sig; + p_sig = malloc (sizeof (*p_sig)); + p_sig->prev = process->pending_signals; + p_sig->signal = signal; + process->pending_signals = p_sig; + } + + if (process->status_pending_p && !check_removed_breakpoint (process)) + return; + + saved_inferior = current_inferior; + current_inferior = get_process_thread (process); + + if (debug_threads) + fprintf (stderr, "Resuming process %d (%s, signal %d, stop %s)\n", inferior_pid, + step ? "step" : "continue", signal, + process->stop_expected ? "expected" : "not expected"); + + /* This bit needs some thinking about. If we get a signal that + we must report while a single-step reinsert is still pending, + we often end up resuming the thread. It might be better to + (ew) allow a stack of pending events; then we could be sure that + the reinsert happened right away and not lose any signals. + + Making this stack would also shrink the window in which breakpoints are + uninserted (see comment in fbsd_wait_for_process) but not enough for + complete correctness, so it won't solve that problem. It may be + worthwhile just to solve this one, however. */ + if (process->bp_reinsert != 0) + { + if (debug_threads) + fprintf (stderr, " pending reinsert at %08lx", (long)process->bp_reinsert); + if (step == 0) + fprintf (stderr, "BAD - reinserting but not stepping.\n"); + step = 1; + + /* Postpone any pending signal. It was enqueued above. */ + signal = 0; + } + + check_removed_breakpoint (process); + + if (debug_threads && the_low_target.get_pc != NULL) + { + fprintf (stderr, " "); + (long) (*the_low_target.get_pc) (); + } + + /* If we have pending signals, consume one unless we are trying to reinsert + a breakpoint. */ + if (process->pending_signals != NULL && process->bp_reinsert == 0) + { + struct pending_signals **p_sig; + + p_sig = &process->pending_signals; + while ((*p_sig)->prev != NULL) + p_sig = &(*p_sig)->prev; + + signal = (*p_sig)->signal; + free (*p_sig); + *p_sig = NULL; + } + + regcache_invalidate_one ((struct inferior_list_entry *) + get_process_thread (process)); + errno = 0; + process->stopped = 0; + process->stepping = step; + ptrace (step ? PT_STEP : PT_CONTINUE, process->lwpid, (PTRACE_ARG3_TYPE) 1, signal); + + current_inferior = saved_inferior; + if (errno) + perror_with_name ("ptrace"); +} + +static struct thread_resume *resume_ptr; + +/* This function is called once per thread. We look up the thread + in RESUME_PTR, and mark the thread with a pointer to the appropriate + resume request. + + This algorithm is O(threads * resume elements), but resume elements + is small (and will remain small at least until GDB supports thread + suspension). */ +static void +fbsd_set_resume_request (struct inferior_list_entry *entry) +{ + struct process_info *process; + struct thread_info *thread; + int ndx; + + thread = (struct thread_info *) entry; + process = get_thread_process (thread); + + ndx = 0; + while (resume_ptr[ndx].thread != -1 && resume_ptr[ndx].thread != entry->id) + ndx++; + + process->resume = &resume_ptr[ndx]; +} + +/* This function is called once per thread. We check the thread's resume + request, which will tell us whether to resume, step, or leave the thread + stopped; and what signal, if any, it should be sent. For threads which + we aren't explicitly told otherwise, we preserve the stepping flag; this + is used for stepping over gdbserver-placed breakpoints. */ + +static void +fbsd_continue_one_thread (struct inferior_list_entry *entry) +{ + struct process_info *process; + struct thread_info *thread; + int step; + + thread = (struct thread_info *) entry; + process = get_thread_process (thread); + + if (process->resume->leave_stopped) + return; + + if (process->resume->thread == -1) + step = process->stepping || process->resume->step; + else + step = process->resume->step; + + fbsd_resume_one_process (&process->head, step, process->resume->sig); + + process->resume = NULL; +} + +/* This function is called once per thread. We check the thread's resume + request, which will tell us whether to resume, step, or leave the thread + stopped; and what signal, if any, it should be sent. We queue any needed + signals, since we won't actually resume. We already have a pending event + to report, so we don't need to preserve any step requests; they should + be re-issued if necessary. */ + +static void +fbsd_queue_one_thread (struct inferior_list_entry *entry) +{ + struct process_info *process; + struct thread_info *thread; + + thread = (struct thread_info *) entry; + process = get_thread_process (thread); + + if (process->resume->leave_stopped) + return; + + /* If we have a new signal, enqueue the signal. */ + if (process->resume->sig != 0) + { + struct pending_signals *p_sig; + p_sig = malloc (sizeof (*p_sig)); + p_sig->prev = process->pending_signals; + p_sig->signal = process->resume->sig; + process->pending_signals = p_sig; + } + + process->resume = NULL; +} + +/* Set DUMMY if this process has an interesting status pending. */ +static int +resume_status_pending_p (struct inferior_list_entry *entry, void *flag_p) +{ + struct process_info *process = (struct process_info *) entry; + + /* Processes which will not be resumed are not interesting, because + we might not wait for them next time through fbsd_wait. */ + if (process->resume->leave_stopped) + return 0; + + /* If this thread has a removed breakpoint, we won't have any + events to report later, so check now. check_removed_breakpoint + may clear status_pending_p. We avoid calling check_removed_breakpoint + for any thread that we are not otherwise going to resume - this + lets us preserve stopped status when two threads hit a breakpoint. + GDB removes the breakpoint to single-step a particular thread + past it, then re-inserts it and resumes all threads. We want + to report the second thread without resuming it in the interim. */ + if (process->status_pending_p) + check_removed_breakpoint (process); + + if (process->status_pending_p) + * (int *) flag_p = 1; + + return 0; +} + +static void +fbsd_resume (struct thread_resume *resume_info) +{ + int pending_flag; + + /* Yes, the use of a global here is rather ugly. */ + resume_ptr = resume_info; + + for_each_inferior (&all_threads, fbsd_set_resume_request); + + /* If there is a thread which would otherwise be resumed, which + has a pending status, then don't resume any threads - we can just + report the pending status. Make sure to queue any signals + that would otherwise be sent. */ + pending_flag = 0; + find_inferior (&all_processes, resume_status_pending_p, &pending_flag); + + if (debug_threads) + { + if (pending_flag) + fprintf (stderr, "Not resuming, pending status\n"); + else + fprintf (stderr, "Resuming, no pending status\n"); + } + + if (pending_flag) + for_each_inferior (&all_threads, fbsd_queue_one_thread); + else + { + block_async_io (); + enable_async_io (); + for_each_inferior (&all_threads, fbsd_continue_one_thread); + } +} + + +static int +regsets_fetch_inferior_registers () +{ + struct regset_info *regset; + + regset = target_regsets; + + while (regset->size >= 0) + { + void *buf; + int res; + + if (regset->size == 0) + { + regset ++; + continue; + } + + buf = malloc (regset->size); + res = ptrace (regset->get_request, inferior_pid, (PTRACE_ARG3_TYPE) buf, 0); + if (res < 0) + { + char s[256]; + sprintf (s, "ptrace(regsets_fetch_inferior_registers) PID=%d", + inferior_pid); + perror (s); + } + regset->store_function (buf); + regset ++; + } + return 0; +} + +static int +regsets_store_inferior_registers () +{ + struct regset_info *regset; + + regset = target_regsets; + + while (regset->size >= 0) + { + void *buf; + int res; + + if (regset->size == 0) + { + regset ++; + continue; + } + + buf = malloc (regset->size); + regset->fill_function (buf); + res = ptrace (regset->set_request, inferior_pid, (PTRACE_ARG3_TYPE) buf, 0); + if (res < 0) + { + perror ("Warning: ptrace(regsets_store_inferior_registers)"); + } + regset ++; + free (buf); + } + return 0; +} + +void +fbsd_fetch_registers (int regno) +{ + regsets_fetch_inferior_registers (); +} + +void +fbsd_store_registers (int regno) +{ + regsets_store_inferior_registers (); +} + + +/* Copy LEN bytes from inferior's memory starting at MEMADDR + to debugger memory starting at MYADDR. */ + +static int +fbsd_read_memory (CORE_ADDR memaddr, char *myaddr, int len) +{ + register int i; + /* Round starting address down to longword boundary. */ + register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE); + /* Round ending address up; get number of longwords that makes. */ + register int count + = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1) + / sizeof (PTRACE_XFER_TYPE); + /* Allocate buffer of that many longwords. */ + register PTRACE_XFER_TYPE *buffer + = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE)); + + /* Read all the longwords */ + for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE)) + { + errno = 0; + buffer[i] = ptrace (PT_READ_D, inferior_pid, (PTRACE_ARG3_TYPE) (intptr_t)addr, 0); + if (errno) + return errno; + } + + /* Copy appropriate bytes out of the buffer. */ + memcpy (myaddr, (char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), len); + + return 0; +} + +/* Copy LEN bytes of data from debugger memory at MYADDR + to inferior's memory at MEMADDR. + On failure (cannot write the inferior) + returns the value of errno. */ + +static int +fbsd_write_memory (CORE_ADDR memaddr, const char *myaddr, int len) +{ + register int i; + /* Round starting address down to longword boundary. */ + register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE); + /* Round ending address up; get number of longwords that makes. */ + register int count + = (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1) / sizeof (PTRACE_XFER_TYPE); + /* Allocate buffer of that many longwords. */ + register PTRACE_XFER_TYPE *buffer = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE)); + extern int errno; + + if (debug_threads) + { + fprintf (stderr, "Writing %02x to %08lx\n", (unsigned)myaddr[0], (long)memaddr); + } + + /* Fill start and end extra bytes of buffer with existing memory data. */ + + buffer[0] = ptrace (PT_READ_D, inferior_pid, + (PTRACE_ARG3_TYPE) (intptr_t)addr, 0); + + if (count > 1) + { + buffer[count - 1] + = ptrace (PT_READ_D, inferior_pid, + (PTRACE_ARG3_TYPE) (intptr_t) (addr + (count - 1) + * sizeof (PTRACE_XFER_TYPE)), + 0); + } + + /* Copy data to be written over corresponding part of buffer */ + + memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_XFER_TYPE) - 1)), myaddr, len); + + /* Write the entire buffer. */ + + for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE)) + { + errno = 0; + ptrace (PT_WRITE_D, inferior_pid, (PTRACE_ARG3_TYPE) (intptr_t)addr, buffer[i]); + if (errno) + return errno; + } + + return 0; +} + +static void +fbsd_look_up_symbols (void) +{ +#ifdef USE_THREAD_DB + if (using_threads) + return; + + using_threads = thread_db_init (); +#endif +} + +static void +fbsd_send_signal (int signum) +{ + extern int signal_pid; + + if (cont_thread > 0) + { + struct process_info *process; + + process = get_thread_process (current_inferior); + kill (process->lwpid, signum); + } + else + kill (signal_pid, signum); +} + +/* Copy LEN bytes from inferior's auxiliary vector starting at OFFSET + to debugger memory starting at MYADDR. */ + +static int +fbsd_read_auxv (CORE_ADDR offset, char *myaddr, unsigned int len) +{ + char filename[PATH_MAX]; + int fd, n; + + snprintf (filename, sizeof filename, "/proc/%d/auxv", inferior_pid); + + fd = open (filename, O_RDONLY); + if (fd < 0) + return -1; + + if (offset != (CORE_ADDR) 0 + && lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset) + n = -1; + else + n = read (fd, myaddr, len); + + close (fd); + + return n; +} + + +static struct target_ops fbsd_target_ops = { + fbsd_create_inferior, + fbsd_attach, + fbsd_kill, + fbsd_detach, + fbsd_thread_alive, + fbsd_resume, + fbsd_wait, + fbsd_fetch_registers, + fbsd_store_registers, + fbsd_read_memory, + fbsd_write_memory, + fbsd_look_up_symbols, + fbsd_send_signal, + fbsd_read_auxv, +}; + +static void +fbsd_init_signals () +{ +} + +void +initialize_low (void) +{ + using_threads = 0; + set_target_ops (&fbsd_target_ops); + set_breakpoint_data (the_low_target.breakpoint, + the_low_target.breakpoint_len); + init_registers (); + fbsd_init_signals (); +} diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-low.h b/gnu/usr.bin/gdb/gdbserver/fbsd-low.h new file mode 100644 index 000000000000..310368c9b2c1 --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/fbsd-low.h @@ -0,0 +1,122 @@ +/* Internal interfaces for the GNU/Linux specific target code for gdbserver. + Copyright 2002, 2004 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* + * $FreeBSD$ + */ + +typedef void (*regset_fill_func) (void *); +typedef void (*regset_store_func) (const void *); +enum regset_type { + GENERAL_REGS, + FP_REGS, + EXTENDED_REGS, +}; + +struct regset_info +{ + int get_request, set_request; + int size; + enum regset_type type; + regset_fill_func fill_function; + regset_store_func store_function; +}; +extern struct regset_info target_regsets[]; + +struct fbsd_target_ops +{ + int num_regs; + int *regmap; + int (*cannot_fetch_register) (int); + + /* Returns 0 if we can store the register, 1 if we can not + store the register, and 2 if failure to store the register + is acceptable. */ + int (*cannot_store_register) (int); + CORE_ADDR (*get_pc) (void); + void (*set_pc) (CORE_ADDR newpc); + const char *breakpoint; + int breakpoint_len; + CORE_ADDR (*breakpoint_reinsert_addr) (void); + + + int decr_pc_after_break; + int (*breakpoint_at) (CORE_ADDR pc); +}; + +extern struct fbsd_target_ops the_low_target; + +#define get_process(inf) ((struct process_info *)(inf)) +#define get_thread_process(thr) (get_process (inferior_target_data (thr))) +#define get_process_thread(proc) ((struct thread_info *) \ + find_inferior_id (&all_threads, \ + get_process (proc)->tid)) + +struct process_info +{ + struct inferior_list_entry head; + int thread_known; + int lwpid; + int tid; + + /* If this flag is set, the next SIGSTOP will be ignored (the process will + be immediately resumed). */ + int stop_expected; + + /* If this flag is set, the process is known to be stopped right now (stop + event already received in a wait()). */ + int stopped; + + /* If this flag is set, we have sent a SIGSTOP to this process and are + waiting for it to stop. */ + int sigstop_sent; + + /* If this flag is set, STATUS_PENDING is a waitstatus that has not yet + been reported. */ + int status_pending_p; + int status_pending; + + /* If this flag is set, the pending status is a (GDB-placed) breakpoint. */ + int pending_is_breakpoint; + CORE_ADDR pending_stop_pc; + + /* If this is non-zero, it is a breakpoint to be reinserted at our next + stop (SIGTRAP stops only). */ + CORE_ADDR bp_reinsert; + + /* If this flag is set, the last continue operation on this process + was a single-step. */ + int stepping; + + /* If this is non-zero, it points to a chain of signals which need to + be delivered to this process. */ + struct pending_signals *pending_signals; + + /* A link used when resuming. It is initialized from the resume request, + and then processed and cleared in fbsd_resume_one_process. */ + + struct thread_resume *resume; +}; + +extern struct inferior_list all_processes; + +void fbsd_attach_lwp (int pid, int tid); + +int thread_db_init (void); diff --git a/gnu/usr.bin/gdb/gdbserver/fbsd-powerpc-low.c b/gnu/usr.bin/gdb/gdbserver/fbsd-powerpc-low.c new file mode 100644 index 000000000000..35f7ac650928 --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/fbsd-powerpc-low.c @@ -0,0 +1,156 @@ +/* FreeBSD/PowerPC specific low level interface, for the remote server for + GDB. + Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "server.h" +#include "fbsd-low.h" + +#include <sys/procfs.h> +#include <sys/ptrace.h> + +#define ppc_num_regs 71 + +/* Currently, don't check/send MQ. */ +static int ppc_regmap[] = + { 0, 4, 8, 12, 16, 20, 24, 28, + 32, 36, 40, 44, 48, 52, 56, 60, + 64, 68, 72, 76, 80, 84, 88, 92, + 96, 100, 104, 108, 112, 116, 120, 124, +#if 0 + /* + * XXX on FreeBSD the gdbserver for PowerPC was only tested with FPU-less + * cores i.e. e500. Let's leave the original FPR references around in case + * someone picks up and brings support for AIM-like FPU machines. + */ + PT_FPR0*4, PT_FPR0*4 + 8, PT_FPR0*4+16, PT_FPR0*4+24, + PT_FPR0*4+32, PT_FPR0*4+40, PT_FPR0*4+48, PT_FPR0*4+56, + PT_FPR0*4+64, PT_FPR0*4+72, PT_FPR0*4+80, PT_FPR0*4+88, + PT_FPR0*4+96, PT_FPR0*4+104, PT_FPR0*4+112, PT_FPR0*4+120, + PT_FPR0*4+128, PT_FPR0*4+136, PT_FPR0*4+144, PT_FPR0*4+152, + PT_FPR0*4+160, PT_FPR0*4+168, PT_FPR0*4+176, PT_FPR0*4+184, + PT_FPR0*4+192, PT_FPR0*4+200, PT_FPR0*4+208, PT_FPR0*4+216, + PT_FPR0*4+224, PT_FPR0*4+232, PT_FPR0*4+240, PT_FPR0*4+248, +#endif + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + 144, -1, 132, 128, 140, 136, -1 + }; + +static int +ppc_cannot_store_register (int regno) +{ + /* Some kernels do not allow us to store fpscr. */ + if (regno == find_regno ("fpscr")) + return 2; + + return 0; +} + +static int +ppc_cannot_fetch_register (int regno) +{ + return 0; +} + +static CORE_ADDR +ppc_get_pc (void) +{ + unsigned long pc; + + collect_register_by_name ("pc", &pc); + return (CORE_ADDR) pc; +} + +static void +ppc_set_pc (CORE_ADDR pc) +{ + unsigned long newpc = pc; + + supply_register_by_name ("pc", &newpc); +} + +/* Correct in either endianness. Note that this file is + for PowerPC only, not PowerPC64. + This instruction is "twge r2, r2", which GDB uses as a software + breakpoint. */ +static const unsigned long ppc_breakpoint = 0x7d821008; +#define ppc_breakpoint_len 4 + +static int +ppc_breakpoint_at (CORE_ADDR where) +{ + unsigned long insn; + + (*the_target->read_memory) (where, (char *) &insn, 4); + if (insn == ppc_breakpoint) + return 1; + /* If necessary, recognize more trap instructions here. GDB only uses the + one. */ + return 0; +} + +static void +ppc_fill_gregset (void *buf) +{ + int i; + + for (i = 0; i < ppc_num_regs; i++) + if (ppc_regmap[i] != -1) + collect_register (i, ((char *) buf) + ppc_regmap[i]); + +} + +static void +ppc_store_gregset (const void *buf) +{ + int i; + + for (i = 0; i < ppc_num_regs; i++) + if (ppc_regmap[i] != -1) + supply_register (i, ((char *) buf) + ppc_regmap[i]); + +} + +struct regset_info target_regsets[] = { + { PT_GETREGS, PT_SETREGS, sizeof (struct reg), + GENERAL_REGS, + ppc_fill_gregset, ppc_store_gregset }, + { 0, 0, -1, -1, NULL, NULL } +}; + +struct fbsd_target_ops the_low_target = { + ppc_num_regs, + ppc_regmap, + ppc_cannot_fetch_register, + ppc_cannot_store_register, + ppc_get_pc, + ppc_set_pc, + (const char *) &ppc_breakpoint, + ppc_breakpoint_len, + NULL, + 0, + ppc_breakpoint_at, +}; diff --git a/gnu/usr.bin/gdb/gdbserver/reg-amd64.c b/gnu/usr.bin/gdb/gdbserver/reg-amd64.c new file mode 100644 index 000000000000..7b0534f0d569 --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/reg-amd64.c @@ -0,0 +1,99 @@ +/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ + +/* A register protocol for GDB, the GNU debugger. + Copyright 2001, 2002 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This file was created with the aid of ``regdat.sh'' and ``../../../../contrib/gdb/gdb/regformats/reg-x86-64.dat''. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "regdef.h" +#include "regcache.h" + +struct reg regs_x86_64[] = { + { "rax", 0, 64 }, + { "rbx", 64, 64 }, + { "rcx", 128, 64 }, + { "rdx", 192, 64 }, + { "rsi", 256, 64 }, + { "rdi", 320, 64 }, + { "rbp", 384, 64 }, + { "rsp", 448, 64 }, + { "r8", 512, 64 }, + { "r9", 576, 64 }, + { "r10", 640, 64 }, + { "r11", 704, 64 }, + { "r12", 768, 64 }, + { "r13", 832, 64 }, + { "r14", 896, 64 }, + { "r15", 960, 64 }, + { "rip", 1024, 64 }, + { "eflags", 1088, 32 }, + { "cs", 1120, 32 }, + { "ss", 1152, 32 }, + { "ds", 1184, 32 }, + { "es", 1216, 32 }, + { "fs", 1248, 32 }, + { "gs", 1280, 32 }, + { "st0", 1312, 80 }, + { "st1", 1392, 80 }, + { "st2", 1472, 80 }, + { "st3", 1552, 80 }, + { "st4", 1632, 80 }, + { "st5", 1712, 80 }, + { "st6", 1792, 80 }, + { "st7", 1872, 80 }, + { "fctrl", 1952, 32 }, + { "fstat", 1984, 32 }, + { "ftag", 2016, 32 }, + { "fiseg", 2048, 32 }, + { "fioff", 2080, 32 }, + { "foseg", 2112, 32 }, + { "fooff", 2144, 32 }, + { "fop", 2176, 32 }, + { "xmm0", 2208, 128 }, + { "xmm1", 2336, 128 }, + { "xmm2", 2464, 128 }, + { "xmm3", 2592, 128 }, + { "xmm4", 2720, 128 }, + { "xmm5", 2848, 128 }, + { "xmm6", 2976, 128 }, + { "xmm7", 3104, 128 }, + { "xmm8", 3232, 128 }, + { "xmm9", 3360, 128 }, + { "xmm10", 3488, 128 }, + { "xmm11", 3616, 128 }, + { "xmm12", 3744, 128 }, + { "xmm13", 3872, 128 }, + { "xmm14", 4000, 128 }, + { "xmm15", 4128, 128 }, + { "mxcsr", 4256, 32 }, +}; + +const char *expedite_regs_x86_64[] = { "rbp", "rsp", "rip", 0 }; + +void +init_registers () +{ + set_register_cache (regs_x86_64, + sizeof (regs_x86_64) / sizeof (regs_x86_64[0])); + gdbserver_expedite_regs = expedite_regs_x86_64; +} diff --git a/gnu/usr.bin/gdb/gdbserver/reg-arm.c b/gnu/usr.bin/gdb/gdbserver/reg-arm.c new file mode 100644 index 000000000000..50379bfed756 --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/reg-arm.c @@ -0,0 +1,68 @@ +/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ + +/* A register protocol for GDB, the GNU debugger. + Copyright 2001, 2002 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This file was created with the aid of ``regdat.sh'' and ``reg-arm.dat''. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "regdef.h" +#include "regcache.h" + +struct reg regs_arm[] = { + { "r0", 0, 32 }, + { "r1", 32, 32 }, + { "r2", 64, 32 }, + { "r3", 96, 32 }, + { "r4", 128, 32 }, + { "r5", 160, 32 }, + { "r6", 192, 32 }, + { "r7", 224, 32 }, + { "r8", 256, 32 }, + { "r9", 288, 32 }, + { "r10", 320, 32 }, + { "r11", 352, 32 }, + { "r12", 384, 32 }, + { "sp", 416, 32 }, + { "lr", 448, 32 }, + { "pc", 480, 32 }, + { "f0", 512, 96 }, + { "f1", 608, 96 }, + { "f2", 704, 96 }, + { "f3", 800, 96 }, + { "f4", 896, 96 }, + { "f5", 992, 96 }, + { "f6", 1088, 96 }, + { "f7", 1184, 96 }, + { "fps", 1280, 32 }, + { "cpsr", 1312, 32 }, +}; + +const char *expedite_regs_arm[] = { "r11", "sp", "pc", 0 }; + +void +init_registers () +{ + set_register_cache (regs_arm, + sizeof (regs_arm) / sizeof (regs_arm[0])); + gdbserver_expedite_regs = expedite_regs_arm; +} diff --git a/gnu/usr.bin/gdb/gdbserver/reg-i386.c b/gnu/usr.bin/gdb/gdbserver/reg-i386.c new file mode 100644 index 000000000000..3307ea933c45 --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/reg-i386.c @@ -0,0 +1,63 @@ +/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ + +/* This file was created with the aid of ``regdat.sh'' and ``../../../../contrib/gdb/gdb/regformats/reg-i386.dat''. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "regdef.h" +#include "regcache.h" + +struct reg regs_i386[] = { + { "eax", 0, 32 }, + { "ecx", 32, 32 }, + { "edx", 64, 32 }, + { "ebx", 96, 32 }, + { "esp", 128, 32 }, + { "ebp", 160, 32 }, + { "esi", 192, 32 }, + { "edi", 224, 32 }, + { "eip", 256, 32 }, + { "eflags", 288, 32 }, + { "cs", 320, 32 }, + { "ss", 352, 32 }, + { "ds", 384, 32 }, + { "es", 416, 32 }, + { "fs", 448, 32 }, + { "gs", 480, 32 }, + { "st0", 512, 80 }, + { "st1", 592, 80 }, + { "st2", 672, 80 }, + { "st3", 752, 80 }, + { "st4", 832, 80 }, + { "st5", 912, 80 }, + { "st6", 992, 80 }, + { "st7", 1072, 80 }, + { "fctrl", 1152, 32 }, + { "fstat", 1184, 32 }, + { "ftag", 1216, 32 }, + { "fiseg", 1248, 32 }, + { "fioff", 1280, 32 }, + { "foseg", 1312, 32 }, + { "fooff", 1344, 32 }, + { "fop", 1376, 32 }, + { "xmm0", 1408, 128 }, + { "xmm1", 1536, 128 }, + { "xmm2", 1664, 128 }, + { "xmm3", 1792, 128 }, + { "xmm4", 1920, 128 }, + { "xmm5", 2048, 128 }, + { "xmm6", 2176, 128 }, + { "xmm7", 2304, 128 }, + { "mxcsr", 2432, 32 }, +}; + +const char *expedite_regs_i386[] = { "ebp", "esp", "eip", 0 }; + +void +init_registers () +{ + set_register_cache (regs_i386, + sizeof (regs_i386) / sizeof (regs_i386[0])); + gdbserver_expedite_regs = expedite_regs_i386; +} diff --git a/gnu/usr.bin/gdb/gdbserver/reg-powerpc.c b/gnu/usr.bin/gdb/gdbserver/reg-powerpc.c new file mode 100644 index 000000000000..47046631d52e --- /dev/null +++ b/gnu/usr.bin/gdb/gdbserver/reg-powerpc.c @@ -0,0 +1,113 @@ +/* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ + +/* A register protocol for GDB, the GNU debugger. + Copyright 2001, 2002 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This file was created with the aid of ``regdat.sh'' and ``../../../../contrib/gdb/gdb/regformats/reg-ppc.dat''. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include "regdef.h" +#include "regcache.h" + +struct reg regs_ppc[] = { + { "r0", 0, 32 }, + { "r1", 32, 32 }, + { "r2", 64, 32 }, + { "r3", 96, 32 }, + { "r4", 128, 32 }, + { "r5", 160, 32 }, + { "r6", 192, 32 }, + { "r7", 224, 32 }, + { "r8", 256, 32 }, + { "r9", 288, 32 }, + { "r10", 320, 32 }, + { "r11", 352, 32 }, + { "r12", 384, 32 }, + { "r13", 416, 32 }, + { "r14", 448, 32 }, + { "r15", 480, 32 }, + { "r16", 512, 32 }, + { "r17", 544, 32 }, + { "r18", 576, 32 }, + { "r19", 608, 32 }, + { "r20", 640, 32 }, + { "r21", 672, 32 }, + { "r22", 704, 32 }, + { "r23", 736, 32 }, + { "r24", 768, 32 }, + { "r25", 800, 32 }, + { "r26", 832, 32 }, + { "r27", 864, 32 }, + { "r28", 896, 32 }, + { "r29", 928, 32 }, + { "r30", 960, 32 }, + { "r31", 992, 32 }, + { "f0", 1024, 64 }, + { "f1", 1088, 64 }, + { "f2", 1152, 64 }, + { "f3", 1216, 64 }, + { "f4", 1280, 64 }, + { "f5", 1344, 64 }, + { "f6", 1408, 64 }, + { "f7", 1472, 64 }, + { "f8", 1536, 64 }, + { "f9", 1600, 64 }, + { "f10", 1664, 64 }, + { "f11", 1728, 64 }, + { "f12", 1792, 64 }, + { "f13", 1856, 64 }, + { "f14", 1920, 64 }, + { "f15", 1984, 64 }, + { "f16", 2048, 64 }, + { "f17", 2112, 64 }, + { "f18", 2176, 64 }, + { "f19", 2240, 64 }, + { "f20", 2304, 64 }, + { "f21", 2368, 64 }, + { "f22", 2432, 64 }, + { "f23", 2496, 64 }, + { "f24", 2560, 64 }, + { "f25", 2624, 64 }, + { "f26", 2688, 64 }, + { "f27", 2752, 64 }, + { "f28", 2816, 64 }, + { "f29", 2880, 64 }, + { "f30", 2944, 64 }, + { "f31", 3008, 64 }, + { "pc", 3072, 32 }, + { "ps", 3104, 32 }, + { "cr", 3136, 32 }, + { "lr", 3168, 32 }, + { "ctr", 3200, 32 }, + { "xer", 3232, 32 }, + { "fpscr", 3264, 32 }, +}; + +const char *expedite_regs_ppc[] = { "r1", "pc", 0 }; + +void +init_registers () +{ + set_register_cache (regs_ppc, + sizeof (regs_ppc) / sizeof (regs_ppc[0])); + gdbserver_expedite_regs = expedite_regs_ppc; +} diff --git a/gnu/usr.bin/gdb/kgdb/Makefile b/gnu/usr.bin/gdb/kgdb/Makefile new file mode 100644 index 000000000000..2796109a8d52 --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/Makefile @@ -0,0 +1,15 @@ +# $FreeBSD$ + +PROG= kgdb${GDB_SUFFIX} +SRCS= main.c kld.c kthr.c trgt.c trgt_${TARGET_CPUARCH}.c +WARNS?= 2 + +BULIBS= ${OBJ_BU}/libbfd/libbfd.a ${OBJ_BU}/libopcodes/libopcodes.a \ + ${OBJ_BU}/libiberty/libiberty.a +GDBLIBS= ${OBJ_GDB}/libgdb/libgdb.a + +DPADD= ${GDBLIBS} ${BULIBS} +LDADD= ${GDBLIBS} ${BULIBS} +LIBADD+= m edit ncursesw gnuregex kvm + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/gdb/kgdb/Makefile.depend b/gnu/usr.bin/gdb/kgdb/Makefile.depend new file mode 100644 index 000000000000..ed1b03ca732f --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/Makefile.depend @@ -0,0 +1,27 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/lib/libreadline/readline \ + gnu/lib/libregex \ + gnu/usr.bin/binutils/libbfd \ + gnu/usr.bin/binutils/libiberty \ + gnu/usr.bin/binutils/libopcodes \ + gnu/usr.bin/gdb/libgdb \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + lib/libelf \ + lib/libkvm \ + lib/msun \ + lib/ncurses/ncursesw \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/gdb/kgdb/kgdb.1 b/gnu/usr.bin/gdb/kgdb/kgdb.1 new file mode 100644 index 000000000000..8ebfbf55ce9f --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/kgdb.1 @@ -0,0 +1,150 @@ +.\" Copyright (c) 2004 Marcel Moolenaar +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd July 5, 2017 +.Dt KGDB 1 +.Os +.Sh NAME +.Nm kgdb +.Nd "kernel debugger" +.Sh SYNOPSIS +.Nm +.Op Fl a | Fl f | Fl fullname +.Op Fl b Ar rate +.Op Fl q | Fl quiet +.Op Fl v +.Op Fl w +.Op Fl d Ar crashdir +.Op Fl c Ar core | Fl n Ar dumpnr | Fl r Ar device +.Op Ar kernel Op Ar core +.Sh DEPRECATION NOTICE +This version of +.Nm +is deprecated and will be removed from future versions of the +.Fx +base system. +A newer version of +.Nm +is available from ports or packages +(devel/gdb). +.Sh DESCRIPTION +The +.Nm +utility is a debugger based on +.Xr gdb 1 +that allows debugging of kernel core files. +.Pp +The options are as follows: +.Bl -tag -width ".Fl d Ar crashdir" +.It Fl a +Increase the annotation level. +An annotation level of 1 features the historical +.Fl fullname +option of +.Xr gdb 1 . +This is useful when running +.Nm +in Emacs. +The +.Fl f +or +.Fl fullname +options are supported for backward compatibility as well. +.It Fl b Ar rate +Set the baudrate to +.Ar rate . +.It Fl q +Suppress printing of the banner when the debugger starts. +The +.Fl quiet +form is supported for compatibility as well. +.It Fl v +Increase verbosity. +.It Fl w +Opens kmem-based targets in read-write mode. +(This is identical to what +.Fl -wcore +used to do in previous +gdb versions for +.Fx . ) +.It Fl d Ar crashdir +Use +.Ar crashdir +instead of the default, +.Pa /var/crash +to locate kernel core dump files in. +The name +.Pa vmcore. +plus the dump number will be appended to determine +the actual dump file name. +.It Fl c Ar core +Explicitly use +.Ar core +as the core dump file. +.It Fl n Ar dumpnr +Use the kernel core dump file numbered +.Ar dumpnr +for debugging. +.It Fl r Ar device +Use +.Ar device +to connect +.Nm +to for a remote debugging session. +.El +.Pp +The +.Fl c , n , +and +.Fl r +options are mutually exclusive. +.Pp +Optionally, the name of the kernel symbol file and +the name of the core dump file can be supplied on the +command-line as positional arguments. +If no kernel symbol file name has been given, the +symbol file of the currently running kernel will be +used. +If no core dump file has been specified through either +of the options or the last command-line argument, +.Pa /dev/mem +will be opened to allow debugging the currently running +kernel. +.Sh FILES +.Bl -tag -width ".Pa /var/crash" +.It Pa /dev/mem +Default memory image to open if no core dump file +has been specified. +.It Pa /var/crash +Default directory to locate kernel core dump files. +.El +.Sh SEE ALSO +.Xr gdb 1 +.Sh HISTORY +The +.Nm +utility first appeared in its current form in +.Fx 5.3 . diff --git a/gnu/usr.bin/gdb/kgdb/kgdb.h b/gnu/usr.bin/gdb/kgdb/kgdb.h new file mode 100644 index 000000000000..8e5d2baf40b4 --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/kgdb.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _KGDB_H_ +#define _KGDB_H_ + +struct thread_info; + +extern kvm_t *kvm; + +struct kthr { + struct kthr *next; + uintptr_t paddr; + uintptr_t kaddr; + uintptr_t kstack; + uintptr_t pcb; + int tid; + int pid; + int cpu; +}; + +extern struct kthr *curkthr; + +void initialize_kld_target(void); +void initialize_kgdb_target(void); +void kgdb_dmesg(void); +CORE_ADDR kgdb_trgt_core_pcb(u_int); +CORE_ADDR kgdb_trgt_stop_pcb(u_int, u_int); +void kgdb_trgt_new_objfile(struct objfile *); +void kgdb_trgt_fetch_registers(int); +void kgdb_trgt_store_registers(int); +void kld_init(void); +void kld_new_objfile(struct objfile *); + +frame_unwind_sniffer_ftype kgdb_trgt_trapframe_sniffer; + +struct kthr *kgdb_thr_first(void); +struct kthr *kgdb_thr_init(void); +struct kthr *kgdb_thr_lookup_tid(int); +struct kthr *kgdb_thr_lookup_pid(int); +struct kthr *kgdb_thr_lookup_paddr(uintptr_t); +struct kthr *kgdb_thr_lookup_taddr(uintptr_t); +struct kthr *kgdb_thr_next(struct kthr *); +struct kthr *kgdb_thr_select(struct kthr *); +char *kgdb_thr_extra_thread_info(int); + +CORE_ADDR kgdb_lookup(const char *sym); +CORE_ADDR kgdb_parse_1(const char *, int); + +#define kgdb_parse(exp) kgdb_parse_1((exp), 0) +#define kgdb_parse_quiet(exp) kgdb_parse_1((exp), 1) + +extern int (*arm_tdep_pc_fixup)(CORE_ADDR *pc); +int kgdb_trgt_pc_fixup(CORE_ADDR *pc); + +#endif /* _KGDB_H_ */ diff --git a/gnu/usr.bin/gdb/kgdb/kld.c b/gnu/usr.bin/gdb/kgdb/kld.c new file mode 100644 index 000000000000..50f0797c4cf4 --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/kld.c @@ -0,0 +1,515 @@ +/* + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <kvm.h> +#include <libgen.h> + +#include <defs.h> +#include <command.h> +#include <completer.h> +#include <environ.h> +#include <exec.h> +#include <frame-unwind.h> +#include <inferior.h> +#include <objfiles.h> +#include <gdbcore.h> +#include <language.h> +#include <solist.h> + +#include "kgdb.h" + +struct lm_info { + CORE_ADDR base_address; +}; + +/* Offsets of fields in linker_file structure. */ +static CORE_ADDR off_address, off_filename, off_pathname, off_next; + +/* KVA of 'linker_path' which corresponds to the kern.module_path sysctl .*/ +static CORE_ADDR module_path_addr; +static CORE_ADDR linker_files_addr; +static CORE_ADDR kernel_file_addr; + +static struct target_so_ops kld_so_ops; + +static int +kld_ok (char *path) +{ + struct stat sb; + + if (stat(path, &sb) == 0 && S_ISREG(sb.st_mode)) + return (1); + return (0); +} + +/* + * Look for a matching file checking for debug suffixes before the raw file: + * - filename + ".debug" (e.g. foo.ko.debug) + * - filename (e.g. foo.ko) + */ +static const char *kld_suffixes[] = { + ".debug", + ".symbols", + "", + NULL +}; + +static int +check_kld_path (char *path, size_t path_size) +{ + const char **suffix; + char *ep; + + ep = path + strlen(path); + suffix = kld_suffixes; + while (*suffix != NULL) { + if (strlcat(path, *suffix, path_size) < path_size) { + if (kld_ok(path)) + return (1); + } + + /* Restore original path to remove suffix. */ + *ep = '\0'; + suffix++; + } + return (0); +} + +/* + * Try to find the path for a kld by looking in the kernel's directory and + * in the various paths in the module path. + */ +static int +find_kld_path (char *filename, char *path, size_t path_size) +{ + char *module_path; + char *kernel_dir, *module_dir, *cp; + int error; + + if (exec_bfd) { + kernel_dir = dirname(bfd_get_filename(exec_bfd)); + if (kernel_dir != NULL) { + snprintf(path, path_size, "%s/%s", kernel_dir, + filename); + if (check_kld_path(path, path_size)) + return (1); + } + } + if (module_path_addr != 0) { + target_read_string(module_path_addr, &module_path, PATH_MAX, + &error); + if (error == 0) { + make_cleanup(xfree, module_path); + cp = module_path; + while ((module_dir = strsep(&cp, ";")) != NULL) { + snprintf(path, path_size, "%s/%s", module_dir, + filename); + if (check_kld_path(path, path_size)) + return (1); + } + } + } + return (0); +} + +/* + * Read a kernel pointer given a KVA in 'address'. + */ +static CORE_ADDR +read_pointer (CORE_ADDR address) +{ + CORE_ADDR value; + + if (target_read_memory(address, (char *)&value, TARGET_PTR_BIT / 8) != + 0) + return (0); + return (extract_unsigned_integer(&value, TARGET_PTR_BIT / 8)); +} + +/* + * Try to find this kld in the kernel linker's list of linker files. + */ +static int +find_kld_address (char *arg, CORE_ADDR *address) +{ + CORE_ADDR kld; + char *kld_filename; + char *filename; + int error; + + if (linker_files_addr == 0 || off_address == 0 || off_filename == 0 || + off_next == 0) + return (0); + + filename = basename(arg); + for (kld = read_pointer(linker_files_addr); kld != 0; + kld = read_pointer(kld + off_next)) { + /* Try to read this linker file's filename. */ + target_read_string(read_pointer(kld + off_filename), + &kld_filename, PATH_MAX, &error); + if (error) + continue; + + /* Compare this kld's filename against our passed in name. */ + if (strcmp(kld_filename, filename) != 0) { + xfree(kld_filename); + continue; + } + xfree(kld_filename); + + /* + * We found a match, use its address as the base + * address if we can read it. + */ + *address = read_pointer(kld + off_address); + if (*address == 0) + return (0); + return (1); + } + return (0); +} + +static void +adjust_section_address (struct section_table *sec, CORE_ADDR *curr_base) +{ + struct bfd_section *asect = sec->the_bfd_section; + bfd *abfd = sec->bfd; + + if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0) { + sec->addr += *curr_base; + sec->endaddr += *curr_base; + return; + } + + *curr_base = align_power(*curr_base, + bfd_get_section_alignment(abfd, asect)); + sec->addr = *curr_base; + sec->endaddr = sec->addr + bfd_section_size(abfd, asect); + *curr_base = sec->endaddr; +} + +static void +load_kld (char *path, CORE_ADDR base_addr, int from_tty) +{ + struct section_addr_info *sap; + struct section_table *sections = NULL, *sections_end = NULL, *s; + struct cleanup *cleanup; + bfd *bfd; + CORE_ADDR curr_addr; + int i; + + /* Open the kld. */ + bfd = bfd_openr(path, gnutarget); + if (bfd == NULL) + error("\"%s\": can't open: %s", path, + bfd_errmsg(bfd_get_error())); + cleanup = make_cleanup_bfd_close(bfd); + + if (!bfd_check_format(bfd, bfd_object)) + error("\%s\": not an object file", path); + + /* Make sure we have a .text section. */ + if (bfd_get_section_by_name (bfd, ".text") == NULL) + error("\"%s\": can't find text section", path); + + /* Build a section table from the bfd and relocate the sections. */ + if (build_section_table (bfd, §ions, §ions_end)) + error("\"%s\": can't find file sections", path); + cleanup = make_cleanup(xfree, sections); + curr_addr = base_addr; + for (s = sections; s < sections_end; s++) + adjust_section_address(s, &curr_addr); + + /* Build a section addr info to pass to symbol_file_add(). */ + sap = build_section_addr_info_from_section_table (sections, + sections_end); + cleanup = make_cleanup((make_cleanup_ftype *)free_section_addr_info, + sap); + + printf_unfiltered("add symbol table from file \"%s\" at\n", path); + for (i = 0; i < sap->num_sections; i++) + printf_unfiltered("\t%s_addr = %s\n", sap->other[i].name, + local_hex_string(sap->other[i].addr)); + + if (from_tty && (!query("%s", ""))) + error("Not confirmed."); + + symbol_file_add(path, from_tty, sap, 0, OBJF_USERLOADED); + + do_cleanups(cleanup); +} + +static void +kgdb_add_kld_cmd (char *arg, int from_tty) +{ + char path[PATH_MAX]; + CORE_ADDR base_addr; + + if (!exec_bfd) + error("No kernel symbol file"); + + /* Try to open the raw path to handle absolute paths first. */ + snprintf(path, sizeof(path), "%s", arg); + if (!check_kld_path(path, sizeof(path))) { + + /* + * If that didn't work, look in the various possible + * paths for the module. + */ + if (!find_kld_path(arg, path, sizeof(path))) { + error("Unable to locate kld"); + return; + } + } + + if (!find_kld_address(arg, &base_addr)) { + error("Unable to find kld in kernel"); + return; + } + + load_kld(path, base_addr, from_tty); + + reinit_frame_cache(); +} + +static void +kld_relocate_section_addresses (struct so_list *so, struct section_table *sec) +{ + static CORE_ADDR curr_addr; + + if (sec == so->sections) + curr_addr = so->lm_info->base_address; + + adjust_section_address(sec, &curr_addr); +} + +static void +kld_free_so (struct so_list *so) +{ + + xfree(so->lm_info); +} + +static void +kld_clear_solib (void) +{ +} + +static void +kld_solib_create_inferior_hook (void) +{ +} + +static void +kld_special_symbol_handling (void) +{ +} + +static struct so_list * +kld_current_sos (void) +{ + struct so_list *head, **prev, *new; + CORE_ADDR kld, kernel; + char *path; + int error; + + if (linker_files_addr == 0 || kernel_file_addr == 0 || + off_address == 0 || off_filename == 0 || off_next == 0) + return (NULL); + + head = NULL; + prev = &head; + + /* + * Walk the list of linker files creating so_list entries for + * each non-kernel file. + */ + kernel = read_pointer(kernel_file_addr); + for (kld = read_pointer(linker_files_addr); kld != 0; + kld = read_pointer(kld + off_next)) { + /* Skip the main kernel file. */ + if (kld == kernel) + continue; + + new = xmalloc(sizeof(*new)); + memset(new, 0, sizeof(*new)); + + new->lm_info = xmalloc(sizeof(*new->lm_info)); + new->lm_info->base_address = 0; + + /* Read the base filename and store it in so_original_name. */ + target_read_string(read_pointer(kld + off_filename), + &path, sizeof(new->so_original_name), &error); + if (error != 0) { + warning("kld_current_sos: Can't read filename: %s\n", + safe_strerror(error)); + free_so(new); + continue; + } + strlcpy(new->so_original_name, path, + sizeof(new->so_original_name)); + xfree(path); + + /* + * Try to read the pathname (if it exists) and store + * it in so_name. + */ + if (find_kld_path(new->so_original_name, new->so_name, + sizeof(new->so_name))) { + /* we found the kld */; + } else if (off_pathname != 0) { + target_read_string(read_pointer(kld + off_pathname), + &path, sizeof(new->so_name), &error); + if (error != 0) { + warning( + "kld_current_sos: Can't read pathname for \"%s\": %s\n", + new->so_original_name, + safe_strerror(error)); + strlcpy(new->so_name, new->so_original_name, + sizeof(new->so_name)); + } else { + strlcpy(new->so_name, path, + sizeof(new->so_name)); + xfree(path); + } + } else + strlcpy(new->so_name, new->so_original_name, + sizeof(new->so_name)); + + /* Read this kld's base address. */ + new->lm_info->base_address = read_pointer(kld + off_address); + if (new->lm_info->base_address == 0) { + warning( + "kld_current_sos: Invalid address for kld \"%s\"", + new->so_original_name); + free_so(new); + continue; + } + + /* Append to the list. */ + *prev = new; + prev = &new->next; + } + + return (head); +} + +static int +kld_open_symbol_file_object (void *from_ttyp) +{ + + return (0); +} + +static int +kld_in_dynsym_resolve_code (CORE_ADDR pc) +{ + + return (0); +} + +static int +kld_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname) +{ + char path[PATH_MAX]; + int fd; + + *temp_pathname = NULL; + if (!find_kld_path(solib, path, sizeof(path))) { + errno = ENOENT; + return (-1); + } + fd = open(path, o_flags, 0); + if (fd >= 0) + *temp_pathname = xstrdup(path); + return (fd); +} + +void +kld_new_objfile (struct objfile *objfile) +{ + + if (!have_partial_symbols()) + return; + + /* + * Compute offsets of relevant members in struct linker_file + * and the addresses of global variables. Don't warn about + * kernels that don't have 'pathname' in the linker_file + * struct since 6.x kernels don't have it. + */ + off_address = kgdb_parse("&((struct linker_file *)0)->address"); + off_filename = kgdb_parse("&((struct linker_file *)0)->filename"); + off_pathname = kgdb_parse_quiet("&((struct linker_file *)0)->pathname"); + off_next = kgdb_parse("&((struct linker_file *)0)->link.tqe_next"); + module_path_addr = kgdb_parse("linker_path"); + linker_files_addr = kgdb_parse("&linker_files.tqh_first"); + kernel_file_addr = kgdb_parse("&linker_kernel_file"); +} + +static int +load_klds_stub (void *arg) +{ + + SOLIB_ADD(NULL, 1, ¤t_target, auto_solib_add); + return (0); +} + +void +kld_init (void) +{ + + catch_errors(load_klds_stub, NULL, NULL, RETURN_MASK_ALL); +} + +void +initialize_kld_target(void) +{ + struct cmd_list_element *c; + + kld_so_ops.relocate_section_addresses = kld_relocate_section_addresses; + kld_so_ops.free_so = kld_free_so; + kld_so_ops.clear_solib = kld_clear_solib; + kld_so_ops.solib_create_inferior_hook = kld_solib_create_inferior_hook; + kld_so_ops.special_symbol_handling = kld_special_symbol_handling; + kld_so_ops.current_sos = kld_current_sos; + kld_so_ops.open_symbol_file_object = kld_open_symbol_file_object; + kld_so_ops.in_dynsym_resolve_code = kld_in_dynsym_resolve_code; + kld_so_ops.find_and_open_solib = kld_find_and_open_solib; + + current_target_so_ops = &kld_so_ops; + + c = add_com("add-kld", class_files, kgdb_add_kld_cmd, + "Usage: add-kld FILE\n\ +Load the symbols from the kernel loadable module FILE."); + set_cmd_completer(c, filename_completer); +} diff --git a/gnu/usr.bin/gdb/kgdb/kthr.c b/gnu/usr.bin/gdb/kgdb/kthr.c new file mode 100644 index 000000000000..1bc95cb18b36 --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/kthr.c @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/cpuset.h> +#include <sys/proc.h> +#include <sys/types.h> +#include <sys/signal.h> +#include <err.h> +#include <inttypes.h> +#include <kvm.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <defs.h> +#include <frame-unwind.h> + +#include "kgdb.h" + +static CORE_ADDR dumppcb; +static int dumptid; + +static cpuset_t stopped_cpus; + +static struct kthr *first; +struct kthr *curkthr; + +CORE_ADDR +kgdb_lookup(const char *sym) +{ + CORE_ADDR addr; + char *name; + + asprintf(&name, "&%s", sym); + addr = kgdb_parse(name); + free(name); + return (addr); +} + +struct kthr * +kgdb_thr_first(void) +{ + return (first); +} + +static void +kgdb_thr_add_procs(uintptr_t paddr) +{ + struct proc p; + struct thread td; + struct kthr *kt; + CORE_ADDR addr; + + while (paddr != 0) { + if (kvm_read(kvm, paddr, &p, sizeof(p)) != sizeof(p)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + break; + } + addr = (uintptr_t)TAILQ_FIRST(&p.p_threads); + while (addr != 0) { + if (kvm_read(kvm, addr, &td, sizeof(td)) != + sizeof(td)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + break; + } + kt = malloc(sizeof(*kt)); + kt->next = first; + kt->kaddr = addr; + if (td.td_tid == dumptid) + kt->pcb = dumppcb; + else if (td.td_oncpu != NOCPU && + CPU_ISSET(td.td_oncpu, &stopped_cpus)) + kt->pcb = kgdb_trgt_core_pcb(td.td_oncpu); + else + kt->pcb = (uintptr_t)td.td_pcb; + kt->kstack = td.td_kstack; + kt->tid = td.td_tid; + kt->pid = p.p_pid; + kt->paddr = paddr; + kt->cpu = td.td_oncpu; + first = kt; + addr = (uintptr_t)TAILQ_NEXT(&td, td_plist); + } + paddr = (uintptr_t)LIST_NEXT(&p, p_list); + } +} + +struct kthr * +kgdb_thr_init(void) +{ + long cpusetsize; + struct kthr *kt; + CORE_ADDR addr; + uintptr_t paddr; + + while (first != NULL) { + kt = first; + first = kt->next; + free(kt); + } + + addr = kgdb_lookup("allproc"); + if (addr == 0) + return (NULL); + kvm_read(kvm, addr, &paddr, sizeof(paddr)); + + dumppcb = kgdb_lookup("dumppcb"); + if (dumppcb == 0) + return (NULL); + + addr = kgdb_lookup("dumptid"); + if (addr != 0) + kvm_read(kvm, addr, &dumptid, sizeof(dumptid)); + else + dumptid = -1; + + addr = kgdb_lookup("stopped_cpus"); + CPU_ZERO(&stopped_cpus); + cpusetsize = sysconf(_SC_CPUSET_SIZE); + if (cpusetsize != -1 && (u_long)cpusetsize <= sizeof(cpuset_t) && + addr != 0) + kvm_read(kvm, addr, &stopped_cpus, cpusetsize); + + kgdb_thr_add_procs(paddr); + addr = kgdb_lookup("zombproc"); + if (addr != 0) { + kvm_read(kvm, addr, &paddr, sizeof(paddr)); + kgdb_thr_add_procs(paddr); + } + curkthr = kgdb_thr_lookup_tid(dumptid); + if (curkthr == NULL) + curkthr = first; + return (first); +} + +struct kthr * +kgdb_thr_lookup_tid(int tid) +{ + struct kthr *kt; + + kt = first; + while (kt != NULL && kt->tid != tid) + kt = kt->next; + return (kt); +} + +struct kthr * +kgdb_thr_lookup_taddr(uintptr_t taddr) +{ + struct kthr *kt; + + kt = first; + while (kt != NULL && kt->kaddr != taddr) + kt = kt->next; + return (kt); +} + +struct kthr * +kgdb_thr_lookup_pid(int pid) +{ + struct kthr *kt; + + kt = first; + while (kt != NULL && kt->pid != pid) + kt = kt->next; + return (kt); +} + +struct kthr * +kgdb_thr_lookup_paddr(uintptr_t paddr) +{ + struct kthr *kt; + + kt = first; + while (kt != NULL && kt->paddr != paddr) + kt = kt->next; + return (kt); +} + +struct kthr * +kgdb_thr_next(struct kthr *kt) +{ + return (kt->next); +} + +struct kthr * +kgdb_thr_select(struct kthr *kt) +{ + struct kthr *pcur; + + pcur = curkthr; + curkthr = kt; + return (pcur); +} + +char * +kgdb_thr_extra_thread_info(int tid) +{ + char comm[MAXCOMLEN + 1]; + char td_name[MAXCOMLEN + 1]; + struct kthr *kt; + struct proc *p; + struct thread *t; + static char buf[64]; + + kt = kgdb_thr_lookup_tid(tid); + if (kt == NULL) + return (NULL); + snprintf(buf, sizeof(buf), "PID=%d", kt->pid); + p = (struct proc *)kt->paddr; + if (kvm_read(kvm, (uintptr_t)&p->p_comm[0], &comm, sizeof(comm)) != + sizeof(comm)) + return (buf); + strlcat(buf, ": ", sizeof(buf)); + strlcat(buf, comm, sizeof(buf)); + t = (struct thread *)kt->kaddr; + if (kvm_read(kvm, (uintptr_t)&t->td_name[0], &td_name, + sizeof(td_name)) == sizeof(td_name) && + strcmp(comm, td_name) != 0) { + strlcat(buf, "/", sizeof(buf)); + strlcat(buf, td_name, sizeof(buf)); + } + return (buf); +} diff --git a/gnu/usr.bin/gdb/kgdb/main.c b/gnu/usr.bin/gdb/kgdb/main.c new file mode 100644 index 000000000000..a1da89314a0e --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/main.c @@ -0,0 +1,481 @@ +/* + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/resource.h> +#include <sys/select.h> +#include <sys/time.h> +#include <sys/wait.h> +#include <errno.h> +#include <err.h> +#include <inttypes.h> +#include <kvm.h> +#include <limits.h> +#include <paths.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +/* libgdb stuff. */ +#include <defs.h> +#include <frame.h> +#include <frame-unwind.h> +#include <inferior.h> +#include <interps.h> +#include <cli-out.h> +#include <main.h> +#include <objfiles.h> +#include <target.h> +#include <top.h> +#include <ui-file.h> +#include <bfd.h> +#include <gdbcore.h> +#include <wrapper.h> + +extern frame_unwind_sniffer_ftype *kgdb_sniffer_kluge; + +#include "kgdb.h" + +static int dumpnr; +static int quiet; +static int verbose; + +static char crashdir[PATH_MAX]; +static char *kernel; +static char *remote; +static char *vmcore; +static struct ui_file *parse_gdberr; + +static void (*kgdb_new_objfile_chain)(struct objfile * objfile); + +static void +usage(void) +{ + + fprintf(stderr, + "usage: %s [-afqvw] [-b rate] [-d crashdir] [-c core | -n dumpnr | -r device]\n" + "\t[kernel [core]]\n", getprogname()); + exit(1); +} + +static void +kernel_from_dumpnr(int nr) +{ + char path[PATH_MAX]; + FILE *info; + char *s; + struct stat st; + int l; + + /* + * If there's a kernel image right here in the crash directory, then + * use it. The kernel image is either called kernel.<nr> or is in a + * subdirectory kernel.<nr> and called kernel. The latter allows us + * to collect the modules in the same place. + */ + snprintf(path, sizeof(path), "%s/kernel.%d", crashdir, nr); + if (stat(path, &st) == 0) { + if (S_ISREG(st.st_mode)) { + kernel = strdup(path); + return; + } + if (S_ISDIR(st.st_mode)) { + snprintf(path, sizeof(path), "%s/kernel.%d/kernel", + crashdir, nr); + if (stat(path, &st) == 0 && S_ISREG(st.st_mode)) { + kernel = strdup(path); + return; + } + } + } + + /* + * No kernel image here. Parse the dump header. The kernel object + * directory can be found there and we probably have the kernel + * image still in it. The object directory may also have a kernel + * with debugging info (called kernel.debug). If we have a debug + * kernel, use it. + */ + snprintf(path, sizeof(path), "%s/info.%d", crashdir, nr); + info = fopen(path, "r"); + if (info == NULL) { + warn("%s", path); + return; + } + while (fgets(path, sizeof(path), info) != NULL) { + l = strlen(path); + if (l > 0 && path[l - 1] == '\n') + path[--l] = '\0'; + if (strncmp(path, " ", 4) == 0) { + s = strchr(path, ':'); + s = (s == NULL) ? path + 4 : s + 1; + l = snprintf(path, sizeof(path), "%s/kernel.debug", s); + if (stat(path, &st) == -1 || !S_ISREG(st.st_mode)) { + path[l - 6] = '\0'; + if (stat(path, &st) == -1 || + !S_ISREG(st.st_mode)) + break; + } + kernel = strdup(path); + break; + } + } + fclose(info); +} + +static void +kgdb_new_objfile(struct objfile *objfile) +{ + static int once = 1; + + kld_new_objfile(objfile); + kgdb_trgt_new_objfile(objfile); + + if (kgdb_new_objfile_chain != NULL) + kgdb_new_objfile_chain(objfile); + + if (once && objfile != NULL && objfile == symfile_objfile) { + /* + * The initial kernel has just been loaded. Start the + * remote target if we have one. + */ + once = 0; + if (remote != NULL) + push_remote_target (remote, 0); + } +} + +/* + * Parse an expression and return its value. If 'quiet' is true, then + * any error messages from the parser are masked. + */ +CORE_ADDR +kgdb_parse_1(const char *exp, int quiet) +{ + struct ui_file *old_stderr; + struct cleanup *old_chain; + struct expression *expr; + struct value *val; + char *s; + CORE_ADDR n; + + old_stderr = gdb_stderr; + if (quiet) + gdb_stderr = parse_gdberr; + n = 0; + s = xstrdup(exp); + old_chain = make_cleanup(xfree, s); + if (gdb_parse_exp_1(&s, NULL, 0, &expr) && *s == '\0') { + make_cleanup(free_current_contents, &expr); + if (gdb_evaluate_expression(expr, &val)) + n = value_as_address(val); + } + do_cleanups(old_chain); + gdb_stderr = old_stderr; + return (n); +} + +#define MSGBUF_SEQ_TO_POS(size, seq) ((seq) % (size)) + +void +kgdb_dmesg(void) +{ + CORE_ADDR bufp; + int size, rseq, wseq; + char c; + + /* + * Display the unread portion of the message buffer. This gives the + * user a some initial data to work from. + */ + if (quiet) + return; + bufp = kgdb_parse("msgbufp->msg_ptr"); + size = (int)kgdb_parse("msgbufp->msg_size"); + if (bufp == 0 || size == 0) + return; + rseq = (int)kgdb_parse("msgbufp->msg_rseq"); + wseq = (int)kgdb_parse("msgbufp->msg_wseq"); + rseq = MSGBUF_SEQ_TO_POS(size, rseq); + wseq = MSGBUF_SEQ_TO_POS(size, wseq); + if (rseq == wseq) + return; + + printf("\nUnread portion of the kernel message buffer:\n"); + while (rseq < wseq) { + read_memory(bufp + rseq, &c, 1); + putchar(c); + rseq++; + if (rseq == size) + rseq = 0; + } + if (c != '\n') + putchar('\n'); + putchar('\n'); +} + +static void +kgdb_init(char *argv0 __unused) +{ + + parse_gdberr = mem_fileopen(); + set_prompt("(kgdb) "); + initialize_kgdb_target(); + initialize_kld_target(); + kgdb_new_objfile_chain = target_new_objfile_hook; + target_new_objfile_hook = kgdb_new_objfile; +} + +/* + * Remote targets can support any number of syntaxes and we want to + * support them all with one addition: we support specifying a device + * node for a serial device without the "/dev/" prefix. + * + * What we do is to stat(2) the existing remote target first. If that + * fails, we try it with "/dev/" prepended. If that succeeds we use + * the resulting path, otherwise we use the original target. If + * either stat(2) succeeds make sure the file is either a character + * device or a FIFO. + */ +static void +verify_remote(void) +{ + char path[PATH_MAX]; + struct stat st; + + if (stat(remote, &st) != 0) { + snprintf(path, sizeof(path), "/dev/%s", remote); + if (stat(path, &st) != 0) + return; + free(remote); + remote = strdup(path); + } + if (!S_ISCHR(st.st_mode) && !S_ISFIFO(st.st_mode)) + errx(1, "%s: not a special file, FIFO or socket", remote); +} + +static void +add_arg(struct captured_main_args *args, char *arg) +{ + + args->argc++; + args->argv = reallocf(args->argv, (args->argc + 1) * sizeof(char *)); + if (args->argv == NULL) + err(1, "Out of memory building argument list"); + args->argv[args->argc] = arg; +} + +int +main(int argc, char *argv[]) +{ + char path[PATH_MAX]; + struct stat st; + struct captured_main_args args; + char *s; + int a, ch; + + dumpnr = -1; + + strlcpy(crashdir, "/var/crash", sizeof(crashdir)); + s = getenv("KGDB_CRASH_DIR"); + if (s != NULL) + strlcpy(crashdir, s, sizeof(crashdir)); + + /* Convert long options into short options. */ + for (a = 1; a < argc; a++) { + s = argv[a]; + if (s[0] == '-') { + s++; + /* Long options take either 1 or 2 dashes. */ + if (s[0] == '-') + s++; + if (strcmp(s, "quiet") == 0) + argv[a] = "-q"; + else if (strcmp(s, "fullname") == 0) + argv[a] = "-f"; + } + } + + quiet = 0; + memset (&args, 0, sizeof args); + args.use_windows = 0; + args.interpreter_p = INTERP_CONSOLE; + args.argv = malloc(sizeof(char *)); + args.argv[0] = argv[0]; + + while ((ch = getopt(argc, argv, "ab:c:d:fn:qr:vw")) != -1) { + switch (ch) { + case 'a': + annotation_level++; + break; + case 'b': { + int i; + char *p; + + i = strtol(optarg, &p, 0); + if (*p != '\0' || p == optarg) + warnx("warning: could not set baud rate to `%s'.\n", + optarg); + else + baud_rate = i; + break; + } + case 'c': /* use given core file. */ + if (vmcore != NULL) { + warnx("option %c: can only be specified once", + optopt); + usage(); + /* NOTREACHED */ + } + vmcore = strdup(optarg); + break; + case 'd': /* lookup dumps in given directory. */ + strlcpy(crashdir, optarg, sizeof(crashdir)); + break; + case 'f': + annotation_level = 1; + break; + case 'n': /* use dump with given number. */ + dumpnr = strtol(optarg, &s, 0); + if (dumpnr < 0 || *s != '\0') { + warnx("option %c: invalid kernel dump number", + optopt); + usage(); + /* NOTREACHED */ + } + break; + case 'q': + quiet = 1; + add_arg(&args, "-q"); + break; + case 'r': /* use given device for remote session. */ + if (remote != NULL) { + warnx("option %c: can only be specified once", + optopt); + usage(); + /* NOTREACHED */ + } + remote = strdup(optarg); + break; + case 'v': /* increase verbosity. */ + verbose++; + break; + case 'w': /* core file is writeable. */ + add_arg(&args, "--write"); + break; + case '?': + default: + usage(); + } + } + + if (((vmcore != NULL) ? 1 : 0) + ((dumpnr >= 0) ? 1 : 0) + + ((remote != NULL) ? 1 : 0) > 1) { + warnx("options -c, -n and -r are mutually exclusive"); + usage(); + /* NOTREACHED */ + } + + if (verbose > 1) + warnx("using %s as the crash directory", crashdir); + + if (argc > optind) + kernel = strdup(argv[optind++]); + + if (argc > optind && (dumpnr >= 0 || remote != NULL)) { + warnx("options -n and -r do not take a core file. Ignored"); + optind = argc; + } + + if (dumpnr >= 0) { + snprintf(path, sizeof(path), "%s/vmcore.%d", crashdir, dumpnr); + if (stat(path, &st) == -1) + err(1, "%s", path); + if (!S_ISREG(st.st_mode)) + errx(1, "%s: not a regular file", path); + vmcore = strdup(path); + } else if (remote != NULL) { + verify_remote(); + } else if (argc > optind) { + if (vmcore == NULL) + vmcore = strdup(argv[optind++]); + if (argc > optind) + warnx("multiple core files specified. Ignored"); + } else if (vmcore == NULL && kernel == NULL) { + vmcore = strdup(_PATH_MEM); + kernel = strdup(getbootfile()); + } + + if (verbose) { + if (vmcore != NULL) + warnx("core file: %s", vmcore); + if (remote != NULL) + warnx("device file: %s", remote); + if (kernel != NULL) + warnx("kernel image: %s", kernel); + } + + /* A remote target requires an explicit kernel argument. */ + if (remote != NULL && kernel == NULL) { + warnx("remote debugging requires a kernel"); + usage(); + /* NOTREACHED */ + } + + /* If we don't have a kernel image yet, try to find one. */ + if (kernel == NULL) { + if (dumpnr >= 0) + kernel_from_dumpnr(dumpnr); + + if (kernel == NULL) + errx(1, "couldn't find a suitable kernel image"); + if (verbose) + warnx("kernel image: %s", kernel); + } + add_arg(&args, kernel); + + if (vmcore != NULL) + add_arg(&args, vmcore); + + /* The libgdb code uses optind too. Reset it... */ + optind = 0; + + /* Terminate argv list. */ + add_arg(&args, NULL); + + init_ui_hook = kgdb_init; + frame_tdep_pc_fixup = kgdb_trgt_pc_fixup; + kgdb_sniffer_kluge = kgdb_trgt_trapframe_sniffer; + + return (gdb_main(&args)); +} diff --git a/gnu/usr.bin/gdb/kgdb/trgt.c b/gnu/usr.bin/gdb/kgdb/trgt.c new file mode 100644 index 000000000000..0cf836130a6f --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/trgt.c @@ -0,0 +1,396 @@ +/* + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/proc.h> +#include <sys/sysctl.h> +#include <sys/user.h> +#include <err.h> +#include <fcntl.h> +#include <kvm.h> + +#include <defs.h> +#include <readline/readline.h> +#include <readline/tilde.h> +#include <command.h> +#include <exec.h> +#include <frame-unwind.h> +#include <gdb.h> +#include <gdbcore.h> +#include <gdbthread.h> +#include <inferior.h> +#include <language.h> +#include <regcache.h> +#include <solib.h> +#include <target.h> +#include <ui-out.h> + +#include "kgdb.h" + +#ifdef CROSS_DEBUGGER +/* + * We suppress the call to add_target() of core_ops in corelow.c because if + * there are multiple core_stratum targets, the find_core_target() function + * won't know which one to return and returns none. We need it to return + * our target. We only have to do that when we're building a cross-debugger + * because fbsd-threads.c is part of a native debugger and it too defines + * coreops_suppress_target with 1 as the initializer. + */ +int coreops_suppress_target = 1; +#endif + +static CORE_ADDR stoppcbs; + +static void kgdb_core_cleanup(void *); + +static char *vmcore; +static struct target_ops kgdb_trgt_ops; + +kvm_t *kvm; +static char kvm_err[_POSIX2_LINE_MAX]; + +#define KERNOFF (kgdb_kernbase ()) +#define PINKERNEL(x) ((x) >= KERNOFF) + +static int +kgdb_resolve_symbol(const char *name, kvaddr_t *kva) +{ + struct minimal_symbol *ms; + + ms = lookup_minimal_symbol (name, NULL, NULL); + if (ms == NULL) + return (1); + + *kva = SYMBOL_VALUE_ADDRESS (ms); + return (0); +} + +static CORE_ADDR +kgdb_kernbase (void) +{ + static CORE_ADDR kernbase; + struct minimal_symbol *sym; + + if (kernbase == 0) { + sym = lookup_minimal_symbol ("kernbase", NULL, NULL); + if (sym == NULL) { + kernbase = KERNBASE; + } else { + kernbase = SYMBOL_VALUE_ADDRESS (sym); + } + } + return kernbase; +} + +static void +kgdb_trgt_open(char *filename, int from_tty) +{ + struct cleanup *old_chain; + struct thread_info *ti; + struct kthr *kt; + kvm_t *nkvm; + char *temp; + int ontop; + + target_preopen (from_tty); + if (!filename) + error ("No vmcore file specified."); + if (!exec_bfd) + error ("Can't open a vmcore without a kernel"); + + filename = tilde_expand (filename); + if (filename[0] != '/') { + temp = concat (current_directory, "/", filename, NULL); + xfree(filename); + filename = temp; + } + + old_chain = make_cleanup (xfree, filename); + + nkvm = kvm_open2(bfd_get_filename(exec_bfd), filename, + write_files ? O_RDWR : O_RDONLY, kvm_err, kgdb_resolve_symbol); + if (nkvm == NULL) + error ("Failed to open vmcore: %s", kvm_err); + + /* Don't free the filename now and close any previous vmcore. */ + discard_cleanups(old_chain); + unpush_target(&kgdb_trgt_ops); + + kvm = nkvm; + vmcore = filename; + old_chain = make_cleanup(kgdb_core_cleanup, NULL); + + ontop = !push_target (&kgdb_trgt_ops); + discard_cleanups (old_chain); + + kgdb_dmesg(); + + init_thread_list(); + kt = kgdb_thr_init(); + while (kt != NULL) { + ti = add_thread(pid_to_ptid(kt->tid)); + kt = kgdb_thr_next(kt); + } + if (curkthr != 0) + inferior_ptid = pid_to_ptid(curkthr->tid); + + if (ontop) { + /* XXX: fetch registers? */ + kld_init(); + flush_cached_frames(); + select_frame (get_current_frame()); + print_stack_frame(get_selected_frame(), + frame_relative_level(get_selected_frame()), 1); + } else + warning( + "you won't be able to access this vmcore until you terminate\n\ +your %s; do ``info files''", target_longname); +} + +static void +kgdb_trgt_close(int quitting) +{ + + if (kvm != NULL) { + inferior_ptid = null_ptid; + CLEAR_SOLIB(); + if (kvm_close(kvm) != 0) + warning("cannot close \"%s\": %s", vmcore, + kvm_geterr(kvm)); + kvm = NULL; + xfree(vmcore); + vmcore = NULL; + if (kgdb_trgt_ops.to_sections) { + xfree(kgdb_trgt_ops.to_sections); + kgdb_trgt_ops.to_sections = NULL; + kgdb_trgt_ops.to_sections_end = NULL; + } + } +} + +static void +kgdb_core_cleanup(void *arg) +{ + + kgdb_trgt_close(0); +} + +static void +kgdb_trgt_detach(char *args, int from_tty) +{ + + if (args) + error ("Too many arguments"); + unpush_target(&kgdb_trgt_ops); + reinit_frame_cache(); + if (from_tty) + printf_filtered("No vmcore file now.\n"); +} + +static char * +kgdb_trgt_extra_thread_info(struct thread_info *ti) +{ + + return (kgdb_thr_extra_thread_info(ptid_get_pid(ti->ptid))); +} + +static void +kgdb_trgt_files_info(struct target_ops *target) +{ + + printf_filtered ("\t`%s', ", vmcore); + wrap_here (" "); + printf_filtered ("file type %s.\n", "FreeBSD kernel vmcore"); +} + +static void +kgdb_trgt_find_new_threads(void) +{ + struct target_ops *tb; + + if (kvm != NULL) + return; + + tb = find_target_beneath(&kgdb_trgt_ops); + if (tb->to_find_new_threads != NULL) + tb->to_find_new_threads(); +} + +static char * +kgdb_trgt_pid_to_str(ptid_t ptid) +{ + static char buf[33]; + + snprintf(buf, sizeof(buf), "Thread %d", ptid_get_pid(ptid)); + return (buf); +} + +static int +kgdb_trgt_thread_alive(ptid_t ptid) +{ + return (kgdb_thr_lookup_tid(ptid_get_pid(ptid)) != NULL); +} + +static int +kgdb_trgt_xfer_memory(CORE_ADDR memaddr, char *myaddr, int len, int write, + struct mem_attrib *attrib, struct target_ops *target) +{ + struct target_ops *tb; + + if (kvm != NULL) { + if (len == 0) + return (0); + if (!write) + return (kvm_read2(kvm, memaddr, myaddr, len)); + else + return (kvm_write(kvm, memaddr, myaddr, len)); + } + tb = find_target_beneath(target); + return (tb->to_xfer_memory(memaddr, myaddr, len, write, attrib, tb)); +} + +static int +kgdb_trgt_ignore_breakpoints(CORE_ADDR addr, char *contents) +{ + + return 0; +} + +static void +kgdb_switch_to_thread(int tid) +{ + char buf[16]; + int thread_id; + + thread_id = pid_to_thread_id(pid_to_ptid(tid)); + if (thread_id == 0) + error ("invalid tid"); + snprintf(buf, sizeof(buf), "%d", thread_id); + gdb_thread_select(uiout, buf); +} + +static void +kgdb_set_proc_cmd (char *arg, int from_tty) +{ + CORE_ADDR addr; + struct kthr *thr; + + if (!arg) + error_no_arg ("proc address for the new context"); + + if (kvm == NULL) + error ("only supported for core file target"); + + addr = (CORE_ADDR) parse_and_eval_address (arg); + + if (!PINKERNEL (addr)) { + thr = kgdb_thr_lookup_pid((int)addr); + if (thr == NULL) + error ("invalid pid"); + } else { + thr = kgdb_thr_lookup_paddr(addr); + if (thr == NULL) + error("invalid proc address"); + } + kgdb_switch_to_thread(thr->tid); +} + +static void +kgdb_set_tid_cmd (char *arg, int from_tty) +{ + CORE_ADDR addr; + struct kthr *thr; + + if (!arg) + error_no_arg ("TID or thread address for the new context"); + + addr = (CORE_ADDR) parse_and_eval_address (arg); + + if (kvm != NULL && PINKERNEL (addr)) { + thr = kgdb_thr_lookup_taddr(addr); + if (thr == NULL) + error("invalid thread address"); + addr = thr->tid; + } + kgdb_switch_to_thread(addr); +} + +int fbsdcoreops_suppress_target = 1; + +void +initialize_kgdb_target(void) +{ + + kgdb_trgt_ops.to_magic = OPS_MAGIC; + kgdb_trgt_ops.to_shortname = "kernel"; + kgdb_trgt_ops.to_longname = "kernel core dump file"; + kgdb_trgt_ops.to_doc = + "Use a vmcore file as a target. Specify the filename of the vmcore file."; + kgdb_trgt_ops.to_stratum = core_stratum; + kgdb_trgt_ops.to_has_memory = 1; + kgdb_trgt_ops.to_has_registers = 1; + kgdb_trgt_ops.to_has_stack = 1; + + kgdb_trgt_ops.to_open = kgdb_trgt_open; + kgdb_trgt_ops.to_close = kgdb_trgt_close; + kgdb_trgt_ops.to_attach = find_default_attach; + kgdb_trgt_ops.to_detach = kgdb_trgt_detach; + kgdb_trgt_ops.to_extra_thread_info = kgdb_trgt_extra_thread_info; + kgdb_trgt_ops.to_fetch_registers = kgdb_trgt_fetch_registers; + kgdb_trgt_ops.to_files_info = kgdb_trgt_files_info; + kgdb_trgt_ops.to_find_new_threads = kgdb_trgt_find_new_threads; + kgdb_trgt_ops.to_pid_to_str = kgdb_trgt_pid_to_str; + kgdb_trgt_ops.to_store_registers = kgdb_trgt_store_registers; + kgdb_trgt_ops.to_thread_alive = kgdb_trgt_thread_alive; + kgdb_trgt_ops.to_xfer_memory = kgdb_trgt_xfer_memory; + kgdb_trgt_ops.to_insert_breakpoint = kgdb_trgt_ignore_breakpoints; + kgdb_trgt_ops.to_remove_breakpoint = kgdb_trgt_ignore_breakpoints; + + add_target(&kgdb_trgt_ops); + + add_com ("proc", class_obscure, kgdb_set_proc_cmd, + "Set current process context"); + add_com ("tid", class_obscure, kgdb_set_tid_cmd, + "Set current thread context"); +} + +CORE_ADDR +kgdb_trgt_stop_pcb(u_int cpuid, u_int pcbsz) +{ + static int once = 0; + + if (stoppcbs == 0 && !once) { + once = 1; + stoppcbs = kgdb_lookup("stoppcbs"); + } + if (stoppcbs == 0) + return 0; + + return (stoppcbs + pcbsz * cpuid); +} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_amd64.c b/gnu/usr.bin/gdb/kgdb/trgt_amd64.c new file mode 100644 index 000000000000..ec0ac0180338 --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/trgt_amd64.c @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <machine/pcb.h> +#include <machine/frame.h> +#include <err.h> +#include <kvm.h> +#include <string.h> + +#include <defs.h> +#include <target.h> +#include <gdbthread.h> +#include <inferior.h> +#include <regcache.h> +#include <frame-unwind.h> +#include <amd64-tdep.h> + +#include "kgdb.h" + +CORE_ADDR +kgdb_trgt_core_pcb(u_int cpuid) +{ + return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); +} + +void +kgdb_trgt_fetch_registers(int regno __unused) +{ + struct kthr *kt; + struct pcb pcb; + + kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); + if (kt == NULL) + return; + if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + memset(&pcb, 0, sizeof(pcb)); + } + + supply_register(AMD64_RBX_REGNUM, (char *)&pcb.pcb_rbx); + supply_register(AMD64_RBP_REGNUM, (char *)&pcb.pcb_rbp); + supply_register(AMD64_RSP_REGNUM, (char *)&pcb.pcb_rsp); + supply_register(AMD64_R8_REGNUM + 4, (char *)&pcb.pcb_r12); + supply_register(AMD64_R8_REGNUM + 5, (char *)&pcb.pcb_r13); + supply_register(AMD64_R8_REGNUM + 6, (char *)&pcb.pcb_r14); + supply_register(AMD64_R15_REGNUM, (char *)&pcb.pcb_r15); + supply_register(AMD64_RIP_REGNUM, (char *)&pcb.pcb_rip); +} + +void +kgdb_trgt_store_registers(int regno __unused) +{ + fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); +} + +void +kgdb_trgt_new_objfile(struct objfile *objfile) +{ +} + +struct kgdb_frame_cache { + CORE_ADDR pc; + CORE_ADDR sp; +}; + +static int kgdb_trgt_frame_offset[20] = { + offsetof(struct trapframe, tf_rax), + offsetof(struct trapframe, tf_rbx), + offsetof(struct trapframe, tf_rcx), + offsetof(struct trapframe, tf_rdx), + offsetof(struct trapframe, tf_rsi), + offsetof(struct trapframe, tf_rdi), + offsetof(struct trapframe, tf_rbp), + offsetof(struct trapframe, tf_rsp), + offsetof(struct trapframe, tf_r8), + offsetof(struct trapframe, tf_r9), + offsetof(struct trapframe, tf_r10), + offsetof(struct trapframe, tf_r11), + offsetof(struct trapframe, tf_r12), + offsetof(struct trapframe, tf_r13), + offsetof(struct trapframe, tf_r14), + offsetof(struct trapframe, tf_r15), + offsetof(struct trapframe, tf_rip), + offsetof(struct trapframe, tf_rflags), + offsetof(struct trapframe, tf_cs), + offsetof(struct trapframe, tf_ss) +}; + +static struct kgdb_frame_cache * +kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) +{ + char buf[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + + cache = *this_cache; + if (cache == NULL) { + cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); + *this_cache = cache; + cache->pc = frame_func_unwind(next_frame); + frame_unwind_register(next_frame, SP_REGNUM, buf); + cache->sp = extract_unsigned_integer(buf, + register_size(current_gdbarch, SP_REGNUM)); + } + return (cache); +} + +static void +kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, + struct frame_id *this_id) +{ + struct kgdb_frame_cache *cache; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *this_id = frame_id_build(cache->sp, cache->pc); +} + +static void +kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, + void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, + CORE_ADDR *addrp, int *realnump, void *valuep) +{ + char dummy_valuep[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + int ofs, regsz; + + regsz = register_size(current_gdbarch, regnum); + + if (valuep == NULL) + valuep = dummy_valuep; + memset(valuep, 0, regsz); + *optimizedp = 0; + *addrp = 0; + *lvalp = not_lval; + *realnump = -1; + + ofs = (regnum >= AMD64_RAX_REGNUM && regnum <= AMD64_EFLAGS_REGNUM + 2) + ? kgdb_trgt_frame_offset[regnum] : -1; + if (ofs == -1) + return; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *addrp = cache->sp + ofs; + *lvalp = lval_memory; + target_read_memory(*addrp, valuep, regsz); +} + +static const struct frame_unwind kgdb_trgt_trapframe_unwind = { + UNKNOWN_FRAME, + &kgdb_trgt_trapframe_this_id, + &kgdb_trgt_trapframe_prev_register +}; + +const struct frame_unwind * +kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) +{ + char *pname; + CORE_ADDR pc; + + pc = frame_pc_unwind(next_frame); + pname = NULL; + find_pc_partial_function(pc, &pname, NULL, NULL); + if (pname == NULL) + return (NULL); + if (strcmp(pname, "calltrap") == 0 || + strcmp(pname, "fast_syscall_common") == 0 || + strcmp(pname, "mchk_calltrap") == 0 || + strcmp(pname, "nmi_calltrap") == 0 || + (pname[0] == 'X' && pname[1] != '_')) + return (&kgdb_trgt_trapframe_unwind); + /* printf("%s: %lx =%s\n", __func__, pc, pname); */ + return (NULL); +} + +/* + * This function ensures, that the PC is inside the + * function section which is understood by GDB. + * + * Return 0 when fixup is necessary, -1 otherwise. + */ +int +kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) +{ + + return (-1); +} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_arm.c b/gnu/usr.bin/gdb/kgdb/trgt_arm.c new file mode 100644 index 000000000000..13111bc43469 --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/trgt_arm.c @@ -0,0 +1,286 @@ +/* + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#ifndef CROSS_DEBUGGER +#include <machine/pcb.h> +#include <machine/frame.h> +#include <machine/armreg.h> +#endif +#include <err.h> +#include <kvm.h> +#include <string.h> + +#include <defs.h> +#include <target.h> +#include <gdbthread.h> +#include <inferior.h> +#include <regcache.h> +#include <frame-unwind.h> +#include <arm-tdep.h> + +#include "kgdb.h" + +CORE_ADDR +kgdb_trgt_core_pcb(u_int cpuid) +{ +#ifndef CROSS_DEBUGGER + return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); +#else + return -1; +#endif +} + +void +kgdb_trgt_fetch_registers(int regno __unused) +{ +#ifndef CROSS_DEBUGGER + struct kthr *kt; + struct pcb pcb; + int i; + + kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); + if (kt == NULL) + return; + if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + memset(&pcb, 0, sizeof(pcb)); + } + for (i = ARM_A1_REGNUM + 4; i <= ARM_SP_REGNUM; i++) { + supply_register(i, (char *)&pcb.pcb_regs.sf_r4 + + (i - (ARM_A1_REGNUM + 4 )) * 4); + } + supply_register(ARM_PC_REGNUM, (char *)&pcb.pcb_regs.sf_pc); + supply_register(ARM_LR_REGNUM, (char *)&pcb.pcb_regs.sf_lr); +#endif +} + +void +kgdb_trgt_store_registers(int regno __unused) +{ + fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); +} + +void +kgdb_trgt_new_objfile(struct objfile *objfile) +{ +} + +#ifndef CROSS_DEBUGGER +struct kgdb_frame_cache { + CORE_ADDR fp; + CORE_ADDR sp; + CORE_ADDR pc; +}; + +static int kgdb_trgt_frame_offset[26] = { + offsetof(struct trapframe, tf_r0), + offsetof(struct trapframe, tf_r1), + offsetof(struct trapframe, tf_r2), + offsetof(struct trapframe, tf_r3), + offsetof(struct trapframe, tf_r4), + offsetof(struct trapframe, tf_r5), + offsetof(struct trapframe, tf_r6), + offsetof(struct trapframe, tf_r7), + offsetof(struct trapframe, tf_r8), + offsetof(struct trapframe, tf_r9), + offsetof(struct trapframe, tf_r10), + offsetof(struct trapframe, tf_r11), + offsetof(struct trapframe, tf_r12), + offsetof(struct trapframe, tf_svc_sp), + offsetof(struct trapframe, tf_svc_lr), + offsetof(struct trapframe, tf_pc), + -1, -1, -1, -1, -1, -1, -1, -1, -1, + offsetof(struct trapframe, tf_spsr) +}; + +static struct kgdb_frame_cache * +kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) +{ + char buf[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + + cache = *this_cache; + if (cache == NULL) { + cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); + *this_cache = cache; + frame_unwind_register(next_frame, ARM_SP_REGNUM, buf); + cache->sp = extract_unsigned_integer(buf, + register_size(current_gdbarch, ARM_SP_REGNUM)); + frame_unwind_register(next_frame, ARM_FP_REGNUM, buf); + cache->fp = extract_unsigned_integer(buf, + register_size(current_gdbarch, ARM_FP_REGNUM)); + cache->pc = frame_func_unwind(next_frame); + } + return (cache); +} + +static int is_undef; + +static void +kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, + struct frame_id *this_id) +{ + struct kgdb_frame_cache *cache; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *this_id = frame_id_build(cache->sp, cache->pc); +} + +static void +kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, + void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, + CORE_ADDR *addrp, int *realnump, void *valuep) +{ + char dummy_valuep[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + int ofs, regsz; + CORE_ADDR sp; + + regsz = register_size(current_gdbarch, regnum); + + if (valuep == NULL) + valuep = dummy_valuep; + memset(valuep, 0, regsz); + *optimizedp = 0; + *addrp = 0; + *lvalp = not_lval; + *realnump = -1; + + ofs = (regnum >= 0 && regnum <= ARM_PS_REGNUM) + ? kgdb_trgt_frame_offset[regnum] : -1; + if (ofs == -1) + return; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + sp = cache->sp; + + ofs = kgdb_trgt_frame_offset[regnum]; + *addrp = sp + ofs; + *lvalp = lval_memory; + target_read_memory(*addrp, valuep, regsz); +} + +static const struct frame_unwind kgdb_trgt_trapframe_unwind = { + UNKNOWN_FRAME, + &kgdb_trgt_trapframe_this_id, + &kgdb_trgt_trapframe_prev_register +}; +#endif + +const struct frame_unwind * +kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) +{ +#ifndef CROSS_DEBUGGER + char *pname; + CORE_ADDR pc; + + pc = frame_pc_unwind(next_frame); + pname = NULL; + find_pc_partial_function(pc, &pname, NULL, NULL); + if (pname == NULL) { + is_undef = 0; + return (NULL); + } + if (!strcmp(pname, "undefinedinstruction")) + is_undef = 1; + if (strcmp(pname, "Laddress_exception_entry") == 0 || + strcmp(pname, "undefined_entry") == 0 || + strcmp(pname, "exception_exit") == 0 || + strcmp(pname, "Laddress_exception_msg") == 0 || + strcmp(pname, "irq_entry") == 0) + return (&kgdb_trgt_trapframe_unwind); + if (!strcmp(pname, "undefinedinstruction")) + is_undef = 1; + else + is_undef = 0; +#endif + return (NULL); +} + +/* + * This function ensures, that the PC is inside the + * function section which is understood by GDB. + * + * Return 0 when fixup is necessary, -1 otherwise. + */ +int +kgdb_trgt_pc_fixup(CORE_ADDR *pc) +{ +#ifndef CROSS_DEBUGGER + struct minimal_symbol *msymbol; + int valpc; + + /* + * exception_exit and swi_exit are special. These functions + * are artificially injected into the stack to be executed + * as the last entry in calling chain when all functions exit. + * Treat them differently. + */ + msymbol = lookup_minimal_symbol_by_pc(*pc); + if (msymbol != NULL) { + if (strcmp(DEPRECATED_SYMBOL_NAME(msymbol), "exception_exit") == 0) + return (0); + if (strcmp(DEPRECATED_SYMBOL_NAME(msymbol), "swi_exit") == 0) + return (0); + } + + /* + * kdb_enter contains an invalid instruction which is supposed + * to generate a trap. BFD does not understand it and treats + * this part of function as a separate function. Move PC + * two instruction earlier to be inside kdb_enter section. + */ + target_read_memory(*pc - 4, (char*)&valpc, 4); + if (valpc == 0xe7ffffff) { + *pc = *pc - 8; + return (0); + } + + /* + * When the panic/vpanic is the last (noreturn) function, + * the bottom of the calling function looks as below. + * mov lr, pc + * b panic + * Normally, GDB is not able to detect function boundaries, + * so move the PC two instruction earlier where it can deal + * with it. + * Match this pair of instructions: mov lr, pc followed with + * non-linked branch. + */ + if ((valpc & 0xff000000) == 0xea000000) { + target_read_memory(*pc - 8, (char*)&valpc, 4); + if (valpc == 0xe1a0e00f) { + *pc -= 8; + return (0); + } + } +#endif + return (-1); +} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_i386.c b/gnu/usr.bin/gdb/kgdb/trgt_i386.c new file mode 100644 index 000000000000..b90eebaaf35e --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/trgt_i386.c @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/proc.h> +#include <vm/vm.h> +#include <vm/pmap.h> +#include <machine/pcb.h> +#include <machine/frame.h> +#include <machine/segments.h> +#include <machine/tss.h> +#include <err.h> +#include <kvm.h> +#include <string.h> + +#include <defs.h> +#include <target.h> +#include <gdbthread.h> +#include <inferior.h> +#include <regcache.h> +#include <frame-unwind.h> +#include <i386-tdep.h> + +#include "kgdb.h" + +static int ofs_fix; + +CORE_ADDR +kgdb_trgt_core_pcb(u_int cpuid) +{ + return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); +} + +void +kgdb_trgt_fetch_registers(int regno __unused) +{ + struct kthr *kt; + struct pcb pcb; + + kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); + if (kt == NULL) + return; + if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + memset(&pcb, 0, sizeof(pcb)); + } + supply_register(I386_EBX_REGNUM, (char *)&pcb.pcb_ebx); + supply_register(I386_ESP_REGNUM, (char *)&pcb.pcb_esp); + supply_register(I386_EBP_REGNUM, (char *)&pcb.pcb_ebp); + supply_register(I386_ESI_REGNUM, (char *)&pcb.pcb_esi); + supply_register(I386_EDI_REGNUM, (char *)&pcb.pcb_edi); + supply_register(I386_EIP_REGNUM, (char *)&pcb.pcb_eip); +} + +void +kgdb_trgt_store_registers(int regno __unused) +{ + fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); +} + +void +kgdb_trgt_new_objfile(struct objfile *objfile) +{ + + /* + * In revision 1.117 of i386/i386/exception.S trap handlers + * were changed to pass trapframes by reference rather than + * by value. Detect this by seeing if the first instruction + * at the 'calltrap' label is a "push %esp" which has the + * opcode 0x54. + */ + if (kgdb_parse("((char *)calltrap)[0]") == 0x54) + ofs_fix = 4; + else + ofs_fix = 0; +} + +struct kgdb_tss_cache { + CORE_ADDR pc; + CORE_ADDR sp; + CORE_ADDR tss; +}; + +static int kgdb_trgt_tss_offset[15] = { + offsetof(struct i386tss, tss_eax), + offsetof(struct i386tss, tss_ecx), + offsetof(struct i386tss, tss_edx), + offsetof(struct i386tss, tss_ebx), + offsetof(struct i386tss, tss_esp), + offsetof(struct i386tss, tss_ebp), + offsetof(struct i386tss, tss_esi), + offsetof(struct i386tss, tss_edi), + offsetof(struct i386tss, tss_eip), + offsetof(struct i386tss, tss_eflags), + offsetof(struct i386tss, tss_cs), + offsetof(struct i386tss, tss_ss), + offsetof(struct i386tss, tss_ds), + offsetof(struct i386tss, tss_es), + offsetof(struct i386tss, tss_fs) +}; + +/* + * If the current thread is executing on a CPU, fetch the common_tss + * for that CPU. + * + * This is painful because 'struct pcpu' is variant sized, so we can't + * use it. Instead, we lookup the GDT selector for this CPU and + * extract the base of the TSS from there. + */ +static CORE_ADDR +kgdb_trgt_fetch_tss(void) +{ + struct kthr *kt; + struct segment_descriptor sd; + uintptr_t addr, cpu0prvpage, tss; + + kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); + if (kt == NULL || kt->cpu == NOCPU || kt->cpu < 0) + return (0); + + addr = kgdb_lookup("gdt"); + if (addr == 0) + return (0); + addr += (kt->cpu * NGDT + GPROC0_SEL) * sizeof(sd); + if (kvm_read(kvm, addr, &sd, sizeof(sd)) != sizeof(sd)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + return (0); + } + if (sd.sd_type != SDT_SYS386BSY) { + warnx("descriptor is not a busy TSS"); + return (0); + } + tss = sd.sd_hibase << 24 | sd.sd_lobase; + + /* + * In SMP kernels, the TSS is stored as part of the per-CPU + * data. On older kernels, the CPU0's private page + * is stored at an address that isn't mapped in minidumps. + * However, the data is mapped at the alternate cpu0prvpage + * address. Thus, if the TSS is at the invalid address, + * change it to be relative to cpu0prvpage instead. + */ + if (trunc_page(tss) == 0xffc00000) { + addr = kgdb_lookup("cpu0prvpage"); + if (addr == 0) + return (0); + if (kvm_read(kvm, addr, &cpu0prvpage, sizeof(cpu0prvpage)) != + sizeof(cpu0prvpage)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + return (0); + } + tss = cpu0prvpage + (tss & PAGE_MASK); + } + return ((CORE_ADDR)tss); +} + +static struct kgdb_tss_cache * +kgdb_trgt_tss_cache(struct frame_info *next_frame, void **this_cache) +{ + char buf[MAX_REGISTER_SIZE]; + struct kgdb_tss_cache *cache; + + cache = *this_cache; + if (cache == NULL) { + cache = FRAME_OBSTACK_ZALLOC(struct kgdb_tss_cache); + *this_cache = cache; + cache->pc = frame_func_unwind(next_frame); + frame_unwind_register(next_frame, SP_REGNUM, buf); + cache->sp = extract_unsigned_integer(buf, + register_size(current_gdbarch, SP_REGNUM)); + cache->tss = kgdb_trgt_fetch_tss(); + } + return (cache); +} + +static void +kgdb_trgt_dblfault_this_id(struct frame_info *next_frame, void **this_cache, + struct frame_id *this_id) +{ + struct kgdb_tss_cache *cache; + + cache = kgdb_trgt_tss_cache(next_frame, this_cache); + *this_id = frame_id_build(cache->sp, cache->pc); +} + +static void +kgdb_trgt_dblfault_prev_register(struct frame_info *next_frame, + void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, + CORE_ADDR *addrp, int *realnump, void *valuep) +{ + char dummy_valuep[MAX_REGISTER_SIZE]; + struct kgdb_tss_cache *cache; + int ofs, regsz; + + regsz = register_size(current_gdbarch, regnum); + + if (valuep == NULL) + valuep = dummy_valuep; + memset(valuep, 0, regsz); + *optimizedp = 0; + *addrp = 0; + *lvalp = not_lval; + *realnump = -1; + + ofs = (regnum >= I386_EAX_REGNUM && regnum <= I386_FS_REGNUM) + ? kgdb_trgt_tss_offset[regnum] : -1; + if (ofs == -1) + return; + + cache = kgdb_trgt_tss_cache(next_frame, this_cache); + if (cache->tss == 0) + return; + *addrp = cache->tss + ofs; + *lvalp = lval_memory; + target_read_memory(*addrp, valuep, regsz); +} + +static const struct frame_unwind kgdb_trgt_dblfault_unwind = { + UNKNOWN_FRAME, + &kgdb_trgt_dblfault_this_id, + &kgdb_trgt_dblfault_prev_register +}; + +struct kgdb_frame_cache { + int frame_type; + CORE_ADDR pc; + CORE_ADDR sp; +}; +#define FT_NORMAL 1 +#define FT_INTRFRAME 2 +#define FT_INTRTRAPFRAME 3 +#define FT_TIMERFRAME 4 + +static int kgdb_trgt_frame_offset[15] = { + offsetof(struct trapframe, tf_eax), + offsetof(struct trapframe, tf_ecx), + offsetof(struct trapframe, tf_edx), + offsetof(struct trapframe, tf_ebx), + offsetof(struct trapframe, tf_esp), + offsetof(struct trapframe, tf_ebp), + offsetof(struct trapframe, tf_esi), + offsetof(struct trapframe, tf_edi), + offsetof(struct trapframe, tf_eip), + offsetof(struct trapframe, tf_eflags), + offsetof(struct trapframe, tf_cs), + offsetof(struct trapframe, tf_ss), + offsetof(struct trapframe, tf_ds), + offsetof(struct trapframe, tf_es), + offsetof(struct trapframe, tf_fs) +}; + +static struct kgdb_frame_cache * +kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) +{ + char buf[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + char *pname; + CORE_ADDR pcx; + uintptr_t addr, setidt_disp; + + cache = *this_cache; + if (cache == NULL) { + cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); + *this_cache = cache; + pcx = frame_pc_unwind(next_frame); + if (pcx >= PMAP_TRM_MIN_ADDRESS) { + addr = kgdb_lookup("setidt_disp"); + if (addr != 0) { + if (kvm_read(kvm, addr, &setidt_disp, + sizeof(setidt_disp)) != + sizeof(setidt_disp)) + warnx("kvm_read: %s", kvm_geterr(kvm)); + else + pcx -= setidt_disp; + } + } + cache->pc = pcx; + find_pc_partial_function(cache->pc, &pname, NULL, NULL); + if (pname[0] != 'X') + cache->frame_type = FT_NORMAL; + else if (strcmp(pname, "Xtimerint") == 0) + cache->frame_type = FT_TIMERFRAME; + else if (strcmp(pname, "Xcpustop") == 0 || + strcmp(pname, "Xrendezvous") == 0 || + strcmp(pname, "Xipi_intr_bitmap_handler") == 0 || + strcmp(pname, "Xlazypmap") == 0) + cache->frame_type = FT_INTRTRAPFRAME; + else + cache->frame_type = FT_INTRFRAME; + frame_unwind_register(next_frame, SP_REGNUM, buf); + cache->sp = extract_unsigned_integer(buf, + register_size(current_gdbarch, SP_REGNUM)); + } + return (cache); +} + +static void +kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, + struct frame_id *this_id) +{ + struct kgdb_frame_cache *cache; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *this_id = frame_id_build(cache->sp, cache->pc); +} + +static void +kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, + void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, + CORE_ADDR *addrp, int *realnump, void *valuep) +{ + char dummy_valuep[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + int ofs, regsz; + + regsz = register_size(current_gdbarch, regnum); + + if (valuep == NULL) + valuep = dummy_valuep; + memset(valuep, 0, regsz); + *optimizedp = 0; + *addrp = 0; + *lvalp = not_lval; + *realnump = -1; + + ofs = (regnum >= I386_EAX_REGNUM && regnum <= I386_FS_REGNUM) + ? kgdb_trgt_frame_offset[regnum] + ofs_fix : -1; + if (ofs == -1) + return; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + switch (cache->frame_type) { + case FT_NORMAL: + break; + case FT_INTRFRAME: + ofs += 4; + break; + case FT_TIMERFRAME: + break; + case FT_INTRTRAPFRAME: + ofs -= ofs_fix; + break; + default: + fprintf_unfiltered(gdb_stderr, "Correct FT_XXX frame offsets " + "for %d\n", cache->frame_type); + break; + } + *addrp = cache->sp + ofs; + *lvalp = lval_memory; + target_read_memory(*addrp, valuep, regsz); +} + +static const struct frame_unwind kgdb_trgt_trapframe_unwind = { + UNKNOWN_FRAME, + &kgdb_trgt_trapframe_this_id, + &kgdb_trgt_trapframe_prev_register +}; + +const struct frame_unwind * +kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) +{ + char *pname; + CORE_ADDR pc; + + pc = frame_pc_unwind(next_frame); + if (pc >= PMAP_TRM_MIN_ADDRESS) + return (&kgdb_trgt_trapframe_unwind); + pname = NULL; + find_pc_partial_function(pc, &pname, NULL, NULL); + if (pname == NULL) + return (NULL); + if (strcmp(pname, "dblfault_handler") == 0) + return (&kgdb_trgt_dblfault_unwind); + if (strcmp(pname, "calltrap") == 0 || + (pname[0] == 'X' && pname[1] != '_')) + return (&kgdb_trgt_trapframe_unwind); + /* printf("%s: %llx =%s\n", __func__, pc, pname); */ + return (NULL); +} + +/* + * This function ensures, that the PC is inside the + * function section which is understood by GDB. + * + * Return 0 when fixup is necessary, -1 otherwise. + */ +int +kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) +{ + + return (-1); +} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_mips.c b/gnu/usr.bin/gdb/kgdb/trgt_mips.c new file mode 100644 index 000000000000..17ea6fe4ca1a --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/trgt_mips.c @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2007 Juniper Networks, Inc. + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * from: src/gnu/usr.bin/gdb/kgdb/trgt_alpha.c,v 1.2.2.1 2005/09/15 05:32:10 marcel + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <machine/asm.h> +#include <machine/pcb.h> +#include <machine/frame.h> +#include <err.h> +#include <kvm.h> +#include <string.h> + +#include <defs.h> +#include <target.h> +#include <gdbthread.h> +#include <inferior.h> +#include <regcache.h> +#include <frame-unwind.h> +#include <mips-tdep.h> + +#ifndef CROSS_DEBUGGER +#include <machine/pcb.h> +#endif + +#include "kgdb.h" + +CORE_ADDR +kgdb_trgt_core_pcb(u_int cpuid) +{ + return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); +} + +void +kgdb_trgt_fetch_registers(int regno __unused) +{ +#ifndef CROSS_DEBUGGER + struct kthr *kt; + struct pcb pcb; + + kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); + if (kt == NULL) + return; + if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + memset(&pcb, 0, sizeof(pcb)); + } + + supply_register(MIPS_S0_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S0]); + supply_register(MIPS_S1_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S1]); + supply_register(MIPS_S2_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S2]); + supply_register(MIPS_S3_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S3]); + supply_register(MIPS_S4_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S4]); + supply_register(MIPS_S5_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S5]); + supply_register(MIPS_S6_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S6]); + supply_register(MIPS_S7_REGNUM, (char *)&pcb.pcb_context[PCB_REG_S7]); + supply_register(MIPS_SP_REGNUM, (char *)&pcb.pcb_context[PCB_REG_SP]); + supply_register(MIPS_FP_REGNUM, (char *)&pcb.pcb_context[PCB_REG_GP]); + supply_register(MIPS_RA_REGNUM, (char *)&pcb.pcb_context[PCB_REG_RA]); + supply_register(MIPS_EMBED_PC_REGNUM, (char *)&pcb.pcb_context[PCB_REG_PC]); +#endif +} + +void +kgdb_trgt_store_registers(int regno __unused) +{ + + fprintf_unfiltered(gdb_stderr, "Unimplemented function: %s\n", __func__); +} + +void +kgdb_trgt_new_objfile(struct objfile *objfile) +{ +} + +#ifndef CROSS_DEBUGGER +struct kgdb_frame_cache { + CORE_ADDR pc; + CORE_ADDR sp; +}; + +static int kgdb_trgt_frame_offset[] = { + offsetof(struct trapframe, zero), + offsetof(struct trapframe, ast), + offsetof(struct trapframe, v0), + offsetof(struct trapframe, v1), + offsetof(struct trapframe, a0), + offsetof(struct trapframe, a1), + offsetof(struct trapframe, a2), + offsetof(struct trapframe, a3), +#if defined(__mips_n32) || defined(__mips_n64) + offsetof(struct trapframe, a4), + offsetof(struct trapframe, a5), + offsetof(struct trapframe, a6), + offsetof(struct trapframe, a7), + offsetof(struct trapframe, t0), + offsetof(struct trapframe, t1), + offsetof(struct trapframe, t2), + offsetof(struct trapframe, t3), +#else + offsetof(struct trapframe, t0), + offsetof(struct trapframe, t1), + offsetof(struct trapframe, t2), + offsetof(struct trapframe, t3), + offsetof(struct trapframe, t4), + offsetof(struct trapframe, t5), + offsetof(struct trapframe, t6), + offsetof(struct trapframe, t7), +#endif + offsetof(struct trapframe, s0), + offsetof(struct trapframe, s1), + offsetof(struct trapframe, s2), + offsetof(struct trapframe, s3), + offsetof(struct trapframe, s4), + offsetof(struct trapframe, s5), + offsetof(struct trapframe, s6), + offsetof(struct trapframe, s7), + offsetof(struct trapframe, t8), + offsetof(struct trapframe, t9), + offsetof(struct trapframe, k0), + offsetof(struct trapframe, k1), + offsetof(struct trapframe, gp), + offsetof(struct trapframe, sp), + offsetof(struct trapframe, s8), + offsetof(struct trapframe, ra), +}; + +static struct kgdb_frame_cache * +kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) +{ + char buf[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + + cache = *this_cache; + if (cache == NULL) { + cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); + *this_cache = cache; + cache->pc = frame_func_unwind(next_frame); + frame_unwind_register(next_frame, SP_REGNUM, buf); + cache->sp = extract_unsigned_integer(buf, + register_size(current_gdbarch, SP_REGNUM)); + } + return (cache); +} + +static void +kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, + struct frame_id *this_id) +{ + struct kgdb_frame_cache *cache; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *this_id = frame_id_build(cache->sp, cache->pc); +} + +static void +kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame __unused, + void **this_cache __unused, int regnum __unused, int *optimizedp __unused, + enum lval_type *lvalp __unused, CORE_ADDR *addrp __unused, + int *realnump __unused, void *valuep __unused) +{ + char dummy_valuep[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + int ofs, regsz; + + regsz = register_size(current_gdbarch, regnum); + + if (valuep == NULL) + valuep = dummy_valuep; + memset(valuep, 0, regsz); + *optimizedp = 0; + *addrp = 0; + *lvalp = not_lval; + *realnump = -1; + + ofs = (regnum >= 0 && regnum <= MIPS_RA_REGNUM) ? + kgdb_trgt_frame_offset[regnum] : -1; + if (ofs == -1) + return; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *addrp = cache->sp + ofs * 8; + *lvalp = lval_memory; + target_read_memory(*addrp, valuep, regsz); +} + +static const struct frame_unwind kgdb_trgt_trapframe_unwind = { + UNKNOWN_FRAME, + &kgdb_trgt_trapframe_this_id, + &kgdb_trgt_trapframe_prev_register +}; +#endif + +const struct frame_unwind * +kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) +{ +#ifndef CROSS_DEBUGGER + char *pname; + CORE_ADDR pc; + + pc = frame_pc_unwind(next_frame); + pname = NULL; + find_pc_partial_function(pc, &pname, NULL, NULL); + if (pname == NULL) + return (NULL); + if ((strcmp(pname, "MipsKernIntr") == 0) || + (strcmp(pname, "MipsKernGenException") == 0) || + (strcmp(pname, "MipsUserIntr") == 0) || + (strcmp(pname, "MipsUserGenException") == 0)) + return (&kgdb_trgt_trapframe_unwind); +#endif + return (NULL); +} + +/* + * This function ensures, that the PC is inside the + * function section which is understood by GDB. + * + * Return 0 when fixup is necessary, -1 otherwise. + */ +int +kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) +{ + + return (-1); +} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c b/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c new file mode 100644 index 000000000000..703cc0f716f9 --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c @@ -0,0 +1,214 @@ +/*- + * Copyright (c) 2006 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#ifdef CROSS_DEBUGGER +#include <sys/powerpc/include/pcb.h> +#include <sys/powerpc/include/frame.h> +#else +#include <machine/pcb.h> +#include <machine/frame.h> +#endif +#include <err.h> +#include <kvm.h> +#include <string.h> + +#include <defs.h> +#include <target.h> +#include <gdbthread.h> +#include <inferior.h> +#include <regcache.h> +#include <frame-unwind.h> +#include <ppc-tdep.h> + +#include "kgdb.h" + +CORE_ADDR +kgdb_trgt_core_pcb(u_int cpuid) +{ + return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); +} + +void +kgdb_trgt_fetch_registers(int regno __unused) +{ + struct kthr *kt; + struct pcb pcb; + struct gdbarch_tdep *tdep; + int i; + + tdep = gdbarch_tdep (current_gdbarch); + + kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); + if (kt == NULL) + return; + if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + memset(&pcb, 0, sizeof(pcb)); + } + + /* + * r14-r31 are saved in the pcb + */ + for (i = 14; i <= 31; i++) { + supply_register(tdep->ppc_gp0_regnum + i, + (char *)&pcb.pcb_context[i]); + } + + /* r1 is saved in the sp field */ + supply_register(tdep->ppc_gp0_regnum + 1, (char *)&pcb.pcb_sp); + + supply_register(tdep->ppc_lr_regnum, (char *)&pcb.pcb_lr); + supply_register(tdep->ppc_cr_regnum, (char *)&pcb.pcb_cr); +} + +void +kgdb_trgt_store_registers(int regno __unused) +{ + fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); +} + +void +kgdb_trgt_new_objfile(struct objfile *objfile) +{ +} + +struct kgdb_frame_cache { + CORE_ADDR pc; + CORE_ADDR sp; +}; + +static struct kgdb_frame_cache * +kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) +{ + char buf[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + + cache = *this_cache; + if (cache == NULL) { + cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); + *this_cache = cache; + cache->pc = frame_func_unwind(next_frame); + frame_unwind_register(next_frame, SP_REGNUM, buf); + cache->sp = extract_unsigned_integer(buf, + register_size(current_gdbarch, SP_REGNUM)); + } + return (cache); +} + +static void +kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, + struct frame_id *this_id) +{ + struct kgdb_frame_cache *cache; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *this_id = frame_id_build(cache->sp, cache->pc); +} + +static void +kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, + void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, + CORE_ADDR *addrp, int *realnump, void *valuep) +{ + char dummy_valuep[MAX_REGISTER_SIZE]; + struct gdbarch_tdep *tdep; + struct kgdb_frame_cache *cache; + int ofs, regsz; + + tdep = gdbarch_tdep(current_gdbarch); + regsz = register_size(current_gdbarch, regnum); + + if (valuep == NULL) + valuep = dummy_valuep; + memset(valuep, 0, regsz); + *optimizedp = 0; + *addrp = 0; + *lvalp = not_lval; + *realnump = -1; + + if (regnum >= tdep->ppc_gp0_regnum && + regnum <= tdep->ppc_gplast_regnum) + ofs = offsetof(struct trapframe, + fixreg[regnum - tdep->ppc_gp0_regnum]); + else if (regnum == tdep->ppc_lr_regnum) + ofs = offsetof(struct trapframe, lr); + else if (regnum == tdep->ppc_cr_regnum) + ofs = offsetof(struct trapframe, cr); + else if (regnum == tdep->ppc_xer_regnum) + ofs = offsetof(struct trapframe, xer); + else if (regnum == tdep->ppc_ctr_regnum) + ofs = offsetof(struct trapframe, ctr); + else if (regnum == PC_REGNUM) + ofs = offsetof(struct trapframe, srr0); + else + return; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *addrp = cache->sp + 8 + ofs; + *lvalp = lval_memory; + target_read_memory(*addrp, valuep, regsz); +} + +static const struct frame_unwind kgdb_trgt_trapframe_unwind = { + UNKNOWN_FRAME, + &kgdb_trgt_trapframe_this_id, + &kgdb_trgt_trapframe_prev_register +}; + +const struct frame_unwind * +kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) +{ + char *pname; + CORE_ADDR pc; + + pc = frame_pc_unwind(next_frame); + pname = NULL; + find_pc_partial_function(pc, &pname, NULL, NULL); + if (pname == NULL) + return (NULL); + if (strcmp(pname, "asttrapexit") == 0 || + strcmp(pname, "trapexit") == 0) + return (&kgdb_trgt_trapframe_unwind); + /* printf("%s: %llx =%s\n", __func__, pc, pname); */ + return (NULL); +} + +/* + * This function ensures, that the PC is inside the + * function section which is understood by GDB. + * + * Return 0 when fixup is necessary, -1 otherwise. + */ +int +kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) +{ + + return (-1); +} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_powerpc64.c b/gnu/usr.bin/gdb/kgdb/trgt_powerpc64.c new file mode 100644 index 000000000000..bfb0d7eed875 --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/trgt_powerpc64.c @@ -0,0 +1,211 @@ +/*- + * Copyright (c) 2006 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <machine/pcb.h> +#include <machine/frame.h> +#include <err.h> +#include <kvm.h> +#include <string.h> + +#include <defs.h> +#include <target.h> +#include <gdbthread.h> +#include <inferior.h> +#include <regcache.h> +#include <frame-unwind.h> +#include <ppc-tdep.h> + +#include "kgdb.h" + +CORE_ADDR +kgdb_trgt_core_pcb(u_int cpuid) +{ + return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); +} + +void +kgdb_trgt_fetch_registers(int regno __unused) +{ + struct kthr *kt; + struct pcb pcb; + struct gdbarch_tdep *tdep; + int i; + + tdep = gdbarch_tdep (current_gdbarch); + + kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); + if (kt == NULL) + return; + if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + memset(&pcb, 0, sizeof(pcb)); + } + + /* + * r14-r31 are saved in the pcb + */ + for (i = 14; i <= 31; i++) { + supply_register(tdep->ppc_gp0_regnum + i, + (char *)&pcb.pcb_context[i]); + } + + /* r1 is saved in the sp field */ + supply_register(tdep->ppc_gp0_regnum + 1, (char *)&pcb.pcb_sp); + /* r2 is saved in the toc field */ + supply_register(tdep->ppc_gp0_regnum + 2, (char *)&pcb.pcb_toc); + + supply_register(tdep->ppc_lr_regnum, (char *)&pcb.pcb_lr); + supply_register(tdep->ppc_cr_regnum, (char *)&pcb.pcb_cr); +} + +void +kgdb_trgt_store_registers(int regno __unused) +{ + fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); +} + +void +kgdb_trgt_new_objfile(struct objfile *objfile) +{ +} + +struct kgdb_frame_cache { + CORE_ADDR pc; + CORE_ADDR sp; +}; + +static struct kgdb_frame_cache * +kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) +{ + char buf[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + + cache = *this_cache; + if (cache == NULL) { + cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); + *this_cache = cache; + cache->pc = frame_func_unwind(next_frame); + frame_unwind_register(next_frame, SP_REGNUM, buf); + cache->sp = extract_unsigned_integer(buf, + register_size(current_gdbarch, SP_REGNUM)); + } + return (cache); +} + +static void +kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, + struct frame_id *this_id) +{ + struct kgdb_frame_cache *cache; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *this_id = frame_id_build(cache->sp, cache->pc); +} + +static void +kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, + void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, + CORE_ADDR *addrp, int *realnump, void *valuep) +{ + char dummy_valuep[MAX_REGISTER_SIZE]; + struct gdbarch_tdep *tdep; + struct kgdb_frame_cache *cache; + int ofs, regsz; + + tdep = gdbarch_tdep(current_gdbarch); + regsz = register_size(current_gdbarch, regnum); + + if (valuep == NULL) + valuep = dummy_valuep; + memset(valuep, 0, regsz); + *optimizedp = 0; + *addrp = 0; + *lvalp = not_lval; + *realnump = -1; + + if (regnum >= tdep->ppc_gp0_regnum && + regnum <= tdep->ppc_gplast_regnum) + ofs = offsetof(struct trapframe, + fixreg[regnum - tdep->ppc_gp0_regnum]); + else if (regnum == tdep->ppc_lr_regnum) + ofs = offsetof(struct trapframe, lr); + else if (regnum == tdep->ppc_cr_regnum) + ofs = offsetof(struct trapframe, cr); + else if (regnum == tdep->ppc_xer_regnum) + ofs = offsetof(struct trapframe, xer); + else if (regnum == tdep->ppc_ctr_regnum) + ofs = offsetof(struct trapframe, ctr); + else if (regnum == PC_REGNUM) + ofs = offsetof(struct trapframe, srr0); + else + return; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *addrp = cache->sp + 48 + ofs; + *lvalp = lval_memory; + target_read_memory(*addrp, valuep, regsz); +} + +static const struct frame_unwind kgdb_trgt_trapframe_unwind = { + UNKNOWN_FRAME, + &kgdb_trgt_trapframe_this_id, + &kgdb_trgt_trapframe_prev_register +}; + +const struct frame_unwind * +kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) +{ + char *pname; + CORE_ADDR pc; + + pc = frame_pc_unwind(next_frame); + pname = NULL; + find_pc_partial_function(pc, &pname, NULL, NULL); + if (pname == NULL) + return (NULL); + if (strcmp(pname, "asttrapexit") == 0 || + strcmp(pname, "trapexit") == 0) + return (&kgdb_trgt_trapframe_unwind); + /* printf("%s: %llx =%s\n", __func__, pc, pname); */ + return (NULL); +} + +/* + * This function ensures, that the PC is inside the + * function section which is understood by GDB. + * + * Return 0 when fixup is necessary, -1 otherwise. + */ +int +kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) +{ + + return (-1); +} diff --git a/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c b/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c new file mode 100644 index 000000000000..b39299f40918 --- /dev/null +++ b/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2004 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <machine/asm.h> +#include <machine/pcb.h> +#include <machine/frame.h> +#include <err.h> +#include <kvm.h> +#include <string.h> + +#include <defs.h> +#include <target.h> +#include <gdbthread.h> +#include <inferior.h> +#include <regcache.h> +#include <frame-unwind.h> +#include <sparc-tdep.h> +#include <sparc64-tdep.h> + +#include "kgdb.h" + +CORE_ADDR +kgdb_trgt_core_pcb(u_int cpuid) +{ + return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb))); +} + +void +kgdb_trgt_fetch_registers(int regno __unused) +{ + struct kthr *kt; + struct pcb pcb; + + kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); + if (kt == NULL) + return; + if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) { + warnx("kvm_read: %s", kvm_geterr(kvm)); + memset(&pcb, 0, sizeof(pcb)); + } + + supply_register(SPARC_SP_REGNUM, (char *)&pcb.pcb_sp); + sparc_supply_rwindow(current_regcache, pcb.pcb_sp, -1); + supply_register(SPARC64_PC_REGNUM, (char *)&pcb.pcb_pc); + pcb.pcb_pc += 4; + supply_register(SPARC64_NPC_REGNUM, (char *)&pcb.pcb_pc); +} + +void +kgdb_trgt_store_registers(int regno __unused) +{ + fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__); +} + +void +kgdb_trgt_new_objfile(struct objfile *objfile) +{ +} + +struct kgdb_frame_cache { + CORE_ADDR pc; + CORE_ADDR sp; + CORE_ADDR fp; +}; + +static struct kgdb_frame_cache * +kgdb_trgt_frame_cache(struct frame_info *next_frame, void **this_cache) +{ + char buf[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + + cache = *this_cache; + if (cache == NULL) { + cache = FRAME_OBSTACK_ZALLOC(struct kgdb_frame_cache); + *this_cache = cache; + cache->pc = frame_func_unwind(next_frame); + frame_unwind_register(next_frame, SPARC_SP_REGNUM, buf); + cache->sp = extract_unsigned_integer(buf, + register_size(current_gdbarch, SPARC_SP_REGNUM)); + frame_unwind_register(next_frame, SPARC_FP_REGNUM, buf); + cache->fp = extract_unsigned_integer(buf, + register_size(current_gdbarch, SPARC_FP_REGNUM)); + cache->fp += BIAS - sizeof(struct trapframe); + } + return (cache); +} + +static void +kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache, + struct frame_id *this_id) +{ + struct kgdb_frame_cache *cache; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + *this_id = frame_id_build(cache->sp, cache->pc); +} + +static void +kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame, + void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, + CORE_ADDR *addrp, int *realnump, void *valuep) +{ + char dummy_valuep[MAX_REGISTER_SIZE]; + struct kgdb_frame_cache *cache; + int ofs, regsz; + + regsz = register_size(current_gdbarch, regnum); + + if (valuep == NULL) + valuep = dummy_valuep; + memset(valuep, 0, regsz); + *optimizedp = 0; + *addrp = 0; + *lvalp = not_lval; + *realnump = -1; + + cache = kgdb_trgt_frame_cache(next_frame, this_cache); + + switch (regnum) { + case SPARC_SP_REGNUM: + ofs = offsetof(struct trapframe, tf_sp); + break; + case SPARC64_PC_REGNUM: + ofs = offsetof(struct trapframe, tf_tpc); + break; + case SPARC64_NPC_REGNUM: + ofs = offsetof(struct trapframe, tf_tnpc); + break; + case SPARC_O0_REGNUM: + case SPARC_O1_REGNUM: + case SPARC_O2_REGNUM: + case SPARC_O3_REGNUM: + case SPARC_O4_REGNUM: + case SPARC_O5_REGNUM: + case SPARC_O7_REGNUM: + ofs = offsetof(struct trapframe, tf_out) + + (regnum - SPARC_O0_REGNUM) * 8; + break; + default: + if (regnum >= SPARC_L0_REGNUM && regnum <= SPARC_I7_REGNUM) { + ofs = (regnum - SPARC_L0_REGNUM) * 8; + *addrp = cache->sp + BIAS + ofs; + *lvalp = lval_memory; + target_read_memory(*addrp, valuep, regsz); + } + return; + } + + *addrp = cache->fp + ofs; + *lvalp = lval_memory; + target_read_memory(*addrp, valuep, regsz); +} + +static const struct frame_unwind kgdb_trgt_trapframe_unwind = { + UNKNOWN_FRAME, + &kgdb_trgt_trapframe_this_id, + &kgdb_trgt_trapframe_prev_register +}; + +const struct frame_unwind * +kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame) +{ + char *pname; + CORE_ADDR pc; + + pc = frame_func_unwind(next_frame); + pname = NULL; + find_pc_partial_function(pc, &pname, NULL, NULL); + if (pname == NULL) + return (NULL); + if (strcmp(pname, "tl0_intr") == 0 || + strcmp(pname, "tl0_trap") == 0 || + strcmp(pname, "tl1_intr") == 0 || + strcmp(pname, "tl1_trap") == 0) + return (&kgdb_trgt_trapframe_unwind); + /* printf("%s: %lx =%s\n", __func__, pc, pname); */ + return (NULL); +} + +/* + * This function ensures, that the PC is inside the + * function section which is understood by GDB. + * + * Return 0 when fixup is necessary, -1 otherwise. + */ +int +kgdb_trgt_pc_fixup(CORE_ADDR *pc __unused) +{ + + return (-1); +} diff --git a/gnu/usr.bin/gdb/libgdb/Makefile b/gnu/usr.bin/gdb/libgdb/Makefile new file mode 100644 index 000000000000..8c27c58907ed --- /dev/null +++ b/gnu/usr.bin/gdb/libgdb/Makefile @@ -0,0 +1,80 @@ +# $FreeBSD$ + +# These assignments duplicate much of the functionality of +# MACHINE_CPUARCH, but there's no easy way to export make functions... + +.if defined(TARGET_ARCH) +TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}} +.else +TARGET_CPUARCH=${MACHINE_CPUARCH} +.endif +TARGET_ARCH?= ${MACHINE_ARCH} + +LIB= gdb +INTERNALLIB= +SRCS= annotate.c arch-utils.c auxv.c ax-gdb.c ax-general.c \ + bcache.c bfd-target.c block.c blockframe.c breakpoint.c \ + buildsym.c \ + c-exp.y c-lang.c c-typeprint.c c-valprint.c charset.c \ + cli-cmds.c cli-decode.c cli-dump.c cli-interp.c cli-logging.c \ + cli-out.c cli-script.c cli-setshow.c cli-utils.c coff-pe-read.c \ + coffread.c complaints.c completer.c copying.c corefile.c \ + corelow.c cp-abi.c cp-namespace.c cp-support.c cp-valprint.c \ + dbxread.c dcache.c demangle.c dictionary.c disasm.c doublest.c \ + dummy-frame.c dwarf2-frame.c dwarf2expr.c dwarf2loc.c \ + dwarf2read.c dwarfread.c \ + elfread.c environ.c eval.c event-loop.c event-top.c exec.c \ + expprint.c \ + f-exp.y f-lang.c f-typeprint.c f-valprint.c findvar.c \ + ${_fork_child} frame-base.c frame-unwind.c frame.c \ + gdb-events.c gdbarch.c gdbtypes.c gnu-v2-abi.c gnu-v3-abi.c \ + hpacc-abi.c \ + inf-loop.c infcall.c infcmd.c inflow.c ${_infptrace} infrun.c \ + ${_inftarg} init.c interps.c \ + jv-exp.y jv-lang.c jv-typeprint.c jv-valprint.c \ + kod-cisco.c kod.c \ + language.c linespec.c \ + m2-exp.y m2-lang.c m2-typeprint.c m2-valprint.c macrocmd.c \ + macroexp.c macroscope.c macrotab.c main.c maint.c mdebugread.c \ + mem-break.c memattr.c mi-cmd-break.c mi-cmd-disas.c \ + mi-cmd-env.c mi-cmd-file.c mi-cmd-stack.c mi-cmd-var.c \ + mi-cmds.c mi-console.c mi-getopt.c mi-interp.c mi-main.c \ + mi-out.c mi-parse.c mi-symbol-cmds.c minsyms.c mipsread.c \ + nlmread.c \ + objc-exp.y objc-lang.c objfiles.c observer.c osabi.c \ + p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \ + regcache.c reggroups.c remote-fileio.c remote-utils.c remote.c \ + scm-exp.c scm-lang.c scm-valprint.c sentinel-frame.c ser-pipe.c \ + ser-tcp.c ser-unix.c serial.c signals.c source.c stabsread.c \ + stack.c std-regs.c symfile.c symmisc.c symtab.c \ + target.c thread.c top.c tracepoint.c trad-frame.c tui-command.c \ + tui-data.c tui-disasm.c tui-file.c tui-hooks.c tui-interp.c \ + tui-io.c tui-layout.c tui-out.c tui-regs.c tui-source.c \ + tui-stack.c tui-win.c tui-windata.c tui-wingeneral.c \ + tui-winsource.c tui.c typeprint.c \ + ui-file.c ui-out.c user-regs.c utils.c \ + valarith.c valops.c valprint.c values.c varobj.c \ + wrapper.c ${LIBSRCS} + +.for stupid_gnu in \ +xregcomp xre_exec xregexec xre_search xre_compile_fastmap xregerror xre_comp xre_set_syntax +CFLAGS+= -D${stupid_gnu}=${stupid_gnu:S/^x//} +.endfor + +.if ${TARGET_ARCH} == ${MACHINE_ARCH} +_fork_child= fork-child.c +_infptrace= infptrace.c +_inftarg= inftarg.c +.endif + +GENSRCS= version.c + +version.c: + echo '#include "version.h"' > ${.TARGET} + echo 'const char version[] = ${VERSION};' >> ${.TARGET} + echo 'const char host_name[] = "${MACHINE_ARCH}-${VENDOR}-freebsd";' \ + >> ${.TARGET} + echo 'const char target_name[] = "${TARGET_ARCH}-${VENDOR}-freebsd";' \ + >> ${.TARGET} + +.include <bsd.lib.mk> diff --git a/gnu/usr.bin/gdb/libgdb/Makefile.depend b/gnu/usr.bin/gdb/libgdb/Makefile.depend new file mode 100644 index 000000000000..80f12f7059aa --- /dev/null +++ b/gnu/usr.bin/gdb/libgdb/Makefile.depend @@ -0,0 +1,19 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/libreadline/readline \ + include \ + include/arpa \ + include/xlocale \ + lib/libthread_db \ + lib/msun \ + lib/ncurses/ncursesw \ + usr.bin/yacc.host \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/gdb/libgdb/fbsd-threads.c b/gnu/usr.bin/gdb/libgdb/fbsd-threads.c new file mode 100644 index 000000000000..78819a743e51 --- /dev/null +++ b/gnu/usr.bin/gdb/libgdb/fbsd-threads.c @@ -0,0 +1,1799 @@ +/* $FreeBSD$ */ +/* FreeBSD libthread_db assisted debugging support. + Copyright 1999, 2000, 2001 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <dlfcn.h> +#include <sys/types.h> +#include <sys/ptrace.h> +#include <signal.h> + +#include "proc_service.h" +#include "thread_db.h" + +#include "defs.h" +#include "bfd.h" +#include "elf-bfd.h" +#include "gdb_assert.h" +#include "gdbcore.h" +#include "gdbthread.h" +#include "inferior.h" +#include "objfiles.h" +#include "regcache.h" +#include "symfile.h" +#include "symtab.h" +#include "target.h" +#include "gdbcmd.h" +#include "solib-svr4.h" + +#include "gregset.h" +#ifdef PT_GETXMMREGS +#include "i387-tdep.h" +#endif + +#define LIBTHREAD_DB_SO "libthread_db.so" + +struct ps_prochandle +{ + pid_t pid; +}; + +extern int child_suppress_run; + +extern struct target_ops child_ops; + +/* This module's target vectors. */ +static struct target_ops fbsd_thread_ops; +static struct target_ops fbsd_core_ops; + +/* Saved copy of orignal core_ops. */ +static struct target_ops orig_core_ops; +extern struct target_ops core_ops; + +/* Pointer to the next function on the objfile event chain. */ +static void (*target_new_objfile_chain) (struct objfile *objfile); + +/* Non-zero if there is a thread module */ +static int fbsd_thread_present; + +/* Non-zero if we're using this module's target vector. */ +static int fbsd_thread_active; + +/* Non-zero if core_open is called */ +static int fbsd_thread_core = 0; + +/* Non-zero if we have to keep this module's target vector active + across re-runs. */ +static int keep_thread_db; + +/* Structure that identifies the child process for the + <proc_service.h> interface. */ +static struct ps_prochandle proc_handle; + +/* Connection to the libthread_db library. */ +static td_thragent_t *thread_agent; + +/* The last thread we are single stepping */ +static ptid_t last_single_step_thread; + +/* Pointers to the libthread_db functions. */ + +static td_err_e (*td_init_p) (void); + +static td_err_e (*td_ta_new_p) (struct ps_prochandle *ps, td_thragent_t **ta); +static td_err_e (*td_ta_delete_p) (td_thragent_t *); +static td_err_e (*td_ta_map_id2thr_p) (const td_thragent_t *ta, thread_t pt, + td_thrhandle_t *__th); +static td_err_e (*td_ta_map_lwp2thr_p) (const td_thragent_t *ta, lwpid_t lwpid, + td_thrhandle_t *th); +static td_err_e (*td_ta_thr_iter_p) (const td_thragent_t *ta, + td_thr_iter_f *callback, + void *cbdata_p, td_thr_state_e state, + int ti_pri, sigset_t *ti_sigmask_p, + unsigned int ti_user_flags); +static td_err_e (*td_ta_event_addr_p) (const td_thragent_t *ta, + td_event_e event, td_notify_t *ptr); +static td_err_e (*td_ta_set_event_p) (const td_thragent_t *ta, + td_thr_events_t *event); +static td_err_e (*td_ta_event_getmsg_p) (const td_thragent_t *ta, + td_event_msg_t *msg); +static td_err_e (*td_thr_get_info_p) (const td_thrhandle_t *th, + td_thrinfo_t *infop); +#ifdef PT_GETXMMREGS +static td_err_e (*td_thr_getxmmregs_p) (const td_thrhandle_t *th, + char *regset); +#endif +static td_err_e (*td_thr_getfpregs_p) (const td_thrhandle_t *th, + prfpregset_t *regset); +static td_err_e (*td_thr_getgregs_p) (const td_thrhandle_t *th, + prgregset_t gregs); +#ifdef PT_GETXMMREGS +static td_err_e (*td_thr_setxmmregs_p) (const td_thrhandle_t *th, + const char *fpregs); +#endif +static td_err_e (*td_thr_setfpregs_p) (const td_thrhandle_t *th, + const prfpregset_t *fpregs); +static td_err_e (*td_thr_setgregs_p) (const td_thrhandle_t *th, + prgregset_t gregs); +static td_err_e (*td_thr_event_enable_p) (const td_thrhandle_t *th, int event); + +static td_err_e (*td_thr_sstep_p) (td_thrhandle_t *th, int step); + +static td_err_e (*td_ta_tsd_iter_p) (const td_thragent_t *ta, + td_key_iter_f *func, void *data); +static td_err_e (*td_thr_tls_get_addr_p) (const td_thrhandle_t *th, + void *map_address, + size_t offset, void **address); +static td_err_e (*td_thr_dbsuspend_p) (const td_thrhandle_t *); +static td_err_e (*td_thr_dbresume_p) (const td_thrhandle_t *); + +static CORE_ADDR td_create_bp_addr; + +/* Location of the thread death event breakpoint. */ +static CORE_ADDR td_death_bp_addr; + +/* Prototypes for local functions. */ +static void fbsd_thread_find_new_threads (void); +static int fbsd_thread_alive (ptid_t ptid); +static void attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, + const td_thrinfo_t *ti_p, int verbose); +static void fbsd_thread_detach (char *args, int from_tty); + +/* Building process ids. */ + +#define GET_PID(ptid) ptid_get_pid (ptid) +#define GET_LWP(ptid) ptid_get_lwp (ptid) +#define GET_THREAD(ptid) ptid_get_tid (ptid) + +#define IS_LWP(ptid) (GET_LWP (ptid) != 0) +#define IS_THREAD(ptid) (GET_THREAD (ptid) != 0) + +#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0) +#define BUILD_THREAD(tid, pid) ptid_build (pid, 0, tid) + +static char * +thread_db_err_str (td_err_e err) +{ + static char buf[64]; + + switch (err) + { + case TD_OK: + return "generic 'call succeeded'"; + case TD_ERR: + return "generic error"; + case TD_NOTHR: + return "no thread to satisfy query"; + case TD_NOSV: + return "no sync handle to satisfy query"; + case TD_NOLWP: + return "no LWP to satisfy query"; + case TD_BADPH: + return "invalid process handle"; + case TD_BADTH: + return "invalid thread handle"; + case TD_BADSH: + return "invalid synchronization handle"; + case TD_BADTA: + return "invalid thread agent"; + case TD_BADKEY: + return "invalid key"; + case TD_NOMSG: + return "no event message for getmsg"; + case TD_NOFPREGS: + return "FPU register set not available"; + case TD_NOLIBTHREAD: + return "application not linked with libthread"; + case TD_NOEVENT: + return "requested event is not supported"; + case TD_NOCAPAB: + return "capability not available"; + case TD_DBERR: + return "debugger service failed"; + case TD_NOAPLIC: + return "operation not applicable to"; + case TD_NOTSD: + return "no thread-specific data for this thread"; + case TD_MALLOC: + return "malloc failed"; + case TD_PARTIALREG: + return "only part of register set was written/read"; + case TD_NOXREGS: + return "X register set not available for this thread"; + default: + snprintf (buf, sizeof (buf), "unknown thread_db error '%d'", err); + return buf; + } +} + +static char * +thread_db_state_str (td_thr_state_e state) +{ + static char buf[64]; + + switch (state) + { + case TD_THR_STOPPED: + return "stopped by debugger"; + case TD_THR_RUN: + return "runnable"; + case TD_THR_ACTIVE: + return "active"; + case TD_THR_ZOMBIE: + return "zombie"; + case TD_THR_SLEEP: + return "sleeping"; + case TD_THR_STOPPED_ASLEEP: + return "stopped by debugger AND blocked"; + default: + snprintf (buf, sizeof (buf), "unknown thread_db state %d", state); + return buf; + } +} + +/* Convert LWP to user-level thread id. */ +static ptid_t +thread_from_lwp (ptid_t ptid, td_thrhandle_t *th, td_thrinfo_t *ti) +{ + td_err_e err; + + gdb_assert (IS_LWP (ptid)); + + if (fbsd_thread_active) + { + err = td_ta_map_lwp2thr_p (thread_agent, GET_LWP (ptid), th); + if (err == TD_OK) + { + err = td_thr_get_info_p (th, ti); + if (err != TD_OK) + error ("Cannot get thread info: %s", thread_db_err_str (err)); + return BUILD_THREAD (ti->ti_tid, GET_PID (ptid)); + } + } + + /* the LWP is not mapped to user thread */ + return BUILD_LWP (GET_LWP (ptid), GET_PID (ptid)); +} + +static void +fbsd_core_get_first_lwp (bfd *abfd, asection *asect, void *obj) +{ + if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0) + return; + + if (*(lwpid_t *)obj != 0) + return; + + *(lwpid_t *)obj = atoi (bfd_section_name (abfd, asect) + 5); +} + +static long +get_current_lwp (int pid) +{ + struct ptrace_lwpinfo pl; + lwpid_t lwpid; + + if (!target_has_execution) + { + lwpid = 0; + bfd_map_over_sections (core_bfd, fbsd_core_get_first_lwp, &lwpid); + return lwpid; + } + if (ptrace (PT_LWPINFO, pid, (caddr_t)&pl, sizeof(pl))) + perror_with_name("PT_LWPINFO"); + + return (long)pl.pl_lwpid; +} + +static void +get_current_thread () +{ + td_thrhandle_t th; + td_thrinfo_t ti; + long lwp; + ptid_t tmp, ptid; + + lwp = get_current_lwp (proc_handle.pid); + tmp = BUILD_LWP (lwp, proc_handle.pid); + ptid = thread_from_lwp (tmp, &th, &ti); + if (!in_thread_list (ptid)) + { + attach_thread (ptid, &th, &ti, 1); + } + inferior_ptid = ptid; +} + +static td_err_e +enable_thread_event (td_thragent_t *thread_agent, int event, CORE_ADDR *bp) +{ + td_notify_t notify; + td_err_e err; + + /* Get the breakpoint address for thread EVENT. */ + err = td_ta_event_addr_p (thread_agent, event, ¬ify); + if (err != TD_OK) + return err; + + /* Set up the breakpoint. */ + (*bp) = gdbarch_convert_from_func_ptr_addr (current_gdbarch, + extract_typed_address(¬ify.u.bptaddr, builtin_type_void_func_ptr), + ¤t_target); + create_thread_event_breakpoint ((*bp)); + + return TD_OK; +} + +static void +enable_thread_event_reporting (void) +{ + td_thr_events_t events; + td_notify_t notify; + td_err_e err; + + /* We cannot use the thread event reporting facility if these + functions aren't available. */ + if (td_ta_event_addr_p == NULL || td_ta_set_event_p == NULL + || td_ta_event_getmsg_p == NULL || td_thr_event_enable_p == NULL) + return; + + /* Set the process wide mask saying which events we're interested in. */ + td_event_emptyset (&events); + td_event_addset (&events, TD_CREATE); + td_event_addset (&events, TD_DEATH); + + err = td_ta_set_event_p (thread_agent, &events); + if (err != TD_OK) + { + warning ("Unable to set global thread event mask: %s", + thread_db_err_str (err)); + return; + } + + /* Delete previous thread event breakpoints, if any. */ + remove_thread_event_breakpoints (); + td_create_bp_addr = 0; + td_death_bp_addr = 0; + + /* Set up the thread creation event. */ + err = enable_thread_event (thread_agent, TD_CREATE, &td_create_bp_addr); + if (err != TD_OK) + { + warning ("Unable to get location for thread creation breakpoint: %s", + thread_db_err_str (err)); + return; + } + + /* Set up the thread death event. */ + err = enable_thread_event (thread_agent, TD_DEATH, &td_death_bp_addr); + if (err != TD_OK) + { + warning ("Unable to get location for thread death breakpoint: %s", + thread_db_err_str (err)); + return; + } +} + +static void +disable_thread_event_reporting (void) +{ + td_thr_events_t events; + + /* Set the process wide mask saying we aren't interested in any + events anymore. */ + td_event_emptyset (&events); + td_ta_set_event_p (thread_agent, &events); + + /* Delete thread event breakpoints, if any. */ + remove_thread_event_breakpoints (); + td_create_bp_addr = 0; + td_death_bp_addr = 0; +} + +static void +fbsd_thread_activate (void) +{ + fbsd_thread_active = 1; + init_thread_list(); + if (fbsd_thread_core == 0) + enable_thread_event_reporting (); + fbsd_thread_find_new_threads (); + get_current_thread (); +} + +static void +fbsd_thread_deactivate (void) +{ + if (fbsd_thread_core == 0) + disable_thread_event_reporting(); + td_ta_delete_p (thread_agent); + + inferior_ptid = pid_to_ptid (proc_handle.pid); + proc_handle.pid = 0; + fbsd_thread_active = 0; + fbsd_thread_present = 0; + init_thread_list (); +} + +static char * +fbsd_thread_get_name (lwpid_t lwpid) +{ + static char last_thr_name[MAXCOMLEN + 1]; + char section_name[32]; + struct ptrace_lwpinfo lwpinfo; + bfd_size_type size; + struct bfd_section *section; + + if (target_has_execution) + { + if (ptrace (PT_LWPINFO, lwpid, (caddr_t)&lwpinfo, sizeof (lwpinfo)) == -1) + goto fail; + strncpy (last_thr_name, lwpinfo.pl_tdname, sizeof (last_thr_name) - 1); + } + else + { + snprintf (section_name, sizeof (section_name), ".tname/%u", lwpid); + section = bfd_get_section_by_name (core_bfd, section_name); + if (! section) + goto fail; + + /* Section size fix-up. */ + size = bfd_section_size (core_bfd, section); + if (size > sizeof (last_thr_name)) + size = sizeof (last_thr_name); + + if (! bfd_get_section_contents (core_bfd, section, last_thr_name, + (file_ptr)0, size)) + goto fail; + if (last_thr_name[0] == '\0') + goto fail; + } + last_thr_name[sizeof (last_thr_name) - 1] = '\0'; + return last_thr_name; +fail: + strcpy (last_thr_name, "<unknown>"); + return last_thr_name; +} + +static void +fbsd_thread_new_objfile (struct objfile *objfile) +{ + td_err_e err; + + if (objfile == NULL) + { + /* All symbols have been discarded. If the thread_db target is + active, deactivate it now. */ + if (fbsd_thread_active) + { + gdb_assert (proc_handle.pid == 0); + fbsd_thread_active = 0; + } + + goto quit; + } + + if (!child_suppress_run) + goto quit; + + /* Nothing to do. The thread library was already detected and the + target vector was already activated. */ + if (fbsd_thread_active) + goto quit; + + /* Initialize the structure that identifies the child process. Note + that at this point there is no guarantee that we actually have a + child process. */ + proc_handle.pid = GET_PID (inferior_ptid); + + /* Now attempt to open a connection to the thread library. */ + err = td_ta_new_p (&proc_handle, &thread_agent); + switch (err) + { + case TD_NOLIBTHREAD: + /* No thread library was detected. */ + break; + + case TD_OK: + /* The thread library was detected. Activate the thread_db target. */ + fbsd_thread_present = 1; + + /* We can only poke around if there actually is a child process. + If there is no child process alive, postpone the steps below + until one has been created. */ + if (fbsd_thread_core == 0 && proc_handle.pid != 0) + { + push_target(&fbsd_thread_ops); + fbsd_thread_activate(); + } + else + { + td_ta_delete_p(thread_agent); + thread_agent = NULL; + } + break; + + default: + warning ("Cannot initialize thread debugging library: %s", + thread_db_err_str (err)); + break; + } + + quit: + if (target_new_objfile_chain) + target_new_objfile_chain (objfile); +} + +static void +fbsd_thread_attach (char *args, int from_tty) +{ + fbsd_thread_core = 0; + + child_ops.to_attach (args, from_tty); + + /* Must get symbols from solibs before libthread_db can run! */ + SOLIB_ADD ((char *) 0, from_tty, (struct target_ops *) 0, auto_solib_add); + + if (fbsd_thread_present && !fbsd_thread_active) + push_target(&fbsd_thread_ops); +} + +static void +fbsd_thread_post_attach (int pid) +{ + child_ops.to_post_attach (pid); + + if (fbsd_thread_present && !fbsd_thread_active) + { + proc_handle.pid = GET_PID (inferior_ptid); + fbsd_thread_activate (); + } +} + +static void +fbsd_thread_detach (char *args, int from_tty) +{ + fbsd_thread_deactivate (); + unpush_target (&fbsd_thread_ops); + + /* Clear gdb solib information and symbol file + cache, so that after detach and re-attach, new_objfile + hook will be called */ + + clear_solib(); + symbol_file_clear(0); + proc_handle.pid = 0; + child_ops.to_detach (args, from_tty); +} + +static int +suspend_thread_callback (const td_thrhandle_t *th_p, void *data) +{ + int err = td_thr_dbsuspend_p (th_p); + if (err != 0) + fprintf_filtered(gdb_stderr, "%s %s\n", __func__, thread_db_err_str (err)); + return (err); +} + +static int +resume_thread_callback (const td_thrhandle_t *th_p, void *data) +{ + int err = td_thr_dbresume_p (th_p); + if (err != 0) + fprintf_filtered(gdb_stderr, "%s %s\n", __func__, thread_db_err_str (err)); + return (err); +} + +static void +fbsd_thread_resume (ptid_t ptid, int step, enum target_signal signo) +{ + td_thrhandle_t th; + td_thrinfo_t ti; + ptid_t work_ptid; + int resume_all, ret; + long lwp, thvalid = 0; + + if (!fbsd_thread_active) + { + child_ops.to_resume (ptid, step, signo); + return; + } + + if (GET_PID(ptid) != -1 && step != 0) + { + resume_all = 0; + work_ptid = ptid; + } + else + { + resume_all = 1; + work_ptid = inferior_ptid; + } + + lwp = GET_LWP (work_ptid); + if (lwp == 0) + { + /* check user thread */ + ret = td_ta_map_id2thr_p (thread_agent, GET_THREAD(work_ptid), &th); + if (ret) + error (thread_db_err_str (ret)); + + /* For M:N thread, we need to tell UTS to set/unset single step + flag at context switch time, the flag will be written into + thread mailbox. This becauses some architecture may not have + machine single step flag in ucontext, so we put the flag in mailbox, + when the thread switches back, kse_switchin restores the single step + state. */ + ret = td_thr_sstep_p (&th, step); + if (ret) + error (thread_db_err_str (ret)); + ret = td_thr_get_info_p (&th, &ti); + if (ret) + error (thread_db_err_str (ret)); + thvalid = 1; + lwp = ti.ti_lid; + } + + if (lwp) + { + int req = step ? PT_SETSTEP : PT_CLEARSTEP; + if (ptrace (req, (pid_t) lwp, (caddr_t) 1, target_signal_to_host(signo))) + perror_with_name ("PT_SETSTEP/PT_CLEARSTEP"); + } + + if (!ptid_equal (last_single_step_thread, null_ptid)) + { + ret = td_ta_thr_iter_p (thread_agent, resume_thread_callback, NULL, + TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, + TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); + if (ret != TD_OK) + error ("resume error: %s", thread_db_err_str (ret)); + } + + if (!resume_all) + { + ret = td_ta_thr_iter_p (thread_agent, suspend_thread_callback, NULL, + TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, + TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); + if (ret != TD_OK) + error ("suspend error: %s", thread_db_err_str (ret)); + last_single_step_thread = work_ptid; + } + else + last_single_step_thread = null_ptid; + + if (thvalid) + { + ret = td_thr_dbresume_p (&th); + if (ret != TD_OK) + error ("resume error: %s", thread_db_err_str (ret)); + } + else + { + /* it is not necessary, put it here for completness */ + ret = ptrace(PT_RESUME, lwp, 0, 0); + } + + /* now continue the process, suspended thread wont run */ + if (ptrace (PT_CONTINUE, proc_handle.pid , (caddr_t)1, + target_signal_to_host(signo))) + perror_with_name ("PT_CONTINUE"); +} + +static void +attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, + const td_thrinfo_t *ti_p, int verbose) +{ + td_err_e err; + + /* Add the thread to GDB's thread list. */ + if (!in_thread_list (ptid)) { + add_thread (ptid); + if (verbose) + printf_unfiltered ("[New %s]\n", target_pid_to_str (ptid)); + } + + if (ti_p->ti_state == TD_THR_UNKNOWN || ti_p->ti_state == TD_THR_ZOMBIE) + return; /* A zombie thread -- do not attach. */ + + if (! IS_THREAD(ptid)) + return; + if (fbsd_thread_core != 0) + return; + /* Enable thread event reporting for this thread. */ + err = td_thr_event_enable_p (th_p, 1); + if (err != TD_OK) + error ("Cannot enable thread event reporting for %s: %s", + target_pid_to_str (ptid), thread_db_err_str (err)); +} + +static void +detach_thread (ptid_t ptid, int verbose) +{ + if (verbose) + printf_unfiltered ("[%s exited]\n", target_pid_to_str (ptid)); +} + +static void +check_event (ptid_t ptid) +{ + td_event_msg_t msg; + td_thrinfo_t ti; + td_err_e err; + CORE_ADDR stop_pc; + int loop = 0; + + /* Bail out early if we're not at a thread event breakpoint. */ + stop_pc = read_pc_pid (ptid) - DECR_PC_AFTER_BREAK; + if (stop_pc != td_create_bp_addr && stop_pc != td_death_bp_addr) + return; + loop = 1; + + do + { + err = td_ta_event_getmsg_p (thread_agent, &msg); + if (err != TD_OK) + { + if (err == TD_NOMSG) + return; + error ("Cannot get thread event message: %s", + thread_db_err_str (err)); + } + err = td_thr_get_info_p ((void *)(uintptr_t)msg.th_p, &ti); + if (err != TD_OK) + error ("Cannot get thread info: %s", thread_db_err_str (err)); + ptid = BUILD_THREAD (ti.ti_tid, GET_PID (ptid)); + switch (msg.event) + { + case TD_CREATE: + /* We may already know about this thread, for instance when the + user has issued the `info threads' command before the SIGTRAP + for hitting the thread creation breakpoint was reported. */ + attach_thread (ptid, (void *)(uintptr_t)msg.th_p, &ti, 1); + break; + case TD_DEATH: + if (!in_thread_list (ptid)) + error ("Spurious thread death event."); + detach_thread (ptid, 1); + break; + default: + error ("Spurious thread event."); + } + } + while (loop); +} + +static ptid_t +fbsd_thread_wait (ptid_t ptid, struct target_waitstatus *ourstatus) +{ + ptid_t ret; + long lwp; + CORE_ADDR stop_pc; + td_thrhandle_t th; + td_thrinfo_t ti; + + ret = child_ops.to_wait (ptid, ourstatus); + if (GET_PID(ret) >= 0 && ourstatus->kind == TARGET_WAITKIND_STOPPED) + { + lwp = get_current_lwp (GET_PID(ret)); + ret = thread_from_lwp (BUILD_LWP(lwp, GET_PID(ret)), + &th, &ti); + if (!in_thread_list(ret)) { + /* + * We have to enable event reporting for initial thread + * which was not mapped before. + */ + attach_thread(ret, &th, &ti, 1); + } + if (ourstatus->value.sig == TARGET_SIGNAL_TRAP) + check_event(ret); + /* this is a hack, if an event won't cause gdb to stop, for example, + SIGARLM, gdb resumes the process immediatly without setting + inferior_ptid to the new thread returned here, this is a bug + because inferior_ptid may already not exist there, and passing + a none existing thread to fbsd_thread_resume causes error. */ + if (!fbsd_thread_alive (inferior_ptid)) + { + delete_thread (inferior_ptid); + inferior_ptid = ret; + } + } + + return (ret); +} + +static int +fbsd_thread_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, + struct mem_attrib *attrib, struct target_ops *target) +{ + int err; + + if (target_has_execution) + err = child_ops.to_xfer_memory (memaddr, myaddr, len, write, attrib, + target); + else + err = orig_core_ops.to_xfer_memory (memaddr, myaddr, len, write, attrib, + target); + + return (err); +} + +static void +fbsd_lwp_fetch_registers (int regno) +{ + gregset_t gregs; + fpregset_t fpregs; + lwpid_t lwp; +#ifdef PT_GETXMMREGS + char xmmregs[512]; +#endif + + if (!target_has_execution) + { + orig_core_ops.to_fetch_registers (-1); + return; + } + + /* XXX: We've replaced the pid with the lwpid for GDB's benefit. */ + lwp = GET_PID (inferior_ptid); + + if (ptrace (PT_GETREGS, lwp, (caddr_t) &gregs, 0) == -1) + error ("Cannot get lwp %d registers: %s\n", lwp, safe_strerror (errno)); + supply_gregset (&gregs); + +#ifdef PT_GETXMMREGS + if (ptrace (PT_GETXMMREGS, lwp, xmmregs, 0) == 0) + { + i387_supply_fxsave (current_regcache, -1, xmmregs); + } + else + { +#endif + if (ptrace (PT_GETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1) + error ("Cannot get lwp %d registers: %s\n ", lwp, safe_strerror (errno)); + supply_fpregset (&fpregs); +#ifdef PT_GETXMMREGS + } +#endif +} + +static void +fbsd_thread_fetch_registers (int regno) +{ + prgregset_t gregset; + prfpregset_t fpregset; + td_thrhandle_t th; + td_err_e err; +#ifdef PT_GETXMMREGS + char xmmregs[512]; +#endif + + if (!IS_THREAD (inferior_ptid)) + { + fbsd_lwp_fetch_registers (regno); + return; + } + + err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_ptid), &th); + if (err != TD_OK) + error ("Cannot find thread %d: Thread ID=%ld, %s", + pid_to_thread_id (inferior_ptid), + GET_THREAD (inferior_ptid), thread_db_err_str (err)); + + err = td_thr_getgregs_p (&th, gregset); + if (err != TD_OK) + error ("Cannot fetch general-purpose registers for thread %d: Thread ID=%ld, %s", + pid_to_thread_id (inferior_ptid), + GET_THREAD (inferior_ptid), thread_db_err_str (err)); +#ifdef PT_GETXMMREGS + err = td_thr_getxmmregs_p (&th, xmmregs); + if (err == TD_OK) + { + i387_supply_fxsave (current_regcache, -1, xmmregs); + } + else + { +#endif + err = td_thr_getfpregs_p (&th, &fpregset); + if (err != TD_OK) + error ("Cannot get floating-point registers for thread %d: Thread ID=%ld, %s", + pid_to_thread_id (inferior_ptid), + GET_THREAD (inferior_ptid), thread_db_err_str (err)); + supply_fpregset (&fpregset); +#ifdef PT_GETXMMREGS + } +#endif + + supply_gregset (gregset); +} + +static void +fbsd_lwp_store_registers (int regno) +{ + gregset_t gregs; + fpregset_t fpregs; + lwpid_t lwp; +#ifdef PT_GETXMMREGS + char xmmregs[512]; +#endif + + /* FIXME, is it possible ? */ + if (!IS_LWP (inferior_ptid)) + { + child_ops.to_store_registers (regno); + return ; + } + + lwp = GET_LWP (inferior_ptid); + if (regno != -1) + if (ptrace (PT_GETREGS, lwp, (caddr_t) &gregs, 0) == -1) + error ("Cannot get lwp %d registers: %s\n", lwp, safe_strerror (errno)); + + fill_gregset (&gregs, regno); + if (ptrace (PT_SETREGS, lwp, (caddr_t) &gregs, 0) == -1) + error ("Cannot set lwp %d registers: %s\n", lwp, safe_strerror (errno)); + +#ifdef PT_GETXMMREGS + if (regno != -1) + if (ptrace (PT_GETXMMREGS, lwp, xmmregs, 0) == -1) + goto noxmm; + + i387_fill_fxsave (xmmregs, regno); + if (ptrace (PT_SETXMMREGS, lwp, xmmregs, 0) == -1) + goto noxmm; + + return; + +noxmm: +#endif + + if (regno != -1) + if (ptrace (PT_GETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1) + error ("Cannot get lwp %d float registers: %s\n", lwp, + safe_strerror (errno)); + + fill_fpregset (&fpregs, regno); + if (ptrace (PT_SETFPREGS, lwp, (caddr_t) &fpregs, 0) == -1) + error ("Cannot set lwp %d float registers: %s\n", lwp, + safe_strerror (errno)); +} + +static void +fbsd_thread_store_registers (int regno) +{ + prgregset_t gregset; + prfpregset_t fpregset; + td_thrhandle_t th; + td_err_e err; +#ifdef PT_GETXMMREGS + char xmmregs[512]; +#endif + + if (!IS_THREAD (inferior_ptid)) + { + fbsd_lwp_store_registers (regno); + return; + } + + err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_ptid), &th); + if (err != TD_OK) + error ("Cannot find thread %d: Thread ID=%ld, %s", + pid_to_thread_id (inferior_ptid), + GET_THREAD (inferior_ptid), + thread_db_err_str (err)); + + if (regno != -1) + { + char old_value[MAX_REGISTER_SIZE]; + + regcache_collect (regno, old_value); + err = td_thr_getgregs_p (&th, gregset); + if (err != TD_OK) + error ("%s: td_thr_getgregs %s", __func__, thread_db_err_str (err)); +#ifdef PT_GETXMMREGS + err = td_thr_getxmmregs_p (&th, xmmregs); + if (err != TD_OK) + { +#endif + err = td_thr_getfpregs_p (&th, &fpregset); + if (err != TD_OK) + error ("%s: td_thr_getfpgregs %s", __func__, thread_db_err_str (err)); +#ifdef PT_GETXMMREGS + } +#endif + supply_register (regno, old_value); + } + + fill_gregset (gregset, regno); + err = td_thr_setgregs_p (&th, gregset); + if (err != TD_OK) + error ("Cannot store general-purpose registers for thread %d: Thread ID=%d, %s", + pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid), + thread_db_err_str (err)); + +#ifdef PT_GETXMMREGS + i387_fill_fxsave (xmmregs, regno); + err = td_thr_setxmmregs_p (&th, xmmregs); + if (err == TD_OK) + return; +#endif + + fill_fpregset (&fpregset, regno); + err = td_thr_setfpregs_p (&th, &fpregset); + if (err != TD_OK) + error ("Cannot store floating-point registers for thread %d: Thread ID=%d, %s", + pid_to_thread_id (inferior_ptid), GET_THREAD (inferior_ptid), + thread_db_err_str (err)); +} + +static void +fbsd_thread_kill (void) +{ + child_ops.to_kill(); +} + +static int +fbsd_thread_can_run (void) +{ + return child_suppress_run; +} + +static void +fbsd_thread_create_inferior (char *exec_file, char *allargs, char **env) +{ + if (fbsd_thread_present && !fbsd_thread_active) + push_target(&fbsd_thread_ops); + + child_ops.to_create_inferior (exec_file, allargs, env); +} + +static void +fbsd_thread_post_startup_inferior (ptid_t ptid) +{ + if (fbsd_thread_present && !fbsd_thread_active) + { + /* The child process is now the actual multi-threaded + program. Snatch its process ID... */ + proc_handle.pid = GET_PID (ptid); + td_ta_new_p (&proc_handle, &thread_agent); + fbsd_thread_activate(); + } +} + +static void +fbsd_thread_mourn_inferior (void) +{ + if (fbsd_thread_active) + fbsd_thread_deactivate (); + + unpush_target (&fbsd_thread_ops); + + child_ops.to_mourn_inferior (); +} + +static void +fbsd_core_check_lwp (bfd *abfd, asection *asect, void *obj) +{ + lwpid_t lwp; + + if (strncmp (bfd_section_name (abfd, asect), ".reg/", 5) != 0) + return; + + /* already found */ + if (*(lwpid_t *)obj == 0) + return; + + lwp = atoi (bfd_section_name (abfd, asect) + 5); + if (*(lwpid_t *)obj == lwp) + *(lwpid_t *)obj = 0; +} + +static int +fbsd_thread_alive (ptid_t ptid) +{ + td_thrhandle_t th; + td_thrinfo_t ti; + td_err_e err; + gregset_t gregs; + lwpid_t lwp; + + if (IS_THREAD (ptid)) + { + err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th); + if (err != TD_OK) + return 0; + + err = td_thr_get_info_p (&th, &ti); + if (err != TD_OK) + return 0; + + /* A zombie thread. */ + if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE) + return 0; + + return 1; + } + else if (GET_LWP (ptid) == 0) + { + /* we sometimes are called with lwp == 0 */ + return 1; + } + + if (fbsd_thread_active) + { + err = td_ta_map_lwp2thr_p (thread_agent, GET_LWP (ptid), &th); + + /* + * if the lwp was already mapped to user thread, don't use it + * directly, please use user thread id instead. + */ + if (err == TD_OK) + return 0; + } + + if (!target_has_execution) + { + lwp = GET_LWP (ptid); + bfd_map_over_sections (core_bfd, fbsd_core_check_lwp, &lwp); + return (lwp == 0); + } + + /* check lwp in kernel */ + return ptrace (PT_GETREGS, GET_LWP (ptid), (caddr_t)&gregs, 0) == 0; +} + +static void +fbsd_thread_files_info (struct target_ops *ignore) +{ + child_ops.to_files_info (ignore); +} + +static int +find_new_threads_callback (const td_thrhandle_t *th_p, void *data) +{ + td_thrinfo_t ti; + td_err_e err; + ptid_t ptid; + + err = td_thr_get_info_p (th_p, &ti); + if (err != TD_OK) + error ("Cannot get thread info: %s", thread_db_err_str (err)); + + /* Ignore zombie */ + if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE) + return 0; + + ptid = BUILD_THREAD (ti.ti_tid, proc_handle.pid); + attach_thread (ptid, th_p, &ti, 1); + return 0; +} + +static void +fbsd_thread_find_new_threads (void) +{ + td_err_e err; + + if (!fbsd_thread_active) + return; + + /* Iterate over all user-space threads to discover new threads. */ + err = td_ta_thr_iter_p (thread_agent, find_new_threads_callback, NULL, + TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, + TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); + if (err != TD_OK) + error ("Cannot find new threads: %s", thread_db_err_str (err)); +} + +static char * +fbsd_thread_pid_to_str (ptid_t ptid) +{ + static char buf[64 + MAXCOMLEN]; + + if (IS_THREAD (ptid)) + { + td_thrhandle_t th; + td_thrinfo_t ti; + td_err_e err; + + err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th); + if (err != TD_OK) + error ("Cannot find thread, Thread ID=%ld, %s", + GET_THREAD (ptid), thread_db_err_str (err)); + + err = td_thr_get_info_p (&th, &ti); + if (err != TD_OK) + error ("Cannot get thread info, Thread ID=%ld, %s", + GET_THREAD (ptid), thread_db_err_str (err)); + + if (ti.ti_lid != 0) + { + snprintf (buf, sizeof (buf), "Thread %llx (LWP %d/%s)", + (unsigned long long)th.th_thread, ti.ti_lid, + fbsd_thread_get_name (ti.ti_lid)); + } + else + { + snprintf (buf, sizeof (buf), "Thread %llx (%s)", + (unsigned long long)th.th_thread, + thread_db_state_str (ti.ti_state)); + } + + return buf; + } + else if (IS_LWP (ptid)) + { + snprintf (buf, sizeof (buf), "LWP %d", (int) GET_LWP (ptid)); + return buf; + } + return normal_pid_to_str (ptid); +} + +CORE_ADDR +fbsd_thread_get_local_address(ptid_t ptid, struct objfile *objfile, + CORE_ADDR offset) +{ + td_thrhandle_t th; + void *address; + CORE_ADDR lm; + void *lm2; + int ret, is_library = (objfile->flags & OBJF_SHARED); + + if (IS_THREAD (ptid)) + { + if (!td_thr_tls_get_addr_p) + error ("Cannot find thread-local interface in thread_db library."); + + /* Get the address of the link map for this objfile. */ + lm = svr4_fetch_objfile_link_map (objfile); + + /* Couldn't find link map. Bail out. */ + if (!lm) + { + if (is_library) + error ("Cannot find shared library `%s' link_map in dynamic" + " linker's module list", objfile->name); + else + error ("Cannot find executable file `%s' link_map in dynamic" + " linker's module list", objfile->name); + } + + ret = td_ta_map_id2thr_p (thread_agent, GET_THREAD(ptid), &th); + + /* get the address of the variable. */ + store_typed_address(&lm2, builtin_type_void_data_ptr, lm); + ret = td_thr_tls_get_addr_p (&th, lm2, offset, &address); + + if (ret != TD_OK) + { + if (is_library) + error ("Cannot find thread-local storage for thread %ld, " + "shared library %s:\n%s", + (long) GET_THREAD (ptid), + objfile->name, thread_db_err_str (ret)); + else + error ("Cannot find thread-local storage for thread %ld, " + "executable file %s:\n%s", + (long) GET_THREAD (ptid), + objfile->name, thread_db_err_str (ret)); + } + + /* Cast assuming host == target. */ + return extract_typed_address(&address, builtin_type_void_data_ptr); + } + return (0); +} + +static int +tsd_cb (thread_key_t key, void (*destructor)(void *), void *ignore) +{ + struct minimal_symbol *ms; + char *name; + + ms = lookup_minimal_symbol_by_pc ( + extract_typed_address(&destructor, builtin_type_void_func_ptr)); + if (!ms) + name = "???"; + else + name = DEPRECATED_SYMBOL_NAME (ms); + + printf_filtered ("Key %d, destructor %p <%s>\n", key, destructor, name); + return 0; +} + +static void +fbsd_thread_tsd_cmd (char *exp, int from_tty) +{ + if (fbsd_thread_active) + td_ta_tsd_iter_p (thread_agent, tsd_cb, NULL); +} + +static void +fbsd_print_sigset (sigset_t *set) +{ + int i; + + for (i = 1; i <= _SIG_MAXSIG; ++i) { + if (sigismember(set, i)) { + if (i < sizeof(sys_signame)/sizeof(sys_signame[0])) + printf_filtered("%s ", sys_signame[i]); + else + printf_filtered("sig%d ", i); + } + } + printf_filtered("\n"); +} + +static void +fbsd_thread_signal_cmd (char *exp, int from_tty) +{ + td_thrhandle_t th; + td_thrinfo_t ti; + td_err_e err; + const char *code; + + if (!fbsd_thread_active || !IS_THREAD(inferior_ptid)) + return; + + err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_ptid), &th); + if (err != TD_OK) + return; + + err = td_thr_get_info_p (&th, &ti); + if (err != TD_OK) + return; + + printf_filtered("signal mask:\n"); + fbsd_print_sigset(&ti.ti_sigmask); + printf_filtered("signal pending:\n"); + fbsd_print_sigset(&ti.ti_pending); + if (ti.ti_siginfo.si_signo != 0) { + printf_filtered("si_signo %d si_errno %d", ti.ti_siginfo.si_signo, + ti.ti_siginfo.si_errno); + if (ti.ti_siginfo.si_errno != 0) + printf_filtered(" (%s)", strerror(ti.ti_siginfo.si_errno)); + printf_filtered("\n"); + switch (ti.ti_siginfo.si_code) { + case SI_NOINFO: + code = "NOINFO"; + break; + case SI_USER: + code = "USER"; + break; + case SI_QUEUE: + code = "QUEUE"; + break; + case SI_TIMER: + code = "TIMER"; + break; + case SI_ASYNCIO: + code = "ASYNCIO"; + break; + case SI_MESGQ: + code = "MESGQ"; + break; + case SI_KERNEL: + code = "KERNEL"; + break; + default: + code = "UNKNOWN"; + break; + } + printf_filtered("si_code %s (%d) si_pid %d si_uid %d si_status %x " + "si_addr %p\n", + code, ti.ti_siginfo.si_code, ti.ti_siginfo.si_pid, ti.ti_siginfo.si_uid, + ti.ti_siginfo.si_status, ti.ti_siginfo.si_addr); + } +} + +static int +ignore (CORE_ADDR addr, char *contents) +{ + return 0; +} + +static void +fbsd_core_open (char *filename, int from_tty) +{ + int err; + + fbsd_thread_core = 1; + + orig_core_ops.to_open (filename, from_tty); + + if (fbsd_thread_present) + { + err = td_ta_new_p (&proc_handle, &thread_agent); + if (err == TD_OK) + { + proc_handle.pid = elf_tdata (core_bfd)->core_pid; + fbsd_thread_activate (); + } + else + error ("fbsd_core_open: td_ta_new: %s", thread_db_err_str (err)); + } +} + +static void +fbsd_core_close (int quitting) +{ + orig_core_ops.to_close (quitting); +} + +static void +fbsd_core_detach (char *args, int from_tty) +{ + if (fbsd_thread_active) + fbsd_thread_deactivate (); + unpush_target (&fbsd_thread_ops); + orig_core_ops.to_detach (args, from_tty); + + /* Clear gdb solib information and symbol file + cache, so that after detach and re-attach, new_objfile + hook will be called */ + clear_solib(); + symbol_file_clear(0); +} + +static void +fbsd_core_files_info (struct target_ops *ignore) +{ + orig_core_ops.to_files_info (ignore); +} + +static void +init_fbsd_core_ops (void) +{ + fbsd_core_ops.to_shortname = "FreeBSD-core"; + fbsd_core_ops.to_longname = "FreeBSD multithreaded core dump file"; + fbsd_core_ops.to_doc = + "Use a core file as a target. Specify the filename of the core file."; + fbsd_core_ops.to_open = fbsd_core_open; + fbsd_core_ops.to_close = fbsd_core_close; + fbsd_core_ops.to_attach = 0; + fbsd_core_ops.to_post_attach = 0; + fbsd_core_ops.to_detach = fbsd_core_detach; + /* fbsd_core_ops.to_resume = 0; */ + /* fbsd_core_ops.to_wait = 0; */ + fbsd_core_ops.to_fetch_registers = fbsd_thread_fetch_registers; + /* fbsd_core_ops.to_store_registers = 0; */ + /* fbsd_core_ops.to_prepare_to_store = 0; */ + fbsd_core_ops.to_xfer_memory = fbsd_thread_xfer_memory; + fbsd_core_ops.to_files_info = fbsd_core_files_info; + fbsd_core_ops.to_insert_breakpoint = ignore; + fbsd_core_ops.to_remove_breakpoint = ignore; + /* fbsd_core_ops.to_lookup_symbol = 0; */ + fbsd_core_ops.to_create_inferior = fbsd_thread_create_inferior; + fbsd_core_ops.to_stratum = core_stratum; + fbsd_core_ops.to_has_all_memory = 0; + fbsd_core_ops.to_has_memory = 1; + fbsd_core_ops.to_has_stack = 1; + fbsd_core_ops.to_has_registers = 1; + fbsd_core_ops.to_has_execution = 0; + fbsd_core_ops.to_has_thread_control = tc_none; + fbsd_core_ops.to_thread_alive = fbsd_thread_alive; + fbsd_core_ops.to_pid_to_str = fbsd_thread_pid_to_str; + fbsd_core_ops.to_find_new_threads = fbsd_thread_find_new_threads; + fbsd_core_ops.to_sections = 0; + fbsd_core_ops.to_sections_end = 0; + fbsd_core_ops.to_magic = OPS_MAGIC; +} + +static void +init_fbsd_thread_ops (void) +{ + fbsd_thread_ops.to_shortname = "freebsd-threads"; + fbsd_thread_ops.to_longname = "FreeBSD multithreaded child process."; + fbsd_thread_ops.to_doc = "FreeBSD threads support."; + fbsd_thread_ops.to_attach = fbsd_thread_attach; + fbsd_thread_ops.to_detach = fbsd_thread_detach; + fbsd_thread_ops.to_post_attach = fbsd_thread_post_attach; + fbsd_thread_ops.to_resume = fbsd_thread_resume; + fbsd_thread_ops.to_wait = fbsd_thread_wait; + fbsd_thread_ops.to_fetch_registers = fbsd_thread_fetch_registers; + fbsd_thread_ops.to_store_registers = fbsd_thread_store_registers; + fbsd_thread_ops.to_xfer_memory = fbsd_thread_xfer_memory; + fbsd_thread_ops.to_files_info = fbsd_thread_files_info; + fbsd_thread_ops.to_kill = fbsd_thread_kill; + fbsd_thread_ops.to_create_inferior = fbsd_thread_create_inferior; + fbsd_thread_ops.to_post_startup_inferior = fbsd_thread_post_startup_inferior; + fbsd_thread_ops.to_mourn_inferior = fbsd_thread_mourn_inferior; + fbsd_thread_ops.to_can_run = fbsd_thread_can_run; + fbsd_thread_ops.to_thread_alive = fbsd_thread_alive; + fbsd_thread_ops.to_find_new_threads = fbsd_thread_find_new_threads; + fbsd_thread_ops.to_pid_to_str = fbsd_thread_pid_to_str; + fbsd_thread_ops.to_stratum = thread_stratum; + fbsd_thread_ops.to_has_thread_control = tc_none; + fbsd_thread_ops.to_has_all_memory = 1; + fbsd_thread_ops.to_has_memory = 1; + fbsd_thread_ops.to_has_stack = 1; + fbsd_thread_ops.to_has_registers = 1; + fbsd_thread_ops.to_has_execution = 1; + fbsd_thread_ops.to_insert_breakpoint = memory_insert_breakpoint; + fbsd_thread_ops.to_remove_breakpoint = memory_remove_breakpoint; + fbsd_thread_ops.to_get_thread_local_address = fbsd_thread_get_local_address; + fbsd_thread_ops.to_magic = OPS_MAGIC; +} + +static int +thread_db_load (void) +{ + void *handle; + td_err_e err; + + handle = dlopen (LIBTHREAD_DB_SO, RTLD_NOW); + if (handle == NULL) + return 0; + +#define resolve(X) \ + if (!(X##_p = dlsym (handle, #X))) \ + return 0; + + resolve(td_init); + resolve(td_ta_new); + resolve(td_ta_delete); + resolve(td_ta_map_id2thr); + resolve(td_ta_map_lwp2thr); + resolve(td_ta_thr_iter); + resolve(td_thr_get_info); +#ifdef PT_GETXMMREGS + resolve(td_thr_getxmmregs); +#endif + resolve(td_thr_getfpregs); + resolve(td_thr_getgregs); +#ifdef PT_GETXMMREGS + resolve(td_thr_setxmmregs); +#endif + resolve(td_thr_setfpregs); + resolve(td_thr_setgregs); + resolve(td_thr_sstep); + resolve(td_ta_tsd_iter); + resolve(td_thr_dbsuspend); + resolve(td_thr_dbresume); + resolve(td_thr_tls_get_addr); + + /* Initialize the library. */ + err = td_init_p (); + if (err != TD_OK) + { + warning ("Cannot initialize libthread_db: %s", thread_db_err_str (err)); + return 0; + } + + /* These are not essential. */ + td_ta_event_addr_p = dlsym (handle, "td_ta_event_addr"); + td_ta_set_event_p = dlsym (handle, "td_ta_set_event"); + td_ta_event_getmsg_p = dlsym (handle, "td_ta_event_getmsg"); + td_thr_event_enable_p = dlsym (handle, "td_thr_event_enable"); + td_thr_tls_get_addr_p = dlsym (handle, "td_thr_tls_get_addr"); + + return 1; +} + +/* we suppress the call to add_target of core_ops in corelow because + if there are two targets in the stratum core_stratum, find_core_target + won't know which one to return. see corelow.c for an additonal + comment on coreops_suppress_target. */ + +int coreops_suppress_target = 1; + +/* similarly we allow this target to be completely skipped. This is used + by kgdb which uses its own core target. */ + +int fbsdcoreops_suppress_target; + +void +_initialize_thread_db (void) +{ + + if (fbsdcoreops_suppress_target) + return; + init_fbsd_thread_ops (); + init_fbsd_core_ops (); + + if (thread_db_load ()) + { + add_target (&fbsd_thread_ops); + + /* "thread tsd" command */ + add_cmd ("tsd", class_run, fbsd_thread_tsd_cmd, + "Show the thread-specific data keys and destructors " + "for the process.\n", + &thread_cmd_list); + + add_cmd ("signal", class_run, fbsd_thread_signal_cmd, + "Show the thread signal info.\n", + &thread_cmd_list); + + memcpy (&orig_core_ops, &core_ops, sizeof (struct target_ops)); + memcpy (&core_ops, &fbsd_core_ops, sizeof (struct target_ops)); + add_target (&core_ops); + + /* Add ourselves to objfile event chain. */ + target_new_objfile_chain = target_new_objfile_hook; + target_new_objfile_hook = fbsd_thread_new_objfile; + + child_suppress_run = 1; + } + else + { + fprintf_unfiltered (gdb_stderr, + "[GDB will not be able to debug user-mode threads: %s]\n", dlerror()); + + /* allow the user to debug non-threaded core files */ + add_target (&core_ops); + } +} + +/* proc service functions */ +void +ps_plog (const char *fmt, ...) +{ + va_list args; + + va_start (args, fmt); + vfprintf_filtered (gdb_stderr, fmt, args); + va_end (args); +} + +ps_err_e +ps_pglobal_lookup (struct ps_prochandle *ph, const char *obj, + const char *name, psaddr_t *sym_addr) +{ + struct minimal_symbol *ms; + CORE_ADDR addr; + + ms = lookup_minimal_symbol (name, NULL, NULL); + if (ms == NULL) + return PS_NOSYM; + + addr = SYMBOL_VALUE_ADDRESS (ms); + store_typed_address(sym_addr, builtin_type_void_data_ptr, addr); + return PS_OK; +} + +ps_err_e +ps_pread (struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t len) +{ + int err = target_read_memory ( + extract_typed_address(&addr, builtin_type_void_data_ptr), buf, len); + return (err == 0 ? PS_OK : PS_ERR); +} + +ps_err_e +ps_pwrite (struct ps_prochandle *ph, psaddr_t addr, const void *buf, + size_t len) +{ + int err = target_write_memory ( + extract_typed_address(&addr, builtin_type_void_data_ptr), (void *)buf, len); + return (err == 0 ? PS_OK : PS_ERR); +} + +ps_err_e +ps_lgetregs (struct ps_prochandle *ph, lwpid_t lwpid, prgregset_t gregset) +{ + struct cleanup *old_chain; + + old_chain = save_inferior_ptid (); + + /* XXX: Target operation isn't lwp aware: replace pid with lwp */ + inferior_ptid = BUILD_LWP (0, lwpid); + + target_fetch_registers (-1); + fill_gregset (gregset, -1); + do_cleanups (old_chain); + return PS_OK; +} + +ps_err_e +ps_lsetregs (struct ps_prochandle *ph, lwpid_t lwpid, const prgregset_t gregset) +{ + struct cleanup *old_chain; + + old_chain = save_inferior_ptid (); + inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); + supply_gregset ((gdb_gregset_t *) gregset); + target_store_registers (-1); + do_cleanups (old_chain); + return PS_OK; +} + +ps_err_e +ps_lgetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, prfpregset_t *fpregset) +{ + struct cleanup *old_chain; + + old_chain = save_inferior_ptid (); + inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); + target_fetch_registers (-1); + fill_fpregset (fpregset, -1); + do_cleanups (old_chain); + return PS_OK; +} + +ps_err_e +ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, + const prfpregset_t *fpregset) +{ + struct cleanup *old_chain; + + old_chain = save_inferior_ptid (); + inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); + supply_fpregset ((gdb_fpregset_t *) fpregset); + target_store_registers (-1); + do_cleanups (old_chain); + return PS_OK; +} + +#ifdef PT_GETXMMREGS +ps_err_e +ps_lgetxmmregs (struct ps_prochandle *ph, lwpid_t lwpid, char *xmmregs) +{ + struct cleanup *old_chain; + + old_chain = save_inferior_ptid (); + inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); + target_fetch_registers (-1); + i387_fill_fxsave (xmmregs, -1); + do_cleanups (old_chain); + return PS_OK; +} + +ps_err_e +ps_lsetxmmregs (struct ps_prochandle *ph, lwpid_t lwpid, + const char *xmmregs) +{ + struct cleanup *old_chain; + + old_chain = save_inferior_ptid (); + inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); + i387_supply_fxsave (current_regcache, -1, xmmregs); + target_store_registers (-1); + do_cleanups (old_chain); + return PS_OK; +} +#endif + +ps_err_e +ps_lstop(struct ps_prochandle *ph, lwpid_t lwpid) +{ + if (ptrace (PT_SUSPEND, lwpid, 0, 0) == -1) + return PS_ERR; + return PS_OK; +} + +ps_err_e +ps_lcontinue(struct ps_prochandle *ph, lwpid_t lwpid) +{ + if (ptrace (PT_RESUME, lwpid, 0, 0) == -1) + return PS_ERR; + return PS_OK; +} + +ps_err_e +ps_linfo(struct ps_prochandle *ph, lwpid_t lwpid, void *info) +{ + if (fbsd_thread_core) { + /* XXX should verify lwpid and make a pseudo lwp info */ + memset(info, 0, sizeof(struct ptrace_lwpinfo)); + return PS_OK; + } + + if (ptrace (PT_LWPINFO, lwpid, info, sizeof(struct ptrace_lwpinfo)) == -1) + return PS_ERR; + return PS_OK; +} diff --git a/gnu/usr.bin/gperf/Makefile b/gnu/usr.bin/gperf/Makefile new file mode 100644 index 000000000000..6f518e5c8625 --- /dev/null +++ b/gnu/usr.bin/gperf/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +.include <bsd.own.mk> +GPERFDIR= ${SRCTOP}/contrib/gperf + +.PATH: ${GPERFDIR}/src ${GPERFDIR}/lib ${GPERFDIR}/doc + +PROG_CXX= gperf +SRCS= bool-array.cc hash-table.cc input.cc keyword-list.cc keyword.cc \ + main.cc options.cc output.cc positions.cc search.cc version.cc \ + getline.cc hash.cc +WARNS= 1 +MAN= gperf.1 gperf.7 + +CXXFLAGS+= -I${GPERFDIR}/lib -I${.CURDIR} + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/gperf/Makefile.depend b/gnu/usr.bin/gperf/Makefile.depend new file mode 100644 index 000000000000..ea8bba31ec06 --- /dev/null +++ b/gnu/usr.bin/gperf/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libc++ \ + lib/libcompiler_rt \ + lib/libcxxrt \ + lib/msun \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/gperf/config.h b/gnu/usr.bin/gperf/config.h new file mode 100644 index 000000000000..91c1236ec1cb --- /dev/null +++ b/gnu/usr.bin/gperf/config.h @@ -0,0 +1,22 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ +/* $FreeBSD$ */ + +/* Define if the C++ compiler supports stack-allocated variable-size arrays. + */ +#define HAVE_DYNAMIC_ARRAY 1 + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" diff --git a/gnu/usr.bin/grep/AUTHORS b/gnu/usr.bin/grep/AUTHORS new file mode 100644 index 000000000000..e08a38cf24e6 --- /dev/null +++ b/gnu/usr.bin/grep/AUTHORS @@ -0,0 +1,44 @@ +Mike Haertel wrote the main program and the dfa and kwset matchers. + +Arthur David Olson contributed the heuristics for finding fixed substrings +at the end of dfa.c. + +Richard Stallman and Karl Berry wrote the regex backtracking matcher. + +Henry Spencer wrote the original test suite from which grep's was derived. + +Scott Anderson invented the Khadafy test. + +David MacKenzie wrote the automatic configuration software use to +produce the configure script. + +Authors of the replacements for standard library routines are identified +in the corresponding source files. + +The idea of using Boyer-Moore type algorithms to quickly filter out +non-matching text before calling the regexp matcher was originally due +to James Woods. He also contributed some code to early versions of +GNU grep. + +Mike Haertel would like to thank Andrew Hume for many fascinating discussions +of string searching issues over the years. Hume & Sunday's excellent +paper on fast string searching (AT&T Bell Laboratories CSTR #156) +describes some of the history of the subject, as well as providing +exhaustive performance analysis of various implementation alternatives. +The inner loop of GNU grep is similar to Hume & Sunday's recommended +"Tuned Boyer Moore" inner loop. + +More work was done on regex.[ch] by Ulrich Drepper and Arnold +Robbins. Regex is now part of GNU C library, see this package +for complete details and credits. + +Arnold Robbins contributed to improve dfa.[ch]. In fact +it came straight from gawk-3.0.3 with small editing and fixes. + +Many folks contributed see THANKS, if I omited someone please +send me email. + +Alain Magloire maintained GNU grep until version 2.5e. + +Bernhard "Bero" Rosenkränzer <bero@redhat.com> is the current maintainer. + diff --git a/gnu/usr.bin/grep/COPYING b/gnu/usr.bin/grep/COPYING new file mode 100644 index 000000000000..60549be514af --- /dev/null +++ b/gnu/usr.bin/grep/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) 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 +this service 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 make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. 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. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +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 +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE 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. + + 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 +convey 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) 19yy <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 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision 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, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This 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 Library General +Public License instead of this License. diff --git a/gnu/usr.bin/grep/ChangeLog b/gnu/usr.bin/grep/ChangeLog new file mode 100644 index 000000000000..aa50e78c1f40 --- /dev/null +++ b/gnu/usr.bin/grep/ChangeLog @@ -0,0 +1,2477 @@ +2002-03-26 Bernhard Rosenkraenzer <bero@redhat.com> + * src/grep.c: Don't fail if we don't have an stdout fd and -q + is used (happens e.g. on calls from hotplug scripts) + * src/grep.c: Don't hang forever if fed with an empty string to + grep for and --color enabled + * src/grep.c: Fix infinite loop on + echo "1 one" | grep -E "[0-9]*" -o + echo "1 one" | grep -E "[0-9]*" --color + * po/*: Sync wiith translation project + * src/grep.c, src/Makefile.am, configure.in: Add patch from + Paul Eggert <eggert@twinsun.com> to comply with ridiculous + guidelines (don't act differently if invoked as egrep or fgrep) + * configure.in: Bump version number, require a recent autoconf + +2002-03-14 Bernhard Rosenkraenzer <bero@redhat.com> + * src/Makefile.am, po/Makefile.in.in: Support DESTDIR properly + * tests/bre.tests: Add fix from + Peter Breitenlohner <peb@mppmu.mpg.de> + +2002-03-13 Bernhard Rosenkraenzer <bero@redhat.com> + * configure.in, m4/regex.m4, m4/malloc.m4, m4/realloc.m4: + Don't set LIBOBJS directly, autoconf 2.53 doesn't like it + * intl/*: Sync with gettext 0.11 + * po/*: Sync with translation project + * configure.in, src/Makefile.am: Don't duplicate code - make + egrep and fgrep links to grep and set matcher based on + application name, suggestion from + Guillaume Cottenceau <gc@mandrakesoft.com> + * src/grep.c: (prline) Add fix for -i --color from + Jim Meyering <meyering@lucent.com> + * configure.in: Version 2.5; release + +2002-01-23 Bernhard Rosenkraenzer <bero@redhat.com> + * configure.in: Version 2.5g + * Makefile.cvs, grep.spec: Add packaging tools + Merge djgpp changes from Andrew Cottrell <anddjgpp@ihug.coml.au>: + * src/grep.c: Added conditional compilation for DJGPP + * djgpp: remove directory as it is no longer required with DJGPP 2.03 + (or 2.04 when released) + * README.DOS: Moved djgpp/readme to readme.dos + * PATCHES.AC, PATCHES.AM: delete files - redundant + * configure.in, Makefile.am: remove djgpp directory from list + +2002-01-22 Bernhard Rosenkraenzer <bero@redhat.com> + * doc/grep.texi, doc/grep.1, NEWS: Document --label + * po/ru.po: Sync with translation project + * po/grep.pot: Sync with source + +2002-01-18 Bernhard Rosenkraenzer <bero@redhat.com> + * src/grep.c: Add --label, based on patch from Stepan Koltsov + +2001-11-20 Bernhard Rosenkraenzer <bero@redhat.com> + * autogen.sh: Don't hardcode aclocal dir + +2001-11-19 Bernhard Rosenkraenzer <bero@redhat.com> + * src/grep.c: Add --only-matching (-o) switch (see NEWS) + * doc/grep.texi, doc/grep.1, NEWS: Document changes + * configure.in, lib/Makefile.am: Don't use internal getopt if + we're on a system that provides a working getopt function + +2001-09-25 Bernhard Rosenkraenzer <bero@redhat.com> + * configure.in: Detect pcre correctly even when it's in + non-standard locations, using pcre-config + * src/grep.c: Add --color={always,never,tty} argument (like in ls) + * src/grep.c: Turn off blinking in the default colorization + * src/grep.c: Add --devices (-D) switch (analogous to --directories) + * src/dfa.c: Fix an i18n bug: echo "A" | grep '[A-Z0-9]' wouldn't work + in non-C-Locales on systems using current versions of glibc. + * AUTHORS: Change maintainer, credit Alain for his work until now + * configure.in, m4/decl.m4, m4/dosfile.m4, m4/gettext.m4, + m4/init.m4, m4/install.m4, m4/largefile.m4, m4/lcmessage.m4, + m4/header.m4, m4/isc-posix.m4, m4/missing.m4, m4/progtest.m4, + m4/sanity.m4: + Fix build with autoconf 2.5x, retain 2.1x compatibility for now + * autogen.sh: Add some crude hacks to make it possible to build with + both autoconf 2.5x and 2.1x + * acconfig.h: removed (no longer required) + * Makefile.am: add cvs-clean target + * doc/grep.texi, doc/grep.1, NEWS: Document changes + (--color, --devices, -D) + * src/dfa.c, src/grep.c: Add vim modelines + +2001-08-30 Alain Magloire + + * configure.in: Add gl in ALL_LINGUAS. + +2001-08-30 Kurt D Schwehr + + * doc/grep.1: Warn that grep insert a "--" between groups of matches, + when using the context options. + * doc/grep.texi: Likewised. + +2001-08-25 Heikki Korpela + + * doc/grep.texi: Point out that some Platforms do not support + reading of directories and silently ignore them. + +2001-08-21 Alain Magloire + + * lib/malloc.c: New file: + * lib/realloc.c: New file: + * lib/Makefile.am: Add malloc.c and realloc.c in EXTRA_DIST. + +2001-07-31 Alain Magloire + + * po/*.po: New files from the translation team: + grep-2.5e.de.po grep-2.5e.el.po grep-2.5e.eo.po grep-2.5e.es.po + grep-2.5e.et.po grep-2.5e.fr.po grep-2.5e.gl.po grep-2.5e.it.po + grep-2.5e.pl.po grep-2.5e.sl.po + +2001-07-31 Andreas Schwab + + * src/grep.c: Fix all uses of error to pass a proper format + string. + +2001-07-29 Alain Magloire + + * grep/src/grep.c (usage): Typos corrected. + Patches from Santiago Vila. + +2001-07-29 Alain Magloire + + David Clissold, wrote: + a small bug in the GNU grep 2.4.2, which may have gone unnoticed + because it only causes a failure if building on a system with large + files enabled (e.g. an "off_t" is a "long long" rather than a "long"). + savedir() takes on off_t argument, but in grepdir() the parameter + is cast to an (unsigned). Well, if an off_t is larger than an int, + the value gets truncated. This would not normally have an effect on a + little-endian platform (unless the file is >2GB), but on a big-endian + system it will always fail. The external effect is that + "grep -r foo dir_name" fails with ENOMEM (from malloc() within + savedir()). + + * grep/src/grep.c (grepdir): Remove the (unsigned) cast when calling + savedir(). + Patch from David Clissold. + +2001-07-29 Alain Magloire + + * grep/doc/grep.texi: In Bugs report use {n,m} for consistency. + * grep/doc/grep.1: Likewised. + Noted by Steven Lucy. + +2001-04-27 Isamu Hasegawa + + * dfa.c (mblen_buf) : New variable contains the amount of remain + byte of corresponding multibyte character in the input string. + (SKIP_REMAIN_MB_IF_INITIAL_STATE) : Use mblen_buf. + (match_anychar) : Use mblen_buf. + (match_mb_charset) : Use mblen_buf. + (transit_state_consume_1char) : Use mblen_buf. + (transit_state) : Use inputwcs to get current (multibyte) character. + (dfaexec) : Add initialization of mblen_buf. + +2001-04-27 Isamu Hasegawa + + * dfa.c (addtok) : Set appropriate value to multibyte_prop. + (dfastate) : Add the initialization of the variable. + (dfaexec) : Call transit_state if d->fail may transit by + multibyte characters. + (transit_state_singlebyte) : Clean up unnecessary code. + (transit_state_consume_1char) : Likewise. + (transit_state) : Add checking for word and newline. + +2001-04-19 Isamu Hasegawa + + * search.c (check_multibyte_string) : Check the case when mbclen == 0. + +2001-04-11 Isamu Hasegawa + + * search.c (check_multibyte_string) : Check the head of multibyte + characters, and optimize a bit. + (EGexecute) : Optimize a bit. + (Fexecute) : Fix the index. + +2001-04-02 Alain Magloire + + * lib/regex.c: Update from GNU lib C, with the changes + provided by Paul Eggert. + * lib/posix/regex.h: Likewise. + +2001-02-17 Paul Eggert + + Stop trying to support hosts that have nonstandard declarations for + mbrtowc and/or mbstate_t. It's not worth the portability hassle. + + * lib/quotearg.c (mbrtowc, mbsinit): Remove workaround macros + for hosts that have mbrtowc but not mbstate_t, as we now + insist on proper declarations for both before using mbrtowc. + +2001-03-18 Alain Magloire + + * configure.in: Call AC_MBSTATE_T. + * Makefile.am: Add mbstate_t.m4 + * m4/Makefile.am: Add mbstate_t.m4 + * m4/mbstate_t.m4: New m4 macro. + * lib/strtol.c: Define CHAR_BITS. + Uwe H. Steinfeld, Ruslan Ermilov, Volkert Bochert, noted + that mbstate_t was not define for certain platforms. + +2001-03-18 Paul Eggert + + * src/grep.c (fillbuf): Fix storage allocation performance + bug: buffer was doubling in size in many cases where it didn't + have to. + +2001-03-17 Paul Eggert + + * src/grep.c (fillbuf): Avoid unnecessary division by 2. + Don't check xrealloc return value; it's guaranteed to be nonzero. + (fillbuf, grepdir): Use xalloc_die rather than error; it's shorter. + +2001-03-17 Alain Magloire + + * src/grep.c (context_length_arg): error () passing wrong format. + Spotted by Jim Meyering. + +2001-03-07 Alain Magloire + + * README-alpha: Removed reference to GNU tar, add the location + of the CVSROOT. + +2001-03-06 Alain Magloire + + Only the Regex patterns should be split in an array, patterns[]. + The dfa and KWset compiled patterns should remain global and the + patterns compiled all at once. + + * src/search.c: include "error.h" and "xalloc.h" to get prototyping + of x*alloc() and error(). + (kwsinit): Reverse to previous behaviour and takes no argument. + (kwsmusts): Likewised. + (Gcompile): For the regex pattern, split them and each pattern + is put in different compiled structure patterns[]. The patterns + are given to dfacomp() and kwsmusts() as is. + (Ecompile): Likewised. + (Fcompile): Reverse to the old behaviour of compiling the enire + patterns in one shot. + (EGexecute): If falling to GNU regex for the matching, loop in the + array of compile patterns[] to find a match. + (error): Many error () were call with arguments in the wrong order. + * tests/file.sh: Simple test to check for pattern in files. + + Reaction to bug report fired by Greg Louis <glouis@dynamicro.on.ca> + +2001-03-06 Isamu Hasegawa + + In multibyte environments, handle multibyte characters as single + characters in bracket expressions. + + * src/dfa.h (mb_char_classes) : new structure. + (mbcsets): new variable. + (nmbcsets): new variable. + (mbcsets_alloc) : new variable. + * src/dfa.c (prtok) : handle MBCSET. + (fetch_wc): new function to fetch a wide character. + (parse_bracket_exp_mb) : new function to handle multibyte character + in lex(). + (lex): invoke parse_bracket_exp_mb() for multibyte bracket expression. + (atom): handle MBCSET. + (epsclosure): likewise. + (dfaanalyze): likewise. + (dfastate): likewise. + (match_mb_charset): new function to judge whether a bracket match + with a multibyte character. + (check_matching_with_multibyte_ops) : handle MBCSET. + (dfainit): initialize new variables. + (dfafree): free new variables. + +2001-03-04 Alain Magloire + + To get more in sync with other GNU utilities like GNU tar and fetish + all the supporting functions are now under lib. + Thanks to Jim Meyering, Volkert Bochert and Paul Eggert for + the code and the reminders. + + * src/grep.c (fatal): Function removed, using error () from + lib/error.c instead. + (usage): Copyright updated. + (error): Function removed, using error () from lib/error.c instead, + adjust prototypes. + (prog): Global variable rename to program_name, to work with new + lib/error.c. + (xrealloc): Removed using lib/xmalloc.c. + (xmalloc): Removed using lib/xmalloc.c + (main): Register with atexit() to check for error on stdout. + * configure.in: Check for atexit(), call jm_MALLOC, jm_RELLOC and + jm_PREREQ_ERROR. + * tests/bre.awk: Removed the hack to drain the buffer since we + always fclose(stdout) atexit. + * tests/ere.awk: Likewise. + * tests/spencer1.awk: Likewise. + * bootstrap/Makefile.try: Update the Makefile to reflect the changes + in the new hierarchy. + + * README-alpha: New File. + * m4/realloc.m4: New File. + * m4/malloc.m4: New File. + * m4/error.m4: New File. + * m4/Makefile.am: Updated. + * lib: New directory. + * lib/Makefile.am: New file. + * lib/closeout.c: New file. + * lib/closeout.h: New file. + * lib/fnmatch.c: New file. + * lib/fnmatch.h: New file. + * lib/atexit.c: New file. + * lib/error.c: New file. + * lib/error.h: New file. + * lib/quotearg.h: New file. + * lib/quotearg.c: New file. + * lib/xmalloc.c: New file. + * lib/posix: New directory. + * lib/posix/Makefile.am: New file. + * src/getopt.c: Moved to lib. + * src/getopt1.c: Moved to lib. + * src/getopt.h: Moved to lib. + * src/alloca.c: Moved to lib. + * src/exclude.c: Moved to lib. + * src/exclude.h: Moved to lib. + * src/hard-locale.h: Moved to lib. + * src/hard-locale.c: Moved to lib. + * src/isdir.c: Moved to lib. + * src/mechr.c: Moved to lib. + * src/obstack.c: Moved to lib. + * src/obstack.h: Moved to lib. + * src/regex.c: Moved to lib. + * src/regex.h: Moved to lib. + * src/posix: Moved to lib. + * src/posix/regex.h: Moved to lib. + * src/savedir.h: Moved to lib. + * src/savedir.c: Moved to lib. + * src/stpcpy.c: Moved to lib. + * src/strtoul.c: Moved to lib. + * src/strtol.c: Moved to lib. + * src/strtoull.c: Moved to lib. + * src/strtoumax.c: Moved to lib. + * src/xstrtol.c: Moved to lib. + * src/xstrtol.h: Moved to lib. + * src/xstrtoumax.c: Moved to lib. + +2001-03-01 Isamu Hasegawa + + Implement the mechanism to match with multibyte characters, + and use it for `period' in multibyte environments. + + * dfa.h (mbps): new variable. + * dfa.c (prtok): handle ANYCHAR. + (lex): use ANYCHAR for `period' in multibyte environments. + (atom): handle ANYCHAR. + (state_index): initialize mbps in multibyte environments. + (epsclosure): handle ANYCHAR. + (dfaanalyze): handle ANYCHAR. + (dfastate): handle ANYCHAR. + (realloc_trans_if_necessary): new function. + (transit_state_singlebyte): new function. + (match_anychar): new function. + (check_matching_with_multibyte_ops): new function. + (transit_state_consume_1char): new function. + (transit_state): new function. + (dfaexec): invoke transit_state if expression can match with + a multibyte character in multibyte environments. + (dfamust): handle ANYCHAR. + +2001-03-01 Alain Magloire + + * src/exclude.c: New file. + * src/exclude.h: New file. + * src/grep.c (main): Took the GNU tar code to handle + the option --include, --exclude, --exclude-from. + Files are check for a match, with exlude_filename (). + New option --exclude-from. + * src/savedir.c: Call exclude_filename() to check for + file pattern exclusion or inclusion. + * configure.in: --disable-pcre rename to --disable-perl-regexp. + + +2001-02-25 Alain Magloire + + * src/dfa.c: Typo corrected. + Noted by Isamu Hasegawa. + * src/savedir.c: Typos corrected. + +2001-02-22 Alain Magloire + + * src/savedir.c (isdir1): New function, calling isdir with + the correct pathname. + +2001-02-19 Isamu Hasegawa + + Avoid incorrect state transition in multibyte environments. + + * dfa.h (nmultibyte_prop): new variable. + (multibyte_prop): new variable. + * dfa.c (addtok): set inputwcs. + (dfastate): avoid incorrect state transition in multibyte + environments. + (dfaexec): likewise. + (dfainit): init multibyte_prop. + (dfafree): free multibyte_prop. + (inputwcs): new variable. + +2001-02-19 Isamu Hasegawa + + Handle a multibyte character followed by '*', '+', and '{n,m}' + correctly. + + * dfa.c (update_mb_len_index): new function. + Support for multibyte string. + (FETCH): call update_mb_len_index. + (lex): check cur_mb_index not to misunderstand multibyte characters. + (atom): make a tree from a multibyte character. + (dfaparse): initialize new variables. + (mbs): new variable. + (cur_mb_len): new variable. + (cur_mb_index): new variable. + +2001-02-18 Jim Meyering + + * m4/dosfile.m4 (AC_DOSFILE): Move AC_DEFINEs out of AC_CACHE_CHECK. + +2001-02-17 Alain Malgoire + + * doc/grep.texi: Document the new options and the new behaviour + back-references are local. Use excerpt from Karl Berry regex + texinfo. + + * bootstrap/Makefile.try: Added xstrtoumax.o xstrtoul.o hard-local.o + +2001-02-17 Alain Magloire + + From Guglielmo 'bond' Bondioni : + The bug was that using a multi line file that contained REs (one per + line), backreferences in the REs were considered global (to the file) + and not local (to the line). + That is, \1 in line n refers to the first \(.\) in the whole file, + rather than in the line itself. + + From Tapani Tarvainen : + # Re: grep -e '\(a\)\1' -e '\(b\)\1' + That's not the way it should work: multiple -e arguments + should be treated as independent patterns and back references + should not refer to previous ones. + + From Paul Eggert : + GNU grep currently does not issue + diagnostics for the following two cases, both of which are erroneous: + grep -e '[' -e ']' + grep '[ + ]' + POSIX requires a diagnostic in both cases because '[' is not a valid + regular expression. + + To overcome those problems, grep no longer pass the concatenate + patterns to GNU regex but rather compile each patterns separately + and keep the result in an array. + + * src/search.c (patterns): New global variable; a structure array + holding the compiled patterns. + Declare function prototypes to minimize error. + (dfa, kswset, regexbuf, regs): Removed, no longer static globals, but + rather fields in patterns[] structure per motif. + (Fcompile): Alloc an entry in patterns[] to hold the regex. + (Ecompile): Alloc an entry per motif in the patterns[] array. + (Gcompile): Likewise. + (EGexecute): Loop through of array of patterns[] for a match. + +2001-02-17 Alain Magloire + + From Bernd Strieder : + # tail -f logfile | grep important | do_something_urgent + # tail -f logfile | grep important | do_something_taking_very_long + If grep does full buffering in these cases then the urgent operation + does not happen as it should in the first case, and in the second case + time is lost due to waiting for the buffer to be filled. + This is clearly spoken not grep's fault in the first place, but libc's. + There is a heuristic in libc that make a stream line-buffered only if a + terminal is on the other end. This doesn't take care of the cases where + this connection is somehow indirect. + + * src/grep.c (line_buffered): new option variable. + (prline): if line_buffered is set fflush() is call. + (usage): line_buffered new option. + Input from Paul Eggert, doing setvbuf() may not be portable + and breaks grep -z. + +2001-02-16 Alain Magloire + + Patch from Isamu Hasegawa, for multibyte support. + This patch prevent kwset_matcher from following problems. + For example, in SJIS encoding, one character has the codepoint 0x895c. + So the second byte of the character can match with '\' incorrectly. + And in eucJP encoding, there are the characters whose codepoints are + 0xa5b9, 0xa5c8. On the other hand, there is one character whose + codepoint is 0xb9a5. So 0xb9a5 can match with 2nd byte of 0xa5b9 + and 1st byte of 0xa5c8. + + * configure.in: Add check for mbrtowc. + * src/search.c (check_multibyte_string): new function. + Support for multibyte string. + (EGexecute): call check_multibyte_string when kwset is set. + (Fexecute): call to check_multibyte_string. + (MBS_SUPPORT): new macro. + (MB_CUR_MAX): new macro. + +2001-02-16 Alain Magloire + + * djgpp/config.bat: Fix for 4dos.com. + * m4/dosfile.m4 (HAVE_DOS_FILE_CONTENTS): Was not set. + Bugs noted and patched by Juan Manuel Guerrero. + +2001-02-16 Alain Magloire + + A much requested feature, the possibility to select + files when doing recurse : + # find . -name "*.c" | xargs grep main {} + # grep --include=*.c main . + # find . -not -name "*.c" | xargs grep main {} + # grep --exclude=*.c main . + + * src/grep.c (short_options): -R equivalent to -r. + (#ifdef) : Fix some inconsistencies in the use of #ifdefs, prefer + #if defined() wen possible. + (long_options): Add --color, --include and exclude. + (Usage): Description of new options. + (color): Rename color variable to color_option. + Removed 'always|never|auto' arguments, not necessary for grep. + (exclude_pattern): new variable, holder for the file pattern. + (include_pattern): new variable, hoder for the file pattern. + * src/savedir.c: Signature change, take two new argmuments. + * doc/grep.texi: Document, new options. + * doc/grep.man: Document, new options. + +2001-02-09 Alain Magloire + + * src/grep.c (long_options): Added equivalent to -r with -R. + * src/grep.c (usage): added --color and --colour. + Noted with patch from, H.Merijn Brand and Wichert Akkerman. + +2001-02-09 Alain Magloire + + Patch from Ulrich Drepper to provide hilighting. + + * src/grep.c: New option --color. + (color): New static var. + (COLOR_OPTION): new constant. + (grep_color): new static var. + (prline): Now when color is set prline() will call the current matcher + to find the offset of the matching string. + * src/savedir.c: Take advantage of _DIRENT_HAVE_TYPE if supported. + * src/search.c (EGexecute, Fexecute, Pexecute): Take a new argument + when doing exact match for the color hiligting. + +2000-09-01 Brian Youmans + + * doc/grep.texi: Typo fixes. + +2000-08-30 Paul Eggert + + * doc/grep.texi (Usage): Talk about what "grep -r hello *.c" + means. + +2000-08-20 Paul Eggert + + Handle range expressions correctly even when they match + strings with two or more characters. + + * src/dfa.h (CRANGE): New enum value. Comment fix. + + * src/dfa.c: Include <locale.h> if HAVE_SETLOCALE. + Include "hard-locale.h". + (prtok): Print CRANGE. + (hard_LC_COLLATE): New static var. + (lex): Return CRANGE when parsing a character range in a hard locale. + Don't use strcoll; it's no longer needed and wasn't correct anyway. + Use unsigned rather than token to hold unsigned chars. + (addtok): Comment fix. + (atom): Treat a CRANGE as if it were (.\1), approximately. + (dfaparse): Initialize hard_LC_COLLATE. + + * src/Makefile.am (base_sources): Add hard-locale.c, hard-locale.h. + + * src/hard-locale.c, src/hard-locale.h: New files, taken from + textutils. + +2000-08-20 Paul Eggert + + * tests/Makefile.am (TESTS_ENVIRONMENT): Add LC_ALL=C, since + some of the tests assume the C locale. + +2000-08-16 Paul Eggert + + * src/search.c (Gcompile, Ecompile): -x overrides -w, for + consistency with fgrep. Don't assume that sizes fit in 'int'. + Fix comments to match code. + +2000-06-06 Paul Eggert + + * src/grep.c (grepdir): Don't look at st_dev when testing for + Mingw32 bug. + +2000-06-05 Paul Eggert + + Port to Mingw32, based on suggestions from Christian Groessler + <cpg@aladdin.de>. + + * src/isdir.c: New file, taken from fileutils. + + * src/Makefile.am (base_sources): Add isdir.c. + + * src/grep.c (grepfile): Use isdir instead of doing it inline. + (grepdir): Suppress ancestor check if the directory's inode and device + are both zero, as that occurs only on Mingw32 which doesn't support + inode or device. + + * src/system.h (isdir): New decl. + (is_EISDIR): Depend on HAVE_DIR_EACCES_BUG, not D_OK. + Use isdir, not access. + +2000-06-02 Paul Eggert + + Problen noted by Gerald Stoller <gerald_stoller@hotmail.com> + + * src/grep.c (main): POSIX.2 says that -q overrides -l, which + in turn overrides the other output options. Fix grep to + behave that way. + +2000-05-27 Paul Eggert + + Simplify and tune the buffer allocation strategy. Do not reserve a + large save area: reserve only enough bytes to hold the residue, plus + page alignment. Put a newline sentinel before the buffer, for speed + when searching backwards for newline. + + * src/grep.c (ubuffer, bufsalloc, PREFERRED_SAVE_FACTOR, page_alloc): + Remove. All uses changed. + (INITIAL_BUFSIZE): New macro. + (reset, fillbuf): Use simpler buffer allocation strategy. + (reset): Check for preposterously large pagesize that would cause + later calculations to overflow. + (fillbuf): Do not resize buffer if there's room at the end for + at least one more page. This greatly increases performance when + reading from non-regular files that contain no newlines. + When growing the buffer, double its size instead of using a + more complicated algorithm. + (prtext, grep): Speed up by relying on the newline sentinel before the + start of the buffer. + (grep): When looking backwards for the last newline in a buffer, + stop when we hit the residue, since it can't contain a newline. + This avoids an O(N**2) algorithm when reading binary data from + a pipe. Use a sentinel to speed up the backward search for newline. + (nlscan): Undo previous change; it wasn't needed and just complicates + and slows down the code a tad. + +2000-05-24 Paul Eggert + + Handle very large input counts better. Bug noted by Jim Meyering. + + * src/grep.c (totalcc, totalnl): Use uintmax_t, not off_t. + (add_count): New function. + (nlscan, prline, grep): Use it to check line and byte count overflows. + (nlscan, grep): Don't keep track of counts when not asked to; this + avoids unnecessary overflow diagnostics. + (print_offset_sep): Now takes args of type uintmax_t and char, + not off_t and int. + +2000-05-16 Paul Eggert + + Problem reported by Bob Proulx <rwp@hprwp.fc.hp.com>, this patch + is base on his finding, with appropiate corrections. + + * src/grep.c (main): Fix bug: -x and -w matched even when no + patterns were specified. + * tests/empty.sh: Test for -x and -w bug in grep 2.4.2. + +2000-04-24 Paul Eggert + + POSIX.2 conformance fixes: grep -q now exits with status zero + if an input line is selected, even if an error also occurs. + grep -s no longer affects exit status. + + * src/grep.c (suppress_errors): Move definition earlier so + that suppressible_error can use it. + (suppressible_error): New function. + (exit_on_match): New var. + (grepbuf): If exit_on_match is nonzero, exit with status zero + immediately. + (grep, grepfile, grepdir): Invoke suppressible_error. + (main): -q sets exit_on_match. + + * doc/grep.1, doc/grep.texi, NEWS: + Document -q's behavior as required by POSIX.2. + + * tests/status.sh: + Test for -q and -s behavior as conforming to POSIX.2. + +2000-04-20 Paul Eggert + + * tests/Makefile.am (TESTS_ENVIRONMENT): + Set GREP_OPTIONS to the empty string. + +2000-04-20 Paul Eggert + + * tests/status.sh: Fix typo: test -b -> test -r. + +2000-04-20 Paul Eggert + + * src/dfa.c (lex): + Do not assume that [c] is equivalent to [c-c]; this isn't true + if LC_COLLATE specifies that some characters are equivalent. + (setbit_case_fold): New function. + (lex): Use it to simplify the code a bit. + +2000-04-17 Paul Eggert + + Do CRLF munging only if HAVE_DOS_FILE_CONTENTS, instead of + having it depend on O_BINARY (which leads to incorrect results + on BeOS, VMS, and MacOS). + + * bootstrap/Makefile.try (DEFS): Add -DHAVE_DOS_FILE_CONTENTS. + * src/system.h (SET_BINARY): Define only if HAVE_DOS_FILE_CONTENTS. + (O_BINARY): Do not define. + + * m4/dosfile.m4: Define HAVE_DOS_FILE_CONTENTS if it appears we're + using DOS. + + * src/grep.c (undossify_input, fillbuf, dosbuf.c, prline, main): + Depend on HAVE_DOS_FILE_CONTENTS, not O_BINARY, when handling CRLF + matters. + (grepfile, main): Depend on SET_BINARY, not O_BINARY, when + handling binary files on hosts that care about text versus binary. + +2000-04-17 Paul Eggert + + * lib/getpagesize.h (getpagesize): Define to B_PAGE_SIZE if + __BEOS__ is defined. Based on a fix by Bruno Haible + <haible@clisp.cons.org>. + +2000-04-17 Bruno Haible + + * src/system.h [BeOS]: Ignore O_BINARY. + * src/getpagesize.h [BeOS]: Define getpagesize() as B_PAGE_SIZE. + +2000-04-10 Paul Eggert + + * doc/grep.1, doc/grep.texi, NEWS: -C now requires an operand. + * src/grep.c (short_options, long_options, main, usage): Likewise. + (context_length_arg): Renamed from ck_atoi. Now reports an error + and exits if the number is out of range for a context length. + (get_nondigit_option): New function, which checks for overflow + correctly, and which does not parse nonadjacent strings of digits + into a single number. + (main): Use get_nondigit_option instead of doing the code inline. + With -A, -B, and -C, optarg is now guaranteed to be nonzero. + +2000-04-08 Paul Eggert + + Now that we know that the input is always terminated by a + newline before the matching algorithms see it, clean up the + matching algorithms so that they no longer need to modify the + input by inserting a sentinel newline, and no longer worry + about running off the end of the buffer due to a missing sentinel. + + * src/grep.c (nlscan, prpending, prtext, grepbuf): Do not + worry about running off the end of the input buffer, since + it's now guaranteed to end in the sentinel newline. + * src/search.c (EGexecute, Pexecute): Likewise. + + * src/dfa.c (prtok, dfasyntax, dfaparse, copy, merge, state_index, + epsclosure, dfaexec, dfacomp): + Change many instances of "T *" to "T const *", to catch + any inadvertent programming errors made during this conversion. + * src/dfa.h (dfacomp, dfaexec, dfaparse): Likewise. + * src/grep.c (struct stats.parent, long_options, grepdir, + compile, execute, fillbuf, lastnl, lastout, nlscan, prline, + prpending, prtext, grepbuf, grep, grepfile, grepdir): Likewise. + * src/grep.h (struct matcher.compile, struct matcher.execute): + Likewise. + * src/kwset.c (struct kwset.trans, kwsalloc, kwsincr, treefails, + treedelta, hasevery, treenext, bmexec, cwexec, kwsexec): Likewise. + * src/kwset.h (kwsalloc, kwsincr, kwsexec): Likewise. + * src/search.c (kwsmusts, Gcompile, Ecompile, EGexecute, Pcompile, + Pexecute): Likewise. + + * src/dfa.c (dfaexec): + Use size_t, not char *, to avoid worrisome casts to convert + char const * to char *. + * src/dfa.h (dfaexec): Likewise. + * src/grep.c (execute): Likewise. + * src/grep.h (execute): Likewise. + * src/kwset.c (bmexec, cwexec, kwsexec): Likewise. + * src/kwset.h (struct kwsmatch.offset, kwsalloc, kwsincr, + kwsexec): Likewise. + * src/search.c (EGexecute, Fexecute, Pexecute): Likewise. + + * src/dfa.h (_PTR_T): Depend on defined __STDC__, not __STDC__. + (PARAMS): Depend on PROTOTYPES, not __STDC__. + + * src/dfa.c (dfasyntax): Last arg is unsigned char, not int. + * src/dfa.h (dfasyntax): Likewise. + + * src/dfa.h (struct dfa): Remove member newlines; no longer needed. + * src/dfa.c (build_state, dfaexec, dfafree): Do not worry + about special newline state. + + * src/search.c (matchers): Move definition to end of file, so + that we don't need forward decls. + (lastexact): Remove. + (kwset_exact_matches): New var; subsumes old lastexact var. + All uses changed. + + * src/dfa.c (index): Remove macro. + (REALLOC_IF_NECESSARY): Skip unnecessary test. + (tstbit, setbit, clrbit): Declare arg to be unsigned, to help compiler. + (copyset, zeroset, equal): Use C builtin primitives, to help compiler. + (dfaexec): Do not modify input string. + Remove newline parameter; no longer needed. + (comsubs): Use strchr, not index. + + * src/grep.h (matchers): Use fixed name size, not pointer (as + there's no need for the extra flexibility). All uses changed. + + * src/kwset.h (struct kwsmatch.offset): Renamed from beg, with + change of type to size_t. All uses changed. + + * src/grep.c (reset): No longer need kludge for dfaexec. Simplify. + (reset, grepbuf): Adjust to new interface for 'execute'. + (install_matcher): List is now terminated by null compile, + not null name. + Do not invoke setrlimit if that wouldn't change the limit. + + * src/dfa.c (xcalloc, xmalloc, xrealloc, prtok, tstbit, setbit, + clrbit, copyset, zeroset, notset, equal, charclass_index, + looking_at, lex, addtok, atom, nsubtoks, copytoks, closure, + branch, regexp, copy, insert, merge, delete, state_index, + build_state, build_state_zero, icatalloc, icpyalloc, istrstr, + ifree, freelist, enlist, comsubs, addlists, inboth): + Remove forward decls; no longer needed. + * src/grep.c (ck_atoi, usage, error, setmatcher, + install_matcher, prepend_args, prepend_default_options, + page_alloc, reset, fillbuf, grepbuf, prtext, prpending, prline, + print_offset_sep, nlscan, grep, grepfile): Likewise. + * src/kwset.c (enqueue, treefails, treedelta, hasevery, + treenext, bmexec, cwexec): Likewise. + * src/search.c (Gcompile, Ecompile, EGexecute, Fcompile, Fexecute, + Pcompile, Pexecute, kwsinit): Likewise. + + * src/search.c (Pcompile): Do not assume newly allocated + storage is zeroed. + +2000-04-06 Paul Eggert + + * doc/grep.1, doc/grep.texi, NEWS: Improve the explanation of + locale-dependent behavior of range expressions. Mention + LC_COLLATE, since this affects range expressions. + +2000-03-26 Paul Eggert + + * Makefile.am (ACINCLUDE_INPUTS): Add decl.m4, inttypes_h.m4, + uintmax_t.m4, ulonglong.m4, xstrtoumax.m4. + * m4/Makefile.am (EXTRA_DIST): Likewise. + + * src/Makefile.am (base_sources): + Add xstrtol.c, xstrtol.h, xstrtoumax.c. + (EXTRA_DIST): Add strtol.c. + + * configure.in (jm_AC_TYPE_UINTMAX_T, jm_AC_PREREQ_XSTRTOUMAX, + HAVE_DECL_STRTOUL, HAVE_DECL_STRTOULL): Add. + (AC_REPLACE_FUNCS): Add strtoul. + + * src/grep.c: Include xstrtol.h. + (ck_atio): Use xstrtoumax and do proper overflow checking. + (max_count, outleft): Now off_t, not int. + (main): Likewise. Use xstrtoumax to convert max_count from string. + + * acconfig.h (HAVE_DECL_STRTOUL, HAVE_DECL_STRTOULL): New #undefs. + (HAVE_STPCPY, ENABLE_NLS, HAVE_CATGETS, HAVE_GETTEXT, + HAVE_LC_MESSAGES): Remove. + + * m4/decl.m4, m4/inttypes_h.m4, m4/uintmax_t.m4, m4/ulonglong.m4, + m4/xstrtoumax.m4, src/strtol.c, src/strtoul.c, src/strtoull.c, + src/strtoumax.c, src/xstrtol.c, src/xstrtol.h, src/xstrtoumax.c: + New files, taken unchanged from textutils, fileutils, sh-utils + and/or tar. + +2000-03-23 Paul Eggert + + * src/search.c (Pcompile): Add support for NUL bytes in + Perl regular expressions. + +2000-03-23 Paul Eggert + + * NEWS, doc/grep.1, doc/grep.texi: Change --pcre to --perl-regexp. + * src/grep.c (long_options, usage): Likewise. + + * doc/grep.1, doc/grep.texi: Remove pgrep program. + * src/Makefile.am (bin_PROGRAMS): Likewise. + (pgrep_SOURCES): Remove. + + * src/grep.c (main): Rename matcher from "pgrep" to "perl". + * src/search.c (matchers): Likewise. + + * src/search.c: Do not include stdio.h; no longer needed. + (NILP): Remove. + (sub): No longer static. + (n_pcre): Remove. + (cre): No longer an array. Present only if HAVE_LIBPCRE. + (extra): New variable. + (Pcompile): Use fatal to report errors. + This also removes a possible core dump. + Add checks (marked FIXME) for restrictions in pcre. + Use pcre_maketables for proper localized behavior. + (Pcompile, Pexecute): Use GNU coding style. + The argument is a single pattern, not a list of patterns separated + by newlines; this is for consistency with grep and egrep. + Use pcre_study for speed. + (Pexecute): Abort if we lack pcre. + Abort if pcre_exec reports an impossible error. + Use code similar to the rest of search.c + to narrow down to the line we've found. + +2000-03-21 Alain Magloire + + * configure.in: added AC_CHECK_LIB(pcre, pcre_exec) + * ChangeLog: Typos corrected. + * src/search.c: new MACRO HAVE_LIBPCRE + +2000-03-21 H.Merijn Brand + + * src/Makefile.am(bin_PROGRAMS): added pgrep and new macro + pgrep_SOURCES. + * src/search.c: new functions Pcompile() and Pexecute() + to support PCRE. Update matcher[] array for pgrep. + * src/grep.c: new short and long option --pcre and -P. + usage() updated. + +2000-03-21 Bastiaan Stougie + + Improvement of the -m or --max-count option. Now works for NUM > 1 and + prints trailing context for the last matching line. + + * src/grep.c + (after_last_match): Is a new off_t variable that replaces inputhwm + to retain the correct input offset even after a call to fillbuf. Note + that after_last_match has a different meaning than inputhwm: + it always points to the offset in the input of the first byte after + the last matching line, and is 0 if no matching line has been found + yet. + (grep): Print trailing context after the NUMth match when the -m NUM + option is used. + (grep): Added comment. Should have been commented already. + (grepbuf): Now updates outleft correctly. This fixes the bug that the + -m NUM option did not stop after NUM lines for NUM greater than 1. + (grepbuf, prtext): Now update after_last_match instead of inputhwm. + (fillbuf): No longer updates inputhwm. + (prpending): When outputting trailing context of the max_count-th + matching line, stop at the first matching line. + (grepfile): Seek to after_last_match or eof, depending on the values + of outleft and bufmapped. + (usage): added the -m or --max-count option to the help message. + * doc/grep.texi, doc/grep.1: Document the change of the -m option. + +2000-03-17 Paul Eggert + + Add new -m or --max-count option, based on a suggestion by + Bastiaan Stougie. + + * doc/grep.texi, doc/grep.1: Document it. + * src/grep.c (short_options, long_options, main): Add it. + (inputhwm): New variable. + (fillbuf, prtext, grepbuf): Set it. + (bufmapped): Now a macro (defined to zero) if HAVE_MMAP is not defined. + (max_count, outleft): New variables. + (prtext, grepbuf, grep): Don't output more than outleft lines. + (grepfile): If grepping standard input, seek to the limit of what + we've read before exiting. This fixes a bug with mmapped input, + and is needed for proper -m support. + (main): Exit immediately if -m 0 is specified. + +2000-03-08 Alain Magloire + + * configure.in: version 2.4.2 + +2000-03-07 Paul Eggert + + * Make intl subdirectory match fileutils, tar, etc.; + see intl/ChangeLog for details. + + * src/getpagesize.h: Reformat to match latest fileutils. + + * src/savedir.c (savedir): Work even if directory size is + negative; this can happen with some NFS screwups. + +2000-03-03 Jim Meyering + + * regex.m4: Make sure re_compile_pattern accepts patterns like `{1'. + +2000-03-02 Alain Magloire + + * 2.4.1 Release + +2000-02-25 Paul Eggert + + * configure.in (LIBOBJS): Work around automake 1.4 bug: + regex.c wasn't being passed through ansi2knr on pre-ANSI hosts. + (ac_use_included_regex): Fix typo in warning. + * src/Makefile.am (EXTRA_DIST): Remove regex.c, as the LIBOBJS + workaround means that automake now puts regex.c into DIST_COMMON. + +2000-02-25 Alain Magloire + + * po/*.po: update of the PO files. + +2000-02-22 Eli Zaretskii + + * doc/grep.1: Two small glitches(typos). + +2000-02-18 Eli Zaretskii + + * djgpp/config.site (prefix, INSTALL): Use /dev/env/DJDIR instead + of ${DJDIR}, so that the produced Makefile's work on any DJGPP + installation. + +2000-01-30 Alain Magloire + + * doc/grep.1: corrected typo. + Noted by Ruslan Ermilov. + +2000-01-30 Alain Magloire + + * vms/Makefile.am: added config_vms.h to EXTRA_DIST. + * vms/config_vms.h: New File, contains macros specific to VMS and + avoid namespace collision with operating system supplied C library. + * vms/make.com: Better compiler auto-detection; information for builds + on pre-OpenVMS 7.x systems; general overhaul. + * src/getpagesize.h: Reinstate support for different pagesizes on + VAX and Alpha. Work around problem with DEC C compiler. + * src/vms_fab.c: Cast to some assigments; fixed typo argcp vs. argp. + * src/vms_fab.h: Added new include files to avoid warnings about + undefined function prototypes. + Those patches were provided by Martin P.J. Zinser (zinser@decus.de). + +2000-01-30 Paul Eggert + + * src/grep.c (main): Update copyright notice. + +2000-01-28 Alain Magloire + + * src/grep.c (usage): The example "%s -i 'hello.*world' could + lead to confusion when progname is 'fgrep. + Noted by Akim Demaille. + + * configure.in: Reenable, jm_INCLUDE_REGEX() since we now + track GNU lib C. + * src/Makefile.am: EXTRA_DIST new macros with regex.c regex.h. + Requested By Ulrich Drepper. + +2000-01-25 Paul Eggert + + * src/grep.c (grep): If the final byte of an input file is not + a newline, grep now silently supplies one. + * doc/grep.texi, NEWS: Likewise. + +2000-01-25 Paul Eggert + + * NEWS, doc/grep.1, doc/grep.texi: Add -I option. + * src/grep.c (short_options, usage, main): Likewise. + + * doc/grep.texi: Fix some incorrect references to ASCII. + +2000-01-25 Paul Eggert + + * doc/grep.1: Simplify synopsis; sort options; mention + environment variables; clean up some minor gaffes. + +2000-01-25 Paul Eggert + + * doc/grep.texi: + Fix some errors in description of [:print:] and the like. + +2000-01-23 Paul Eggert + + * src/dfa.c (FETCH, lex): Put brackets around if-body to avoid + GCC warning about ambiguous if-then-else. + +2000-01-23 Paul Eggert + + * src/regex.c (GET_UNSIGNED_NUMBER): Allow only ASCII digits. + * src/dfa.c (ISASCIIDIGIT): New macro. + (lex): Use it instead of ISDIGIT. + +2000-01-23 Paul Eggert + + The bug is that regular expression ranges like [a-z] compare raw + byte codes to the range boundaries, whereas POSIX says that they + should use the current collating sequence instead. For example, + in Solaris 7 with LC_ALL=en_US, the command + echo x | grep '[ -~]' + outputs 'x', but it shouldn't output anything since ' ' and '~' + sort before all letters in that locale. + + * src/regex.c (compile_range): When matching a character + range, use the current collating sequence, as POSIX requires. + * src/dfa.c (lex): Likewise. + +2000-01-20 Alain Magloire + + * tests/Makefile.am (dist-hook): Added new rule to make sure + that the shell scripts have the right permissions. + * src/posix/Makefile.am (EXTRA_DIST): added regex.h in the + distribution. + * THANKS: updated. + +2000-01-18 Alain Magloire + + * Rectification the initial patch to add --binary-file option + was done by Ruslan Ermilov. + +2000-01-17 Paul Eggert + + Sync with sources of fileutils 4.0n, tar 1.13.17, glibc 2.1.3a1. + Convert to ANSI C prototypes (using ansi2knr for backwards + compatibility), as this makes it easier to sync. + + * configure.in (AC_OBJEXT): Spell in a funny way, to work around + a bug in automake 1.4 with ansi2knr. + (LIBOBJS): Add assignment so that .o files in LIBOBJS are also built + via the ANSI2KNR-filtering rules. + (AC_OUTPUT): Add src/posix/Makefile. + * src/Makefile.am (AUTOMAKE_OPTIONS): Add ansi2knr. + (SUBDIRS): New macro. + * src/ansi2knr.1, src/ansi2knr.c, src/posix/Makefile.am: New files. + * src/dfa.c, src/dosbuf.c, src/grep.c, src/kwset.c, src/search.c, + src/vms_fab.c: + Use prototypes for function definitions. + * src/grep.c (main): Use int counter for default context, + fixing an ANSI portability bug uncovered by the above changes. + + * config.guess, config.sub, install-sh, missing, src/alloca.c, + src/getpagesize.h, src/memchr.c, src/savedir.c, src/savedir.h, + src/stpcpy.c: + Upgrade to latest version from fileutils 4.0n. + + * src/getopt.c, src/getopt.h, src/getopt1.c: Upgrade to latest + version from tar 1.13.17. + + * src/obstack.c, src/obstack.h, src/regex.c, src/regex.h: + Upgrade to glibc 2.1.3 alpha 1, with K&R C portability fix. + * src/posix/regex.h: New file, from glibc 2.1.3 alpha 1. + +2000-01-04 Paul Eggert + + Initial patch by Ruslan Ermilov. + + Add --binary-files option. + * NEWS, doc/grep.1, doc/grep.texi: Document it. + * src/grep.c (BINARY_FILES_OPTION): New constant. + (long_options, grep, usage, main): New --binary-files option. + (binary_files): New var. + * src/system.h (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM, CHAR_MAX): + New macros. + (INT_MAX, UCHAR_MAX): Define in terms of TYPE_MAXIMUM. + +2000-01-04 Paul Eggert + + * savedir.c (savedir): Don't store past the end of an array if + name_size is zero and the directory is empty. + Reported by Dima Barsky <dima@pwd.hp.com>. + +1999-12-03 Alain Magloire + + * 2.4 Release. + +1999-11-18 Paul Eggert + + * m4/largefile.m4 (AC_SYS_LARGEFILE_FLAGS): Work around a + problem with the QNX 4.25 shell, which doesn't propagate exit + status of failed commands inside shell assignments. + +1999-11-13 Eli Zaretskii + + * doc/grep.texi: Minor markup and spelling corrections. Use + @noindent where appropriate. + + * PATCHES-{AM,AC}: rename to PATCHES.{AM,AC} + +1999-11-12 Eli Zaretskii + + doc/grep.texi: Minor fixes and typos corrected. + djgpp/README: Updated version. + +1999-11-07 Paul Eggert + + * src/grep.c (usage): Fix misspelling. + +1999-11-07 Paul Eggert + + Don't assume that the C library has re_set_syntax and friends. + * src/Makefile.am (base_sources): Add regex.c, regex.h. + (EXTRA_DIST): Remove regex.c, regex.h. + + * src/grep.c (prtext): Use out_quiet, not not_text, to decide + whether to set pending to zero at the end. + (not_text): Remove static variable, undoing latest change. + (grep): Likewise. + + * doc/grep.texi: Tighten up the text, and fix some minor + spelling and usage errors. Use @enumerate rather than @table + @samp, since it's better for Q&A format. Add cross + references. + +1999-11-01 Alain Magloire + + * src/search.c: Use the more portable [[:alnum:]] + to define a word instead of Ascii dependent [0-9A-Za-z] + * src/grep.c: make not_text global to not display text when + the context switches -A/-B/-C are use on binary files. + * make grep-2.3g available for testing. + * configure.in: drop support for --without-included-regex. + This was generating bogus bug reports, since many GNU/Linux + users have different version of glibc. And glibc maintainers + decided to drop k&r support. + +1999-11-01 Arnold D. Robbins + + * regex.c (init_syntax_once): move below definition of + ISALNUM etc., then use ISALNUM to init the table, so that + the word ops will work if i18n'ed. + (SYNTAX): And subscript with 0xFF for Latin-1 characters. + +1999-10-26 Alain Magloire + + * src/regex.c: Merge changes from GNU lib C. + * Updated the *.po files + +1999-10-26 Paul Eggert + + * src/grep.c (fillbuf): Don't report buffer size overflow if + newalloc == save and maxalloc == save. This can happen + e.g. when reading a large page-aligned file that contains + no newlines. + +1999-10-21 Paul Eggert + + * src/grep.c (usage): Give example. Clarify -F. + Explain exit status more clearly. + +1999-10-12 Paul Eggert + + * doc/grep.texi: Shorten the commentary about egrep and {. + "BSD grep" -> "traditional grep". + * doc/grep.1: Match recent changes to grep.texi. + +1999-10-11 Paul Eggert + + * NEWS, doc/grep.1, doc/grep.texi: New option --mmap. + * src/grep.c (mmap_option): New variable. + (long_options, reset, usage): Add --mmap. + Default is now read, not mmap. + + * doc/grep.1: Document -Z or --null. + +1999-10-11 Paul Eggert + + * doc/grep.texi: Fix texinfo glitches. POSIX -> POSIX.2 where + appropriate. + +1999-10-11 Paul Eggert + + * acconfig.h (ssize_t): New #undef. + + * configure.in (AC_CHECK_TYPE): Add ssize_t. + + * src/grep.c (PREFERRED_SAVE_FACTOR): New macro. + (reset): If the buffer has already been allocated, set bufsalloc to + be bufalloc / PREFERRED_SAVE_FACTOR. This avoids problems when + bufsalloc == bufalloc (possible after reading a large binary file). + (reset): Use PREFERRED_SAVE_FACTOR instead of magic constant. + Do not set bufbeg; nobody uses it. + Always set buflim. + Check for lseek error. + Use SEEK_CUR, not a magic constant. + (fillbuf): Return an error indication, not a count. + All callers changed. + Do not assume ssize_t fits in int. + Use PREFERRED_SAVE_FACTOR instead of magic constant. + Clean up mmap code. + Do not attempt to mmap zero bytes. + Check for lseek error. + Use SEEK_SET, not a magic constant. + Work correctly if read is interrupted. + (grepfile): Work correctly if open or close is interrupted. + + * src/system.h (SEEK_SET, SEEK_CUR): New macros. + +1999-10-02 Alain Magloire + + * src/regex.[ch]: upgrade from GNU lib C source tree. + + * make beta 2.3f available. + +1999-10-02 Paul Eggert + + * NEWS: egrep is now equivalent to `grep -E'. + The lower bound of an interval is not optional. + You can specify a matcher multiple types without error. + -u and -U are now allowed on non-DOS hosts, and have no effect. + * doc/grep.texi: Likewise. + * doc/grep.1: Likewise. + Fix some troff bugs that prevented `groff' from rendering the page. + + * src/egrepmat.c, src/fgrepmat.c, src/grepmat.c (default_matcher): + Remove. + (matcher): Add. + * src/grep.h (default_matcher): Remove. + (matcher): Now exported from ?grepmat.c, not grep.c. + + * src/dfa.c (lex): If { would start an invalid interval specification, + treat it as a normal character. + Remove (broken) support for {,M} meaning {0,M}. + Diagnose bogus intervals like {1,0}. + (closure): maxrep is now -1 to indicate no limit, not zero; + zero is a valid value for maxrep, meaning an upper bound of zero. + + * src/grep.c (short_options): New constant. + (long_options, main): -u and -U are now supported on Unix, + with no effect. + (matcher): Removed; now defined by ?grepmat.c. + (install_matcher): Renamed from setmatcher. + (setmatcher): New function. + (usage): Report new, more uniform option scheme. + (main): Do not initialize matcher; ?grepmat.c now does this. + Rely on setmatcher to catch matcher conflicts. + Default matcher is "grep". + + * src/search.c (matchers): + Remove "posix-egrep" matcher; no longer needed. + (Ecompile): Likewise. + The egrep matcher now has POSIX behavior. + + * tests/bre.tests: grep '\{' is no longer an error. + Fix test for interval too large, and enable it. + * tests/ere.tests: grep -E {1 is no longer an error + Likewise for a{1, a{1a, a{1a}, a{1,x}. + +1999-09-22 Paul Eggert + + * largefile.m4 (AC_SYS_LARGEFILE_FLAGS): Work around GCC + 2.95.1 bug with HP-UX 10.20. + +1999-09-12 Paul Eggert + + * src/grep.c (fillbuf): Fix typo: we sometimes reported + arithmetic overflow even when there wasn't any. + +1999-09-12 Paul Eggert + + * configure.in (AC_CHECK_FUNCS): Add memmove. + + * src/system.h (S_ISREG): New macro. + (memmove): Define if ! defined HAVE_MEMMOVE && ! defined memmove, + not if !defined STDC_HEADERS. This is needed for SunOS 4.1.4, + which defines STDC_HEADERS but lacks memmove. + + * src/grep.c (bufoffset): Needed even if !defined HAVE_MMAP. + (reset): Always fstat the file, since we always need its size if it is + regular. + Similarly, get the buffer offset of every regular file. + Set bufmapped to 0 if the file's initial offset is not a multiple + of the page size. + (fillbuf): Calculate an upper bound on how much memory we should + allocate only for regular files, since we don't know the sizes of + other files. + Don't bother to check whether the file offset is a multiple of the page + size, since we now do that just once in `reset'. + When an mmapped area would fall past the end of the file, trim it to + just before instead of giving up immediately and doing a `read'; + that avoids a worst-case behavior that could read half an mmapped file. + Fix bug when computing offsets on hosts that don't have mmap. + +1999-08-27 Paul Eggert + + * src/system.h (memmove): New macro. + + * src/grep.c (page_alloc): Reallocate the old buffer instead + of having both old and new buffers active simultaneously. + Remove valloc debugging variant, which no longer applies. + + (fillbuf): Rejigger the buffer allocation mechanism. The old + mechanism could allocate more than 10*N bytes for an N-byte + file, which was excessive. Check for arithmetic overflow a + bit more carefully. + +1999-08-25 Paul Eggert + + * src/grep.c (grepdir): + Don't assume that st_ino and st_dev must be integers; + POSIX.1 allows them to be floating-point (!). + + * src/vms_fab.h (arr_ptr): `:' -> `;' to fix typo. + +1999-08-18 Alain Magloire + + * 2.3e snapshot. + +1999-08-18 Alain Magloire + + * src/search.c: On a CRAY J90 system running UNICOS 8.0. + Compilation of ./src/search.c failed because the declaration of + the variable "regex": + static struct re_pattern_buffer regex; + conflicted with a previous declaration search.c #includes "system.h", + which #includes <stdlib.h>, which declares : + extern char *regex __((char *_Re, char *_Subject, ...)); + The declaration in search.c is local to that one source file. + I just changed its name to something less likely to conflict. + (I called it "regexbuf", but you could pick any name you want.) + Excerpt email from Dean Kopesky. + +1999-08-16 Paul Eggert + + Upgrade large-file support to the version used in tar and + textutils. + + * Makefile.am (ACLOCAL_AMFLAGS): Define to be empty. + (M4DIR, ACINCLUDE_INPUTS): New macros. + ($(srcdir)/acinclude.m4): New rule. + + * configure.in (AC_CANONICAL_HOST, AM_C_PROTOTYPES): Add. + (AC_SYS_LARGEFILE): Renamed from AC_LFS, for compatibility + with what should appear in the next autoconf release. + + * m4/largefile.m4: Renamed from m4/lfs.m4. + + * src/ansi2knr.1, src/ansi2knr.c, config.guess, config.sub: + New files. config.guess and config.sub ar needed by the new + AC_SYS_LARGEFILE. ansi2knr is needed by AM_C_PROTOTYPES, + which in turn is needed by the new AC_SYS_LARGEFILE. + +1999-08-16 Alain Magloire + + * 2.3d snapshot on ftp server. + +1999-07-26 Paul Eggert + +Several GNU tools have options to process arbitrary file names, even +file names that contain newline characters. These include `find +-print0', `perl -0', `sort -z', and `xargs -0'. It'd be handy if GNU +grep also processed such file names. Here's a proposed patch to do +this, relative to grep 2.3c. This patch introduces two options, one +for the data, and one for the file names. (Sometimes one wants +null-terminated file names in the output, and sometimes one wants to +process lists of null-terminated strings, and these are orthogonal +axes.) + + * NEWS, doc/grep.texi: New -z or --null-data and -Z or --null options. + * src/grep.c (long_options, usage, main): Likewise. + + * src/dfa.h (dfasyntax): New eol parameter. + * src/dfa.c (eolbyte): New var. + (dfasyntax): Set it from new parameter. + (lex, dfastat, build_state, dfaexec): Use it instead of '\n'. + + * src/grep.h (eolbyte): New decl. + * src/grep.c (eolbyte): New var. + (nlscan, prpending, prtext, grepbuf, grep): Use it instead of '\n'. + (filename_mask): New var. + (prline, grepfile): Output NUL separator if filename_mask is zero. + (grep): Look for '\200' as the hallmark of a binary file, not '\0', + if -z or --null-data is specified, since it implies that '\0' is + expected as text. + + * src/search.c (Gcompile, Ecompile): Pass eolbyte to dfasyntax. + (EGexecute, Fexecute): Use eolbyte instead of '\n'. + +1999-06-15 Alain Magloire + + * src/grep.c, doc/grep{1,texi} : + --revert-match should be --invert-match. + Correction proposed by Karl Berry. + +1999-06-12 Alain Magloire + + * doc/grep.{1,texi}: add description for --with-filename. + Noted missing by UEBAYASHI Masao. + +1999-03-17 Paul Eggert + + * NEWS: Add GREP_OPTIONS. + + * doc/grep.texi: Document GREP_OPTIONS, and the other + environment variables. Fix doc for [:blank:], [:cntrl:], [:punct:]. + + * src/grep.c (prepend_args, prepend_default_options): New functions. + (main): Use them to implement GREP_OPTIONS. + * src/system.h (getenv): New decl. + +1999-03-16 Volker Borchert + + * configure.in: Use case case ... esac for checking Visual C++. + When ${CC} contains options it was not recognize. + +1999-03-07 Paul Eggert + + * src/grep.c (usage): Don't report -E, -F, and -G unless we're grep. + (main): Don't match options -E, -F, and -G unless we're grep. + Remove after-the-fact check for options -E, -F, and -G, since + they're no longer needed. + +1999-03-05 Eli Zaretskii + + * src/grep.c (main): Print the name of the default matcher instead + of just "grep". + +1999-02-06 Alain Magloire + + * tests/*.awk : Linux users are seeing "Broken Pipe" on make check. + The problem is that grep does not drain its stdin, thus the previous + process in the pipeline receives a SIGPIPE. Other shells are silent + about this. There is actually no failure, since the broken pipe is + expected. You can work around it by changing the pipeline, so that + the input is drained, like this: + status=`echo 'check' | { ${GREP} -E -e pattern >/dev/null 2>&1; + echo $?; cat >/dev/null; }`; if test $status -ne $errnu then ... fi + Excerpt email from Andreas Schwab. + +1999-02-23 Alain Magloire + + * src/grep.c : Restrict the use of -E, -F, -G + to only grep driver, Posix behaviour. {f,e}grep + the matcher is already set. This change may brake + scripts, warn in NEWS. + + * doc/grep.{1,texi} : -C takes arguments, upgrade manual. + + * beta 2.3a + +1999-02-23 Alain Magloire + + * configure.in : Change the configure VC test from + 'test x$ac_cv_prog_CC = xcl;' to 'test x"$ac_cv_prog_CC" = xcl;' + Email from Joshua R. Poulson. + +1999-02-23 Paul Eggert + + Fix porting bug reported by Amakawa Shuhei for SunOS 4.1.4-JL. + The btowc.c shipped with grep 2.3 is incorrect for Solaris + 2.5.1 and earlier, as it assumes UTF8, which these OSes do not + support. Solaris 7 supports btowc, so there's no need to ship + a substitute for it. The only questionable case is Solaris + 2.6, which lacks btowc but does support UTF8. However, 2.6 + supports UTF8 but only as a demonstration (for an English + locale!); Japanese Solaris 2.6 users typically use EUC, or + sometimes shift-JIS, but they cannot use UTF8 since Japanese + UTF8 is not supported. Hence there's no point to having grep + substitute a btowc that uses UTF8, as it is either redundant, + or it will almost invariably have incorrect behavior. + + * configure.in (AC_CHECK_HEADERS): Don't set USE_WCHAR. + (AC_CHECK_FUNCS): Add btowc, wctype. + (AC_REPLACE_FUNCS): Don't replace btowc; our replacement is + invariably doing the wrong thing anyway, at least on SunOS/Solaris. + Don't bother to check for wctype in -lw, as we don't support + wide characters on Solaris 2.5.1 or earlier anyway. + + * bootstrap/Makefile.try (OBJS): Remove btowc.$(OBJEXT). + + * src/btowc.c: Removed; no longer needed. + +1999-02-19 Paul Eggert + + * NEWS: Fix typo when talking about the old behavior of + silently skipping directories; it was grep 2.1, not grep 2.2. + +1999-02-15 Alain Magloire + + * bootstrap/Makefile.try : add DJGPP DEFS. + Done by Elie Zaretsckii. + +1999-02-14 Alain Magloire + + * m4/gettext.m4 : Guard [] with changequote. + From Elie Zaretskii. + + * djgpp/config.bat : Makefile.in.in --> Makefile.in-in + From Elie Zaretskii. + + * src/dosbuf: k&r function parameter. + + * release of 2.3. + +1999-02-10 Alain Magloire + + * bootstrap/{Makefile{try,am},REAMDE} : skeleton + provided for system lacking the tools to autoconfigure. + + * src/{e,f,}grepmat.c: added guard [HAVE_CONFIG_H] + +1999-02-10 Alain Magloire + + * PATCHES-AC, PATCHES-AM: updated. + + * m4/regex.m4 : updated. + +1999-02-05 Eli Zaretskii + + * m4/gettext.m4 : Support DOS-style D:/foo/bar absolute file + names. + + * aclocal.m4 (DJGPP) : Use $DJ_GPP instead, since changing the + latter prevents GCC from finding headers and libraries. + + * djgpp/config.bat: Make building from another directory work + + * djgpp/config.sed: Remove redundant command wich edited path + separator: now done by configure. + + * src/grep.c [O_BINARY]: Add prototype for undossify_input. + + * doc/grep.texi (Introduction): Typo fixed. + +1999-02-03 Alain Magloire + + * grep-2.2f beta release. + +1999-02-02 Alain Magloire + + * m4/{djgpp,envsep,glibc,regex,dosfile,isc-posix}.m4 : + New files to aid configuration and unload configure.in. + * m4/Makefile.am : updated. + * src/btowc.c : protect for wchar.h + +1999-01-28 Alain Magloire + + * intl/Makefile.in: Replace .o with .${ac_objext} where necessary. + Work around a limitation of Visual C++ on Cygwin32. + * acconfig.h configure.in: Define `alloca' as `_alloca' when CC=cl. + This little hack was suggested by Ian Roxborough <irox@cygnus.com>. + Patch forwarded by Ben Elliston. + +1999-01-28 Alain Magloire + + * PATCHES-AM: New file. A small patch for automake-1.4, use $(sep) + as the path separator base on @SEP@. + * PATCHES-AC configure.in : updated for autoconf-13. + +1999-01-27 Volker Borchert + + * grep.c: fgrep -NUM not working correctly. + add the argument number to digit_args_val. + +1999-01-22 Paul Eggert + + Prevent grep -r from recursing infinitely through directory loops via + symbolic links. + + * grep.c (struct stats): New type. + (stats_base): New var. + (bufstat): Remove; subsumed by stats->stat. + (reset, fillbuf, grep, grepdir, grepfile): Pass struct stats * arg, + for directory loop checking; use this instead of the bufstat global. + All callers changed. + (grepfile): Stat the file before invoking grepdir. + (grepdir): Assume that the argument has already been statted. + No longer a need for a directory size argument, since it + can be gotten from the struct stats * argument. + Check for directory loops. + Create linked list of directories currently being visited, + to detect loops. + +1998-12-29 Kaveh R. Ghazi + + intl/localealias.c: When building grep-2.2e using cc on Irix4, + I needed the following patch to intl/localealias.c. + (Its the same patch used by fileutils-4.0.) The patch resolves + conflicts between char* and unsigned char* in the i18n code. + +1998-12-10 Alain Magloire + + * src/grep.c : Typo in contex -->context + Noted by Vladimir Michl. + +1998-12-01 Alain Magloire + + * doc/Makefile.am djgpp/Makefile.am m4/Makefile.am vms/Makefile.am: + New files. + + * m4/progtest.m4: proctect '[]' from m4. + Noted by Eli Z. + + * PATCHES-AC: New file, add the patch for autoconf in the dist. + + * acconfig.h: (HAVE_DOS_FILENAME) + + * TODO: updated. + + * src/search.c: remove obsolete 'gegrep,ggrep,gnugrep' + matchers. grep no longer depend on argv[0]. + + * grep-2.2e beta to test DJGPP port. + +1998-11-28 Paul Eggert + + Various portability enhancements: + - Don't assume that O_BINARY implies DOS. Use separate + macros D_OK (for DOS-like directory access) and + HAVE_DOS_FILE_NAMES (for DOS-like file names). + - Don't assume that off_t fits into long; it doesn't on Solaris 2.6. + - Have is_EISDIR set errno properly on hosts with screwed-up EISDIR. + - Treat ':' specially in DOS file names only if it's the end of a + drive specifier. + - Protect against errno < 0. + + * src/grep.c (is_EISDIR): Move defn to system.h. + (print_offset_sep): New function. + (fillbuf): Remove redundant test of O_BINARY. + (totalcc, totalnl): Now of type off_t. + (prline): Use print_offset_sep to print file offsets. + (grepfile): Don't set e to EISDIR; that's is_EISDIR's responsibility + on machines that don't work properly with EISDIR. + (grepdir): Don't assume ':' means slash on all DOS filenames; + it means it only in the file prefix. + + * src/system.h (strerror): Check for negative error numbers. + (is_EISDIR): Depend on D_OK, not O_BINARY. + (SET_BINARY): Depend on HAVE_SETMODE, not __DJGPP__. + (IS_SLASH, FILESYSTEM_PREFIX_LEN): Depend on HAVE_DOS_FILE_NAMES, + not O_BINARY. + (CHAR_BIT): New macro. + + * src/dosbuf.c (struct dos_map): + pos and add members are now of type off_t. + (dos_stripped_crs): Now of type off_t. + (dossified_pos): Now accepts arg and returns value of type off_t. + + * configure.in (AC_CHECK_FUNCS): Add setmode. + (HAVE_DOS_FILENAMES): New macro + +1998-11-27 Eli Zaretskii + + * djgpp/config.sed: New file, a Sed script to edit configure + script before running it on DOS/Windows. + * djgpp/config.bat: Updated to handle po2tbl.sed.in and + po/Makefile.in.in on DOS filesystems, and to run config.sed. + +1998-11-24 Jim Meyering + + * src/grep.c : Typo s/infalid/invalid/ + Also noted by Stanislav Brabec. + +1998-11-24 Eli Zaretskii + + * doc/grep.texi: I found and corrected several typos. + I believe the GNU standards require the section that describes the + options to the programs to be called ``Invoking'' or ``Invoking + <program-name>''. This is so users and programs can easily find + that node in any Info file. So I changed the name of the + `Options' chapter to `Invoking', and corrected the + cross-references accordingly. + I added some markup to things like file names and options. + I added some additional index entries where that seemed useful. + I also corrected some index entries, such as "@cindex [:alnum:]", + which used a colon in them (the colons confuse Info readers). + +1998-11-24 Alain Magloire + + * grep/doc/grep.texi : -h is not use for help. + Nit spotted by Jim Meyering. + +1998-11-23 Alain Magloire + + * doc: New directory, grep.1, {e,f}grep.man move here + * doc/grep.texi: New info manual + * doc/version.texi: New + * doc/Makefile.am: New + * tests/{ere,bre}.*: New files. The spencer2 test is split + in two ere/bre. + * config.hin: New, config.h.in rename to config.hin for OS + with limited file system aka DOS. + + * grep-2.2d release for beta. + +1998-11-18 Alain Magloire + + * src/regex.[ch] : Updated from GLibc, previous patches were + integrate by Ulrich Drepper and some added ones. + +1998-11-16 Paul Eggert + + * grep.h (__attribute__): New macro, if not GCC. + (fatal): Add __attribute__((noreturn)). + * grep.c (usage): Add __attribute__((noreturn)). + +1998-11-16 Paul Eggert + + Remove memory leak with valloced buffers, by invoking malloc instead. + + * configure.in (AC_CHECK_FUNCS), src/system.h (valloc): Remove. + * src/grep.c (page_alloc): New function. + (ubuffer, pagesize): New vars. + (ALIGN_TO): New macro. + (reset): Initialize new vars. Check for overflow in buffer size calc. + Use page_alloc instead of valloc. + (fillbuf): Likewise. Use memcpy to copy saved area. + +1998-11-15 Paul Eggert + + * dfa.c (dfacomp), search.c (EGexecute): Don't assume char is unsigned. + +1998-11-14 Paul Eggert + + * src/grep.c (grepdir): Fix bug: memory freed twice. + + * src/search.c (Gcompile, Ecompile): Don't invoke dfainit, + since dfacomp does it for us, and if we also do it then we + leak memory. + +1998-11-13 Eli Zaretskii + + * djgpp/config.bat: Rewrite to run the configure script via Bash. + * djgpp/config.site, djgpp/getconf: New files. + * djgpp/config.h, djgpp/*.mak, djgpp/po2tbl.sed: Remove. + * djgpp/README: Update instructions. + + * Makefile.am (EXTRA_DIST): Update the list of DJGPP files. + + * src/system.h (IS_SLASH): New macro. + (is_EISDIR): Define it here for DOS and Windows. + + * src/grep.c (main) [O_BINARY]: Set stdout to binary mode, so the + EOL formats of the input and output files match, unless stdout is + the console device. + (is_EISDIR): Don't define if already defined. Accept a second + argument, the file name; all callers changed. + (grepdir): Don't free `file', inside the loop. Use IS_SLASH to + check whether `dir' needs a slash. + (grepfile): If file is a directory, set e to EISDIR. + +1998-11-10 Alain Magloire + + * src/vms_fab.{c,h}: New file for VMS wildcard expansion + Written by Phillip C. Brisco. + + * vms/make.com : add line to compile vms_fab.c and + {e,f,}grepmat.c with link for each grep/fgrep/egrep. + Base on patch send by Phillib C. Brisco. + +1998-11-09 Alain Magloire + + * grep-2.2c on alpha for testing. + +1998-11-09 Paul Eggert + + * src/grep.1: Fix `Last Change' of output by generating the date + from the RCS Id. + + * src/grep.c (is_EISDIR): New macro. + (grep): If -s, suppress errors from trying to read directories. + (grepfile): Use is_EISDIR to simplify code. + (grepdir): If -s, suppress errors from trying to read directories. + + * src/grep.1: Fix -q -r -s problems; describe BSD grep better. + + * src/grep.c (main): Update copyright. + + Specify default matcher with default_matcher extern var, not + DEFAULT_MATCHER macro. This is more straightforward and means + we need to compile grep.c just once. + + * src/egrepmat.c, src/fgrepmat.c, src/grepmat.c: New files. + + * src/Makefile.am (base_sources): New macro. + (egrep_SOURCES, fgrep_SOURCES, grep_SOURCES): Now consist of + $(base_sources) plus the single tailoring file. + (grep_LDADD, egrep_LDADD, fgrep_LDADD): Remove. + (EXTRA_DIST): Remove grep.c, regex.c. + (fgrep.o, egrep.o): Remove. + + * src/grep.h (matcher): Now char const *. + (default_matcher): New decl. + + * src/grep.c (matcher): Now char const *. + (setmatcher): Now accepts char const *. + (main): Default the matcher from default_matcher (linked externally) + rather than DEFAULT_MATCHER (a macro). + +1998-11-08 Alain Magloire + + * src/grep.1: `prep.ai.mit.edu' should be replaced with `gnu.org'. + Nit from Paul Eggert. + +1998-11-06 Alain Magloire + + * src/grep.c: The Matcher is not set to argv[0] but + explicitly by a #define MATCHER at compile time default is "grep". + + * aclocal/: NEW dir. provides our own *.m4 + + * configure.in: Move Paul's Large Files to AC_LFS.(aclocal/lfs.m4) + Taken from Jim Meyering fileutils. + +1998-11-05 Alain Magloire + + * src/grep.1: update the man pages according to the + changes make by Miles. + + * po/*.po: updated. + + * first beta release for 2.3 (2.2a). + +1998-11-04 Miles Bader + + * src/grep.c (main): Rationalize interaction of -C/-NUM/-A/-B + options, and allow -C to have an optional argument. -NUM can + now be mixed with -C, and -A, -B always take precedence over + -C/-NUM, regardless of order. + (long_options): Let -C/--context take an optional argument. + +1998-11-03 Alain Magloire + + * src/dfa.c: HP-UX define clrbit/setbit as macros in <sys/param.h> + #undef if defined. + Fixed by Andreas Ley and Philippe Defert. + + * src/grep.1 : mention that -s follows POSIX.2 behavior. + Noted by Paul Eggert and others. + + * tests/khadafy.sh: a typo in failure(s). + Spotted By Sotiris Vassilopoulos. + +1998-11-01 Paul Eggert + + * src/system.h (IN_CTYPE_DOMAIN): New macro. + (ISALPHA, ISUPPER, ISLOWER, ISDIGIT, ISXDIGIT, ISSPACE, + ISPUNCT, ISALNUM, ISPRINT, ISGRAPH, ISCNTRL): Use + IN_CTYPE_DOMAIN instead of isascii. + +1998-08-18 Paul Eggert + + Add support for new -r or --recursive (or -d recurse or + --directories=recurse) option. + + * src/Makefile.am (grep_SOURCES): Add savedir.c, savedir.h, stpcpy.c. + + * src/grep.1: Describe new options. + + * src/grep.c: Include "savedir.h". + (long_options): Add -r or --recursive. + (RECURSE_DIRECTORIES): New enum value. + (IS_DIRECTORY_ERRNO): Remove. + (reset, grep): Add file name arg. + (grepdir, grepfile): New functions. + (initial_bufoffset): New var. + (reset): Initialize it. + (fillbuf): Use it. + (count_matches, list_files, no_filenames, suppress_errors): New static + vars; formerly were local to `main'. + (grep): Recurse through directories if the user asks for this. + (usage, main): Add new options. + (main): Change some local vars to be static, as described above. + Move most of the guts into grepfile function. + so that it can be recursed through. + + * configure.in (AC_HEADER_DIRENT, AC_FUNC_CLOSEDIR_VOID): Add. + (AC_REPLACE_FUNCS): Add stpcpy. + + * src/savedir.c, src/savedir.h, src/stpcpy.c: New files; + taken from fileutils 3.16u. + +1998-08-11 Paul Eggert + + * src/system.h (initialize_main): New macro. + * src/grep.c (main): Invoke initialize_main first thing. + +1998-04-29 Paul Eggert + + * NEWS, src/grep.1: Describe new -a and -d options. + + * src/grep.c (long_options, usage, main): + New options -d or --directories and -a or --text. + (directories, always_text): New variables. + (IS_DIRECTORY_ERRNO): New macro. + (reset): Now returns value specifying whether to skip this file. + Stat the file if either mmap or directory-skipping is possible. + Skip the file if it's a directory and we're skipping directories. + (grep): Skip the file if `reset' tells us to. + (main): If open fails because the file is a directory, and if we're + skipping directories, don't report an error. + Remove special case for DOS and Windows. + + * src/dosbuf.c (guess_type): Use the same method for guessing whether a + file is binary as grep.c's grep does. + There's no longer any need to declare `bp' to be unsigned. + +1998-04-26 Alain Magloire + + * grep-2.2 release. + + * src/dfa.c: Wrong revision was pulled out + for beta 2.1.1d. + * src/search.c: Wrong revision was pulled out + for beta 2.1.1d. + + * src/grep.c: ck_atoi () added instead of atoi (). + Suggestion from Jim Meyering. + ck_atoi () pulled from diffutils-2.7, maintained by Paul Eggert. + + * AUTHORS: Rephrase of some sentences. + * README: Rewording. + Noted and patched by Joel N. Weber II. + +1998-04-17 Kaveh R. Ghazi + + * src/dfa.h: Don't define `const', trust autoconf to handle it. + +1998-04-16 Alain Magloire + + * tests/{status,empty}.sh: wrong return status. + + * src/grep.c: Remove the REGEX part in usage (), it was + consider overkill by most. + +1998-04-14 Eli Zaretskii + + * djgpp/config.bat: Support file names with multiple dots on all + platforms. + + * djgpp/README: Add instructions about file names illegal on + MS-DOS. + +1998-04-13 Alain Magloire + + * src/dfa.c: by "popular" demand reverse + back to '_' not word-constituent. + + * grep-2.1.1c available for testing. + +1998-04-13 Karl Heuer + + * src/grep.c: (a) The directory check is done too early: + logically, if the argument is "-", then it refers to standard + input, regardless of whether there's something in the file + system answering to "-". + (b) The sh command "grep -l root /etc/passwd /etc/group 0<&-" + prints "(standard input)" instead of "/etc/passwd", because it + mistakenly believes that a named file will never be opened on fd + 0. The string "(standard input)" should be based on the file + having been originally specified as "-", rather than making + assumptions about the fd. + (c) the code that calls close(fd) is being done outside of the + test for a bad fd. Thus, if the open failed, this code will + attempt to close(-1). It should be done inside the "fd != -1" + branch. + This patch addresses all three of these problems. + +1998-04-13 Alain Magloire + + * configure.in: remove the deprecated AC_ISC_POSIX macro. + Spotted by Karl Heuer. + +1998-04-03 Eli Zaretskii + + * djgpp/main.mak, djgpp/src.mak, djgpp/tests.mak: Updated from the + relevant Makefile.in files. + + * djgpp/config.bat: Create files in intl directory like the + configure script does. + +1998-03-28 Eli Zaretskii + + * djgpp/main.mak, djgpp/src.mak, djgpp/tests.mak: Updated to track + changes in respective Makefile.in files. + + * src/dosbuf.c (guess_type): Avoid running off the end of the + buffer. Spotted by Paul Eggert. + +1998-03-27 Alain Magloire + + * grep-2.1.1b.tar.gz available. + + * src/regex.c: CLASS_CHAR_MAX set to 256 instead of 6 + when WCTYPE and WCHAR are not defined. When class names + where bigger then 6, it will not detect an error. + example '[[:alphabet:]]'. + + * Updated the copyright of the files with emacs. + With emacs Jim :). + +1998-03-26 Jim Meyering + + * src/dfa.c (IS_WORD_CONSTITUENT): Define. + (lex): Use IS_WORD_CONSTITUENT, not ISALNUM. + Don't special-case '_'. + (dfastate): Use IS_WORD_CONSTITUENT, not ISALNUM. + (dfaexec): Likewise. + +1998-03-25 Alain Magloire + + * tests/warning.sh: typos and replace the echos with + a simple cat. + Noted By Jim Meyering. + + * src/regex.c: #undef ISASCII and ISPRINT before defining + them(On Solaris it was define). + Pattern 'a[[:]:]]b' is an invalid char class and the error + from regex was 1(REG_NOMATCH) instead of 2 (REG_ECTYPE). + Fix with help from Ulrich Drepper. + + * src/grep.c (usage): Ulrich wrote: "A single printf should + not have more than 900 bytes. For translation reasons the + text shouldn't be split in too many pieces since this is + tiresome and also does not help to generate a consistent picture." + Noted by Ulrich Drepper. + * src/grep.c (usage): Dig out and old patch from + Franc,ois to explain the regex in usage(). + Ideas from Franc,ois Pinard. + +1998-03-23 Alain Magloire + + * testing: grep-2.1.1a for testing. + + * configure.in: Solaris needs '-lw' if we use wchar/wctype + functions. + * src/btowc.c: New file from GNU libc. Solaris 2.5 don't + have it define. + * configure.in : check for btowc (). + + * regex.c: Include <wchar.h> before <wctype.h>, to work around + a Solaris 2.5 bug. + Patch provided by Paul Eggert. + + * tests/status.sh: new file to check return status code. + * tests/empty.sh: new file to check for empty pattern. + * tests/warning.sh: new file to tell where to report errors. + + * configure.in: If available, prefer support for large files + unless the user specified one of the CPPFLAGS, LDFLAGS, or LIBS + variables. + Done by Paul Eggert. + + * src/grep.c (usage): change prep.ai.mit.edu for gnu.org. + +1998-03-18 Alain Magloire + + * src/grep.c (usage): Formating the --help message a bit off. + Noted by William Bader. + + * src/grep.c (main): When checking conflicting matcher for option -E the + matcher was to "egrep" instead of "posix-egrep". + Reported by kwzh@gnu.org. + + * src/grep.c: Typos and rewording the --help message. + Reported by Karl Heuer. + + * src/grep.1: The man page wording : + A regular expression matching a single character may be + followed by one of several repetition operators: + is unclear since 'x(yz)*z' is a valid regex. + Remove the "matching a single character". + Suggested by Harald Hanche-Olsen. + + * src/grep.c (main): `-f /dev/null' now specifies no patterns + and therfore matches nothing. + Reported by Jorge Stolfi. + Patched by Paul Eggert. + +1998-03-10 Alain Magloire + + * Ice storm 98(el nino). Lost grep repository disk, + and my $HOME directory, etc .. + Trying to get the emails/patch from dejanews.com + and start from grep-2.1. + sigh .... + +1997-11-01 Alain Magloire + + * src/grep.c: For the long options, the problems are: + --file appears in the option table as 'no_argument' + instead of 'required_argument'. + --files-with-matches is missing from the option table. + The help lists '--fixed-strings' as the long option for -F, + the table has '--fixed-regexp'. + --regexp appears in the option table as 'no_argument' + instead of 'required_argument'. + --with-filename is missing from the option table. + Reported by Grant McDorman and Krishna Sethuraman. + +1997-10-19 Alain Magloire + + * src/grep.c: the option "with-filename was not in the arg table. + Corrected by Jim Hand. + + * GNU gettext library from gettext-0.10.32. + + * src/grep.c: reverse back to greping directories, + One could skip the error message by defining + SKIP_DIR_ERROR. There is no clear way of doing + things, I hope to setle this on the next majore release + Thanks Paul Eggert, Eli Zaretskii and gnits for the + exchange. + + * tests/status.sh: add this check to make sure + That the return status code is ok. + +1997-10-10 Andreas Schwab + + * src/grep.1: Fix formatting. + + * configure.in: Check for wctype.h, wchar.h, libintl.h and + isascii, which are needed for regex.c. + +1997-10-01 Paul Eggert + + * src/grep.c (fillbuf): Don't warn about mmap failures. + +1997-09-7 Alain Magloire + + * src/grep.c: added code for -H --with-filename. + + * djgpp/*: patch wrongly apply + duplication of text in djgpp/{README,config.h}. + Filter djgpp/config.bat with unix2dos. + + * djgpp/make.mak: beautify + From Eli Zaretskii. + + * grep-2.1 release. + +1997-09-01 Alain Magloire + + * grep-2.0f out for testing. + + * update to GNU gettext library from gettext-0.10.31 + + * grep.c : have a nicer format for --version. + Noted by Ulrich Drepper. + + * obstack.[ch]: updated from GNU C library + * configure.in: look for stdlib.h [HAVE_STDLIB_H] + Comments from Ulrich Drepper. + +1997-08-25 Philippe De Muyter <phdm@info.ucl.ac.be> + + * src/dfa.c (sys/types.h): File included unconditionnaly. + +1997-08-16 Eli Zaretskii <eliz@is.elta.co.il> + + * grep.c (long_options) [O_BINARY]: Add DOS-specific options. + (fillbuf) [O_BINARY]: For DOS-style text files, strip CR + characters at end of line. + (prline) [O_BINARY]: Report correct byte offsets, even though CR + characters were stripped when reading the file. + (usage) [O_BINARY]: Add DOS-specific options. + (setmatcher) [HAVE_SETRLIMIT]: Set re_max_failures so that the + matcher won't ever overflow the stack. + (main) [__MSDOS__, _WIN32]: Handle backslashes and drive letters + in argv[0], remove the .exe suffix, and downcase the prgram name. + [O_BINARY]: Pass additional DOS-specific options to getopt_long + and handle them. Call stat before attempting to open the file, in + case it is a directory (DOS will fail the open call for + directories). Switch the input descriptor to binary mode, unless + it is a terminal device. + + * system.h [O_BINARY]: Define macros to switch a handle to binary + mode, so binary files could be grep'ed on MS-DOS and MS-Windows. + [HAVE_SETLOCALE]: Test for HAVE_SETLOCALE instead of + HAVE_LC_MESSAGES, to prevent compilation error in grep.c on + systems which don't define HAVE_LC_MESSAGES, but have setlocale. + + * dosbuf.c: New file, functions specific for MS-DOS/MS-Windows. + (guess_type, undossify_input, dossified_pos): New functions. + + * djgpp/config.h, djgpp/config.bat, djgpp/main.mak, djgpp/src.mak, + djgpp/po.mak, djgpp/intl.mak, djgpp/tests.mak, djgpp/po2tbl.sed: + New files, for building Grep with DJGPP tools for MS-DOS and + MS-Windows. + + * grep.1: Document DOS-specific switches. + +1997-08-08 Alain Magloire + + * grep-2.0e: available for testing + + * grep.c: change LC_MESSAGE to LC_ALL for (LC_CTYPE). + Suggested by Jochen Hein. + + * ABOUT-NLS: updated. + * grep.c: --version: more verbosity (COPYRIGHT). + * grep.c: --help: PATTERN, FILE instead of <pattern>, <file>. + * INSTALL.grep: not necessary removed. + * configure.in: --disable-regex rename --without-include-regex. + * THANKS: format: first row name, second email. + * ChangeLog: format ISO 8601. + Reported by Franc,ois Pinard. + + * grep.c: move dcl of struct stat st into "else" where it's used. + Reported by Jim Meyering. + + * grep.c: totalnl should be %u in printf. + Reported by Michael Aichlmay + Corrected with guidance from Ulrich Drepper + +1997-07-24 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * Makefile.am: corrected an error when installing {f,e}grep.1. + From Kaveh R. Ghazi <ghazi@caip.rutgers.edu>. + From Ulrich Drepper <drepper@cygnus.com>. + + * Many files: use PARAMS instead of __STDC__ for prototypes. + From Jim Meyering <meyering@eng.ascend.com>. + Patch provided by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>. + + * dfa.[ch]: uses the one in gawk-3.0.3 with the patch from + Arnold (see Changelog: July 12 1997) + + * grep.1: a note to say -l, -L, -q stop on first match. + Noted by Andrew Beattie <gaffer@tug.com>. + + * grep.c: refuse to scan if the file is a directory. + This was causing problems on SUNs. If the directory contains + a file that could match the pattern, garbage was display. + + * tests directory: added new set of tests from Henry Spencer + regex package. Change the way the tests were done to be more + conformant to automake. + + * configure.in: added --disable-regex for folks with their own fuctions. + + * grep-20d : available for testing + +1997-07-18 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * grep-2.0c: available for testing + +1997-07-17 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * src/grep.c: Cause grep to fail if `fclose (stdout)' fails. + From Jim Meyering <meyering@eng.ascend.com>. + + * grep.c:usage() more consistency in the --help. + + * egrep, fgrep were links This is in violation of GNU standards: + "Please don't make the behavior of a utility depend on the name used + to invoke it. It is useful sometimes to make a link to a utility with + a different name, and that should not change what it does." + For now egrep and fgrep will be copies of grep. A better scheme + should be found later. + After discussion with Tom Tromey <tromey@cygnus.com>. + + * fgrep.man and egrep.man included: They are stubs that call grep.1. + * Makefile.am: modified to install {f,e,}grep[,.1]. + + * speed hack for -l, -L: bail out on first match. + From Scott Weikart <scott@igc.apc.org>. + + * *.[ch]: provided prototypes for strict argument checking + With the help of Stewart Levin <stew@sep.stanford.edu>. + +1997-07-16 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * configure.in: typo in the creation of po/Makefile + Noted by Volker Borchert bt@teknon.de. + + * grep-2.0b: make it available for testing. + +1997-07-15 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * src/grep.c usage(): cut the --help in smaller printf()'s + Noted by Ulrich Drepper <drepper@cygnus.com>. + +1997-07-14 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * grep-2.0a: make an alpha available for testing. + +1997-07-12 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * run gettextize: added the po directory filled with *.po files. + + * check.sh, scriptgen.awk: fix grep paths. + + * change the directory strucure: grep is now in src to comply with + gettext.m4. + + * grep.c version.c [VERSION]: got rid of version.c, + it is now define via config.h. + + * dfa.c: patch to speed up initialization. + Arnold Robbins (arnold@gnu.ai.mit.edu). + +1997-07-09 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * *.c [HAVE_CONFIG_H]: Macro defined. + + * support for I18N in Makefile.am and configure.in. + + * update all the string to use gettext(I18N). + Help from Franc,ois Pinard previous patch <pinard@IRO.UMontreal.CA>. + +1997-07-04 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * obstack.[ch]: updated from glibc. + Work of Ulrich Drepper <drepper@cygnus.com>. + + * regex.[ch]: updated from glibc. + Work of Ulrich Drepper <drepper@cygnus.com>. + + * grep.c: for option -e not counting '\n' for new keys. + From Mark Waite <markw@mddmew.fc.hp.com>. + + * grep.c: for option -f allocating the right count. + From Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>. + Mike Heartel (mike@cs.uoregon.edu). + + * kwset.c (bmexec): Cast tp[-2] to unsigned char before comparing. + From Jim Meyering <meyering@asic.sc.ti.com>. + + * grep.1: various typos. + From Keith Bostic <bostic@bsdi.com>. + Mike Heartel (mike@cs.uoregon.edu). + +1997-06-17 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * grep.c: support for long options. + patch done by Franc,ois Pinard <pinard@IRO.UMontreal.CA>. + + * add getopt1.c in Makefile.am. + Noted by Franc,ois Pinard <pinard@IRO.UMontreal.CA> + + * replace getopt.[ch] and add getopt1.c. + + * kwset.c: undef malloc before define it. + Franc,ois Pinard <pinard@IRO.UMontreal.CA>. + +1997-06-07 Alain Magloire <alainm@rcsm.ee.mcgill.ca> + + * grep.c: format incorrect in + fprintf("%s: warning: %s: %s...", filename, strerror(errno)). + Mike Heartel (mike@cs.uoregon.edu). + +1996-11-19 David J MacKenzie <djm@catapult.va.pubnix.com> + + * make.com: Set the logical SYS. From rdb@cocamrd.oz.au (Rodney Brown). + + * grep.c (S_ISREG): Define if not defined already, for e.g. + SunOS 4.0.3. + + * dfa.c (test_bit, set_bit, clear_bit): Renamed from tstbit, + setbit, clrbit to avoid conflict with HP-UX sys/param.h macros. + + * memchr.c: New file, from GNU libc. + * grep.c (memchr): Remove definition. + * configure.in: Use AC_REPLACE_FUNCS for memchr. + + * configure.in: Remove unused checks for memalign and unsigned char. + * grep.c: HAVE_WORKING_MMAP -> HAVE_MMAP. + + * system.h: New file. + * dfa.c, kwset.c, grep.c, search.c: Use it instead of duplicating + portability boilerplate. + + * grep.c: Include sys/types.h once, instead of three times + conditionally. + * dfa.c, kwset.c, search.c: Include sys/types.h unconditionally, + to always try to get size_t (needed on some old SysV's). + + * dfa.c: Define strchr in terms of index, not the other way around. + * search.c: Use memcpy instead of bcopy. + +1996-11-15 David J MacKenzie <djm@catapult.va.pubnix.com> + + * Many files: Update FSF address. + Update configuration to use autoconf v2 and automake. + +1993-05-22 Mike Haertel <mike@cs.uoregon.edu> + + * Version 2.0 released. diff --git a/gnu/usr.bin/grep/FREEBSD-upgrade b/gnu/usr.bin/grep/FREEBSD-upgrade new file mode 100644 index 000000000000..06b14fe13139 --- /dev/null +++ b/gnu/usr.bin/grep/FREEBSD-upgrade @@ -0,0 +1,37 @@ +$FreeBSD$ + +GNU grep + +Original source distribution can be found at: + http://ftp.gnu.org/pub/gnu/grep/ + +Due to an unfortunate number of bugs and performance problems in +GNU grep 2.5.1, various patches from The Fedora Project have been applied. +These patches can be extracted from the SRPM package available at: + + http://download.fedora.redhat.com/pub/fedora/linux/core/test/ + 3.92/SRPMS/grep-2.5.1-48.src.rpm + +The following patches have been applied: + + grep-2.5-i18n.patch + grep-2.5.1-bracket.patch + grep-2.5.1-color.patch + grep-2.5.1-dfa-optional.patch + grep-2.5.1-egf-speedup.patch + grep-2.5.1-fgrep.patch + grep-2.5.1-icolor.patch + grep-2.5.1-oi.patch + grep-2.5.1-w.patch + +In addition to these, some FreeBSD-specific changes have been made +to add bzip2 support, etc. + +Due to the large number of patches applied, conflicts are likely with +future releases. However, most of the patches are either (a) small bug +fixes that have been fed upstream, or (b) performance improvements that +could be reverted without loss of functionality. + +It is suggested that those planning to import a newer release of GNU grep +should revert all local changes since the 2.5.1 import before proceeding +with the newer import. diff --git a/gnu/usr.bin/grep/Makefile b/gnu/usr.bin/grep/Makefile new file mode 100644 index 000000000000..b24b1ea292e0 --- /dev/null +++ b/gnu/usr.bin/grep/Makefile @@ -0,0 +1,56 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +GREP_LIBZ=YES + +.if ${MK_BSD_GREP} != "yes" +PROG= grep +.else +PROG= gnugrep +.endif +SRCS= closeout.c dfa.c error.c exclude.c grep.c grepmat.c hard-locale.c \ + isdir.c kwset.c obstack.c quotearg.c savedir.c search.c xmalloc.c \ + xstrtoumax.c +CLEANFILES+= gnugrep.1 + +CFLAGS+=-I${.CURDIR} -I${SYSROOT:U${DESTDIR}}/usr/include/gnu -DHAVE_CONFIG_H + +.if ${MK_BSD_GREP} != "yes" +LINKS+= ${BINDIR}/grep ${BINDIR}/egrep \ + ${BINDIR}/grep ${BINDIR}/fgrep +MLINKS= grep.1 egrep.1 grep.1 fgrep.1 +.endif + +LIBADD= gnuregex bz2 + +.if defined(GREP_LIBZ) && !empty(GREP_LIBZ) +LIBADD+= z +CFLAGS+=-DHAVE_LIBZ=1 +.endif + +gnugrep.1: grep.1 + ${CP} ${.ALLSRC} ${.TARGET} + +check: all + @failed=0; total=0; \ + for tst in ${TESTS}; do \ + total=$$(($$total+1)); \ + if GREP=${.OBJDIR}/${PROG} srcdir=${.CURDIR}/tests \ + ${.CURDIR}/tests/$$tst; then \ + echo "PASS: $$tst"; \ + else \ + failed=$$(($$failed+1)); \ + echo "FAIL: $$tst"; \ + fi; \ + done; \ + if [ "$$failed" -eq 0 ]; then \ + echo "All $$total tests passed"; \ + else \ + echo "$$failed of $$total tests failed"; \ + fi + +TESTS= warning.sh khadafy.sh spencer1.sh bre.sh ere.sh status.sh empty.sh \ + options.sh backref.sh file.sh + +.include <bsd.prog.mk> diff --git a/gnu/usr.bin/grep/Makefile.depend b/gnu/usr.bin/grep/Makefile.depend new file mode 100644 index 000000000000..bdea82e9f7cd --- /dev/null +++ b/gnu/usr.bin/grep/Makefile.depend @@ -0,0 +1,20 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + gnu/lib/csu \ + gnu/lib/libregex \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libbz2 \ + lib/libc \ + lib/libcompiler_rt \ + lib/libz \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/gnu/usr.bin/grep/NEWS b/gnu/usr.bin/grep/NEWS new file mode 100644 index 000000000000..9bb821937eb3 --- /dev/null +++ b/gnu/usr.bin/grep/NEWS @@ -0,0 +1,238 @@ +Version 2.5.1 + - This is a bugfix release. No new features. + +Version 2.5 + - The new option --label allows to specify a different name for input + from stdin. See the man or info pages for details. + + - The internal lib/getopt* files are no longer used on systems providing + getopt functionality in their libc (e.g. glibc 2.2.x). + If you need the old getopt files, use --with-included-getopt. + + - The new option --only-matching (-o) will print only the part of matching + lines that matches the pattern. This is useful, for example, to extract + IP addresses from log files. + + - i18n bug fixed ([A-Z0-9] wouldn't match A in locales other than C on + systems using recent glibc builds + + - GNU grep can now be built with autoconf 2.52. + + - The new option --devices controls how grep handles device files. Its usage + is analogous to --directories. + + - The new option --line-buffered fflush on everyline. There is a noticeable + slow down when forcing line buffering. + + - Back references are now local to the regex. + grep -e '\(a\)\1' -e '\(b\)\1' + The last backref \1 in the second expression refer to \(b\) + + - The new option --include=PATTERN will only search matching files + when recursing in directories + + - The new option --exclude=PATTERN will skip matching files when + recursing in directories. + + - The new option --color will use the environment variable GREP_COLOR + (default is red) to highlight the matching string. + --color takes an optional argument specifying when to colorize a line: + --color=always, --color=tty, --color=never + + - The following changes are for POSIX.2 conformance: + + . The -q or --quiet or --silent option now causes grep to exit + with zero status when a input line is selected, even if an error + also occurs. + + . The -s or --no-messages option no longer affects the exit status. + + . Bracket regular expressions like [a-z] are now locale-dependent. + For example, many locales sort characters in dictionary order, + and in these locales the regular expression [a-d] is not + equivalent to [abcd]; it might be equivalent to [aBbCcDd], for + example. To obtain the traditional interpretation of bracket + expressions, you can use the C locale by setting the LC_ALL + environment variable to the value "C". + + - The -C or --context option now requires an argument, partly for + consistency, and partly because POSIX.2 recommends against + optional arguments. + + - The new -P or --perl-regexp option tells grep to interpert the pattern as + a Perl regular expression. + + - The new option --max-count=num makes grep stop reading a file after num + matching lines. + New option -m; equivalent to --max-count. + + - Translations for bg, ca, da, nb and tr have been added. + +Version 2.4.2 + + - Added more check in configure to default the grep-${version}/src/regex.c + instead of the one in GNU Lib C. + +Version 2.4.1 + + - If the final byte of an input file is not a newline, grep now silently + supplies one. + + - The new option --binary-files=TYPE makes grep assume that a binary input + file is of type TYPE. + --binary-files='binary' (the default) outputs a 1-line summary of matches. + --binary-files='without-match' assumes binary files do not match. + --binary-files='text' treats binary files as text + (equivalent to the -a or --text option). + + - New option -I; equivalent to --binary-files='without-match'. + +Version 2.4: + + - egrep is now equivalent to `grep -E' as required by POSIX, + removing a longstanding source of confusion and incompatibility. + `grep' is now more forgiving about stray `{'s, for backward + compatibility with traditional egrep. + + - The lower bound of an interval is not optional. + You must use an explicit zero, e.g. `x{0,10}' instead of `x{,10}'. + (The old documentation incorrectly claimed that it was optional.) + + - The --revert-match option has been renamed to --invert-match. + + - The --fixed-regexp option has been renamed to --fixed-string. + + - New option -H or --with-filename. + + - New option --mmap. By default, GNU grep now uses read instead of mmap. + This is faster on some hosts, and is safer on all. + + - The new option -z or --null-data causes `grep' to treat a zero byte + (the ASCII NUL character) as a line terminator in input data, and + to treat newlines as ordinary data. + + - The new option -Z or --null causes `grep' to output a zero byte + instead of the normal separator after a file name. + + - These two options can be used with commands like `find -print0', + `perl -0', `sort -z', and `xargs -0' to process arbitrary file names, + even those that contain newlines. + + - The environment variable GREP_OPTIONS specifies default options; + e.g. GREP_OPTIONS='--directories=skip' reestablishes grep 2.1's + behavior of silently skipping directories. + + - You can specify a matcher multiple times without error, e.g. + `grep -E -E' or `fgrep -F'. It is still an error to specify + conflicting matchers. + + - -u and -U are now allowed on non-DOS hosts, and have no effect. + + - Modifications of the tests scripts to go around the "Broken Pipe" + errors from bash. See Bash FAQ. + + - New option -r or --recursive or --directories=recurse. + (This option was also in grep 2.3, but wasn't announced here.) + + - --without-included-regex disable, was causing bogus reports .i.e + doing more harm then good. + +Version 2.3: + + - When searching a binary file FOO, grep now just reports + `Binary file FOO matches' instead of outputting binary data. + This is typically more useful than the old behavior, + and it is also more consistent with other utilities like `diff'. + A file is considered to be binary if it contains a NUL (i.e. zero) byte. + + The new -a or --text option causes `grep' to assume that all + input is text. (This option has the same meaning as with `diff'.) + Use it if you want binary data in your output. + + - `grep' now searches directories just like ordinary files; it no longer + silently skips directories. This is the traditional behavior of + Unix text utilities (in particular, of traditional `grep'). + Hence `grep PATTERN DIRECTORY' should report + `grep: DIRECTORY: Is a directory' on hosts where the operating system + does not permit programs to read directories directly, and + `grep: DIRECTORY: Binary file matches' (or nothing) otherwise. + + The new -d ACTION or --directories=ACTION option affects directory handling. + `-d skip' causes `grep' to silently skip directories, as in grep 2.1; + `-d read' (the default) causes `grep' to read directories if possible, + as in earlier versions of grep. + + - The MS-DOS and Microsoft Windows ports now behave identically to the + GNU and Unix ports with respect to binary files and directories. + +Version 2.2: + +Bug fix release. + + - Status error number fix. + - Skipping directories removed. + - Many typos fix. + - -f /dev/null fix(not to consider as an empty pattern). + - Checks for wctype/wchar. + - -E was using the wrong matcher fix. + - bug in regex char class fix + - Fixes for DJGPP + +Version 2.1: + +This is a bug fix release(see Changelog) i.e. no new features. + + - More compliance to GNU standard. + - Long options. + - Internationalisation. + - Use automake/autoconf. + - Directory hierarchy change. + - Sigvec with -e on Linux corrected. + - Sigvec with -f on Linux corrected. + - Sigvec with the mmap() corrected. + - Bug in kwset corrected. + - -q, -L and -l stop on first match. + - New and improve regex.[ch] from Ulrich Drepper. + - New and improve dfa.[ch] from Arnold Robbins. + - Prototypes for over zealous C compiler. + - Not scanning a file, if it's a directory + (cause problems on Sun). + - Ported to MS-DOS/MS-Windows with DJGPP tools. + +See Changelog for the full story and proper credits. + +Version 2.0: + +The most important user visible change is that egrep and fgrep have +disappeared as separate programs into the single grep program mandated +by POSIX 1003.2. New options -G, -E, and -F have been added, +selecting grep, egrep, and fgrep behavior respectively. For +compatibility with historical practice, hard links named egrep and +fgrep are also provided. See the manual page for details. + +In addition, the regular expression facilities described in Posix +draft 11.2 are now supported, except for internationalization features +related to locale-dependent collating sequence information. + +There is a new option, -L, which is like -l except it lists +files which don't contain matches. The reason this option was +added is because '-l -v' doesn't do what you expect. + +Performance has been improved; the amount of improvement is platform +dependent, but (for example) grep 2.0 typically runs at least 30% faster +than grep 1.6 on a DECstation using the MIPS compiler. Where possible, +grep now uses mmap() for file input; on a Sun 4 running SunOS 4.1 this +may cut system time by as much as half, for a total reduction in running +time by nearly 50%. On machines that don't use mmap(), the buffering +code has been rewritten to choose more favorable alignments and buffer +sizes for read(). + +Portability has been substantially cleaned up, and an automatic +configure script is now provided. + +The internals have changed in ways too numerous to mention. +People brave enough to reuse the DFA matcher in other programs +will now have their bravery amply "rewarded", for the interface +to that file has been completely changed. Some changes were +necessary to track the evolution of the regex package, and since +I was changing it anyway I decided to do a general cleanup. diff --git a/gnu/usr.bin/grep/README b/gnu/usr.bin/grep/README new file mode 100644 index 000000000000..66c1bb2ba784 --- /dev/null +++ b/gnu/usr.bin/grep/README @@ -0,0 +1,26 @@ +This is GNU grep, the "fastest grep in the west" (we hope). All +bugs reported in previous releases have been fixed. Many exciting new +bugs have probably been introduced in this revision. + +GNU grep is provided "as is" with no warranty. The exact terms +under which you may use and (re)distribute this program are detailed +in the GNU General Public License, in the file COPYING. + +GNU grep is based on a fast lazy-state deterministic matcher (about +twice as fast as stock Unix egrep) hybridized with a Boyer-Moore-Gosper +search for a fixed string that eliminates impossible text from being +considered by the full regexp matcher without necessarily having to +look at every character. The result is typically many times faster +than Unix grep or egrep. (Regular expressions containing backreferencing +will run more slowly, however.) + +See the files AUTHORS and THANKS for a list of authors and other contributors. + +See the file INSTALL for compilation and installation instructions. + +See the file NEWS for a description of major changes in this release. + +See the file TODO for ideas on how you could help us improve grep. + +Send bug reports to bug-gnu-utils@gnu.org. Be sure to +include the word "grep" in your Subject: header field. diff --git a/gnu/usr.bin/grep/THANKS b/gnu/usr.bin/grep/THANKS new file mode 100644 index 000000000000..93dd31c1b06e --- /dev/null +++ b/gnu/usr.bin/grep/THANKS @@ -0,0 +1,72 @@ +Aharon Robbins <arnold@gnu.org> +Akim Demaille <akim@epita.fr> +Alain Magloire <alainm@gnu.org> +Andreas Schwab <schwab@suse.de> +Andreas Ley <andy@rz.uni-karlsruhe.de> +Bastiaan "Darquan" Stougie <darquan@zonnet.nl> +Ben Elliston <bje@cygnus.com> +Bernd Strieder <strieder@student.uni-kl.de> +Bernhard Rosenkraenzer <bero@redhat.com> +Bob Proulx <rwp@hprwp.fc.hp.com> +Brian Youmans <3diff@gnu.org> +Bruno Haible <haible@ilog.fr> +Christian Groessler <cpg@aladdin.de> +David Clissold <cliss@austin.ibm.com> +David J MacKenzie <djm@catapult.va.pubnix.com> +David O'Brien <obrien@freebsd.org> +Eli Zaretskii <eliz@is.elta.co.il> +Florian La Roche <laroche@redhat.com> +Franc,ois Pinard <pinard@IRO.UMontreal.CA> +Gerald Stoller <gerald_stoller@hotmail.com> +Grant McDorman <grant@isgtec.com> +Greg Louis <glouis@dynamicro.on.ca> +Guglielmo 'bond' Bondioni <g.bondioni@libero.it> +H. Merijn Brand <h.m.brand@hccnet.nl> +Harald Hanche-Olsen <hanche@math.ntnu.no> +Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de> +Heikki Korpela <heko@iki.fi> +Isamu Hasegawa <isamu@yamato.ibm.com> +Jeff Bailey <jbailey@nisa.net> +Jim Hand <jhand@austx.tandem.com> +Jim Meyering <meyering@asic.sc.ti.com> +Jochen Hein <jochen.hein@delphi.central.de> +Joel N. Weber II <devnull@gnu.org> +John Hughes <john@nitelite.calvacom.fr> +Jorge Stolfi <stolfi@dcc.unicamp.br> +Juan Manuel Guerrero <ST001906@HRZ1.HRZ.TU-Darmstadt.De> +Karl Berry <karl@cs.umb.edu> +Karl Heuer <kwzh@gnu.org> +Kaveh R. Ghazi <ghazi@caip.rutgers.edu> +Kazuro Furukawa <furukawa@apricot.kek.jp> +Keith Bostic <bostic@bsdi.com> +Krishna Sethuraman <krishna@sgihub.corp.sgi.com> +Kurt D Schwehr <kdschweh@insci14.ucsd.edu> +Mark Waite <markw@mddmew.fc.hp.com> +Martin P.J. Zinser <zinser@decus.de> +Martin Rex <martin.rex@sap-ag.de> +Michael Aichlmayr <mikla@nx.com> +Miles Bader <miles@ccs.mt.nec.co.jp> +Olaf Kirch <okir@ns.lst.de> +Paul Eggert <eggert@twinsun.com> +Paul Kimoto <kimoto@spacenet.tn.cornell.edu> +Phillip C. Brisco <phillip.craig.brisco@ccmail.census.gov> +Philippe Defert <Philippe.Defert@cern.ch> +Philippe De Muyter <phdm@info.ucl.ac.be> +Philip Hazel <ph10@cus.cam.ac.uk> +Roland Roberts <rroberts@muller.com> +Ruslan Ermilov <ru@freebsd.org> +Santiago Vila <sanvila@unex.es> +Shannon Hill <hill@synnet.com> +Sotiris Vassilopoulos <Sotiris.Vassilopoulos@betatech.gr> +Stewart Levin <stew@sep.stanford.edu> +Sydoruk Stepan <step@unitex.kiev.ua> +Tapani Tarvainen <tt@mit.jyu.fi> +Tom 'moof' Spindler <dogcow@ccs.neu.edu> +Tom Tromey <tromey@creche.cygnus.com> +Ulrich Drepper <drepper@cygnus.com> +UEBAYASHI Masao <masao@nf.enveng.titech.ac.jp> +Uwe H. Steinfeld <usteinfeld@gmx.net> +Volker Borchert <bt@teknon.de> +Wichert Akkerman <wichert@cistron.nl> +William Bader <william@nscs.fast.net> +Wolfgang Schludi <schludi@syscomp.de> diff --git a/gnu/usr.bin/grep/closeout.c b/gnu/usr.bin/grep/closeout.c new file mode 100644 index 000000000000..4fdac32b2e85 --- /dev/null +++ b/gnu/usr.bin/grep/closeout.c @@ -0,0 +1,121 @@ +/* closeout.c - close standard output + Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#if ENABLE_NLS +# include <libintl.h> +# define _(Text) gettext (Text) +#else +# define _(Text) Text +#endif + +#if HAVE_STDLIB_H +# include <stdlib.h> +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif + +#include <stdio.h> + +#include <errno.h> +#ifndef errno +extern int errno; +#endif + +#include "closeout.h" +#include "error.h" +#include "quotearg.h" +#if 0 +#include "__fpending.h" +#endif + +static int default_exit_status = EXIT_FAILURE; +static const char *file_name; + +/* Set the value to be used for the exit status when close_stdout is called. + This is useful when it is not convenient to call close_stdout_status, + e.g., when close_stdout is called via atexit. */ +void +close_stdout_set_status (int status) +{ + default_exit_status = status; +} + +/* Set the file name to be reported in the event an error is detected + by close_stdout_status. */ +void +close_stdout_set_file_name (const char *file) +{ + file_name = file; +} + +/* Close standard output, exiting with status STATUS on failure. + If a program writes *anything* to stdout, that program should `fflush' + stdout and make sure that it succeeds before exiting. Otherwise, + suppose that you go to the extreme of checking the return status + of every function that does an explicit write to stdout. The last + printf can succeed in writing to the internal stream buffer, and yet + the fclose(stdout) could still fail (due e.g., to a disk full error) + when it tries to write out that buffered data. Thus, you would be + left with an incomplete output file and the offending program would + exit successfully. + + FIXME: note the fflush suggested above is implicit in the fclose + we actually do below. Consider doing only the fflush and/or using + setvbuf to inhibit buffering. + + Besides, it's wasteful to check the return value from every call + that writes to stdout -- just let the internal stream state record + the failure. That's what the ferror test is checking below. + + It's important to detect such failures and exit nonzero because many + tools (most notably `make' and other build-management systems) depend + on being able to detect failure in other tools via their exit status. */ + +void +close_stdout_status (int status) +{ + int e = ferror (stdout) ? 0 : -1; + +#if 0 + if (__fpending (stdout) == 0) + return; +#endif + + if (fclose (stdout) != 0) + e = errno; + + if (0 < e) + { + char const *write_error = _("write error"); + if (file_name) + error (status, e, "%s: %s", quotearg_colon (file_name), write_error); + else + error (status, e, "%s", write_error); + } +} + +/* Close standard output, exiting with status EXIT_FAILURE on failure. */ +void +close_stdout (void) +{ + close_stdout_status (default_exit_status); +} diff --git a/gnu/usr.bin/grep/closeout.h b/gnu/usr.bin/grep/closeout.h new file mode 100644 index 000000000000..80f24e45f9da --- /dev/null +++ b/gnu/usr.bin/grep/closeout.h @@ -0,0 +1,17 @@ +#ifndef CLOSEOUT_H +# define CLOSEOUT_H 1 + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +void close_stdout_set_status PARAMS ((int status)); +void close_stdout_set_file_name PARAMS ((const char *file)); +void close_stdout PARAMS ((void)); +void close_stdout_status PARAMS ((int status)); + +#endif diff --git a/gnu/usr.bin/grep/config.h b/gnu/usr.bin/grep/config.h new file mode 100644 index 000000000000..5f00fb6097ea --- /dev/null +++ b/gnu/usr.bin/grep/config.h @@ -0,0 +1,342 @@ +/* $FreeBSD$ */ +/* config.h. Generated by configure. */ +/* config.hin. Generated from configure.in by autoheader. */ + +/* Define to 1 if the `closedir' function returns void instead of `int'. */ +/* #undef CLOSEDIR_VOID */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +/* #undef CRAY_STACKSEG_END */ + +/* Define to 1 if using `alloca.c'. */ +/* #undef C_ALLOCA */ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +/* #undef ENABLE_NLS */ + +/* We are building grep */ +#define GREP 1 + +/* Define to 1 if you have `alloca', as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). + */ +/* #undef HAVE_ALLOCA_H */ + +/* Define to 1 if you have the <argz.h> header file. */ +/* #undef HAVE_ARGZ_H */ + +/* Define to 1 if you have the `atexit' function. */ +#define HAVE_ATEXIT 1 + +/* Define to 1 if you have the `btowc' function. */ +#define HAVE_BTOWC 1 + +/* Define to 1 if you have the `dcgettext' function. */ +/* #undef HAVE_DCGETTEXT */ + +/* Define to 1 if strerror_r is declared. */ +#define HAVE_DECL_STRERROR_R 1 + +/* Define if <stdlib.h> declares strtoul. */ +#define HAVE_DECL_STRTOUL 1 + +/* Define if <stdlib.h> declares strtoull. */ +#define HAVE_DECL_STRTOULL 1 + +/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if the malloc check has been performed. */ +#define HAVE_DONE_WORKING_MALLOC_CHECK 1 + +/* Define if the realloc check has been performed. */ +#define HAVE_DONE_WORKING_REALLOC_CHECK 1 + +/* Define to 1 if you have the `doprnt' function. */ +/* #undef HAVE_DOPRNT */ + +/* Define if text file lines end in CRLF. */ +/* #undef HAVE_DOS_FILE_CONTENTS */ + +/* Define if your OS uses backslashes as directory separators */ +/* #undef HAVE_DOS_FILE_NAMES */ + +/* Define to 1 if you have the `feof_unlocked' function. */ +#define HAVE_FEOF_UNLOCKED 1 + +/* Define to 1 if you have the `fgets_unlocked' function. */ +/* #undef HAVE_FGETS_UNLOCKED */ + +/* Define to 1 if you have the `fnmatch' function. */ +#define HAVE_FNMATCH 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define to 1 if you have the `getegid' function. */ +#define HAVE_GETEGID 1 + +/* Define to 1 if you have the `geteuid' function. */ +#define HAVE_GETEUID 1 + +/* Define to 1 if you have the `getgid' function. */ +#define HAVE_GETGID 1 + +/* Define to 1 if you have the `getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if the GNU gettext() function is already present or preinstalled. */ +/* #undef HAVE_GETTEXT */ + +/* Define to 1 if you have the `getuid' function. */ +#define HAVE_GETUID 1 + +/* Define if you have the iconv() function. */ +#define HAVE_ICONV 1 + +/* Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, and + declares uintmax_t. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `isascii' function. */ +#define HAVE_ISASCII 1 + +/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */ +#define HAVE_LANGINFO_CODESET 1 + +/* Define if your <locale.h> file defines LC_MESSAGES. */ +#define HAVE_LC_MESSAGES 1 + +/* Define to 1 if you have the <libintl.h> header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define to 1 if you have the `pcre' library (-lpcre). */ +/* #undef HAVE_LIBPCRE */ + +/* Define to 1 if you have the <limits.h> header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the <locale.h> header file. */ +#define HAVE_LOCALE_H 1 + +/* Define to 1 if you have the <malloc.h> header file. */ +/* #undef HAVE_MALLOC_H */ + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the `memchr' function. */ +#define HAVE_MEMCHR 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mempcpy' function. */ +/* #undef HAVE_MEMPCPY */ + +/* Define to 1 if you have a working `mmap' system call. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `munmap' function. */ +#define HAVE_MUNMAP 1 + +/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the <nl_types.h> header file. */ +#define HAVE_NL_TYPES_H 1 + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setmode' function. */ +#define HAVE_SETMODE 1 + +/* Define to 1 if you have the <stddef.h> header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +#define HAVE_STPCPY 1 + +/* Define to 1 if you have the `strcasecmp' function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strerror_r' function. */ +#define HAVE_STRERROR_R 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strtoull' function. */ +/* #undef HAVE_STRTOULL */ + +/* Define to 1 if you have the `strtoumax' function. */ +#define HAVE_STRTOUMAX 1 + +/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the `tsearch' function. */ +#define HAVE_TSEARCH 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the unsigned long long type. */ +#define HAVE_UNSIGNED_LONG_LONG 1 + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the <wchar.h> header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wctype' function. */ +#define HAVE_WCTYPE 1 + +/* Define to 1 if you have the <wctype.h> header file. */ +#define HAVE_WCTYPE_H 1 + +/* Define to 1 if strerror_r returns a string. */ +/* #undef HAVE_WORKING_STRERROR_R */ + +/* Define to 1 if you have the `__argz_count' function. */ +/* #undef HAVE___ARGZ_COUNT */ + +/* Define to 1 if you have the `__argz_next' function. */ +/* #undef HAVE___ARGZ_NEXT */ + +/* Define to 1 if you have the `__argz_stringify' function. */ +/* #undef HAVE___ARGZ_STRINGIFY */ + +/* Define as const if the declaration of iconv() needs const. */ +#define ICONV_CONST + +/* Name of package */ +#define PACKAGE "grep" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "" + +/* Define if compiler has function prototypes */ +#define PROTOTYPES 1 + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +/* #undef STACK_DIRECTION */ + +/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "2.5.1-FreeBSD" + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define to make fseeko etc. visible, on some hosts. */ +/* #undef _LARGEFILE_SOURCE */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* Define if your compiler is broken */ +/* #undef alloca */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define as `__inline' if that's what the C compiler calls it, or to nothing + if it is not supported. */ +/* #undef inline */ + +/* Define to rpl_malloc if the replacement function should be used. */ +/* #undef malloc */ + +/* Define to a type if <wchar.h> does not define. */ +/* #undef mbstate_t */ + +/* Define to `long' if <sys/types.h> does not define. */ +/* #undef off_t */ + +/* Define to rpl_realloc if the replacement function should be used. */ +/* #undef realloc */ + +/* Define to `unsigned' if <sys/types.h> does not define. */ +/* #undef size_t */ + +/* Define to `int' if <sys/types.h> does not define. */ +/* #undef ssize_t */ + +/* Define to unsigned long or unsigned long long if <inttypes.h> doesn't + define. */ +/* #undef uintmax_t */ diff --git a/gnu/usr.bin/grep/dfa.c b/gnu/usr.bin/grep/dfa.c new file mode 100644 index 000000000000..faf4f0b008a1 --- /dev/null +++ b/gnu/usr.bin/grep/dfa.c @@ -0,0 +1,3586 @@ +/* dfa.c - deterministic extended regexp routines for GNU + Copyright 1988, 1998, 2000 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ + +/* Written June, 1988 by Mike Haertel + Modified July, 1988 by Arthur David Olson to assist BMG speedups */ + +/* $FreeBSD$ */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <assert.h> +#include <ctype.h> +#include <stdio.h> + +#include <sys/types.h> +#ifdef STDC_HEADERS +#include <stdlib.h> +#else +extern char *calloc(), *malloc(), *realloc(); +extern void free(); +#endif + +#if defined(HAVE_STRING_H) || defined(STDC_HEADERS) +#include <string.h> +#else +#include <strings.h> +#endif + +#if HAVE_SETLOCALE +# include <locale.h> +#endif + +#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC +/* We can handle multibyte string. */ +# define MBS_SUPPORT +#endif + +#ifdef MBS_SUPPORT +# include <wchar.h> +# include <wctype.h> +#endif + +#ifndef DEBUG /* use the same approach as regex.c */ +#undef assert +#define assert(e) +#endif /* DEBUG */ + +#ifndef isgraph +#define isgraph(C) (isprint(C) && !isspace(C)) +#endif + +#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) +#define ISALPHA(C) isalpha(C) +#define ISUPPER(C) isupper(C) +#define ISLOWER(C) islower(C) +#define ISDIGIT(C) isdigit(C) +#define ISXDIGIT(C) isxdigit(C) +#define ISSPACE(C) isspace(C) +#define ISPUNCT(C) ispunct(C) +#define ISALNUM(C) isalnum(C) +#define ISPRINT(C) isprint(C) +#define ISGRAPH(C) isgraph(C) +#define ISCNTRL(C) iscntrl(C) +#else +#define ISALPHA(C) (isascii(C) && isalpha(C)) +#define ISUPPER(C) (isascii(C) && isupper(C)) +#define ISLOWER(C) (isascii(C) && islower(C)) +#define ISDIGIT(C) (isascii(C) && isdigit(C)) +#define ISXDIGIT(C) (isascii(C) && isxdigit(C)) +#define ISSPACE(C) (isascii(C) && isspace(C)) +#define ISPUNCT(C) (isascii(C) && ispunct(C)) +#define ISALNUM(C) (isascii(C) && isalnum(C)) +#define ISPRINT(C) (isascii(C) && isprint(C)) +#define ISGRAPH(C) (isascii(C) && isgraph(C)) +#define ISCNTRL(C) (isascii(C) && iscntrl(C)) +#endif + +/* ISASCIIDIGIT differs from ISDIGIT, as follows: + - Its arg may be any int or unsigned int; it need not be an unsigned char. + - It's guaranteed to evaluate its argument exactly once. + - It's typically faster. + Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that + only '0' through '9' are digits. Prefer ISASCIIDIGIT to ISDIGIT unless + it's important to use the locale's definition of `digit' even when the + host does not conform to Posix. */ +#define ISASCIIDIGIT(c) ((unsigned) (c) - '0' <= 9) + +/* If we (don't) have I18N. */ +/* glibc defines _ */ +#ifndef _ +# ifdef HAVE_LIBINTL_H +# include <libintl.h> +# ifndef _ +# define _(Str) gettext (Str) +# endif +# else +# define _(Str) (Str) +# endif +#endif + +#include "regex.h" +#include "dfa.h" +#include "hard-locale.h" + +/* HPUX, define those as macros in sys/param.h */ +#ifdef setbit +# undef setbit +#endif +#ifdef clrbit +# undef clrbit +#endif + +static void dfamust PARAMS ((struct dfa *dfa)); +static void regexp PARAMS ((int toplevel)); + +static ptr_t +xcalloc (size_t n, size_t s) +{ + ptr_t r = calloc(n, s); + + if (!r) + dfaerror(_("Memory exhausted")); + return r; +} + +static ptr_t +xmalloc (size_t n) +{ + ptr_t r = malloc(n); + + assert(n != 0); + if (!r) + dfaerror(_("Memory exhausted")); + return r; +} + +static ptr_t +xrealloc (ptr_t p, size_t n) +{ + ptr_t r = realloc(p, n); + + assert(n != 0); + if (!r) + dfaerror(_("Memory exhausted")); + return r; +} + +#define CALLOC(p, t, n) ((p) = (t *) xcalloc((size_t)(n), sizeof (t))) +#define MALLOC(p, t, n) ((p) = (t *) xmalloc((n) * sizeof (t))) +#define REALLOC(p, t, n) ((p) = (t *) xrealloc((ptr_t) (p), (n) * sizeof (t))) + +/* Reallocate an array of type t if nalloc is too small for index. */ +#define REALLOC_IF_NECESSARY(p, t, nalloc, index) \ + if ((index) >= (nalloc)) \ + { \ + do \ + (nalloc) *= 2; \ + while ((index) >= (nalloc)); \ + REALLOC(p, t, nalloc); \ + } + +#ifdef DEBUG + +static void +prtok (token t) +{ + char const *s; + + if (t < 0) + fprintf(stderr, "END"); + else if (t < NOTCHAR) + fprintf(stderr, "%c", t); + else + { + switch (t) + { + case EMPTY: s = "EMPTY"; break; + case BACKREF: s = "BACKREF"; break; + case BEGLINE: s = "BEGLINE"; break; + case ENDLINE: s = "ENDLINE"; break; + case BEGWORD: s = "BEGWORD"; break; + case ENDWORD: s = "ENDWORD"; break; + case LIMWORD: s = "LIMWORD"; break; + case NOTLIMWORD: s = "NOTLIMWORD"; break; + case QMARK: s = "QMARK"; break; + case STAR: s = "STAR"; break; + case PLUS: s = "PLUS"; break; + case CAT: s = "CAT"; break; + case OR: s = "OR"; break; + case ORTOP: s = "ORTOP"; break; + case LPAREN: s = "LPAREN"; break; + case RPAREN: s = "RPAREN"; break; + case CRANGE: s = "CRANGE"; break; +#ifdef MBS_SUPPORT + case ANYCHAR: s = "ANYCHAR"; break; + case MBCSET: s = "MBCSET"; break; +#endif /* MBS_SUPPORT */ + default: s = "CSET"; break; + } + fprintf(stderr, "%s", s); + } +} +#endif /* DEBUG */ + +/* Stuff pertaining to charclasses. */ + +static int +tstbit (unsigned b, charclass c) +{ + return c[b / INTBITS] & 1 << b % INTBITS; +} + +static void +setbit (unsigned b, charclass c) +{ + c[b / INTBITS] |= 1 << b % INTBITS; +} + +static void +clrbit (unsigned b, charclass c) +{ + c[b / INTBITS] &= ~(1 << b % INTBITS); +} + +static void +copyset (charclass src, charclass dst) +{ + memcpy (dst, src, sizeof (charclass)); +} + +static void +zeroset (charclass s) +{ + memset (s, 0, sizeof (charclass)); +} + +static void +notset (charclass s) +{ + int i; + + for (i = 0; i < CHARCLASS_INTS; ++i) + s[i] = ~s[i]; +} + +static int +equal (charclass s1, charclass s2) +{ + return memcmp (s1, s2, sizeof (charclass)) == 0; +} + +/* A pointer to the current dfa is kept here during parsing. */ +static struct dfa *dfa; + +/* Find the index of charclass s in dfa->charclasses, or allocate a new charclass. */ +static int +charclass_index (charclass s) +{ + int i; + + for (i = 0; i < dfa->cindex; ++i) + if (equal(s, dfa->charclasses[i])) + return i; + REALLOC_IF_NECESSARY(dfa->charclasses, charclass, dfa->calloc, dfa->cindex); + ++dfa->cindex; + copyset(s, dfa->charclasses[i]); + return i; +} + +/* Syntax bits controlling the behavior of the lexical analyzer. */ +static reg_syntax_t syntax_bits, syntax_bits_set; + +/* Flag for case-folding letters into sets. */ +static int case_fold; + +/* End-of-line byte in data. */ +static unsigned char eolbyte; + +/* Entry point to set syntax options. */ +void +dfasyntax (reg_syntax_t bits, int fold, unsigned char eol) +{ + syntax_bits_set = 1; + syntax_bits = bits; + case_fold = fold; + eolbyte = eol; +} + +/* Like setbit, but if case is folded, set both cases of a letter. */ +static void +setbit_case_fold (unsigned b, charclass c) +{ + setbit (b, c); + if (case_fold) + { + if (ISUPPER (b)) + setbit (tolower (b), c); + else if (ISLOWER (b)) + setbit (toupper (b), c); + } +} + +/* Lexical analyzer. All the dross that deals with the obnoxious + GNU Regex syntax bits is located here. The poor, suffering + reader is referred to the GNU Regex documentation for the + meaning of the @#%!@#%^!@ syntax bits. */ + +static char const *lexstart; /* Pointer to beginning of input string. */ +static char const *lexptr; /* Pointer to next input character. */ +static int lexleft; /* Number of characters remaining. */ +static token lasttok; /* Previous token returned; initially END. */ +static int laststart; /* True if we're separated from beginning or (, | + only by zero-width characters. */ +static int parens; /* Count of outstanding left parens. */ +static int minrep, maxrep; /* Repeat counts for {m,n}. */ +static int hard_LC_COLLATE; /* Nonzero if LC_COLLATE is hard. */ + +#ifdef MBS_SUPPORT +/* These variables are used only if (MB_CUR_MAX > 1). */ +static mbstate_t mbs; /* Mbstate for mbrlen(). */ +static ssize_t cur_mb_len; /* Byte length of the current scanning + multibyte character. Must also handle + negative result from mbrlen(). */ +static ssize_t cur_mb_index; /* Byte index of the current scanning multibyte + character. + + singlebyte character : cur_mb_index = 0 + multibyte character + 1st byte : cur_mb_index = 1 + 2nd byte : cur_mb_index = 2 + ... + nth byte : cur_mb_index = n */ +static unsigned char *mblen_buf;/* Correspond to the input buffer in dfaexec(). + Each element store the amount of remain + byte of corresponding multibyte character + in the input string. A element's value + is 0 if corresponding character is a + singlebyte chracter. + e.g. input : 'a', <mb(0)>, <mb(1)>, <mb(2)> + mblen_buf : 0, 3, 2, 1 + */ +static wchar_t *inputwcs; /* Wide character representation of input + string in dfaexec(). + The length of this array is same as + the length of input string(char array). + inputstring[i] is a single-byte char, + or 1st byte of a multibyte char. + And inputwcs[i] is the codepoint. */ +static unsigned char const *buf_begin;/* refference to begin in dfaexec(). */ +static unsigned char const *buf_end; /* refference to end in dfaexec(). */ +#endif /* MBS_SUPPORT */ + +#ifdef MBS_SUPPORT +/* This function update cur_mb_len, and cur_mb_index. + p points current lexptr, len is the remaining buffer length. */ +static void +update_mb_len_index (unsigned char const *p, size_t len) +{ + /* If last character is a part of a multibyte character, + we update cur_mb_index. */ + if (cur_mb_index) + cur_mb_index = (cur_mb_index >= cur_mb_len)? 0 + : cur_mb_index + 1; + + /* If last character is a single byte character, or the + last portion of a multibyte character, we check whether + next character is a multibyte character or not. */ + if (! cur_mb_index) + { + cur_mb_len = mbrlen(p, len, &mbs); + if (cur_mb_len > 1) + /* It is a multibyte character. + cur_mb_len was already set by mbrlen(). */ + cur_mb_index = 1; + else if (cur_mb_len < 1) + /* Invalid sequence. We treat it as a singlebyte character. + cur_mb_index is aleady 0. */ + cur_mb_len = 1; + /* Otherwise, cur_mb_len == 1, it is a singlebyte character. + cur_mb_index is aleady 0. */ + } +} +#endif /* MBS_SUPPORT */ + +#ifdef MBS_SUPPORT +/* Note that characters become unsigned here. */ +# define FETCH(c, eoferr) \ + { \ + if (! lexleft) \ + { \ + if (eoferr != 0) \ + dfaerror (eoferr); \ + else \ + return lasttok = END; \ + } \ + if (MB_CUR_MAX > 1) \ + update_mb_len_index(lexptr, lexleft); \ + (c) = (unsigned char) *lexptr++; \ + --lexleft; \ + } + +/* This function fetch a wide character, and update cur_mb_len, + used only if the current locale is a multibyte environment. */ +static wint_t +fetch_wc (char const *eoferr) +{ + wchar_t wc; + if (! lexleft) + { + if (eoferr != 0) + dfaerror (eoferr); + else + return WEOF; + } + + cur_mb_len = mbrtowc(&wc, lexptr, lexleft, &mbs); + if (cur_mb_len <= 0) + { + cur_mb_len = 1; + wc = *lexptr; + } + lexptr += cur_mb_len; + lexleft -= cur_mb_len; + return wc; +} +#else +/* Note that characters become unsigned here. */ +# define FETCH(c, eoferr) \ + { \ + if (! lexleft) \ + { \ + if (eoferr != 0) \ + dfaerror (eoferr); \ + else \ + return lasttok = END; \ + } \ + (c) = (unsigned char) *lexptr++; \ + --lexleft; \ + } +#endif /* MBS_SUPPORT */ + +#ifdef MBS_SUPPORT +/* Multibyte character handling sub-routin for lex. + This function parse a bracket expression and build a struct + mb_char_classes. */ +static void +parse_bracket_exp_mb () +{ + wint_t wc, wc1, wc2; + + /* Work area to build a mb_char_classes. */ + struct mb_char_classes *work_mbc; + int chars_al, range_sts_al, range_ends_al, ch_classes_al, + equivs_al, coll_elems_al; + + REALLOC_IF_NECESSARY(dfa->mbcsets, struct mb_char_classes, + dfa->mbcsets_alloc, dfa->nmbcsets + 1); + /* dfa->multibyte_prop[] hold the index of dfa->mbcsets. + We will update dfa->multibyte_prop in addtok(), because we can't + decide the index in dfa->tokens[]. */ + + /* Initialize work are */ + work_mbc = &(dfa->mbcsets[dfa->nmbcsets++]); + + chars_al = 1; + range_sts_al = range_ends_al = 0; + ch_classes_al = equivs_al = coll_elems_al = 0; + MALLOC(work_mbc->chars, wchar_t, chars_al); + + work_mbc->nchars = work_mbc->nranges = work_mbc->nch_classes = 0; + work_mbc->nequivs = work_mbc->ncoll_elems = 0; + work_mbc->chars = work_mbc->ch_classes = NULL; + work_mbc->range_sts = work_mbc->range_ends = NULL; + work_mbc->equivs = work_mbc->coll_elems = NULL; + + wc = fetch_wc(_("Unbalanced [")); + if (wc == L'^') + { + wc = fetch_wc(_("Unbalanced [")); + work_mbc->invert = 1; + } + else + work_mbc->invert = 0; + do + { + wc1 = WEOF; /* mark wc1 is not initialized". */ + + /* Note that if we're looking at some other [:...:] construct, + we just treat it as a bunch of ordinary characters. We can do + this because we assume regex has checked for syntax errors before + dfa is ever called. */ + if (wc == L'[' && (syntax_bits & RE_CHAR_CLASSES)) + { +#define BRACKET_BUFFER_SIZE 128 + char str[BRACKET_BUFFER_SIZE]; + wc1 = wc; + wc = fetch_wc(_("Unbalanced [")); + + /* If pattern contains `[[:', `[[.', or `[[='. */ + if (cur_mb_len == 1 && (wc == L':' || wc == L'.' || wc == L'=')) + { + unsigned char c; + unsigned char delim = (unsigned char)wc; + int len = 0; + for (;;) + { + if (! lexleft) + dfaerror (_("Unbalanced [")); + c = (unsigned char) *lexptr++; + --lexleft; + + if ((c == delim && *lexptr == ']') || lexleft == 0) + break; + if (len < BRACKET_BUFFER_SIZE) + str[len++] = c; + else + /* This is in any case an invalid class name. */ + str[0] = '\0'; + } + str[len] = '\0'; + + if (lexleft == 0) + { + REALLOC_IF_NECESSARY(work_mbc->chars, wchar_t, chars_al, + work_mbc->nchars + 2); + work_mbc->chars[work_mbc->nchars++] = L'['; + work_mbc->chars[work_mbc->nchars++] = delim; + break; + } + + if (--lexleft, *lexptr++ != ']') + dfaerror (_("Unbalanced [")); + if (delim == ':') + /* build character class. */ + { + wctype_t wt; + /* Query the character class as wctype_t. */ + wt = wctype (str); + + if (ch_classes_al == 0) + MALLOC(work_mbc->ch_classes, wchar_t, ++ch_classes_al); + REALLOC_IF_NECESSARY(work_mbc->ch_classes, wctype_t, + ch_classes_al, + work_mbc->nch_classes + 1); + work_mbc->ch_classes[work_mbc->nch_classes++] = wt; + + } + else if (delim == '=' || delim == '.') + { + char *elem; + MALLOC(elem, char, len + 1); + strncpy(elem, str, len + 1); + + if (delim == '=') + /* build equivalent class. */ + { + if (equivs_al == 0) + MALLOC(work_mbc->equivs, char*, ++equivs_al); + REALLOC_IF_NECESSARY(work_mbc->equivs, char*, + equivs_al, + work_mbc->nequivs + 1); + work_mbc->equivs[work_mbc->nequivs++] = elem; + } + + if (delim == '.') + /* build collating element. */ + { + if (coll_elems_al == 0) + MALLOC(work_mbc->coll_elems, char*, ++coll_elems_al); + REALLOC_IF_NECESSARY(work_mbc->coll_elems, char*, + coll_elems_al, + work_mbc->ncoll_elems + 1); + work_mbc->coll_elems[work_mbc->ncoll_elems++] = elem; + } + } + wc1 = wc = WEOF; + } + else + /* We treat '[' as a normal character here. */ + { + wc2 = wc1; wc1 = wc; wc = wc2; /* swap */ + } + } + else + { + if (wc == L'\\' && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS)) + wc = fetch_wc(("Unbalanced [")); + } + + if (wc1 == WEOF) + wc1 = fetch_wc(_("Unbalanced [")); + + if (wc1 == L'-') + /* build range characters. */ + { + wc2 = fetch_wc(_("Unbalanced [")); + if (wc2 == L']') + { + /* In the case [x-], the - is an ordinary hyphen, + which is left in c1, the lookahead character. */ + lexptr -= cur_mb_len; + lexleft += cur_mb_len; + wc2 = wc; + } + else + { + if (wc2 == L'\\' + && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS)) + wc2 = fetch_wc(_("Unbalanced [")); + wc1 = fetch_wc(_("Unbalanced [")); + } + + if (range_sts_al == 0) + { + MALLOC(work_mbc->range_sts, wchar_t, ++range_sts_al); + MALLOC(work_mbc->range_ends, wchar_t, ++range_ends_al); + } + REALLOC_IF_NECESSARY(work_mbc->range_sts, wchar_t, + range_sts_al, work_mbc->nranges + 1); + work_mbc->range_sts[work_mbc->nranges] = (wchar_t)wc; + REALLOC_IF_NECESSARY(work_mbc->range_ends, wchar_t, + range_ends_al, work_mbc->nranges + 1); + work_mbc->range_ends[work_mbc->nranges++] = (wchar_t)wc2; + } + else if (wc != WEOF) + /* build normal characters. */ + { + REALLOC_IF_NECESSARY(work_mbc->chars, wchar_t, chars_al, + work_mbc->nchars + 1); + work_mbc->chars[work_mbc->nchars++] = (wchar_t)wc; + } + } + while ((wc = wc1) != L']'); +} +#endif /* MBS_SUPPORT */ + +#ifdef __STDC__ +#define FUNC(F, P) static int F(int c) { return P(c); } +#else +#define FUNC(F, P) static int F(c) int c; { return P(c); } +#endif + +FUNC(is_alpha, ISALPHA) +FUNC(is_upper, ISUPPER) +FUNC(is_lower, ISLOWER) +FUNC(is_digit, ISDIGIT) +FUNC(is_xdigit, ISXDIGIT) +FUNC(is_space, ISSPACE) +FUNC(is_punct, ISPUNCT) +FUNC(is_alnum, ISALNUM) +FUNC(is_print, ISPRINT) +FUNC(is_graph, ISGRAPH) +FUNC(is_cntrl, ISCNTRL) + +static int +is_blank (int c) +{ + return (c == ' ' || c == '\t'); +} + +/* The following list maps the names of the Posix named character classes + to predicate functions that determine whether a given character is in + the class. The leading [ has already been eaten by the lexical analyzer. */ +static struct { + const char *name; + int (*pred) PARAMS ((int)); +} const prednames[] = { + { ":alpha:]", is_alpha }, + { ":upper:]", is_upper }, + { ":lower:]", is_lower }, + { ":digit:]", is_digit }, + { ":xdigit:]", is_xdigit }, + { ":space:]", is_space }, + { ":punct:]", is_punct }, + { ":alnum:]", is_alnum }, + { ":print:]", is_print }, + { ":graph:]", is_graph }, + { ":cntrl:]", is_cntrl }, + { ":blank:]", is_blank }, + { 0 } +}; + +/* Return non-zero if C is a `word-constituent' byte; zero otherwise. */ +#define IS_WORD_CONSTITUENT(C) (ISALNUM(C) || (C) == '_') + +static int +looking_at (char const *s) +{ + size_t len; + + len = strlen(s); + if (lexleft < len) + return 0; + return strncmp(s, lexptr, len) == 0; +} + +static token +lex (void) +{ + unsigned c, c1, c2; + int backslash = 0, invert; + charclass ccl; + int i; + + /* Basic plan: We fetch a character. If it's a backslash, + we set the backslash flag and go through the loop again. + On the plus side, this avoids having a duplicate of the + main switch inside the backslash case. On the minus side, + it means that just about every case begins with + "if (backslash) ...". */ + for (i = 0; i < 2; ++i) + { + FETCH(c, 0); +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1 && cur_mb_index) + /* If this is a part of a multi-byte character, we must treat + this byte data as a normal character. + e.g. In case of SJIS encoding, some character contains '\', + but they must not be backslash. */ + goto normal_char; +#endif /* MBS_SUPPORT */ + switch (c) + { + case '\\': + if (backslash) + goto normal_char; + if (lexleft == 0) + dfaerror(_("Unfinished \\ escape")); + backslash = 1; + break; + + case '^': + if (backslash) + goto normal_char; + if (syntax_bits & RE_CONTEXT_INDEP_ANCHORS + || lasttok == END + || lasttok == LPAREN + || lasttok == OR) + return lasttok = BEGLINE; + goto normal_char; + + case '$': + if (backslash) + goto normal_char; + if (syntax_bits & RE_CONTEXT_INDEP_ANCHORS + || lexleft == 0 + || (syntax_bits & RE_NO_BK_PARENS + ? lexleft > 0 && *lexptr == ')' + : lexleft > 1 && lexptr[0] == '\\' && lexptr[1] == ')') + || (syntax_bits & RE_NO_BK_VBAR + ? lexleft > 0 && *lexptr == '|' + : lexleft > 1 && lexptr[0] == '\\' && lexptr[1] == '|') + || ((syntax_bits & RE_NEWLINE_ALT) + && lexleft > 0 && *lexptr == '\n')) + return lasttok = ENDLINE; + goto normal_char; + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (backslash && !(syntax_bits & RE_NO_BK_REFS)) + { + laststart = 0; + return lasttok = BACKREF; + } + goto normal_char; + + case '`': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = BEGLINE; /* FIXME: should be beginning of string */ + goto normal_char; + + case '\'': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = ENDLINE; /* FIXME: should be end of string */ + goto normal_char; + + case '<': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = BEGWORD; + goto normal_char; + + case '>': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = ENDWORD; + goto normal_char; + + case 'b': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = LIMWORD; + goto normal_char; + + case 'B': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = NOTLIMWORD; + goto normal_char; + + case '?': + if (syntax_bits & RE_LIMITED_OPS) + goto normal_char; + if (backslash != ((syntax_bits & RE_BK_PLUS_QM) != 0)) + goto normal_char; + if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) + goto normal_char; + return lasttok = QMARK; + + case '*': + if (backslash) + goto normal_char; + if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) + goto normal_char; + return lasttok = STAR; + + case '+': + if (syntax_bits & RE_LIMITED_OPS) + goto normal_char; + if (backslash != ((syntax_bits & RE_BK_PLUS_QM) != 0)) + goto normal_char; + if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) + goto normal_char; + return lasttok = PLUS; + + case '{': + if (!(syntax_bits & RE_INTERVALS)) + goto normal_char; + if (backslash != ((syntax_bits & RE_NO_BK_BRACES) == 0)) + goto normal_char; + if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) + goto normal_char; + + if (syntax_bits & RE_NO_BK_BRACES) + { + /* Scan ahead for a valid interval; if it's not valid, + treat it as a literal '{'. */ + int lo = -1, hi = -1; + char const *p = lexptr; + char const *lim = p + lexleft; + for (; p != lim && ISASCIIDIGIT (*p); p++) + lo = (lo < 0 ? 0 : lo * 10) + *p - '0'; + if (p != lim && *p == ',') + while (++p != lim && ISASCIIDIGIT (*p)) + hi = (hi < 0 ? 0 : hi * 10) + *p - '0'; + else + hi = lo; + if (p == lim || *p != '}' + || lo < 0 || RE_DUP_MAX < hi || (0 <= hi && hi < lo)) + goto normal_char; + } + + minrep = 0; + /* Cases: + {M} - exact count + {M,} - minimum count, maximum is infinity + {M,N} - M through N */ + FETCH(c, _("unfinished repeat count")); + if (ISASCIIDIGIT (c)) + { + minrep = c - '0'; + for (;;) + { + FETCH(c, _("unfinished repeat count")); + if (! ISASCIIDIGIT (c)) + break; + minrep = 10 * minrep + c - '0'; + } + } + else + dfaerror(_("malformed repeat count")); + if (c == ',') + { + FETCH (c, _("unfinished repeat count")); + if (! ISASCIIDIGIT (c)) + maxrep = -1; + else + { + maxrep = c - '0'; + for (;;) + { + FETCH (c, _("unfinished repeat count")); + if (! ISASCIIDIGIT (c)) + break; + maxrep = 10 * maxrep + c - '0'; + } + if (0 <= maxrep && maxrep < minrep) + dfaerror (_("malformed repeat count")); + } + } + else + maxrep = minrep; + if (!(syntax_bits & RE_NO_BK_BRACES)) + { + if (c != '\\') + dfaerror(_("malformed repeat count")); + FETCH(c, _("unfinished repeat count")); + } + if (c != '}') + dfaerror(_("malformed repeat count")); + laststart = 0; + return lasttok = REPMN; + + case '|': + if (syntax_bits & RE_LIMITED_OPS) + goto normal_char; + if (backslash != ((syntax_bits & RE_NO_BK_VBAR) == 0)) + goto normal_char; + laststart = 1; + return lasttok = OR; + + case '\n': + if (syntax_bits & RE_LIMITED_OPS + || backslash + || !(syntax_bits & RE_NEWLINE_ALT)) + goto normal_char; + laststart = 1; + return lasttok = OR; + + case '(': + if (backslash != ((syntax_bits & RE_NO_BK_PARENS) == 0)) + goto normal_char; + ++parens; + laststart = 1; + return lasttok = LPAREN; + + case ')': + if (backslash != ((syntax_bits & RE_NO_BK_PARENS) == 0)) + goto normal_char; + if (parens == 0 && syntax_bits & RE_UNMATCHED_RIGHT_PAREN_ORD) + goto normal_char; + --parens; + laststart = 0; + return lasttok = RPAREN; + + case '.': + if (backslash) + goto normal_char; +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + /* In multibyte environment period must match with a single + character not a byte. So we use ANYCHAR. */ + laststart = 0; + return lasttok = ANYCHAR; + } +#endif /* MBS_SUPPORT */ + zeroset(ccl); + notset(ccl); + if (!(syntax_bits & RE_DOT_NEWLINE)) + clrbit(eolbyte, ccl); + if (syntax_bits & RE_DOT_NOT_NULL) + clrbit('\0', ccl); + laststart = 0; + return lasttok = CSET + charclass_index(ccl); + + case 'w': + case 'W': + if (!backslash || (syntax_bits & RE_NO_GNU_OPS)) + goto normal_char; + zeroset(ccl); + for (c2 = 0; c2 < NOTCHAR; ++c2) + if (IS_WORD_CONSTITUENT(c2)) + setbit(c2, ccl); + if (c == 'W') + notset(ccl); + laststart = 0; + return lasttok = CSET + charclass_index(ccl); + + case '[': + if (backslash) + goto normal_char; + laststart = 0; +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + /* In multibyte environment a bracket expression may contain + multibyte characters, which must be treated as characters + (not bytes). So we parse it by parse_bracket_exp_mb(). */ + parse_bracket_exp_mb(); + return lasttok = MBCSET; + } +#endif + zeroset(ccl); + FETCH(c, _("Unbalanced [")); + if (c == '^') + { + FETCH(c, _("Unbalanced [")); + invert = 1; + } + else + invert = 0; + do + { + /* Nobody ever said this had to be fast. :-) + Note that if we're looking at some other [:...:] + construct, we just treat it as a bunch of ordinary + characters. We can do this because we assume + regex has checked for syntax errors before + dfa is ever called. */ + if (c == '[' && (syntax_bits & RE_CHAR_CLASSES)) + for (c1 = 0; prednames[c1].name; ++c1) + if (looking_at(prednames[c1].name)) + { + int (*pred) PARAMS ((int)) = prednames[c1].pred; + + for (c2 = 0; c2 < NOTCHAR; ++c2) + if ((*pred)(c2)) + setbit_case_fold (c2, ccl); + lexptr += strlen(prednames[c1].name); + lexleft -= strlen(prednames[c1].name); + FETCH(c1, _("Unbalanced [")); + goto skip; + } + if (c == '\\' && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS)) + FETCH(c, _("Unbalanced [")); + FETCH(c1, _("Unbalanced [")); + if (c1 == '-') + { + FETCH(c2, _("Unbalanced [")); + if (c2 == ']') + { + /* In the case [x-], the - is an ordinary hyphen, + which is left in c1, the lookahead character. */ + --lexptr; + ++lexleft; + } + else + { + if (c2 == '\\' + && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS)) + FETCH(c2, _("Unbalanced [")); + FETCH(c1, _("Unbalanced [")); + if (!hard_LC_COLLATE) { + for (; c <= c2; c++) + setbit_case_fold (c, ccl); + } else { + /* POSIX locales are painful - leave the decision to libc */ + char expr[6] = { '[', c, '-', c2, ']', '\0' }; + regex_t re; + if (regcomp (&re, expr, case_fold ? REG_ICASE : 0) == REG_NOERROR) { + for (c = 0; c < NOTCHAR; ++c) { + char buf[2] = { c, '\0' }; + regmatch_t mat; + if (regexec (&re, buf, 1, &mat, 0) == REG_NOERROR + && mat.rm_so == 0 && mat.rm_eo == 1) + setbit_case_fold (c, ccl); + } + regfree (&re); + } + } + continue; + } + } + + setbit_case_fold (c, ccl); + + skip: + ; + } + while ((c = c1) != ']'); + if (invert) + { + notset(ccl); + if (syntax_bits & RE_HAT_LISTS_NOT_NEWLINE) + clrbit(eolbyte, ccl); + } + return lasttok = CSET + charclass_index(ccl); + + default: + normal_char: + laststart = 0; + if (case_fold && ISALPHA(c)) + { + zeroset(ccl); + setbit_case_fold (c, ccl); + return lasttok = CSET + charclass_index(ccl); + } + return c; + } + } + + /* The above loop should consume at most a backslash + and some other character. */ + abort(); + return END; /* keeps pedantic compilers happy. */ +} + +/* Recursive descent parser for regular expressions. */ + +static token tok; /* Lookahead token. */ +static int depth; /* Current depth of a hypothetical stack + holding deferred productions. This is + used to determine the depth that will be + required of the real stack later on in + dfaanalyze(). */ + +/* Add the given token to the parse tree, maintaining the depth count and + updating the maximum depth if necessary. */ +static void +addtok (token t) +{ +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + REALLOC_IF_NECESSARY(dfa->multibyte_prop, int, dfa->nmultibyte_prop, + dfa->tindex); + /* Set dfa->multibyte_prop. See struct dfa in dfa.h. */ + if (t == MBCSET) + dfa->multibyte_prop[dfa->tindex] = ((dfa->nmbcsets - 1) << 2) + 3; + else if (t < NOTCHAR) + dfa->multibyte_prop[dfa->tindex] + = (cur_mb_len == 1)? 3 /* single-byte char */ + : (((cur_mb_index == 1)? 1 : 0) /* 1st-byte of multibyte char */ + + ((cur_mb_index == cur_mb_len)? 2 : 0)); /* last-byte */ + else + /* It may be unnecesssary, but it is safer to treat other + symbols as singlebyte characters. */ + dfa->multibyte_prop[dfa->tindex] = 3; + } +#endif + + REALLOC_IF_NECESSARY(dfa->tokens, token, dfa->talloc, dfa->tindex); + dfa->tokens[dfa->tindex++] = t; + + switch (t) + { + case QMARK: + case STAR: + case PLUS: + break; + + case CAT: + case OR: + case ORTOP: + --depth; + break; + + default: + ++dfa->nleaves; + case EMPTY: + ++depth; + break; + } + if (depth > dfa->depth) + dfa->depth = depth; +} + +/* The grammar understood by the parser is as follows. + + regexp: + regexp OR branch + branch + + branch: + branch closure + closure + + closure: + closure QMARK + closure STAR + closure PLUS + closure REPMN + atom + + atom: + <normal character> + <multibyte character> + ANYCHAR + MBCSET + CSET + BACKREF + BEGLINE + ENDLINE + BEGWORD + ENDWORD + LIMWORD + NOTLIMWORD + CRANGE + LPAREN regexp RPAREN + <empty> + + The parser builds a parse tree in postfix form in an array of tokens. */ + +static void +atom (void) +{ + if ((tok >= 0 && tok < NOTCHAR) || tok >= CSET || tok == BACKREF + || tok == BEGLINE || tok == ENDLINE || tok == BEGWORD +#ifdef MBS_SUPPORT + || tok == ANYCHAR || tok == MBCSET /* MB_CUR_MAX > 1 */ +#endif /* MBS_SUPPORT */ + || tok == ENDWORD || tok == LIMWORD || tok == NOTLIMWORD) + { + addtok(tok); + tok = lex(); +#ifdef MBS_SUPPORT + /* We treat a multibyte character as a single atom, so that DFA + can treat a multibyte character as a single expression. + + e.g. We construct following tree from "<mb1><mb2>". + <mb1(1st-byte)><mb1(2nd-byte)><CAT><mb1(3rd-byte)><CAT> + <mb2(1st-byte)><mb2(2nd-byte)><CAT><mb2(3rd-byte)><CAT><CAT> + */ + if (MB_CUR_MAX > 1) + { + while (cur_mb_index > 1 && tok >= 0 && tok < NOTCHAR) + { + addtok(tok); + addtok(CAT); + tok = lex(); + } + } +#endif /* MBS_SUPPORT */ + } + else if (tok == CRANGE) + { + /* A character range like "[a-z]" in a locale other than "C" or + "POSIX". This range might any sequence of one or more + characters. Unfortunately the POSIX locale primitives give + us no practical way to find what character sequences might be + matched. Treat this approximately like "(.\1)" -- i.e. match + one character, and then punt to the full matcher. */ + charclass ccl; + zeroset (ccl); + notset (ccl); + addtok (CSET + charclass_index (ccl)); + addtok (BACKREF); + addtok (CAT); + tok = lex (); + } + else if (tok == LPAREN) + { + tok = lex(); + regexp(0); + if (tok != RPAREN) + dfaerror(_("Unbalanced (")); + tok = lex(); + } + else + addtok(EMPTY); +} + +/* Return the number of tokens in the given subexpression. */ +static int +nsubtoks (int tindex) +{ + int ntoks1; + + switch (dfa->tokens[tindex - 1]) + { + default: + return 1; + case QMARK: + case STAR: + case PLUS: + return 1 + nsubtoks(tindex - 1); + case CAT: + case OR: + case ORTOP: + ntoks1 = nsubtoks(tindex - 1); + return 1 + ntoks1 + nsubtoks(tindex - 1 - ntoks1); + } +} + +/* Copy the given subexpression to the top of the tree. */ +static void +copytoks (int tindex, int ntokens) +{ + int i; + + for (i = 0; i < ntokens; ++i) + addtok(dfa->tokens[tindex + i]); +} + +static void +closure (void) +{ + int tindex, ntokens, i; + + atom(); + while (tok == QMARK || tok == STAR || tok == PLUS || tok == REPMN) + if (tok == REPMN) + { + ntokens = nsubtoks(dfa->tindex); + tindex = dfa->tindex - ntokens; + if (maxrep < 0) + addtok(PLUS); + if (minrep == 0) + addtok(QMARK); + for (i = 1; i < minrep; ++i) + { + copytoks(tindex, ntokens); + addtok(CAT); + } + for (; i < maxrep; ++i) + { + copytoks(tindex, ntokens); + addtok(QMARK); + addtok(CAT); + } + tok = lex(); + } + else + { + addtok(tok); + tok = lex(); + } +} + +static void +branch (void) +{ + closure(); + while (tok != RPAREN && tok != OR && tok >= 0) + { + closure(); + addtok(CAT); + } +} + +static void +regexp (int toplevel) +{ + branch(); + while (tok == OR) + { + tok = lex(); + branch(); + if (toplevel) + addtok(ORTOP); + else + addtok(OR); + } +} + +/* Main entry point for the parser. S is a string to be parsed, len is the + length of the string, so s can include NUL characters. D is a pointer to + the struct dfa to parse into. */ +void +dfaparse (char const *s, size_t len, struct dfa *d) +{ + dfa = d; + lexstart = lexptr = s; + lexleft = len; + lasttok = END; + laststart = 1; + parens = 0; + hard_LC_COLLATE = hard_locale (LC_COLLATE); +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + cur_mb_index = 0; + cur_mb_len = 0; + memset(&mbs, 0, sizeof(mbstate_t)); + } +#endif /* MBS_SUPPORT */ + + if (! syntax_bits_set) + dfaerror(_("No syntax specified")); + + tok = lex(); + depth = d->depth; + + regexp(1); + + if (tok != END) + dfaerror(_("Unbalanced )")); + + addtok(END - d->nregexps); + addtok(CAT); + + if (d->nregexps) + addtok(ORTOP); + + ++d->nregexps; +} + +/* Some primitives for operating on sets of positions. */ + +/* Copy one set to another; the destination must be large enough. */ +static void +copy (position_set const *src, position_set *dst) +{ + int i; + + for (i = 0; i < src->nelem; ++i) + dst->elems[i] = src->elems[i]; + dst->nelem = src->nelem; +} + +/* Insert a position in a set. Position sets are maintained in sorted + order according to index. If position already exists in the set with + the same index then their constraints are logically or'd together. + S->elems must point to an array large enough to hold the resulting set. */ +static void +insert (position p, position_set *s) +{ + int i; + position t1, t2; + + for (i = 0; i < s->nelem && p.index < s->elems[i].index; ++i) + continue; + if (i < s->nelem && p.index == s->elems[i].index) + s->elems[i].constraint |= p.constraint; + else + { + t1 = p; + ++s->nelem; + while (i < s->nelem) + { + t2 = s->elems[i]; + s->elems[i++] = t1; + t1 = t2; + } + } +} + +/* Merge two sets of positions into a third. The result is exactly as if + the positions of both sets were inserted into an initially empty set. */ +static void +merge (position_set const *s1, position_set const *s2, position_set *m) +{ + int i = 0, j = 0; + + m->nelem = 0; + while (i < s1->nelem && j < s2->nelem) + if (s1->elems[i].index > s2->elems[j].index) + m->elems[m->nelem++] = s1->elems[i++]; + else if (s1->elems[i].index < s2->elems[j].index) + m->elems[m->nelem++] = s2->elems[j++]; + else + { + m->elems[m->nelem] = s1->elems[i++]; + m->elems[m->nelem++].constraint |= s2->elems[j++].constraint; + } + while (i < s1->nelem) + m->elems[m->nelem++] = s1->elems[i++]; + while (j < s2->nelem) + m->elems[m->nelem++] = s2->elems[j++]; +} + +/* Delete a position from a set. */ +static void +delete (position p, position_set *s) +{ + int i; + + for (i = 0; i < s->nelem; ++i) + if (p.index == s->elems[i].index) + break; + if (i < s->nelem) + for (--s->nelem; i < s->nelem; ++i) + s->elems[i] = s->elems[i + 1]; +} + +/* Find the index of the state corresponding to the given position set with + the given preceding context, or create a new state if there is no such + state. Newline and letter tell whether we got here on a newline or + letter, respectively. */ +static int +state_index (struct dfa *d, position_set const *s, int newline, int letter) +{ + int hash = 0; + int constraint; + int i, j; + + newline = newline ? 1 : 0; + letter = letter ? 1 : 0; + + for (i = 0; i < s->nelem; ++i) + hash ^= s->elems[i].index + s->elems[i].constraint; + + /* Try to find a state that exactly matches the proposed one. */ + for (i = 0; i < d->sindex; ++i) + { + if (hash != d->states[i].hash || s->nelem != d->states[i].elems.nelem + || newline != d->states[i].newline || letter != d->states[i].letter) + continue; + for (j = 0; j < s->nelem; ++j) + if (s->elems[j].constraint + != d->states[i].elems.elems[j].constraint + || s->elems[j].index != d->states[i].elems.elems[j].index) + break; + if (j == s->nelem) + return i; + } + + /* We'll have to create a new state. */ + REALLOC_IF_NECESSARY(d->states, dfa_state, d->salloc, d->sindex); + d->states[i].hash = hash; + MALLOC(d->states[i].elems.elems, position, s->nelem); + copy(s, &d->states[i].elems); + d->states[i].newline = newline; + d->states[i].letter = letter; + d->states[i].backref = 0; + d->states[i].constraint = 0; + d->states[i].first_end = 0; +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + d->states[i].mbps.nelem = 0; +#endif + for (j = 0; j < s->nelem; ++j) + if (d->tokens[s->elems[j].index] < 0) + { + constraint = s->elems[j].constraint; + if (SUCCEEDS_IN_CONTEXT(constraint, newline, 0, letter, 0) + || SUCCEEDS_IN_CONTEXT(constraint, newline, 0, letter, 1) + || SUCCEEDS_IN_CONTEXT(constraint, newline, 1, letter, 0) + || SUCCEEDS_IN_CONTEXT(constraint, newline, 1, letter, 1)) + d->states[i].constraint |= constraint; + if (! d->states[i].first_end) + d->states[i].first_end = d->tokens[s->elems[j].index]; + } + else if (d->tokens[s->elems[j].index] == BACKREF) + { + d->states[i].constraint = NO_CONSTRAINT; + d->states[i].backref = 1; + } + + ++d->sindex; + + return i; +} + +/* Find the epsilon closure of a set of positions. If any position of the set + contains a symbol that matches the empty string in some context, replace + that position with the elements of its follow labeled with an appropriate + constraint. Repeat exhaustively until no funny positions are left. + S->elems must be large enough to hold the result. */ +static void +epsclosure (position_set *s, struct dfa const *d) +{ + int i, j; + int *visited; + position p, old; + + MALLOC(visited, int, d->tindex); + for (i = 0; i < d->tindex; ++i) + visited[i] = 0; + + for (i = 0; i < s->nelem; ++i) + if (d->tokens[s->elems[i].index] >= NOTCHAR + && d->tokens[s->elems[i].index] != BACKREF +#ifdef MBS_SUPPORT + && d->tokens[s->elems[i].index] != ANYCHAR + && d->tokens[s->elems[i].index] != MBCSET +#endif + && d->tokens[s->elems[i].index] < CSET) + { + old = s->elems[i]; + p.constraint = old.constraint; + delete(s->elems[i], s); + if (visited[old.index]) + { + --i; + continue; + } + visited[old.index] = 1; + switch (d->tokens[old.index]) + { + case BEGLINE: + p.constraint &= BEGLINE_CONSTRAINT; + break; + case ENDLINE: + p.constraint &= ENDLINE_CONSTRAINT; + break; + case BEGWORD: + p.constraint &= BEGWORD_CONSTRAINT; + break; + case ENDWORD: + p.constraint &= ENDWORD_CONSTRAINT; + break; + case LIMWORD: + p.constraint &= LIMWORD_CONSTRAINT; + break; + case NOTLIMWORD: + p.constraint &= NOTLIMWORD_CONSTRAINT; + break; + default: + break; + } + for (j = 0; j < d->follows[old.index].nelem; ++j) + { + p.index = d->follows[old.index].elems[j].index; + insert(p, s); + } + /* Force rescan to start at the beginning. */ + i = -1; + } + + free(visited); +} + +/* Perform bottom-up analysis on the parse tree, computing various functions. + Note that at this point, we're pretending constructs like \< are real + characters rather than constraints on what can follow them. + + Nullable: A node is nullable if it is at the root of a regexp that can + match the empty string. + * EMPTY leaves are nullable. + * No other leaf is nullable. + * A QMARK or STAR node is nullable. + * A PLUS node is nullable if its argument is nullable. + * A CAT node is nullable if both its arguments are nullable. + * An OR node is nullable if either argument is nullable. + + Firstpos: The firstpos of a node is the set of positions (nonempty leaves) + that could correspond to the first character of a string matching the + regexp rooted at the given node. + * EMPTY leaves have empty firstpos. + * The firstpos of a nonempty leaf is that leaf itself. + * The firstpos of a QMARK, STAR, or PLUS node is the firstpos of its + argument. + * The firstpos of a CAT node is the firstpos of the left argument, union + the firstpos of the right if the left argument is nullable. + * The firstpos of an OR node is the union of firstpos of each argument. + + Lastpos: The lastpos of a node is the set of positions that could + correspond to the last character of a string matching the regexp at + the given node. + * EMPTY leaves have empty lastpos. + * The lastpos of a nonempty leaf is that leaf itself. + * The lastpos of a QMARK, STAR, or PLUS node is the lastpos of its + argument. + * The lastpos of a CAT node is the lastpos of its right argument, union + the lastpos of the left if the right argument is nullable. + * The lastpos of an OR node is the union of the lastpos of each argument. + + Follow: The follow of a position is the set of positions that could + correspond to the character following a character matching the node in + a string matching the regexp. At this point we consider special symbols + that match the empty string in some context to be just normal characters. + Later, if we find that a special symbol is in a follow set, we will + replace it with the elements of its follow, labeled with an appropriate + constraint. + * Every node in the firstpos of the argument of a STAR or PLUS node is in + the follow of every node in the lastpos. + * Every node in the firstpos of the second argument of a CAT node is in + the follow of every node in the lastpos of the first argument. + + Because of the postfix representation of the parse tree, the depth-first + analysis is conveniently done by a linear scan with the aid of a stack. + Sets are stored as arrays of the elements, obeying a stack-like allocation + scheme; the number of elements in each set deeper in the stack can be + used to determine the address of a particular set's array. */ +void +dfaanalyze (struct dfa *d, int searchflag) +{ + int *nullable; /* Nullable stack. */ + int *nfirstpos; /* Element count stack for firstpos sets. */ + position *firstpos; /* Array where firstpos elements are stored. */ + int *nlastpos; /* Element count stack for lastpos sets. */ + position *lastpos; /* Array where lastpos elements are stored. */ + int *nalloc; /* Sizes of arrays allocated to follow sets. */ + position_set tmp; /* Temporary set for merging sets. */ + position_set merged; /* Result of merging sets. */ + int wants_newline; /* True if some position wants newline info. */ + int *o_nullable; + int *o_nfirst, *o_nlast; + position *o_firstpos, *o_lastpos; + int i, j; + position *pos; + +#ifdef DEBUG + fprintf(stderr, "dfaanalyze:\n"); + for (i = 0; i < d->tindex; ++i) + { + fprintf(stderr, " %d:", i); + prtok(d->tokens[i]); + } + putc('\n', stderr); +#endif + + d->searchflag = searchflag; + + MALLOC(nullable, int, d->depth); + o_nullable = nullable; + MALLOC(nfirstpos, int, d->depth); + o_nfirst = nfirstpos; + MALLOC(firstpos, position, d->nleaves); + o_firstpos = firstpos, firstpos += d->nleaves; + MALLOC(nlastpos, int, d->depth); + o_nlast = nlastpos; + MALLOC(lastpos, position, d->nleaves); + o_lastpos = lastpos, lastpos += d->nleaves; + MALLOC(nalloc, int, d->tindex); + for (i = 0; i < d->tindex; ++i) + nalloc[i] = 0; + MALLOC(merged.elems, position, d->nleaves); + + CALLOC(d->follows, position_set, d->tindex); + + for (i = 0; i < d->tindex; ++i) +#ifdef DEBUG + { /* Nonsyntactic #ifdef goo... */ +#endif + switch (d->tokens[i]) + { + case EMPTY: + /* The empty set is nullable. */ + *nullable++ = 1; + + /* The firstpos and lastpos of the empty leaf are both empty. */ + *nfirstpos++ = *nlastpos++ = 0; + break; + + case STAR: + case PLUS: + /* Every element in the firstpos of the argument is in the follow + of every element in the lastpos. */ + tmp.nelem = nfirstpos[-1]; + tmp.elems = firstpos; + pos = lastpos; + for (j = 0; j < nlastpos[-1]; ++j) + { + merge(&tmp, &d->follows[pos[j].index], &merged); + REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems, position, + nalloc[pos[j].index], merged.nelem - 1); + copy(&merged, &d->follows[pos[j].index]); + } + + case QMARK: + /* A QMARK or STAR node is automatically nullable. */ + if (d->tokens[i] != PLUS) + nullable[-1] = 1; + break; + + case CAT: + /* Every element in the firstpos of the second argument is in the + follow of every element in the lastpos of the first argument. */ + tmp.nelem = nfirstpos[-1]; + tmp.elems = firstpos; + pos = lastpos + nlastpos[-1]; + for (j = 0; j < nlastpos[-2]; ++j) + { + merge(&tmp, &d->follows[pos[j].index], &merged); + REALLOC_IF_NECESSARY(d->follows[pos[j].index].elems, position, + nalloc[pos[j].index], merged.nelem - 1); + copy(&merged, &d->follows[pos[j].index]); + } + + /* The firstpos of a CAT node is the firstpos of the first argument, + union that of the second argument if the first is nullable. */ + if (nullable[-2]) + nfirstpos[-2] += nfirstpos[-1]; + else + firstpos += nfirstpos[-1]; + --nfirstpos; + + /* The lastpos of a CAT node is the lastpos of the second argument, + union that of the first argument if the second is nullable. */ + if (nullable[-1]) + nlastpos[-2] += nlastpos[-1]; + else + { + pos = lastpos + nlastpos[-2]; + for (j = nlastpos[-1] - 1; j >= 0; --j) + pos[j] = lastpos[j]; + lastpos += nlastpos[-2]; + nlastpos[-2] = nlastpos[-1]; + } + --nlastpos; + + /* A CAT node is nullable if both arguments are nullable. */ + nullable[-2] = nullable[-1] && nullable[-2]; + --nullable; + break; + + case OR: + case ORTOP: + /* The firstpos is the union of the firstpos of each argument. */ + nfirstpos[-2] += nfirstpos[-1]; + --nfirstpos; + + /* The lastpos is the union of the lastpos of each argument. */ + nlastpos[-2] += nlastpos[-1]; + --nlastpos; + + /* An OR node is nullable if either argument is nullable. */ + nullable[-2] = nullable[-1] || nullable[-2]; + --nullable; + break; + + default: + /* Anything else is a nonempty position. (Note that special + constructs like \< are treated as nonempty strings here; + an "epsilon closure" effectively makes them nullable later. + Backreferences have to get a real position so we can detect + transitions on them later. But they are nullable. */ + *nullable++ = d->tokens[i] == BACKREF; + + /* This position is in its own firstpos and lastpos. */ + *nfirstpos++ = *nlastpos++ = 1; + --firstpos, --lastpos; + firstpos->index = lastpos->index = i; + firstpos->constraint = lastpos->constraint = NO_CONSTRAINT; + + /* Allocate the follow set for this position. */ + nalloc[i] = 1; + MALLOC(d->follows[i].elems, position, nalloc[i]); + break; + } +#ifdef DEBUG + /* ... balance the above nonsyntactic #ifdef goo... */ + fprintf(stderr, "node %d:", i); + prtok(d->tokens[i]); + putc('\n', stderr); + fprintf(stderr, nullable[-1] ? " nullable: yes\n" : " nullable: no\n"); + fprintf(stderr, " firstpos:"); + for (j = nfirstpos[-1] - 1; j >= 0; --j) + { + fprintf(stderr, " %d:", firstpos[j].index); + prtok(d->tokens[firstpos[j].index]); + } + fprintf(stderr, "\n lastpos:"); + for (j = nlastpos[-1] - 1; j >= 0; --j) + { + fprintf(stderr, " %d:", lastpos[j].index); + prtok(d->tokens[lastpos[j].index]); + } + putc('\n', stderr); + } +#endif + + /* For each follow set that is the follow set of a real position, replace + it with its epsilon closure. */ + for (i = 0; i < d->tindex; ++i) + if (d->tokens[i] < NOTCHAR || d->tokens[i] == BACKREF +#ifdef MBS_SUPPORT + || d->tokens[i] == ANYCHAR + || d->tokens[i] == MBCSET +#endif + || d->tokens[i] >= CSET) + { +#ifdef DEBUG + fprintf(stderr, "follows(%d:", i); + prtok(d->tokens[i]); + fprintf(stderr, "):"); + for (j = d->follows[i].nelem - 1; j >= 0; --j) + { + fprintf(stderr, " %d:", d->follows[i].elems[j].index); + prtok(d->tokens[d->follows[i].elems[j].index]); + } + putc('\n', stderr); +#endif + copy(&d->follows[i], &merged); + epsclosure(&merged, d); + if (d->follows[i].nelem < merged.nelem) + REALLOC(d->follows[i].elems, position, merged.nelem); + copy(&merged, &d->follows[i]); + } + + /* Get the epsilon closure of the firstpos of the regexp. The result will + be the set of positions of state 0. */ + merged.nelem = 0; + for (i = 0; i < nfirstpos[-1]; ++i) + insert(firstpos[i], &merged); + epsclosure(&merged, d); + + /* Check if any of the positions of state 0 will want newline context. */ + wants_newline = 0; + for (i = 0; i < merged.nelem; ++i) + if (PREV_NEWLINE_DEPENDENT(merged.elems[i].constraint)) + wants_newline = 1; + + /* Build the initial state. */ + d->salloc = 1; + d->sindex = 0; + MALLOC(d->states, dfa_state, d->salloc); + state_index(d, &merged, wants_newline, 0); + + free(o_nullable); + free(o_nfirst); + free(o_firstpos); + free(o_nlast); + free(o_lastpos); + free(nalloc); + free(merged.elems); +} + +/* Find, for each character, the transition out of state s of d, and store + it in the appropriate slot of trans. + + We divide the positions of s into groups (positions can appear in more + than one group). Each group is labeled with a set of characters that + every position in the group matches (taking into account, if necessary, + preceding context information of s). For each group, find the union + of the its elements' follows. This set is the set of positions of the + new state. For each character in the group's label, set the transition + on this character to be to a state corresponding to the set's positions, + and its associated backward context information, if necessary. + + If we are building a searching matcher, we include the positions of state + 0 in every state. + + The collection of groups is constructed by building an equivalence-class + partition of the positions of s. + + For each position, find the set of characters C that it matches. Eliminate + any characters from C that fail on grounds of backward context. + + Search through the groups, looking for a group whose label L has nonempty + intersection with C. If L - C is nonempty, create a new group labeled + L - C and having the same positions as the current group, and set L to + the intersection of L and C. Insert the position in this group, set + C = C - L, and resume scanning. + + If after comparing with every group there are characters remaining in C, + create a new group labeled with the characters of C and insert this + position in that group. */ +void +dfastate (int s, struct dfa *d, int trans[]) +{ + position_set grps[NOTCHAR]; /* As many as will ever be needed. */ + charclass labels[NOTCHAR]; /* Labels corresponding to the groups. */ + int ngrps = 0; /* Number of groups actually used. */ + position pos; /* Current position being considered. */ + charclass matches; /* Set of matching characters. */ + int matchesf; /* True if matches is nonempty. */ + charclass intersect; /* Intersection with some label set. */ + int intersectf; /* True if intersect is nonempty. */ + charclass leftovers; /* Stuff in the label that didn't match. */ + int leftoversf; /* True if leftovers is nonempty. */ + static charclass letters; /* Set of characters considered letters. */ + static charclass newline; /* Set of characters that aren't newline. */ + position_set follows; /* Union of the follows of some group. */ + position_set tmp; /* Temporary space for merging sets. */ + int state; /* New state. */ + int wants_newline; /* New state wants to know newline context. */ + int state_newline; /* New state on a newline transition. */ + int wants_letter; /* New state wants to know letter context. */ + int state_letter; /* New state on a letter transition. */ + static int initialized; /* Flag for static initialization. */ +#ifdef MBS_SUPPORT + int next_isnt_1st_byte = 0; /* Flag If we can't add state0. */ +#endif + int i, j, k; + + /* Initialize the set of letters, if necessary. */ + if (! initialized) + { + initialized = 1; + for (i = 0; i < NOTCHAR; ++i) + if (IS_WORD_CONSTITUENT(i)) + setbit(i, letters); + setbit(eolbyte, newline); + } + + zeroset(matches); + + for (i = 0; i < d->states[s].elems.nelem; ++i) + { + pos = d->states[s].elems.elems[i]; + if (d->tokens[pos.index] >= 0 && d->tokens[pos.index] < NOTCHAR) + setbit(d->tokens[pos.index], matches); + else if (d->tokens[pos.index] >= CSET) + copyset(d->charclasses[d->tokens[pos.index] - CSET], matches); +#ifdef MBS_SUPPORT + else if (d->tokens[pos.index] == ANYCHAR + || d->tokens[pos.index] == MBCSET) + /* MB_CUR_MAX > 1 */ + { + /* ANYCHAR and MBCSET must match with a single character, so we + must put it to d->states[s].mbps, which contains the positions + which can match with a single character not a byte. */ + if (d->states[s].mbps.nelem == 0) + { + MALLOC(d->states[s].mbps.elems, position, + d->states[s].elems.nelem); + } + insert(pos, &(d->states[s].mbps)); + continue; + } +#endif /* MBS_SUPPORT */ + else + continue; + + /* Some characters may need to be eliminated from matches because + they fail in the current context. */ + if (pos.constraint != 0xFF) + { + if (! MATCHES_NEWLINE_CONTEXT(pos.constraint, + d->states[s].newline, 1)) + clrbit(eolbyte, matches); + if (! MATCHES_NEWLINE_CONTEXT(pos.constraint, + d->states[s].newline, 0)) + for (j = 0; j < CHARCLASS_INTS; ++j) + matches[j] &= newline[j]; + if (! MATCHES_LETTER_CONTEXT(pos.constraint, + d->states[s].letter, 1)) + for (j = 0; j < CHARCLASS_INTS; ++j) + matches[j] &= ~letters[j]; + if (! MATCHES_LETTER_CONTEXT(pos.constraint, + d->states[s].letter, 0)) + for (j = 0; j < CHARCLASS_INTS; ++j) + matches[j] &= letters[j]; + + /* If there are no characters left, there's no point in going on. */ + for (j = 0; j < CHARCLASS_INTS && !matches[j]; ++j) + continue; + if (j == CHARCLASS_INTS) + continue; + } + + for (j = 0; j < ngrps; ++j) + { + /* If matches contains a single character only, and the current + group's label doesn't contain that character, go on to the + next group. */ + if (d->tokens[pos.index] >= 0 && d->tokens[pos.index] < NOTCHAR + && !tstbit(d->tokens[pos.index], labels[j])) + continue; + + /* Check if this group's label has a nonempty intersection with + matches. */ + intersectf = 0; + for (k = 0; k < CHARCLASS_INTS; ++k) + (intersect[k] = matches[k] & labels[j][k]) ? (intersectf = 1) : 0; + if (! intersectf) + continue; + + /* It does; now find the set differences both ways. */ + leftoversf = matchesf = 0; + for (k = 0; k < CHARCLASS_INTS; ++k) + { + /* Even an optimizing compiler can't know this for sure. */ + int match = matches[k], label = labels[j][k]; + + (leftovers[k] = ~match & label) ? (leftoversf = 1) : 0; + (matches[k] = match & ~label) ? (matchesf = 1) : 0; + } + + /* If there were leftovers, create a new group labeled with them. */ + if (leftoversf) + { + copyset(leftovers, labels[ngrps]); + copyset(intersect, labels[j]); + MALLOC(grps[ngrps].elems, position, d->nleaves); + copy(&grps[j], &grps[ngrps]); + ++ngrps; + } + + /* Put the position in the current group. Note that there is no + reason to call insert() here. */ + grps[j].elems[grps[j].nelem++] = pos; + + /* If every character matching the current position has been + accounted for, we're done. */ + if (! matchesf) + break; + } + + /* If we've passed the last group, and there are still characters + unaccounted for, then we'll have to create a new group. */ + if (j == ngrps) + { + copyset(matches, labels[ngrps]); + zeroset(matches); + MALLOC(grps[ngrps].elems, position, d->nleaves); + grps[ngrps].nelem = 1; + grps[ngrps].elems[0] = pos; + ++ngrps; + } + } + + MALLOC(follows.elems, position, d->nleaves); + MALLOC(tmp.elems, position, d->nleaves); + + /* If we are a searching matcher, the default transition is to a state + containing the positions of state 0, otherwise the default transition + is to fail miserably. */ + if (d->searchflag) + { + wants_newline = 0; + wants_letter = 0; + for (i = 0; i < d->states[0].elems.nelem; ++i) + { + if (PREV_NEWLINE_DEPENDENT(d->states[0].elems.elems[i].constraint)) + wants_newline = 1; + if (PREV_LETTER_DEPENDENT(d->states[0].elems.elems[i].constraint)) + wants_letter = 1; + } + copy(&d->states[0].elems, &follows); + state = state_index(d, &follows, 0, 0); + if (wants_newline) + state_newline = state_index(d, &follows, 1, 0); + else + state_newline = state; + if (wants_letter) + state_letter = state_index(d, &follows, 0, 1); + else + state_letter = state; + for (i = 0; i < NOTCHAR; ++i) + trans[i] = (IS_WORD_CONSTITUENT(i)) ? state_letter : state; + trans[eolbyte] = state_newline; + } + else + for (i = 0; i < NOTCHAR; ++i) + trans[i] = -1; + + for (i = 0; i < ngrps; ++i) + { + follows.nelem = 0; + + /* Find the union of the follows of the positions of the group. + This is a hideously inefficient loop. Fix it someday. */ + for (j = 0; j < grps[i].nelem; ++j) + for (k = 0; k < d->follows[grps[i].elems[j].index].nelem; ++k) + insert(d->follows[grps[i].elems[j].index].elems[k], &follows); + +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + /* If a token in follows.elems is not 1st byte of a multibyte + character, or the states of follows must accept the bytes + which are not 1st byte of the multibyte character. + Then, if a state of follows encounter a byte, it must not be + a 1st byte of a multibyte character nor singlebyte character. + We cansel to add state[0].follows to next state, because + state[0] must accept 1st-byte + + For example, we assume <sb a> is a certain singlebyte + character, <mb A> is a certain multibyte character, and the + codepoint of <sb a> equals the 2nd byte of the codepoint of + <mb A>. + When state[0] accepts <sb a>, state[i] transit to state[i+1] + by accepting accepts 1st byte of <mb A>, and state[i+1] + accepts 2nd byte of <mb A>, if state[i+1] encounter the + codepoint of <sb a>, it must not be <sb a> but 2nd byte of + <mb A>, so we can not add state[0]. */ + + next_isnt_1st_byte = 0; + for (j = 0; j < follows.nelem; ++j) + { + if (!(d->multibyte_prop[follows.elems[j].index] & 1)) + { + next_isnt_1st_byte = 1; + break; + } + } + } +#endif + + /* If we are building a searching matcher, throw in the positions + of state 0 as well. */ +#ifdef MBS_SUPPORT + if (d->searchflag && (MB_CUR_MAX == 1 || !next_isnt_1st_byte)) +#else + if (d->searchflag) +#endif + for (j = 0; j < d->states[0].elems.nelem; ++j) + insert(d->states[0].elems.elems[j], &follows); + + /* Find out if the new state will want any context information. */ + wants_newline = 0; + if (tstbit(eolbyte, labels[i])) + for (j = 0; j < follows.nelem; ++j) + if (PREV_NEWLINE_DEPENDENT(follows.elems[j].constraint)) + wants_newline = 1; + + wants_letter = 0; + for (j = 0; j < CHARCLASS_INTS; ++j) + if (labels[i][j] & letters[j]) + break; + if (j < CHARCLASS_INTS) + for (j = 0; j < follows.nelem; ++j) + if (PREV_LETTER_DEPENDENT(follows.elems[j].constraint)) + wants_letter = 1; + + /* Find the state(s) corresponding to the union of the follows. */ + state = state_index(d, &follows, 0, 0); + if (wants_newline) + state_newline = state_index(d, &follows, 1, 0); + else + state_newline = state; + if (wants_letter) + state_letter = state_index(d, &follows, 0, 1); + else + state_letter = state; + + /* Set the transitions for each character in the current label. */ + for (j = 0; j < CHARCLASS_INTS; ++j) + for (k = 0; k < INTBITS; ++k) + if (labels[i][j] & 1 << k) + { + int c = j * INTBITS + k; + + if (c == eolbyte) + trans[c] = state_newline; + else if (IS_WORD_CONSTITUENT(c)) + trans[c] = state_letter; + else if (c < NOTCHAR) + trans[c] = state; + } + } + + for (i = 0; i < ngrps; ++i) + free(grps[i].elems); + free(follows.elems); + free(tmp.elems); +} + +/* Some routines for manipulating a compiled dfa's transition tables. + Each state may or may not have a transition table; if it does, and it + is a non-accepting state, then d->trans[state] points to its table. + If it is an accepting state then d->fails[state] points to its table. + If it has no table at all, then d->trans[state] is NULL. + TODO: Improve this comment, get rid of the unnecessary redundancy. */ + +static void +build_state (int s, struct dfa *d) +{ + int *trans; /* The new transition table. */ + int i; + + /* Set an upper limit on the number of transition tables that will ever + exist at once. 1024 is arbitrary. The idea is that the frequently + used transition tables will be quickly rebuilt, whereas the ones that + were only needed once or twice will be cleared away. */ + if (d->trcount >= 1024) + { + for (i = 0; i < d->tralloc; ++i) + if (d->trans[i]) + { + free((ptr_t) d->trans[i]); + d->trans[i] = NULL; + } + else if (d->fails[i]) + { + free((ptr_t) d->fails[i]); + d->fails[i] = NULL; + } + d->trcount = 0; + } + + ++d->trcount; + + /* Set up the success bits for this state. */ + d->success[s] = 0; + if (ACCEPTS_IN_CONTEXT(d->states[s].newline, 1, d->states[s].letter, 0, + s, *d)) + d->success[s] |= 4; + if (ACCEPTS_IN_CONTEXT(d->states[s].newline, 0, d->states[s].letter, 1, + s, *d)) + d->success[s] |= 2; + if (ACCEPTS_IN_CONTEXT(d->states[s].newline, 0, d->states[s].letter, 0, + s, *d)) + d->success[s] |= 1; + + MALLOC(trans, int, NOTCHAR); + dfastate(s, d, trans); + + /* Now go through the new transition table, and make sure that the trans + and fail arrays are allocated large enough to hold a pointer for the + largest state mentioned in the table. */ + for (i = 0; i < NOTCHAR; ++i) + if (trans[i] >= d->tralloc) + { + int oldalloc = d->tralloc; + + while (trans[i] >= d->tralloc) + d->tralloc *= 2; + REALLOC(d->realtrans, int *, d->tralloc + 1); + d->trans = d->realtrans + 1; + REALLOC(d->fails, int *, d->tralloc); + REALLOC(d->success, int, d->tralloc); + while (oldalloc < d->tralloc) + { + d->trans[oldalloc] = NULL; + d->fails[oldalloc++] = NULL; + } + } + + /* Newline is a sentinel. */ + trans[eolbyte] = -1; + + if (ACCEPTING(s, *d)) + d->fails[s] = trans; + else + d->trans[s] = trans; +} + +static void +build_state_zero (struct dfa *d) +{ + d->tralloc = 1; + d->trcount = 0; + CALLOC(d->realtrans, int *, d->tralloc + 1); + d->trans = d->realtrans + 1; + CALLOC(d->fails, int *, d->tralloc); + MALLOC(d->success, int, d->tralloc); + build_state(0, d); +} + +#ifdef MBS_SUPPORT +/* Multibyte character handling sub-routins for dfaexec. */ + +/* Initial state may encounter the byte which is not a singlebyte character + nor 1st byte of a multibyte character. But it is incorrect for initial + state to accept such a byte. + For example, in sjis encoding the regular expression like "\\" accepts + the codepoint 0x5c, but should not accept the 2nd byte of the codepoint + 0x815c. Then Initial state must skip the bytes which are not a singlebyte + character nor 1st byte of a multibyte character. */ +#define SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p) \ + if (s == 0) \ + { \ + while (inputwcs[p - buf_begin] == 0 \ + && mblen_buf[p - buf_begin] > 0 \ + && p < buf_end) \ + ++p; \ + if (p >= end) \ + { \ + free(mblen_buf); \ + free(inputwcs); \ + return (size_t) -1; \ + } \ + } + +static void +realloc_trans_if_necessary(struct dfa *d, int new_state) +{ + /* Make sure that the trans and fail arrays are allocated large enough + to hold a pointer for the new state. */ + if (new_state >= d->tralloc) + { + int oldalloc = d->tralloc; + + while (new_state >= d->tralloc) + d->tralloc *= 2; + REALLOC(d->realtrans, int *, d->tralloc + 1); + d->trans = d->realtrans + 1; + REALLOC(d->fails, int *, d->tralloc); + REALLOC(d->success, int, d->tralloc); + while (oldalloc < d->tralloc) + { + d->trans[oldalloc] = NULL; + d->fails[oldalloc++] = NULL; + } + } +} + +/* Return values of transit_state_singlebyte(), and + transit_state_consume_1char. */ +typedef enum +{ + TRANSIT_STATE_IN_PROGRESS, /* State transition has not finished. */ + TRANSIT_STATE_DONE, /* State transition has finished. */ + TRANSIT_STATE_END_BUFFER /* Reach the end of the buffer. */ +} status_transit_state; + +/* Consume a single byte and transit state from 's' to '*next_state'. + This function is almost same as the state transition routin in dfaexec(). + But state transition is done just once, otherwise matching succeed or + reach the end of the buffer. */ +static status_transit_state +transit_state_singlebyte (struct dfa *d, int s, unsigned char const *p, + int *next_state) +{ + int *t; + int works = s; + + status_transit_state rval = TRANSIT_STATE_IN_PROGRESS; + + while (rval == TRANSIT_STATE_IN_PROGRESS) + { + if ((t = d->trans[works]) != NULL) + { + works = t[*p]; + rval = TRANSIT_STATE_DONE; + if (works < 0) + works = 0; + } + else if (works < 0) + { + if (p == buf_end) + /* At the moment, it must not happen. */ + return TRANSIT_STATE_END_BUFFER; + works = 0; + } + else if (d->fails[works]) + { + works = d->fails[works][*p]; + rval = TRANSIT_STATE_DONE; + } + else + { + build_state(works, d); + } + } + *next_state = works; + return rval; +} + +/* Check whether period can match or not in the current context. If it can, + return the amount of the bytes with which period can match, otherwise + return 0. + `pos' is the position of the period. `index' is the index from the + buf_begin, and it is the current position in the buffer. */ +static int +match_anychar (struct dfa *d, int s, position pos, int index) +{ + int newline = 0; + int letter = 0; + wchar_t wc; + int mbclen; + + wc = inputwcs[index]; + mbclen = (mblen_buf[index] == 0)? 1 : mblen_buf[index]; + + /* Check context. */ + if (wc == (wchar_t)eolbyte) + { + if (!(syntax_bits & RE_DOT_NEWLINE)) + return 0; + newline = 1; + } + else if (wc == (wchar_t)'\0') + { + if (syntax_bits & RE_DOT_NOT_NULL) + return 0; + newline = 1; + } + + if (iswalnum(wc) || wc == L'_') + letter = 1; + + if (!SUCCEEDS_IN_CONTEXT(pos.constraint, d->states[s].newline, + newline, d->states[s].letter, letter)) + return 0; + + return mbclen; +} + +/* Check whether bracket expression can match or not in the current context. + If it can, return the amount of the bytes with which expression can match, + otherwise return 0. + `pos' is the position of the bracket expression. `index' is the index + from the buf_begin, and it is the current position in the buffer. */ +int +match_mb_charset (struct dfa *d, int s, position pos, int index) +{ + int i; + int match; /* Flag which represent that matching succeed. */ + int match_len; /* Length of the character (or collating element) + with which this operator match. */ + size_t op_len; /* Length of the operator. */ + char buffer[128]; + wchar_t wcbuf[6]; + + /* Pointer to the structure to which we are currently reffering. */ + struct mb_char_classes *work_mbc; + + int newline = 0; + int letter = 0; + wchar_t wc; /* Current reffering character. */ + + wc = inputwcs[index]; + + /* Check context. */ + if (wc == (wchar_t)eolbyte) + { + if (!(syntax_bits & RE_DOT_NEWLINE)) + return 0; + newline = 1; + } + else if (wc == (wchar_t)'\0') + { + if (syntax_bits & RE_DOT_NOT_NULL) + return 0; + newline = 1; + } + if (iswalnum(wc) || wc == L'_') + letter = 1; + if (!SUCCEEDS_IN_CONTEXT(pos.constraint, d->states[s].newline, + newline, d->states[s].letter, letter)) + return 0; + + /* Assign the current reffering operator to work_mbc. */ + work_mbc = &(d->mbcsets[(d->multibyte_prop[pos.index]) >> 2]); + match = !work_mbc->invert; + match_len = (mblen_buf[index] == 0)? 1 : mblen_buf[index]; + + /* match with a character class? */ + for (i = 0; i<work_mbc->nch_classes; i++) + { + if (iswctype((wint_t)wc, work_mbc->ch_classes[i])) + goto charset_matched; + } + + strncpy(buffer, buf_begin + index, match_len); + buffer[match_len] = '\0'; + + /* match with an equivalent class? */ + for (i = 0; i<work_mbc->nequivs; i++) + { + op_len = strlen(work_mbc->equivs[i]); + strncpy(buffer, buf_begin + index, op_len); + buffer[op_len] = '\0'; + if (strcoll(work_mbc->equivs[i], buffer) == 0) + { + match_len = op_len; + goto charset_matched; + } + } + + /* match with a collating element? */ + for (i = 0; i<work_mbc->ncoll_elems; i++) + { + op_len = strlen(work_mbc->coll_elems[i]); + strncpy(buffer, buf_begin + index, op_len); + buffer[op_len] = '\0'; + + if (strcoll(work_mbc->coll_elems[i], buffer) == 0) + { + match_len = op_len; + goto charset_matched; + } + } + + wcbuf[0] = wc; + wcbuf[1] = wcbuf[3] = wcbuf[5] = '\0'; + + /* match with a range? */ + for (i = 0; i<work_mbc->nranges; i++) + { + wcbuf[2] = work_mbc->range_sts[i]; + wcbuf[4] = work_mbc->range_ends[i]; + + if (wcscoll(wcbuf, wcbuf+2) >= 0 && + wcscoll(wcbuf+4, wcbuf) >= 0) + goto charset_matched; + } + + /* match with a character? */ + if (case_fold) + wc = towlower (wc); + for (i = 0; i<work_mbc->nchars; i++) + { + if (wc == work_mbc->chars[i]) + goto charset_matched; + } + + match = !match; + + charset_matched: + return match ? match_len : 0; +} + +/* Check each of `d->states[s].mbps.elem' can match or not. Then return the + array which corresponds to `d->states[s].mbps.elem' and each element of + the array contains the amount of the bytes with which the element can + match. + `index' is the index from the buf_begin, and it is the current position + in the buffer. + Caller MUST free the array which this function return. */ +static int* +check_matching_with_multibyte_ops (struct dfa *d, int s, int index) +{ + int i; + int* rarray; + + MALLOC(rarray, int, d->states[s].mbps.nelem); + for (i = 0; i < d->states[s].mbps.nelem; ++i) + { + position pos = d->states[s].mbps.elems[i]; + switch(d->tokens[pos.index]) + { + case ANYCHAR: + rarray[i] = match_anychar(d, s, pos, index); + break; + case MBCSET: + rarray[i] = match_mb_charset(d, s, pos, index); + break; + default: + break; /* can not happen. */ + } + } + return rarray; +} + +/* Consume a single character and enumerate all of the positions which can + be next position from the state `s'. + `match_lens' is the input. It can be NULL, but it can also be the output + of check_matching_with_multibyte_ops() for optimization. + `mbclen' and `pps' are the output. `mbclen' is the length of the + character consumed, and `pps' is the set this function enumerate. */ +static status_transit_state +transit_state_consume_1char (struct dfa *d, int s, unsigned char const **pp, + int *match_lens, int *mbclen, position_set *pps) +{ + int i, j; + int s1, s2; + int* work_mbls; + status_transit_state rs = TRANSIT_STATE_DONE; + + /* Calculate the length of the (single/multi byte) character + to which p points. */ + *mbclen = (mblen_buf[*pp - buf_begin] == 0)? 1 + : mblen_buf[*pp - buf_begin]; + + /* Calculate the state which can be reached from the state `s' by + consuming `*mbclen' single bytes from the buffer. */ + s1 = s; + for (i = 0; i < *mbclen; i++) + { + s2 = s1; + rs = transit_state_singlebyte(d, s2, (*pp)++, &s1); + } + /* Copy the positions contained by `s1' to the set `pps'. */ + copy(&(d->states[s1].elems), pps); + + /* Check (inputed)match_lens, and initialize if it is NULL. */ + if (match_lens == NULL && d->states[s].mbps.nelem != 0) + work_mbls = check_matching_with_multibyte_ops(d, s, *pp - buf_begin); + else + work_mbls = match_lens; + + /* Add all of the positions which can be reached from `s' by consuming + a single character. */ + for (i = 0; i < d->states[s].mbps.nelem ; i++) + { + if (work_mbls[i] == *mbclen) + for (j = 0; j < d->follows[d->states[s].mbps.elems[i].index].nelem; + j++) + insert(d->follows[d->states[s].mbps.elems[i].index].elems[j], + pps); + } + + if (match_lens == NULL && work_mbls != NULL) + free(work_mbls); + return rs; +} + +/* Transit state from s, then return new state and update the pointer of the + buffer. This function is for some operator which can match with a multi- + byte character or a collating element(which may be multi characters). */ +static int +transit_state (struct dfa *d, int s, unsigned char const **pp) +{ + int s1; + int mbclen; /* The length of current input multibyte character. */ + int maxlen = 0; + int i, j; + int *match_lens = NULL; + int nelem = d->states[s].mbps.nelem; /* Just a alias. */ + position_set follows; + unsigned char const *p1 = *pp; + status_transit_state rs; + wchar_t wc; + + if (nelem > 0) + /* This state has (a) multibyte operator(s). + We check whether each of them can match or not. */ + { + /* Note: caller must free the return value of this function. */ + match_lens = check_matching_with_multibyte_ops(d, s, *pp - buf_begin); + + for (i = 0; i < nelem; i++) + /* Search the operator which match the longest string, + in this state. */ + { + if (match_lens[i] > maxlen) + maxlen = match_lens[i]; + } + } + + if (nelem == 0 || maxlen == 0) + /* This state has no multibyte operator which can match. + We need to check only one singlebyte character. */ + { + status_transit_state rs; + rs = transit_state_singlebyte(d, s, *pp, &s1); + + /* We must update the pointer if state transition succeeded. */ + if (rs == TRANSIT_STATE_DONE) + ++*pp; + + if (match_lens != NULL) + free(match_lens); + return s1; + } + + /* This state has some operators which can match a multibyte character. */ + follows.nelem = 0; + MALLOC(follows.elems, position, d->nleaves); + + /* `maxlen' may be longer than the length of a character, because it may + not be a character but a (multi character) collating element. + We enumerate all of the positions which `s' can reach by consuming + `maxlen' bytes. */ + rs = transit_state_consume_1char(d, s, pp, match_lens, &mbclen, &follows); + + wc = inputwcs[*pp - mbclen - buf_begin]; + s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc)); + realloc_trans_if_necessary(d, s1); + + while (*pp - p1 < maxlen) + { + follows.nelem = 0; + rs = transit_state_consume_1char(d, s1, pp, NULL, &mbclen, &follows); + + for (i = 0; i < nelem ; i++) + { + if (match_lens[i] == *pp - p1) + for (j = 0; + j < d->follows[d->states[s1].mbps.elems[i].index].nelem; j++) + insert(d->follows[d->states[s1].mbps.elems[i].index].elems[j], + &follows); + } + + wc = inputwcs[*pp - mbclen - buf_begin]; + s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc)); + realloc_trans_if_necessary(d, s1); + } + free(match_lens); + free(follows.elems); + return s1; +} + +#endif + +/* Search through a buffer looking for a match to the given struct dfa. + Find the first occurrence of a string matching the regexp in the buffer, + and the shortest possible version thereof. Return the offset of the first + character after the match, or (size_t) -1 if none is found. BEGIN points to + the beginning of the buffer, and SIZE is the size of the buffer. If SIZE + is nonzero, BEGIN[SIZE - 1] must be a newline. BACKREF points to a place + where we're supposed to store a 1 if backreferencing happened and the + match needs to be verified by a backtracking matcher. Otherwise + we store a 0 in *backref. */ +size_t +dfaexec (struct dfa *d, char const *begin, size_t size, int *backref) +{ + register int s; /* Current state. */ + register unsigned char const *p; /* Current input character. */ + register unsigned char const *end; /* One past the last input character. */ + register int **trans, *t; /* Copy of d->trans so it can be optimized + into a register. */ + register unsigned char eol = eolbyte; /* Likewise for eolbyte. */ + static int sbit[NOTCHAR]; /* Table for anding with d->success. */ + static int sbit_init; + + if (! sbit_init) + { + int i; + + sbit_init = 1; + for (i = 0; i < NOTCHAR; ++i) + sbit[i] = (IS_WORD_CONSTITUENT(i)) ? 2 : 1; + sbit[eol] = 4; + } + + if (! d->tralloc) + build_state_zero(d); + + s = 0; + p = (unsigned char const *) begin; + end = p + size; + trans = d->trans; + +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + int remain_bytes, i; + buf_begin = begin; + buf_end = end; + + /* initialize mblen_buf, and inputwcs. */ + MALLOC(mblen_buf, unsigned char, end - (unsigned char const *)begin + 2); + MALLOC(inputwcs, wchar_t, end - (unsigned char const *)begin + 2); + memset(&mbs, 0, sizeof(mbstate_t)); + remain_bytes = 0; + for (i = 0; i < end - (unsigned char const *)begin + 1; i++) + { + if (remain_bytes == 0) + { + remain_bytes + = mbrtowc(inputwcs + i, begin + i, + end - (unsigned char const *)begin - i + 1, &mbs); + if (remain_bytes <= 1) + { + remain_bytes = 0; + inputwcs[i] = (wchar_t)begin[i]; + mblen_buf[i] = 0; + } + else + { + mblen_buf[i] = remain_bytes; + remain_bytes--; + } + } + else + { + mblen_buf[i] = remain_bytes; + inputwcs[i] = 0; + remain_bytes--; + } + } + mblen_buf[i] = 0; + inputwcs[i] = 0; /* sentinel */ + } +#endif /* MBS_SUPPORT */ + + for (;;) + { +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + while ((t = trans[s])) + { + if (d->states[s].mbps.nelem != 0) + { + /* Can match with a multibyte character( and multi character + collating element). */ + unsigned char const *nextp; + + SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p); + + nextp = p; + s = transit_state(d, s, &nextp); + p = nextp; + + /* Trans table might be updated. */ + trans = d->trans; + } + else + { + SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p); + s = t[*p++]; + } + } + else +#endif /* MBS_SUPPORT */ + while ((t = trans[s])) + s = t[*p++]; + + if (s < 0) + { + if (p == end) + { +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + free(mblen_buf); + free(inputwcs); + } +#endif /* MBS_SUPPORT */ + return (size_t) -1; + } + s = 0; + } + else if ((t = d->fails[s])) + { + if (d->success[s] & sbit[*p]) + { + if (backref) + *backref = (d->states[s].backref != 0); +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + free(mblen_buf); + free(inputwcs); + } +#endif /* MBS_SUPPORT */ + return (char const *) p - begin; + } + +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p); + if (d->states[s].mbps.nelem != 0) + { + /* Can match with a multibyte character( and multi + character collating element). */ + unsigned char const *nextp; + nextp = p; + s = transit_state(d, s, &nextp); + p = nextp; + + /* Trans table might be updated. */ + trans = d->trans; + } + else + s = t[*p++]; + } + else +#endif /* MBS_SUPPORT */ + s = t[*p++]; + } + else + { + build_state(s, d); + trans = d->trans; + } + } +} + +/* Initialize the components of a dfa that the other routines don't + initialize for themselves. */ +void +dfainit (struct dfa *d) +{ + d->calloc = 1; + MALLOC(d->charclasses, charclass, d->calloc); + d->cindex = 0; + + d->talloc = 1; + MALLOC(d->tokens, token, d->talloc); + d->tindex = d->depth = d->nleaves = d->nregexps = 0; +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + d->nmultibyte_prop = 1; + MALLOC(d->multibyte_prop, int, d->nmultibyte_prop); + d->nmbcsets = 0; + d->mbcsets_alloc = 1; + MALLOC(d->mbcsets, struct mb_char_classes, d->mbcsets_alloc); + } +#endif + + d->searchflag = 0; + d->tralloc = 0; + + d->musts = 0; +} + +/* Parse and analyze a single string of the given length. */ +void +dfacomp (char const *s, size_t len, struct dfa *d, int searchflag) +{ + if (case_fold) /* dummy folding in service of dfamust() */ + { + char *lcopy; + int i; + + lcopy = malloc(len); + if (!lcopy) + dfaerror(_("out of memory")); + + /* This is a kludge. */ + case_fold = 0; + for (i = 0; i < len; ++i) + if (ISUPPER ((unsigned char) s[i])) + lcopy[i] = tolower ((unsigned char) s[i]); + else + lcopy[i] = s[i]; + + dfainit(d); + dfaparse(lcopy, len, d); + free(lcopy); + dfamust(d); + d->cindex = d->tindex = d->depth = d->nleaves = d->nregexps = 0; + case_fold = 1; + dfaparse(s, len, d); + dfaanalyze(d, searchflag); + } + else + { + dfainit(d); + dfaparse(s, len, d); + dfamust(d); + dfaanalyze(d, searchflag); + } +} + +/* Free the storage held by the components of a dfa. */ +void +dfafree (struct dfa *d) +{ + int i; + struct dfamust *dm, *ndm; + + free((ptr_t) d->charclasses); + free((ptr_t) d->tokens); + +#ifdef MBS_SUPPORT + if (MB_CUR_MAX > 1) + { + free((ptr_t) d->multibyte_prop); + for (i = 0; i < d->nmbcsets; ++i) + { + int j; + struct mb_char_classes *p = &(d->mbcsets[i]); + if (p->chars != NULL) + free(p->chars); + if (p->ch_classes != NULL) + free(p->ch_classes); + if (p->range_sts != NULL) + free(p->range_sts); + if (p->range_ends != NULL) + free(p->range_ends); + + for (j = 0; j < p->nequivs; ++j) + free(p->equivs[j]); + if (p->equivs != NULL) + free(p->equivs); + + for (j = 0; j < p->ncoll_elems; ++j) + free(p->coll_elems[j]); + if (p->coll_elems != NULL) + free(p->coll_elems); + } + free((ptr_t) d->mbcsets); + } +#endif /* MBS_SUPPORT */ + + for (i = 0; i < d->sindex; ++i) + free((ptr_t) d->states[i].elems.elems); + free((ptr_t) d->states); + for (i = 0; i < d->tindex; ++i) + if (d->follows[i].elems) + free((ptr_t) d->follows[i].elems); + free((ptr_t) d->follows); + for (i = 0; i < d->tralloc; ++i) + if (d->trans[i]) + free((ptr_t) d->trans[i]); + else if (d->fails[i]) + free((ptr_t) d->fails[i]); + if (d->realtrans) free((ptr_t) d->realtrans); + if (d->fails) free((ptr_t) d->fails); + if (d->success) free((ptr_t) d->success); + for (dm = d->musts; dm; dm = ndm) + { + ndm = dm->next; + free(dm->must); + free((ptr_t) dm); + } +} + +/* Having found the postfix representation of the regular expression, + try to find a long sequence of characters that must appear in any line + containing the r.e. + Finding a "longest" sequence is beyond the scope here; + we take an easy way out and hope for the best. + (Take "(ab|a)b"--please.) + + We do a bottom-up calculation of sequences of characters that must appear + in matches of r.e.'s represented by trees rooted at the nodes of the postfix + representation: + sequences that must appear at the left of the match ("left") + sequences that must appear at the right of the match ("right") + lists of sequences that must appear somewhere in the match ("in") + sequences that must constitute the match ("is") + + When we get to the root of the tree, we use one of the longest of its + calculated "in" sequences as our answer. The sequence we find is returned in + d->must (where "d" is the single argument passed to "dfamust"); + the length of the sequence is returned in d->mustn. + + The sequences calculated for the various types of node (in pseudo ANSI c) + are shown below. "p" is the operand of unary operators (and the left-hand + operand of binary operators); "q" is the right-hand operand of binary + operators. + + "ZERO" means "a zero-length sequence" below. + + Type left right is in + ---- ---- ----- -- -- + char c # c # c # c # c + + ANYCHAR ZERO ZERO ZERO ZERO + + MBCSET ZERO ZERO ZERO ZERO + + CSET ZERO ZERO ZERO ZERO + + STAR ZERO ZERO ZERO ZERO + + QMARK ZERO ZERO ZERO ZERO + + PLUS p->left p->right ZERO p->in + + CAT (p->is==ZERO)? (q->is==ZERO)? (p->is!=ZERO && p->in plus + p->left : q->right : q->is!=ZERO) ? q->in plus + p->is##q->left p->right##q->is p->is##q->is : p->right##q->left + ZERO + + OR longest common longest common (do p->is and substrings common to + leading trailing q->is have same p->in and q->in + (sub)sequence (sub)sequence length and + of p->left of p->right content) ? + and q->left and q->right p->is : NULL + + If there's anything else we recognize in the tree, all four sequences get set + to zero-length sequences. If there's something we don't recognize in the tree, + we just return a zero-length sequence. + + Break ties in favor of infrequent letters (choosing 'zzz' in preference to + 'aaa')? + + And. . .is it here or someplace that we might ponder "optimizations" such as + egrep 'psi|epsilon' -> egrep 'psi' + egrep 'pepsi|epsilon' -> egrep 'epsi' + (Yes, we now find "epsi" as a "string + that must occur", but we might also + simplify the *entire* r.e. being sought) + grep '[c]' -> grep 'c' + grep '(ab|a)b' -> grep 'ab' + grep 'ab*' -> grep 'a' + grep 'a*b' -> grep 'b' + + There are several issues: + + Is optimization easy (enough)? + + Does optimization actually accomplish anything, + or is the automaton you get from "psi|epsilon" (for example) + the same as the one you get from "psi" (for example)? + + Are optimizable r.e.'s likely to be used in real-life situations + (something like 'ab*' is probably unlikely; something like is + 'psi|epsilon' is likelier)? */ + +static char * +icatalloc (char *old, char *new) +{ + char *result; + size_t oldsize, newsize; + + newsize = (new == NULL) ? 0 : strlen(new); + if (old == NULL) + oldsize = 0; + else if (newsize == 0) + return old; + else oldsize = strlen(old); + if (old == NULL) + result = (char *) malloc(newsize + 1); + else + result = (char *) realloc((void *) old, oldsize + newsize + 1); + if (result != NULL && new != NULL) + (void) strcpy(result + oldsize, new); + return result; +} + +static char * +icpyalloc (char *string) +{ + return icatalloc((char *) NULL, string); +} + +static char * +istrstr (char *lookin, char *lookfor) +{ + char *cp; + size_t len; + + len = strlen(lookfor); + for (cp = lookin; *cp != '\0'; ++cp) + if (strncmp(cp, lookfor, len) == 0) + return cp; + return NULL; +} + +static void +ifree (char *cp) +{ + if (cp != NULL) + free(cp); +} + +static void +freelist (char **cpp) +{ + int i; + + if (cpp == NULL) + return; + for (i = 0; cpp[i] != NULL; ++i) + { + free(cpp[i]); + cpp[i] = NULL; + } +} + +static char ** +enlist (char **cpp, char *new, size_t len) +{ + int i, j; + + if (cpp == NULL) + return NULL; + if ((new = icpyalloc(new)) == NULL) + { + freelist(cpp); + return NULL; + } + new[len] = '\0'; + /* Is there already something in the list that's new (or longer)? */ + for (i = 0; cpp[i] != NULL; ++i) + if (istrstr(cpp[i], new) != NULL) + { + free(new); + return cpp; + } + /* Eliminate any obsoleted strings. */ + j = 0; + while (cpp[j] != NULL) + if (istrstr(new, cpp[j]) == NULL) + ++j; + else + { + free(cpp[j]); + if (--i == j) + break; + cpp[j] = cpp[i]; + cpp[i] = NULL; + } + /* Add the new string. */ + cpp = (char **) realloc((char *) cpp, (i + 2) * sizeof *cpp); + if (cpp == NULL) + return NULL; + cpp[i] = new; + cpp[i + 1] = NULL; + return cpp; +} + +/* Given pointers to two strings, return a pointer to an allocated + list of their distinct common substrings. Return NULL if something + seems wild. */ +static char ** +comsubs (char *left, char *right) +{ + char **cpp; + char *lcp; + char *rcp; + size_t i, len; + + if (left == NULL || right == NULL) + return NULL; + cpp = (char **) malloc(sizeof *cpp); + if (cpp == NULL) + return NULL; + cpp[0] = NULL; + for (lcp = left; *lcp != '\0'; ++lcp) + { + len = 0; + rcp = strchr (right, *lcp); + while (rcp != NULL) + { + for (i = 1; lcp[i] != '\0' && lcp[i] == rcp[i]; ++i) + continue; + if (i > len) + len = i; + rcp = strchr (rcp + 1, *lcp); + } + if (len == 0) + continue; + if ((cpp = enlist(cpp, lcp, len)) == NULL) + break; + } + return cpp; +} + +static char ** +addlists (char **old, char **new) +{ + int i; + + if (old == NULL || new == NULL) + return NULL; + for (i = 0; new[i] != NULL; ++i) + { + old = enlist(old, new[i], strlen(new[i])); + if (old == NULL) + break; + } + return old; +} + +/* Given two lists of substrings, return a new list giving substrings + common to both. */ +static char ** +inboth (char **left, char **right) +{ + char **both; + char **temp; + int lnum, rnum; + + if (left == NULL || right == NULL) + return NULL; + both = (char **) malloc(sizeof *both); + if (both == NULL) + return NULL; + both[0] = NULL; + for (lnum = 0; left[lnum] != NULL; ++lnum) + { + for (rnum = 0; right[rnum] != NULL; ++rnum) + { + temp = comsubs(left[lnum], right[rnum]); + if (temp == NULL) + { + freelist(both); + return NULL; + } + both = addlists(both, temp); + freelist(temp); + free(temp); + if (both == NULL) + return NULL; + } + } + return both; +} + +typedef struct +{ + char **in; + char *left; + char *right; + char *is; +} must; + +static void +resetmust (must *mp) +{ + mp->left[0] = mp->right[0] = mp->is[0] = '\0'; + freelist(mp->in); +} + +static void +dfamust (struct dfa *dfa) +{ + must *musts; + must *mp; + char *result; + int ri; + int i; + int exact; + token t; + static must must0; + struct dfamust *dm; + static char empty_string[] = ""; + + result = empty_string; + exact = 0; + musts = (must *) malloc((dfa->tindex + 1) * sizeof *musts); + if (musts == NULL) + return; + mp = musts; + for (i = 0; i <= dfa->tindex; ++i) + mp[i] = must0; + for (i = 0; i <= dfa->tindex; ++i) + { + mp[i].in = (char **) malloc(sizeof *mp[i].in); + mp[i].left = malloc(2); + mp[i].right = malloc(2); + mp[i].is = malloc(2); + if (mp[i].in == NULL || mp[i].left == NULL || + mp[i].right == NULL || mp[i].is == NULL) + goto done; + mp[i].left[0] = mp[i].right[0] = mp[i].is[0] = '\0'; + mp[i].in[0] = NULL; + } +#ifdef DEBUG + fprintf(stderr, "dfamust:\n"); + for (i = 0; i < dfa->tindex; ++i) + { + fprintf(stderr, " %d:", i); + prtok(dfa->tokens[i]); + } + putc('\n', stderr); +#endif + for (ri = 0; ri < dfa->tindex; ++ri) + { + switch (t = dfa->tokens[ri]) + { + case LPAREN: + case RPAREN: + goto done; /* "cannot happen" */ + case EMPTY: + case BEGLINE: + case ENDLINE: + case BEGWORD: + case ENDWORD: + case LIMWORD: + case NOTLIMWORD: + case BACKREF: + resetmust(mp); + break; + case STAR: + case QMARK: + if (mp <= musts) + goto done; /* "cannot happen" */ + --mp; + resetmust(mp); + break; + case OR: + case ORTOP: + if (mp < &musts[2]) + goto done; /* "cannot happen" */ + { + char **new; + must *lmp; + must *rmp; + int j, ln, rn, n; + + rmp = --mp; + lmp = --mp; + /* Guaranteed to be. Unlikely, but. . . */ + if (strcmp(lmp->is, rmp->is) != 0) + lmp->is[0] = '\0'; + /* Left side--easy */ + i = 0; + while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i]) + ++i; + lmp->left[i] = '\0'; + /* Right side */ + ln = strlen(lmp->right); + rn = strlen(rmp->right); + n = ln; + if (n > rn) + n = rn; + for (i = 0; i < n; ++i) + if (lmp->right[ln - i - 1] != rmp->right[rn - i - 1]) + break; + for (j = 0; j < i; ++j) + lmp->right[j] = lmp->right[(ln - i) + j]; + lmp->right[j] = '\0'; + new = inboth(lmp->in, rmp->in); + if (new == NULL) + goto done; + freelist(lmp->in); + free((char *) lmp->in); + lmp->in = new; + } + break; + case PLUS: + if (mp <= musts) + goto done; /* "cannot happen" */ + --mp; + mp->is[0] = '\0'; + break; + case END: + if (mp != &musts[1]) + goto done; /* "cannot happen" */ + for (i = 0; musts[0].in[i] != NULL; ++i) + if (strlen(musts[0].in[i]) > strlen(result)) + result = musts[0].in[i]; + if (strcmp(result, musts[0].is) == 0) + exact = 1; + goto done; + case CAT: + if (mp < &musts[2]) + goto done; /* "cannot happen" */ + { + must *lmp; + must *rmp; + + rmp = --mp; + lmp = --mp; + /* In. Everything in left, plus everything in + right, plus catenation of + left's right and right's left. */ + lmp->in = addlists(lmp->in, rmp->in); + if (lmp->in == NULL) + goto done; + if (lmp->right[0] != '\0' && + rmp->left[0] != '\0') + { + char *tp; + + tp = icpyalloc(lmp->right); + if (tp == NULL) + goto done; + tp = icatalloc(tp, rmp->left); + if (tp == NULL) + goto done; + lmp->in = enlist(lmp->in, tp, + strlen(tp)); + free(tp); + if (lmp->in == NULL) + goto done; + } + /* Left-hand */ + if (lmp->is[0] != '\0') + { + lmp->left = icatalloc(lmp->left, + rmp->left); + if (lmp->left == NULL) + goto done; + } + /* Right-hand */ + if (rmp->is[0] == '\0') + lmp->right[0] = '\0'; + lmp->right = icatalloc(lmp->right, rmp->right); + if (lmp->right == NULL) + goto done; + /* Guaranteed to be */ + if (lmp->is[0] != '\0' && rmp->is[0] != '\0') + { + lmp->is = icatalloc(lmp->is, rmp->is); + if (lmp->is == NULL) + goto done; + } + else + lmp->is[0] = '\0'; + } + break; + default: + if (t < END) + { + /* "cannot happen" */ + goto done; + } + else if (t == '\0') + { + /* not on *my* shift */ + goto done; + } + else if (t >= CSET +#ifdef MBS_SUPPORT + || t == ANYCHAR + || t == MBCSET +#endif /* MBS_SUPPORT */ + ) + { + /* easy enough */ + resetmust(mp); + } + else + { + /* plain character */ + resetmust(mp); + mp->is[0] = mp->left[0] = mp->right[0] = t; + mp->is[1] = mp->left[1] = mp->right[1] = '\0'; + mp->in = enlist(mp->in, mp->is, (size_t)1); + if (mp->in == NULL) + goto done; + } + break; + } +#ifdef DEBUG + fprintf(stderr, " node: %d:", ri); + prtok(dfa->tokens[ri]); + fprintf(stderr, "\n in:"); + for (i = 0; mp->in[i]; ++i) + fprintf(stderr, " \"%s\"", mp->in[i]); + fprintf(stderr, "\n is: \"%s\"\n", mp->is); + fprintf(stderr, " left: \"%s\"\n", mp->left); + fprintf(stderr, " right: \"%s\"\n", mp->right); +#endif + ++mp; + } + done: + if (strlen(result)) + { + dm = (struct dfamust *) malloc(sizeof (struct dfamust)); + dm->exact = exact; + dm->must = malloc(strlen(result) + 1); + strcpy(dm->must, result); + dm->next = dfa->musts; + dfa->musts = dm; + } + mp = musts; + for (i = 0; i <= dfa->tindex; ++i) + { + freelist(mp[i].in); + ifree((char *) mp[i].in); + ifree(mp[i].left); + ifree(mp[i].right); + ifree(mp[i].is); + } + free((char *) mp); +} +/* vim:set shiftwidth=2: */ diff --git a/gnu/usr.bin/grep/dfa.h b/gnu/usr.bin/grep/dfa.h new file mode 100644 index 000000000000..4cdbe7a4f7f9 --- /dev/null +++ b/gnu/usr.bin/grep/dfa.h @@ -0,0 +1,434 @@ +/* dfa.h - declarations for GNU deterministic regexp compiler + Copyright (C) 1988, 1998 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ + +/* Written June, 1988 by Mike Haertel */ + +/* $FreeBSD$ */ + +/* FIXME: + 2. We should not export so much of the DFA internals. + In addition to clobbering modularity, we eat up valuable + name space. */ + +#ifdef __STDC__ +# ifndef _PTR_T +# define _PTR_T + typedef void * ptr_t; +# endif +#else +# ifndef _PTR_T +# define _PTR_T + typedef char * ptr_t; +# endif +#endif + +#ifdef PARAMS +# undef PARAMS +#endif +#if PROTOTYPES +# define PARAMS(x) x +#else +# define PARAMS(x) () +#endif + +/* Number of bits in an unsigned char. */ +#ifndef CHARBITS +#define CHARBITS 8 +#endif + +/* First integer value that is greater than any character code. */ +#define NOTCHAR (1 << CHARBITS) + +/* INTBITS need not be exact, just a lower bound. */ +#ifndef INTBITS +#define INTBITS (CHARBITS * sizeof (int)) +#endif + +/* Number of ints required to hold a bit for every character. */ +#define CHARCLASS_INTS ((NOTCHAR + INTBITS - 1) / INTBITS) + +/* Sets of unsigned characters are stored as bit vectors in arrays of ints. */ +typedef int charclass[CHARCLASS_INTS]; + +/* The regexp is parsed into an array of tokens in postfix form. Some tokens + are operators and others are terminal symbols. Most (but not all) of these + codes are returned by the lexical analyzer. */ + +typedef enum +{ + END = -1, /* END is a terminal symbol that matches the + end of input; any value of END or less in + the parse tree is such a symbol. Accepting + states of the DFA are those that would have + a transition on END. */ + + /* Ordinary character values are terminal symbols that match themselves. */ + + EMPTY = NOTCHAR, /* EMPTY is a terminal symbol that matches + the empty string. */ + + BACKREF, /* BACKREF is generated by \<digit>; it + it not completely handled. If the scanner + detects a transition on backref, it returns + a kind of "semi-success" indicating that + the match will have to be verified with + a backtracking matcher. */ + + BEGLINE, /* BEGLINE is a terminal symbol that matches + the empty string if it is at the beginning + of a line. */ + + ENDLINE, /* ENDLINE is a terminal symbol that matches + the empty string if it is at the end of + a line. */ + + BEGWORD, /* BEGWORD is a terminal symbol that matches + the empty string if it is at the beginning + of a word. */ + + ENDWORD, /* ENDWORD is a terminal symbol that matches + the empty string if it is at the end of + a word. */ + + LIMWORD, /* LIMWORD is a terminal symbol that matches + the empty string if it is at the beginning + or the end of a word. */ + + NOTLIMWORD, /* NOTLIMWORD is a terminal symbol that + matches the empty string if it is not at + the beginning or end of a word. */ + + QMARK, /* QMARK is an operator of one argument that + matches zero or one occurences of its + argument. */ + + STAR, /* STAR is an operator of one argument that + matches the Kleene closure (zero or more + occurrences) of its argument. */ + + PLUS, /* PLUS is an operator of one argument that + matches the positive closure (one or more + occurrences) of its argument. */ + + REPMN, /* REPMN is a lexical token corresponding + to the {m,n} construct. REPMN never + appears in the compiled token vector. */ + + CAT, /* CAT is an operator of two arguments that + matches the concatenation of its + arguments. CAT is never returned by the + lexical analyzer. */ + + OR, /* OR is an operator of two arguments that + matches either of its arguments. */ + + ORTOP, /* OR at the toplevel in the parse tree. + This is used for a boyer-moore heuristic. */ + + LPAREN, /* LPAREN never appears in the parse tree, + it is only a lexeme. */ + + RPAREN, /* RPAREN never appears in the parse tree. */ + + CRANGE, /* CRANGE never appears in the parse tree. + It stands for a character range that can + match a string of one or more characters. + For example, [a-z] can match "ch" in + a Spanish locale. */ + +#ifdef MBS_SUPPORT + ANYCHAR, /* ANYCHAR is a terminal symbol that matches + any multibyte(or singlebyte) characters. + It is used only if MB_CUR_MAX > 1. */ + + MBCSET, /* MBCSET is similar to CSET, but for + multibyte characters. */ +#endif /* MBS_SUPPORT */ + + CSET /* CSET and (and any value greater) is a + terminal symbol that matches any of a + class of characters. */ +} token; + +/* Sets are stored in an array in the compiled dfa; the index of the + array corresponding to a given set token is given by SET_INDEX(t). */ +#define SET_INDEX(t) ((t) - CSET) + +/* Sometimes characters can only be matched depending on the surrounding + context. Such context decisions depend on what the previous character + was, and the value of the current (lookahead) character. Context + dependent constraints are encoded as 8 bit integers. Each bit that + is set indicates that the constraint succeeds in the corresponding + context. + + bit 7 - previous and current are newlines + bit 6 - previous was newline, current isn't + bit 5 - previous wasn't newline, current is + bit 4 - neither previous nor current is a newline + bit 3 - previous and current are word-constituents + bit 2 - previous was word-constituent, current isn't + bit 1 - previous wasn't word-constituent, current is + bit 0 - neither previous nor current is word-constituent + + Word-constituent characters are those that satisfy isalnum(). + + The macro SUCCEEDS_IN_CONTEXT determines whether a a given constraint + succeeds in a particular context. Prevn is true if the previous character + was a newline, currn is true if the lookahead character is a newline. + Prevl and currl similarly depend upon whether the previous and current + characters are word-constituent letters. */ +#define MATCHES_NEWLINE_CONTEXT(constraint, prevn, currn) \ + ((constraint) & 1 << (((prevn) ? 2 : 0) + ((currn) ? 1 : 0) + 4)) +#define MATCHES_LETTER_CONTEXT(constraint, prevl, currl) \ + ((constraint) & 1 << (((prevl) ? 2 : 0) + ((currl) ? 1 : 0))) +#define SUCCEEDS_IN_CONTEXT(constraint, prevn, currn, prevl, currl) \ + (MATCHES_NEWLINE_CONTEXT(constraint, prevn, currn) \ + && MATCHES_LETTER_CONTEXT(constraint, prevl, currl)) + +/* The following macros give information about what a constraint depends on. */ +#define PREV_NEWLINE_DEPENDENT(constraint) \ + (((constraint) & 0xc0) >> 2 != ((constraint) & 0x30)) +#define PREV_LETTER_DEPENDENT(constraint) \ + (((constraint) & 0x0c) >> 2 != ((constraint) & 0x03)) + +/* Tokens that match the empty string subject to some constraint actually + work by applying that constraint to determine what may follow them, + taking into account what has gone before. The following values are + the constraints corresponding to the special tokens previously defined. */ +#define NO_CONSTRAINT 0xff +#define BEGLINE_CONSTRAINT 0xcf +#define ENDLINE_CONSTRAINT 0xaf +#define BEGWORD_CONSTRAINT 0xf2 +#define ENDWORD_CONSTRAINT 0xf4 +#define LIMWORD_CONSTRAINT 0xf6 +#define NOTLIMWORD_CONSTRAINT 0xf9 + +/* States of the recognizer correspond to sets of positions in the parse + tree, together with the constraints under which they may be matched. + So a position is encoded as an index into the parse tree together with + a constraint. */ +typedef struct +{ + unsigned index; /* Index into the parse array. */ + unsigned constraint; /* Constraint for matching this position. */ +} position; + +/* Sets of positions are stored as arrays. */ +typedef struct +{ + position *elems; /* Elements of this position set. */ + int nelem; /* Number of elements in this set. */ +} position_set; + +/* A state of the dfa consists of a set of positions, some flags, + and the token value of the lowest-numbered position of the state that + contains an END token. */ +typedef struct +{ + int hash; /* Hash of the positions of this state. */ + position_set elems; /* Positions this state could match. */ + char newline; /* True if previous state matched newline. */ + char letter; /* True if previous state matched a letter. */ + char backref; /* True if this state matches a \<digit>. */ + unsigned char constraint; /* Constraint for this state to accept. */ + int first_end; /* Token value of the first END in elems. */ +#ifdef MBS_SUPPORT + position_set mbps; /* Positions which can match multibyte + characters. e.g. period. + These staff are used only if + MB_CUR_MAX > 1. */ +#endif +} dfa_state; + +/* Element of a list of strings, at least one of which is known to + appear in any R.E. matching the DFA. */ +struct dfamust +{ + int exact; + char *must; + struct dfamust *next; +}; + +#ifdef MBS_SUPPORT +/* A bracket operator. + e.g. [a-c], [[:alpha:]], etc. */ +struct mb_char_classes +{ + int invert; + wchar_t *chars; /* Normal characters. */ + int nchars; + wctype_t *ch_classes; /* Character classes. */ + int nch_classes; + wchar_t *range_sts; /* Range characters (start of the range). */ + wchar_t *range_ends; /* Range characters (end of the range). */ + int nranges; + char **equivs; /* Equivalent classes. */ + int nequivs; + char **coll_elems; + int ncoll_elems; /* Collating elements. */ +}; +#endif + +/* A compiled regular expression. */ +struct dfa +{ + /* Stuff built by the scanner. */ + charclass *charclasses; /* Array of character sets for CSET tokens. */ + int cindex; /* Index for adding new charclasses. */ + int calloc; /* Number of charclasses currently allocated. */ + + /* Stuff built by the parser. */ + token *tokens; /* Postfix parse array. */ + int tindex; /* Index for adding new tokens. */ + int talloc; /* Number of tokens currently allocated. */ + int depth; /* Depth required of an evaluation stack + used for depth-first traversal of the + parse tree. */ + int nleaves; /* Number of leaves on the parse tree. */ + int nregexps; /* Count of parallel regexps being built + with dfaparse(). */ +#ifdef MBS_SUPPORT + /* These stuff are used only if MB_CUR_MAX > 1 or multibyte environments. */ + int nmultibyte_prop; + int *multibyte_prop; + /* The value of multibyte_prop[i] is defined by following rule. + if tokens[i] < NOTCHAR + bit 1 : tokens[i] is a singlebyte character, or the last-byte of + a multibyte character. + bit 0 : tokens[i] is a singlebyte character, or the 1st-byte of + a multibyte character. + if tokens[i] = MBCSET + ("the index of mbcsets correspnd to this operator" << 2) + 3 + + e.g. + tokens + = 'single_byte_a', 'multi_byte_A', single_byte_b' + = 'sb_a', 'mb_A(1st byte)', 'mb_A(2nd byte)', 'mb_A(3rd byte)', 'sb_b' + multibyte_prop + = 3 , 1 , 0 , 2 , 3 + */ + + /* Array of the bracket expressoin in the DFA. */ + struct mb_char_classes *mbcsets; + int nmbcsets; + int mbcsets_alloc; +#endif + + /* Stuff owned by the state builder. */ + dfa_state *states; /* States of the dfa. */ + int sindex; /* Index for adding new states. */ + int salloc; /* Number of states currently allocated. */ + + /* Stuff built by the structure analyzer. */ + position_set *follows; /* Array of follow sets, indexed by position + index. The follow of a position is the set + of positions containing characters that + could conceivably follow a character + matching the given position in a string + matching the regexp. Allocated to the + maximum possible position index. */ + int searchflag; /* True if we are supposed to build a searching + as opposed to an exact matcher. A searching + matcher finds the first and shortest string + matching a regexp anywhere in the buffer, + whereas an exact matcher finds the longest + string matching, but anchored to the + beginning of the buffer. */ + + /* Stuff owned by the executor. */ + int tralloc; /* Number of transition tables that have + slots so far. */ + int trcount; /* Number of transition tables that have + actually been built. */ + int **trans; /* Transition tables for states that can + never accept. If the transitions for a + state have not yet been computed, or the + state could possibly accept, its entry in + this table is NULL. */ + int **realtrans; /* Trans always points to realtrans + 1; this + is so trans[-1] can contain NULL. */ + int **fails; /* Transition tables after failing to accept + on a state that potentially could do so. */ + int *success; /* Table of acceptance conditions used in + dfaexec and computed in build_state. */ + struct dfamust *musts; /* List of strings, at least one of which + is known to appear in any r.e. matching + the dfa. */ +}; + +/* Some macros for user access to dfa internals. */ + +/* ACCEPTING returns true if s could possibly be an accepting state of r. */ +#define ACCEPTING(s, r) ((r).states[s].constraint) + +/* ACCEPTS_IN_CONTEXT returns true if the given state accepts in the + specified context. */ +#define ACCEPTS_IN_CONTEXT(prevn, currn, prevl, currl, state, dfa) \ + SUCCEEDS_IN_CONTEXT((dfa).states[state].constraint, \ + prevn, currn, prevl, currl) + +/* FIRST_MATCHING_REGEXP returns the index number of the first of parallel + regexps that a given state could accept. Parallel regexps are numbered + starting at 1. */ +#define FIRST_MATCHING_REGEXP(state, dfa) (-(dfa).states[state].first_end) + +/* Entry points. */ + +/* dfasyntax() takes three arguments; the first sets the syntax bits described + earlier in this file, the second sets the case-folding flag, and the + third specifies the line terminator. */ +extern void dfasyntax PARAMS ((reg_syntax_t, int, unsigned char)); + +/* Compile the given string of the given length into the given struct dfa. + Final argument is a flag specifying whether to build a searching or an + exact matcher. */ +extern void dfacomp PARAMS ((char const *, size_t, struct dfa *, int)); + +/* Execute the given struct dfa on the buffer of characters. The + last byte of the buffer must equal the end-of-line byte. + The final argument points to a flag that will + be set if further examination by a backtracking matcher is needed in + order to verify backreferencing; otherwise the flag will be cleared. + Returns (size_t) -1 if no match is found, or the offset of the first + character after the first & shortest matching string in the buffer. */ +extern size_t dfaexec PARAMS ((struct dfa *, char const *, size_t, int *)); + +/* Free the storage held by the components of a struct dfa. */ +extern void dfafree PARAMS ((struct dfa *)); + +/* Entry points for people who know what they're doing. */ + +/* Initialize the components of a struct dfa. */ +extern void dfainit PARAMS ((struct dfa *)); + +/* Incrementally parse a string of given length into a struct dfa. */ +extern void dfaparse PARAMS ((char const *, size_t, struct dfa *)); + +/* Analyze a parsed regexp; second argument tells whether to build a searching + or an exact matcher. */ +extern void dfaanalyze PARAMS ((struct dfa *, int)); + +/* Compute, for each possible character, the transitions out of a given + state, storing them in an array of integers. */ +extern void dfastate PARAMS ((int, struct dfa *, int [])); + +/* Error handling. */ + +/* dfaerror() is called by the regexp routines whenever an error occurs. It + takes a single argument, a NUL-terminated string describing the error. + The user must supply a dfaerror. */ +extern void dfaerror PARAMS ((const char *)); diff --git a/gnu/usr.bin/grep/error.c b/gnu/usr.bin/grep/error.c new file mode 100644 index 000000000000..c78b6cffb94a --- /dev/null +++ b/gnu/usr.bin/grep/error.c @@ -0,0 +1,276 @@ +/* Error handler for noninteractive utilities + Copyright (C) 1990-1998, 2000 Free Software Foundation, Inc. + + This file is part of the GNU C Library. Its master source is NOT part of + the C library, however. The master source lives in /gd/gnu/lib. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> +#if HAVE_LIBINTL_H +# include <libintl.h> +#endif + +#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC +# if __STDC__ +# include <stdarg.h> +# define VA_START(args, lastarg) va_start(args, lastarg) +# else +# include <varargs.h> +# define VA_START(args, lastarg) va_start(args) +# endif +#else +# define va_alist a1, a2, a3, a4, a5, a6, a7, a8 +# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8; +#endif + +#if STDC_HEADERS || _LIBC +# include <stdlib.h> +# include <string.h> +#else +void exit (); +#endif + +#include "error.h" + +#ifndef HAVE_DECL_STRERROR_R +"this configure-time declaration test was not run" +#endif +#if !HAVE_DECL_STRERROR_R +char *strerror_r (); +#endif + +#ifndef _ +# define _(String) String +#endif + +/* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +void (*error_print_progname) ( +#if __STDC__ - 0 + void +#endif + ); + +/* This variable is incremented each time `error' is called. */ +unsigned int error_message_count; + +#ifdef _LIBC +/* In the GNU C library, there is a predefined variable for this. */ + +# define program_name program_invocation_name +# include <errno.h> + +/* In GNU libc we want do not want to use the common name `error' directly. + Instead make it a weak alias. */ +# define error __error +# define error_at_line __error_at_line + +# ifdef USE_IN_LIBIO +# include <libio/iolibio.h> +# define fflush(s) _IO_fflush (s) +# endif + +#else /* not _LIBC */ + +/* The calling program should define program_name and set it to the + name of the executing program. */ +extern char *program_name; + +# ifdef HAVE_STRERROR_R +# define __strerror_r strerror_r +# else +# if HAVE_STRERROR +# ifndef strerror /* On some systems, strerror is a macro */ +char *strerror (); +# endif +# else +static char * +private_strerror (errnum) + int errnum; +{ + extern char *sys_errlist[]; + extern int sys_nerr; + + if (errnum > 0 && errnum <= sys_nerr) + return _(sys_errlist[errnum]); + return _("Unknown system error"); +} +# define strerror private_strerror +# endif /* HAVE_STRERROR */ +# endif /* HAVE_STRERROR_R */ +#endif /* not _LIBC */ + +/* Print the program name and error message MESSAGE, which is a printf-style + format string with optional args. + If ERRNUM is nonzero, print its corresponding system error message. + Exit with status STATUS if it is nonzero. */ +/* VARARGS */ + +void +#if defined VA_START && __STDC__ +error (int status, int errnum, const char *message, ...) +#else +error (status, errnum, message, va_alist) + int status; + int errnum; + char *message; + va_dcl +#endif +{ +#ifdef VA_START + va_list args; +#endif + + if (error_print_progname) + (*error_print_progname) (); + else + { + fflush (stdout); + fprintf (stderr, "%s: ", program_name); + } + +#ifdef VA_START + VA_START (args, message); +# if HAVE_VPRINTF || _LIBC + vfprintf (stderr, message, args); +# else + _doprnt (message, args, stderr); +# endif + va_end (args); +#else + fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); +#endif + + ++error_message_count; + if (errnum) + { +#if defined HAVE_STRERROR_R || _LIBC + char errbuf[1024]; +# if HAVE_WORKING_STRERROR_R || _LIBC + fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf)); +# else + /* Don't use __strerror_r's return value because on some systems + (at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */ + __strerror_r (errnum, errbuf, sizeof errbuf); + fprintf (stderr, ": %s", errbuf); +# endif +#else + fprintf (stderr, ": %s", strerror (errnum)); +#endif + } + putc ('\n', stderr); + fflush (stderr); + if (status) + exit (status); +} + +/* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +int error_one_per_line; + +void +#if defined VA_START && __STDC__ +error_at_line (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, ...) +#else +error_at_line (status, errnum, file_name, line_number, message, va_alist) + int status; + int errnum; + const char *file_name; + unsigned int line_number; + char *message; + va_dcl +#endif +{ +#ifdef VA_START + va_list args; +#endif + + if (error_one_per_line) + { + static const char *old_file_name; + static unsigned int old_line_number; + + if (old_line_number == line_number && + (file_name == old_file_name || !strcmp (old_file_name, file_name))) + /* Simply return and print nothing. */ + return; + + old_file_name = file_name; + old_line_number = line_number; + } + + if (error_print_progname) + (*error_print_progname) (); + else + { + fflush (stdout); + fprintf (stderr, "%s:", program_name); + } + + if (file_name != NULL) + fprintf (stderr, "%s:%d: ", file_name, line_number); + +#ifdef VA_START + VA_START (args, message); +# if HAVE_VPRINTF || _LIBC + vfprintf (stderr, message, args); +# else + _doprnt (message, args, stderr); +# endif + va_end (args); +#else + fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); +#endif + + ++error_message_count; + if (errnum) + { +#if defined HAVE_STRERROR_R || _LIBC + char errbuf[1024]; +# if HAVE_WORKING_STRERROR_R || _LIBC + fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf)); +# else + /* Don't use __strerror_r's return value because on some systems + (at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */ + __strerror_r (errnum, errbuf, sizeof errbuf); + fprintf (stderr, ": %s", errbuf); +# endif +#else + fprintf (stderr, ": %s", strerror (errnum)); +#endif + } + putc ('\n', stderr); + fflush (stderr); + if (status) + exit (status); +} + +#ifdef _LIBC +/* Make the weak alias. */ +# undef error +# undef error_at_line +weak_alias (__error, error) +weak_alias (__error_at_line, error_at_line) +#endif diff --git a/gnu/usr.bin/grep/error.h b/gnu/usr.bin/grep/error.h new file mode 100644 index 000000000000..20f75824d615 --- /dev/null +++ b/gnu/usr.bin/grep/error.h @@ -0,0 +1,78 @@ +/* Declaration for error-reporting function + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + + + NOTE: The canonical source of this file is maintained with the GNU C Library. + Bugs can be reported to bug-glibc@prep.ai.mit.edu. + + 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, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + +#ifndef _ERROR_H +#define _ERROR_H 1 + +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ +# define __attribute__(Spec) /* empty */ +# endif +/* The __-protected variants of `format' and `printf' attributes + are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) +# define __format__ format +# define __printf__ printf +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined (__STDC__) && __STDC__ + +/* Print a message with `fprintf (stderr, FORMAT, ...)'; + if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). + If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ + +extern void error (int status, int errnum, const char *format, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + +extern void error_at_line (int status, int errnum, const char *fname, + unsigned int lineno, const char *format, ...) + __attribute__ ((__format__ (__printf__, 5, 6))); + +/* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +extern void (*error_print_progname) (void); + +#else +void error (); +void error_at_line (); +extern void (*error_print_progname) (); +#endif + +/* This variable is incremented each time `error' is called. */ +extern unsigned int error_message_count; + +/* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +extern int error_one_per_line; + +#ifdef __cplusplus +} +#endif + +#endif /* error.h */ diff --git a/gnu/usr.bin/grep/exclude.c b/gnu/usr.bin/grep/exclude.c new file mode 100644 index 000000000000..1925a398a01c --- /dev/null +++ b/gnu/usr.bin/grep/exclude.c @@ -0,0 +1,128 @@ +/* exclude.c -- exclude file names + Copyright 1992, 1993, 1994, 1997, 1999, 2000 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Paul Eggert <eggert@twinsun.com> */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include <errno.h> +#ifndef errno +extern int errno; +#endif +#include <exclude.h> +#include <fnmatch.h> +#include <stdio.h> +#include <sys/types.h> + +void *xmalloc PARAMS ((size_t)); +void *xrealloc PARAMS ((void *, size_t)); + +/* Keep track of excluded file name patterns. */ + +struct exclude + { + char const **exclude; + int exclude_alloc; + int exclude_count; + }; + +struct exclude * +new_exclude (void) +{ + struct exclude *ex = (struct exclude *) xmalloc (sizeof (struct exclude)); + ex->exclude_count = 0; + ex->exclude_alloc = 64; + ex->exclude = (char const **) xmalloc (ex->exclude_alloc * sizeof (char *)); + return ex; +} + +int +excluded_filename (struct exclude const *ex, char const *f, int options) +{ + char const * const *exclude = ex->exclude; + int exclude_count = ex->exclude_count; + int i; + + for (i = 0; i < exclude_count; i++) + if (fnmatch (exclude[i], f, options) == 0) + return 1; + + return 0; +} + +void +add_exclude (struct exclude *ex, char const *pattern) +{ + if (ex->exclude_alloc <= ex->exclude_count) + ex->exclude = (char const **) xrealloc (ex->exclude, + ((ex->exclude_alloc *= 2) + * sizeof (char *))); + + ex->exclude[ex->exclude_count++] = pattern; +} + +int +add_exclude_file (void (*add_func) PARAMS ((struct exclude *, char const *)), + struct exclude *ex, char const *filename, char line_end) +{ + int use_stdin = filename[0] == '-' && !filename[1]; + FILE *in; + char *buf; + char *p; + char const *pattern; + char const *lim; + size_t buf_alloc = 1024; + size_t buf_count = 0; + int c; + int e = 0; + + if (use_stdin) + in = stdin; + else if (! (in = fopen (filename, "r"))) + return -1; + + buf = xmalloc (buf_alloc); + + while ((c = getc (in)) != EOF) + { + buf[buf_count++] = c; + if (buf_count == buf_alloc) + buf = xrealloc (buf, buf_alloc *= 2); + } + + buf = xrealloc (buf, buf_count + 1); + + if (ferror (in)) + e = errno; + + if (!use_stdin && fclose (in) != 0) + e = errno; + + for (pattern = p = buf, lim = buf + buf_count; p <= lim; p++) + if (p < lim ? *p == line_end : buf < p && p[-1]) + { + *p = '\0'; + (*add_func) (ex, pattern); + pattern = p + 1; + } + + errno = e; + return e ? -1 : 0; +} diff --git a/gnu/usr.bin/grep/exclude.h b/gnu/usr.bin/grep/exclude.h new file mode 100644 index 000000000000..8a48a00ecea2 --- /dev/null +++ b/gnu/usr.bin/grep/exclude.h @@ -0,0 +1,35 @@ +/* exclude.h -- declarations for excluding file names + Copyright 1992, 1993, 1994, 1997, 1999 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, 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; see the file COPYING. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Paul Eggert <eggert@twinsun.com> */ + +#ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +struct exclude; + +struct exclude *new_exclude PARAMS ((void)); +void add_exclude PARAMS ((struct exclude *, char const *)); +int add_exclude_file PARAMS ((void (*) (struct exclude *, char const *), + struct exclude *, char const *, char)); +int excluded_filename PARAMS ((struct exclude const *, char const *, int)); diff --git a/gnu/usr.bin/grep/getpagesize.h b/gnu/usr.bin/grep/getpagesize.h new file mode 100644 index 000000000000..7b3e3763c45f --- /dev/null +++ b/gnu/usr.bin/grep/getpagesize.h @@ -0,0 +1,48 @@ +/* Emulate getpagesize on systems that lack it. */ + +/* $FreeBSD$ */ + +#ifndef HAVE_GETPAGESIZE + +#if !defined getpagesize && defined __BEOS__ +# include <OS.h> +# define getpagesize() B_PAGE_SIZE +#endif + +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif + +#if !defined getpagesize && defined _SC_PAGESIZE +# if !(defined VMS && __VMS_VER < 70000000) +# define getpagesize() sysconf (_SC_PAGESIZE) +# endif +#endif + +#if !defined getpagesize && defined VMS +# ifdef __ALPHA +# define getpagesize() 8192 +# else +# define getpagesize() 512 +# endif +#endif + +#ifndef getpagesize +# include <sys/param.h> +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else +# ifdef NBPG +# ifndef CLSIZE +# define CLSIZE 1 +# endif +# define getpagesize() (NBPG * CLSIZE) +# else +# ifdef NBPC +# define getpagesize() NBPC +# endif +# endif +# endif +#endif + +#endif /* not HAVE_GETPAGESIZE */ diff --git a/gnu/usr.bin/grep/grep.1 b/gnu/usr.bin/grep/grep.1 new file mode 100644 index 000000000000..877dd25795fb --- /dev/null +++ b/gnu/usr.bin/grep/grep.1 @@ -0,0 +1,780 @@ +.\" grep man page +.\" $FreeBSD$ +.if !\n(.g \{\ +. if !\w|\*(lq| \{\ +. ds lq `` +. if \w'\(lq' .ds lq "\(lq +. \} +. if !\w|\*(rq| \{\ +. ds rq '' +. if \w'\(rq' .ds rq "\(rq +. \} +.\} +.de Id +.ds Dt \\$4 +.. +.Id $Id: grep.1,v 1.23 2002/01/22 13:20:04 bero Exp $ +.TH GREP 1 \*(Dt "GNU Project" +.SH NAME +grep, egrep, fgrep, zgrep, zegrep, zfgrep, +bzgrep, bzegrep, bzfgrep \- print lines matching a pattern +.SH SYNOPSIS +.B grep +.RI [ options ] +.I PATTERN +.RI [ FILE .\|.\|.] +.br +.B grep +.RI [ options ] +.RB [ \-e +.I PATTERN +| +.B \-f +.IR FILE ] +.RI [ FILE .\|.\|.] +.SH DESCRIPTION +.B grep +searches the named input +.IR FILE s +(or standard input if no files are named, or +the file name +.B \- +is given) +for lines containing a match to the given +.IR PATTERN . +By default, +.B grep +prints the matching lines. +.PP +In addition, two variant programs +.B egrep +and +.B fgrep +are available. +.B egrep +is the same as +.BR "grep\ \-E" . +.B fgrep +is the same as +.BR "grep\ \-F" . +.B zgrep +is the same as +.BR "grep\ \-Z" . +.B zegrep +is the same as +.BR "grep\ \-EZ" . +.B zfgrep +is the same as +.BR "grep\ \-FZ" . +.SH OPTIONS +.TP +.BI \-A " NUM" "\fR,\fP \-\^\-after-context=" NUM +Print +.I NUM +lines of trailing context after matching lines. +Places a line containing +.B \-\^\- +between contiguous groups of matches. +.TP +.BR \-a ", " \-\^\-text +Process a binary file as if it were text; this is equivalent to the +.B \-\^\-binary-files=text +option. +.TP +.BI \-B " NUM" "\fR,\fP \-\^\-before-context=" NUM +Print +.I NUM +lines of leading context before matching lines. +Places a line containing +.B \-\^\- +between contiguous groups of matches. +.TP +.BI \-C " NUM" "\fR,\fP \-\^\-context=" NUM +Print +.I NUM +lines of output context. +Places a line containing +.B \-\^\- +between contiguous groups of matches. +.TP +.BR \-b ", " \-\^\-byte-offset +Print the byte offset within the input file before +each line of output. +.TP +.BI \-\^\-binary-files= TYPE +If the first few bytes of a file indicate that the file contains binary +data, assume that the file is of type +.IR TYPE . +By default, +.I TYPE +is +.BR binary , +and +.B grep +normally outputs either +a one-line message saying that a binary file matches, or no message if +there is no match. +If +.I TYPE +is +.BR without-match , +.B grep +assumes that a binary file does not match; this is equivalent to the +.B \-I +option. +If +.I TYPE +is +.BR text , +.B grep +processes a binary file as if it were text; this is equivalent to the +.B \-a +option. +.I Warning: +.B "grep \-\^\-binary-files=text" +might output binary garbage, +which can have nasty side effects if the output is a terminal and if the +terminal driver interprets some of it as commands. +.TP +.BI \-\^\-colour[=\fIWHEN\fR] ", " \-\^\-color[=\fIWHEN\fR] +Surround the matching string with the marker find in +.B GREP_COLOR +environment variable. WHEN may be `never', `always', or `auto' +.TP +.BR \-c ", " \-\^\-count +Suppress normal output; instead print a count of +matching lines for each input file. +With the +.BR \-v ", " \-\^\-invert-match +option (see below), count non-matching lines. +.TP +.BI \-D " ACTION" "\fR,\fP \-\^\-devices=" ACTION +If an input file is a device, FIFO or socket, use +.I ACTION +to process it. By default, +.I ACTION +is +.BR read , +which means that devices are read just as if they were ordinary files. +If +.I ACTION +is +.BR skip , +devices are silently skipped. +.TP +.BI \-d " ACTION" "\fR,\fP \-\^\-directories=" ACTION +If an input file is a directory, use +.I ACTION +to process it. By default, +.I ACTION +is +.BR read , +which means that directories are read just as if they were ordinary files. +If +.I ACTION +is +.BR skip , +directories are silently skipped. +If +.I ACTION +is +.BR recurse , +.B grep +reads all files under each directory, recursively; +this is equivalent to the +.B \-r +option. +.TP +.BR \-E ", " \-\^\-extended-regexp +Interpret +.I PATTERN +as an extended regular expression (see below). +.TP +.BI \-e " PATTERN" "\fR,\fP \-\^\-regexp=" PATTERN +Use +.I PATTERN +as the pattern; useful to protect patterns beginning with +.BR \- . +.TP +.BR \-F ", " \-\^\-fixed-strings +Interpret +.I PATTERN +as a list of fixed strings, separated by newlines, +any of which is to be matched. +.TP +.BR \-P ", " \-\^\-perl-regexp +Interpret +.I PATTERN +as a Perl regular expression. +This option is not supported in FreeBSD. +.TP +.BI \-f " FILE" "\fR,\fP \-\^\-file=" FILE +Obtain patterns from +.IR FILE , +one per line. +The empty file contains zero patterns, and therefore matches nothing. +.TP +.BR \-G ", " \-\^\-basic-regexp +Interpret +.I PATTERN +as a basic regular expression (see below). This is the default. +.TP +.BR \-H ", " \-\^\-with-filename +Print the filename for each match. +.TP +.BR \-h ", " \-\^\-no-filename +Suppress the prefixing of filenames on output +when multiple files are searched. +.TP +.B \-\^\-help +Output a brief help message. +.TP +.BR \-I +Process a binary file as if it did not contain matching data; this is +equivalent to the +.B \-\^\-binary-files=without-match +option. +.TP +.BR \-i ", " \-\^\-ignore-case +Ignore case distinctions in both the +.I PATTERN +and the input files. +.TP +.BR \-L ", " \-\^\-files-without-match +Suppress normal output; instead print the name +of each input file from which no output would +normally have been printed. The scanning will stop +on the first match. +.TP +.BR \-l ", " \-\^\-files-with-matches +Suppress normal output; instead print +the name of each input file from which output +would normally have been printed. The scanning will +stop on the first match. +.TP +.BI \-m " NUM" "\fR,\fP \-\^\-max-count=" NUM +Stop reading a file after +.I NUM +matching lines. If the input is standard input from a regular file, +and +.I NUM +matching lines are output, +.B grep +ensures that the standard input is positioned to just after the last +matching line before exiting, regardless of the presence of trailing +context lines. This enables a calling process to resume a search. +When +.B grep +stops after +.I NUM +matching lines, it outputs any trailing context lines. When the +.B \-c +or +.B \-\^\-count +option is also used, +.B grep +does not output a count greater than +.IR NUM . +When the +.B \-v +or +.B \-\^\-invert-match +option is also used, +.B grep +stops after outputting +.I NUM +non-matching lines. +.TP +.B \-\^\-mmap +If possible, use the +.BR mmap (2) +system call to read input, instead of +the default +.BR read (2) +system call. In some situations, +.B \-\^\-mmap +yields better performance. However, +.B \-\^\-mmap +can cause undefined behavior (including core dumps) +if an input file shrinks while +.B grep +is operating, or if an I/O error occurs. +.TP +.BR \-n ", " \-\^\-line-number +Prefix each line of output with the line number +within its input file. +.TP +.BR \-o ", " \-\^\-only-matching +Show only the part of a matching line that matches +.I PATTERN. +.TP +.BI \-\^\-label= LABEL +Displays input actually coming from standard input as input coming from file +.I LABEL. +This is especially useful for tools like zgrep, e.g. +.B "gzip -cd foo.gz |grep --label=foo something" +.TP +.BR \-\^\-line-buffered +Flush output on every line. +Note that this incurs a performance penalty. +.TP +.BR \-q ", " \-\^\-quiet ", " \-\^\-silent +Quiet; do not write anything to standard output. +Exit immediately with zero status if any match is found, +even if an error was detected. +Also see the +.B \-s +or +.B \-\^\-no-messages +option. +.TP +.BR \-R ", " \-r ", " \-\^\-recursive +Read all files under each directory, recursively; +this is equivalent to the +.B "\-d recurse" +option. +.TP +.BR "\fR \fP \-\^\-include=" PATTERN +Recurse in directories only searching file matching +.I PATTERN. +.TP +.BR "\fR \fP \-\^\-exclude=" PATTERN +Recurse in directories skip file matching +.I PATTERN. +.TP +.BR \-s ", " \-\^\-no-messages +Suppress error messages about nonexistent or unreadable files. +Portability note: unlike \s-1GNU\s0 +.BR grep , +traditional +.B grep +did not conform to \s-1POSIX.2\s0, because traditional +.B grep +lacked a +.B \-q +option and its +.B \-s +option behaved like \s-1GNU\s0 +.BR grep 's +.B \-q +option. +Shell scripts intended to be portable to traditional +.B grep +should avoid both +.B \-q +and +.B \-s +and should redirect output to /dev/null instead. +.TP +.BR \-U ", " \-\^\-binary +Treat the file(s) as binary. By default, under MS-DOS and MS-Windows, +.BR grep +guesses the file type by looking at the contents of the first 32KB +read from the file. If +.BR grep +decides the file is a text file, it strips the CR characters from the +original file contents (to make regular expressions with +.B ^ +and +.B $ +work correctly). Specifying +.B \-U +overrules this guesswork, causing all files to be read and passed to the +matching mechanism verbatim; if the file is a text file with CR/LF +pairs at the end of each line, this will cause some regular +expressions to fail. +This option has no effect on platforms other than MS-DOS and +MS-Windows. +.TP +.BR \-u ", " \-\^\-unix-byte-offsets +Report Unix-style byte offsets. This switch causes +.B grep +to report byte offsets as if the file were Unix-style text file, i.e. with +CR characters stripped off. This will produce results identical to running +.B grep +on a Unix machine. This option has no effect unless +.B \-b +option is also used; +it has no effect on platforms other than MS-DOS and MS-Windows. +.TP +.BR \-V ", " \-\^\-version +Print the version number of +.B grep +to standard error. This version number should +be included in all bug reports (see below). +.TP +.BR \-v ", " \-\^\-invert-match +Invert the sense of matching, to select non-matching lines. +.TP +.BR \-w ", " \-\^\-word-regexp +Select only those lines containing matches that form whole words. +The test is that the matching substring must either be at the +beginning of the line, or preceded by a non-word constituent +character. Similarly, it must be either at the end of the line +or followed by a non-word constituent character. Word-constituent +characters are letters, digits, and the underscore. +.TP +.BR \-x ", " \-\^\-line-regexp +Select only those matches that exactly match the whole line. +.TP +.B \-y +Obsolete synonym for +.BR \-i . +.TP +.B \-\^\-null +Output a zero byte (the \s-1ASCII\s0 +.B NUL +character) instead of the character that normally follows a file name. +For example, +.B "grep \-l \-\^\-null" +outputs a zero byte after each file name instead of the usual newline. +This option makes the output unambiguous, even in the presence of file +names containing unusual characters like newlines. This option can be +used with commands like +.BR "find \-print0" , +.BR "perl \-0" , +.BR "sort \-z" , +and +.B "xargs \-0" +to process arbitrary file names, +even those that contain newline characters. +.TP +.BR \-Z ", " \-\^\-decompress +Decompress the input data before searching. +This option is only available if compiled with +.BR zlib (3) +library. +.TP +.BR \-J ", " \-\^\-bz2decompress +Decompress the +.BR bzip2 (1) +compressed input data before searching. +.SH "REGULAR EXPRESSIONS" +A regular expression is a pattern that describes a set of strings. +Regular expressions are constructed analogously to arithmetic +expressions, by using various operators to combine smaller expressions. +.PP +.B grep +understands two different versions of regular expression syntax: +\*(lqbasic\*(rq and \*(lqextended.\*(rq In +.RB "\s-1GNU\s0\ " grep , +there is no difference in available functionality using either syntax. +In other implementations, basic regular expressions are less powerful. +The following description applies to extended regular expressions; +differences for basic regular expressions are summarized afterwards. +.PP +The fundamental building blocks are the regular expressions that match +a single character. Most characters, including all letters and digits, +are regular expressions that match themselves. Any metacharacter with +special meaning may be quoted by preceding it with a backslash. +.PP +A +.I "bracket expression" +is a list of characters enclosed by +.B [ +and +.BR ] . +It matches any single +character in that list; if the first character of the list +is the caret +.B ^ +then it matches any character +.I not +in the list. +For example, the regular expression +.B [0123456789] +matches any single digit. +.PP +Within a bracket expression, a +.I "range expression" +consists of two characters separated by a hyphen. +It matches any single character that sorts between the two characters, +inclusive, using the locale's collating sequence and character set. +For example, in the default C locale, +.B [a\-d] +is equivalent to +.BR [abcd] . +Many locales sort characters in dictionary order, and in these locales +.B [a\-d] +is typically not equivalent to +.BR [abcd] ; +it might be equivalent to +.BR [aBbCcDd] , +for example. +To obtain the traditional interpretation of bracket expressions, +you can use the C locale by setting the +.B LC_ALL +environment variable to the value +.BR C . +.PP +Finally, certain named classes of characters are predefined within +bracket expressions, as follows. +Their names are self explanatory, and they are +.BR [:alnum:] , +.BR [:alpha:] , +.BR [:blank:] , +.BR [:cntrl:] , +.BR [:digit:] , +.BR [:graph:] , +.BR [:lower:] , +.BR [:print:] , +.BR [:punct:] , +.BR [:space:] , +.BR [:upper:] , +and +.BR [:xdigit:]. +For example, +.B [[:alnum:]] +means +.BR [0\-9A\-Za\-z] , +except the latter form depends upon the C locale and the +\s-1ASCII\s0 character encoding, whereas the former is independent +of locale and character set. +(Note that the brackets in these class names are part of the symbolic +names, and must be included in addition to the brackets delimiting +the bracket list.) Most metacharacters lose their special meaning +inside lists. To include a literal +.B ] +place it first in the list. Similarly, to include a literal +.B ^ +place it anywhere but first. Finally, to include a literal +.B \- +place it last. +.PP +The period +.B . +matches any single character. +The symbol +.B \ew +is a synonym for +.B [[:alnum:]] +and +.B \eW +is a synonym for +.BR [^[:alnum:]] . +.PP +The caret +.B ^ +and the dollar sign +.B $ +are metacharacters that respectively match the empty string at the +beginning and end of a line. +The symbols +.B \e< +and +.B \e> +respectively match the empty string at the beginning and end of a word. +The symbol +.B \eb +matches the empty string at the edge of a word, +and +.B \eB +matches the empty string provided it's +.I not +at the edge of a word. +.PP +A regular expression may be followed by one of several repetition operators: +.PD 0 +.TP +.B ? +The preceding item is optional and matched at most once. +.TP +.B * +The preceding item will be matched zero or more times. +.TP +.B + +The preceding item will be matched one or more times. +.TP +.BI { n } +The preceding item is matched exactly +.I n +times. +.TP +.BI { n ,} +The preceding item is matched +.I n +or more times. +.TP +.BI { n , m } +The preceding item is matched at least +.I n +times, but not more than +.I m +times. +.PD +.PP +Two regular expressions may be concatenated; the resulting +regular expression matches any string formed by concatenating +two substrings that respectively match the concatenated +subexpressions. +.PP +Two regular expressions may be joined by the infix operator +.BR | ; +the resulting regular expression matches any string matching +either subexpression. +.PP +Repetition takes precedence over concatenation, which in turn +takes precedence over alternation. A whole subexpression may be +enclosed in parentheses to override these precedence rules. +.PP +The backreference +.BI \e n\c +\&, where +.I n +is a single digit, matches the substring +previously matched by the +.IR n th +parenthesized subexpression of the regular expression. +.PP +In basic regular expressions the metacharacters +.BR ? , +.BR + , +.BR { , +.BR | , +.BR ( , +and +.BR ) +lose their special meaning; instead use the backslashed +versions +.BR \e? , +.BR \e+ , +.BR \e{ , +.BR \e| , +.BR \e( , +and +.BR \e) . +.PP +Traditional +.B egrep +did not support the +.B { +metacharacter, and some +.B egrep +implementations support +.B \e{ +instead, so portable scripts should avoid +.B { +in +.B egrep +patterns and should use +.B [{] +to match a literal +.BR { . +.PP +\s-1GNU\s0 +.B egrep +attempts to support traditional usage by assuming that +.B { +is not special if it would be the start of an invalid interval +specification. For example, the shell command +.B "egrep '{1'" +searches for the two-character string +.B {1 +instead of reporting a syntax error in the regular expression. +\s-1POSIX.2\s0 allows this behavior as an extension, but portable scripts +should avoid it. +.SH "ENVIRONMENT VARIABLES" +Grep's behavior is affected by the following environment variables. +.PP +A locale +.BI LC_ foo +is specified by examining the three environment variables +.BR LC_ALL , +.BR LC_\fIfoo\fP , +.BR LANG , +in that order. +The first of these variables that is set specifies the locale. +For example, if +.B LC_ALL +is not set, but +.B LC_MESSAGES +is set to +.BR pt_BR , +then Brazilian Portuguese is used for the +.B LC_MESSAGES +locale. +The C locale is used if none of these environment variables are set, +or if the locale catalog is not installed, or if +.B grep +was not compiled with national language support (\s-1NLS\s0). +.TP +.B GREP_OPTIONS +This variable specifies default options to be placed in front of any +explicit options. For example, if +.B GREP_OPTIONS +is +.BR "'\-\^\-binary-files=without-match \-\^\-directories=skip'" , +.B grep +behaves as if the two options +.B \-\^\-binary-files=without-match +and +.B \-\^\-directories=skip +had been specified before any explicit options. +Option specifications are separated by whitespace. +A backslash escapes the next character, +so it can be used to specify an option containing whitespace or a backslash. +.TP +.B GREP_COLOR +Specifies the marker for highlighting. +.TP +\fBLC_ALL\fP, \fBLC_COLLATE\fP, \fBLANG\fP +These variables specify the +.B LC_COLLATE +locale, which determines the collating sequence used to interpret +range expressions like +.BR [a\-z] . +.TP +\fBLC_ALL\fP, \fBLC_CTYPE\fP, \fBLANG\fP +These variables specify the +.B LC_CTYPE +locale, which determines the type of characters, e.g., which +characters are whitespace. +.TP +\fBLC_ALL\fP, \fBLC_MESSAGES\fP, \fBLANG\fP +These variables specify the +.B LC_MESSAGES +locale, which determines the language that +.B grep +uses for messages. +The default C locale uses American English messages. +.TP +.B POSIXLY_CORRECT +If set, +.B grep +behaves as \s-1POSIX.2\s0 requires; otherwise, +.B grep +behaves more like other \s-1GNU\s0 programs. +\s-1POSIX.2\s0 requires that options that follow file names must be +treated as file names; by default, such options are permuted to the +front of the operand list and are treated as options. +Also, \s-1POSIX.2\s0 requires that unrecognized options be diagnosed as +\*(lqillegal\*(rq, but since they are not really against the law the default +is to diagnose them as \*(lqinvalid\*(rq. +.SH DIAGNOSTICS +.PP +Normally, exit status is 0 if selected lines are found and 1 otherwise. +But the exit status is 2 if an error occurred, unless the +.B \-q +or +.B \-\^\-quiet +or +.B \-\^\-silent +option is used and a selected line is found. +.SH BUGS +Email bug reports to +.BR bug-gnu-utils@gnu.org . +Be sure to include the word \*(lqgrep\*(rq somewhere in the +\*(lqSubject:\*(rq field. +.PP +Large repetition counts in the +.BI { n , m } +construct may cause grep to use lots of memory. +In addition, +certain other obscure regular expressions require exponential time +and space, and may cause +.B grep +to run out of memory. +.PP +Backreferences are very slow, and may require exponential time. +.\" Work around problems with some troff -man implementations. +.br diff --git a/gnu/usr.bin/grep/grep.c b/gnu/usr.bin/grep/grep.c new file mode 100644 index 000000000000..61d1bf152f81 --- /dev/null +++ b/gnu/usr.bin/grep/grep.c @@ -0,0 +1,1867 @@ +/* grep.c - main driver file for grep. + Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +/* Written July 1992 by Mike Haertel. */ +/* Builtin decompression 1997 by Wolfram Schneider <wosch@FreeBSD.org>. */ + +/* $FreeBSD$ */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#include <sys/types.h> +#include <sys/stat.h> +#if defined(HAVE_MMAP) +# include <sys/mman.h> +#endif +#if defined(HAVE_SETRLIMIT) +# include <sys/time.h> +# include <sys/resource.h> +#endif +#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC +/* We can handle multibyte string. */ +# define MBS_SUPPORT +# include <wchar.h> +# include <wctype.h> +#endif +#include <stdio.h> +#include "system.h" +#include "getopt.h" +#include "getpagesize.h" +#include "grep.h" +#include "savedir.h" +#include "xstrtol.h" +#include "xalloc.h" +#include "error.h" +#include "exclude.h" +#include "closeout.h" + +#undef MAX +#define MAX(A,B) ((A) > (B) ? (A) : (B)) + +struct stats +{ + struct stats const *parent; + struct stat stat; +}; + +/* base of chain of stat buffers, used to detect directory loops */ +static struct stats stats_base; + +/* if non-zero, display usage information and exit */ +static int show_help; + +/* If non-zero, print the version on standard output and exit. */ +static int show_version; + +/* If nonzero, suppress diagnostics for nonexistent or unreadable files. */ +static int suppress_errors; + +/* If nonzero, use mmap if possible. */ +static int mmap_option; + +/* If zero, output nulls after filenames. */ +static int filename_mask; + +/* If nonzero, use grep_color marker. */ +static int color_option; + +/* If nonzero, show only the part of a line matching the expression. */ +static int only_matching; + +/* The color string used. The user can overwrite it using the environment + variable GREP_COLOR. The default is to print red. */ +static const char *grep_color = "01;31"; + +static struct exclude *excluded_patterns; +static struct exclude *included_patterns; +/* Short options. */ +static char const short_options[] = +"0123456789A:B:C:D:EFGHIJPUVX:abcd:e:f:hiKLlm:noqRrsuvwxyZz"; + +/* Non-boolean long options that have no corresponding short equivalents. */ +enum +{ + BINARY_FILES_OPTION = CHAR_MAX + 1, + COLOR_OPTION, + INCLUDE_OPTION, + EXCLUDE_OPTION, + EXCLUDE_FROM_OPTION, + LINE_BUFFERED_OPTION, + LABEL_OPTION +}; + +/* Long options equivalences. */ +static struct option const long_options[] = +{ + {"after-context", required_argument, NULL, 'A'}, + {"basic-regexp", no_argument, NULL, 'G'}, + {"before-context", required_argument, NULL, 'B'}, + {"binary-files", required_argument, NULL, BINARY_FILES_OPTION}, + {"byte-offset", no_argument, NULL, 'b'}, + {"context", required_argument, NULL, 'C'}, + {"color", optional_argument, NULL, COLOR_OPTION}, + {"colour", optional_argument, NULL, COLOR_OPTION}, + {"count", no_argument, NULL, 'c'}, + {"devices", required_argument, NULL, 'D'}, + {"directories", required_argument, NULL, 'd'}, + {"extended-regexp", no_argument, NULL, 'E'}, + {"exclude", required_argument, NULL, EXCLUDE_OPTION}, + {"exclude-from", required_argument, NULL, EXCLUDE_FROM_OPTION}, + {"file", required_argument, NULL, 'f'}, + {"files-with-matches", no_argument, NULL, 'l'}, + {"files-without-match", no_argument, NULL, 'L'}, + {"fixed-regexp", no_argument, NULL, 'F'}, + {"fixed-strings", no_argument, NULL, 'F'}, + {"help", no_argument, &show_help, 1}, + {"include", required_argument, NULL, INCLUDE_OPTION}, + {"ignore-case", no_argument, NULL, 'i'}, + {"label", required_argument, NULL, LABEL_OPTION}, + {"line-buffered", no_argument, NULL, LINE_BUFFERED_OPTION}, + {"line-number", no_argument, NULL, 'n'}, + {"line-regexp", no_argument, NULL, 'x'}, + {"max-count", required_argument, NULL, 'm'}, + {"mmap", no_argument, &mmap_option, 1}, + {"no-filename", no_argument, NULL, 'h'}, + {"no-messages", no_argument, NULL, 's'}, + {"bz2decompress", no_argument, NULL, 'J'}, +#if HAVE_LIBZ > 0 + {"decompress", no_argument, NULL, 'Z'}, + {"null", no_argument, &filename_mask, 0}, +#else + {"null", no_argument, NULL, 'Z'}, +#endif + {"null-data", no_argument, NULL, 'z'}, + {"only-matching", no_argument, NULL, 'o'}, + {"perl-regexp", no_argument, NULL, 'P'}, + {"quiet", no_argument, NULL, 'q'}, + {"recursive", no_argument, NULL, 'r'}, + {"recursive", no_argument, NULL, 'R'}, + {"regexp", required_argument, NULL, 'e'}, + {"invert-match", no_argument, NULL, 'v'}, + {"silent", no_argument, NULL, 'q'}, + {"text", no_argument, NULL, 'a'}, + {"binary", no_argument, NULL, 'U'}, + {"unix-byte-offsets", no_argument, NULL, 'u'}, + {"version", no_argument, NULL, 'V'}, + {"with-filename", no_argument, NULL, 'H'}, + {"word-regexp", no_argument, NULL, 'w'}, + {0, 0, 0, 0} +}; + +/* Define flags declared in grep.h. */ +int match_icase; +int match_words; +int match_lines; +unsigned char eolbyte; + +/* For error messages. */ +/* The name the program was run with, stripped of any leading path. */ +char *program_name; +static char const *filename; +static int errseen; + +/* How to handle directories. */ +static enum + { + READ_DIRECTORIES, + RECURSE_DIRECTORIES, + SKIP_DIRECTORIES + } directories = READ_DIRECTORIES; + +/* How to handle devices. */ +static enum + { + READ_DEVICES, + SKIP_DEVICES + } devices = READ_DEVICES; + +static int grepdir PARAMS ((char const *, struct stats const *)); +#if defined(HAVE_DOS_FILE_CONTENTS) +static inline int undossify_input PARAMS ((register char *, size_t)); +#endif + +/* Functions we'll use to search. */ +static void (*compile) PARAMS ((char const *, size_t)); +static size_t (*execute) PARAMS ((char const *, size_t, size_t *, int)); + +/* Like error, but suppress the diagnostic if requested. */ +static void +suppressible_error (char const *mesg, int errnum) +{ + if (! suppress_errors) + error (0, errnum, "%s", mesg); + errseen = 1; +} + +/* Convert STR to a positive integer, storing the result in *OUT. + STR must be a valid context length argument; report an error if it + isn't. */ +static void +context_length_arg (char const *str, int *out) +{ + uintmax_t value; + if (! (xstrtoumax (str, 0, 10, &value, "") == LONGINT_OK + && 0 <= (*out = value) + && *out == value)) + { + error (2, 0, "%s: %s\n", str, _("invalid context length argument")); + } +} + + +/* Hairy buffering mechanism for grep. The intent is to keep + all reads aligned on a page boundary and multiples of the + page size, unless a read yields a partial page. */ + +static char *buffer; /* Base of buffer. */ +static size_t bufalloc; /* Allocated buffer size, counting slop. */ +#define INITIAL_BUFSIZE 32768 /* Initial buffer size, not counting slop. */ +static int bufdesc; /* File descriptor. */ +static char *bufbeg; /* Beginning of user-visible stuff. */ +static char *buflim; /* Limit of user-visible stuff. */ +static size_t pagesize; /* alignment of memory pages */ +static off_t bufoffset; /* Read offset; defined on regular files. */ +static off_t after_last_match; /* Pointer after last matching line that + would have been output if we were + outputting characters. */ + +#if defined(HAVE_MMAP) +static int bufmapped; /* True if buffer is memory-mapped. */ +static off_t initial_bufoffset; /* Initial value of bufoffset. */ +#else +# define bufmapped 0 +#endif + +#include <bzlib.h> +static BZFILE* bzbufdesc; /* libbz2 file handle. */ +static int BZflag; /* uncompress before searching. */ +#if HAVE_LIBZ > 0 +#include <zlib.h> +static gzFile gzbufdesc; /* zlib file descriptor. */ +static int Zflag; /* uncompress before searching. */ +#endif + +/* Return VAL aligned to the next multiple of ALIGNMENT. VAL can be + an integer or a pointer. Both args must be free of side effects. */ +#define ALIGN_TO(val, alignment) \ + ((size_t) (val) % (alignment) == 0 \ + ? (val) \ + : (val) + ((alignment) - (size_t) (val) % (alignment))) + +/* Reset the buffer for a new file, returning zero if we should skip it. + Initialize on the first time through. */ +static int +reset (int fd, char const *file, struct stats *stats) +{ + if (! pagesize) + { + pagesize = getpagesize (); + if (pagesize == 0 || 2 * pagesize + 1 <= pagesize) + abort (); + bufalloc = ALIGN_TO (INITIAL_BUFSIZE, pagesize) + pagesize + 1; + buffer = xmalloc (bufalloc); + } + if (BZflag) + { + bzbufdesc = BZ2_bzdopen(fd, "r"); + if (bzbufdesc == NULL) + error(2, 0, _("memory exhausted")); + } +#if HAVE_LIBZ > 0 + if (Zflag) + { + gzbufdesc = gzdopen(fd, "r"); + if (gzbufdesc == NULL) + error(2, 0, _("memory exhausted")); + } +#endif + + bufbeg = buflim = ALIGN_TO (buffer + 1, pagesize); + bufbeg[-1] = eolbyte; + bufdesc = fd; + + if (fstat (fd, &stats->stat) != 0) + { + error (0, errno, "fstat"); + return 0; + } + if (fd != STDIN_FILENO) { + if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode)) + return 0; +#ifndef DJGPP + if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode) || S_ISFIFO(stats->stat.st_mode))) +#else + if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode))) +#endif + return 0; + } + if ( + BZflag || +#if HAVE_LIBZ > 0 + Zflag || +#endif + S_ISREG (stats->stat.st_mode)) + { + if (file) + bufoffset = 0; + else + { + bufoffset = lseek (fd, 0, SEEK_CUR); + if (bufoffset < 0) + { + error (0, errno, "lseek"); + return 0; + } + } +#if defined(HAVE_MMAP) + initial_bufoffset = bufoffset; + bufmapped = mmap_option && bufoffset % pagesize == 0; +#endif + } + else + { +#if defined(HAVE_MMAP) + bufmapped = 0; +#endif + } + return 1; +} + +/* Read new stuff into the buffer, saving the specified + amount of old stuff. When we're done, 'bufbeg' points + to the beginning of the buffer contents, and 'buflim' + points just after the end. Return zero if there's an error. */ +static int +fillbuf (size_t save, struct stats const *stats) +{ + size_t fillsize = 0; + int cc = 1; + char *readbuf; + size_t readsize; + + /* Offset from start of buffer to start of old stuff + that we want to save. */ + size_t saved_offset = buflim - save - buffer; + + if (pagesize <= buffer + bufalloc - buflim) + { + readbuf = buflim; + bufbeg = buflim - save; + } + else + { + size_t minsize = save + pagesize; + size_t newsize; + size_t newalloc; + char *newbuf; + + /* Grow newsize until it is at least as great as minsize. */ + for (newsize = bufalloc - pagesize - 1; newsize < minsize; newsize *= 2) + if (newsize * 2 < newsize || newsize * 2 + pagesize + 1 < newsize * 2) + xalloc_die (); + + /* Try not to allocate more memory than the file size indicates, + as that might cause unnecessary memory exhaustion if the file + is large. However, do not use the original file size as a + heuristic if we've already read past the file end, as most + likely the file is growing. */ + if (S_ISREG (stats->stat.st_mode)) + { + off_t to_be_read = stats->stat.st_size - bufoffset; + off_t maxsize_off = save + to_be_read; + if (0 <= to_be_read && to_be_read <= maxsize_off + && maxsize_off == (size_t) maxsize_off + && minsize <= (size_t) maxsize_off + && (size_t) maxsize_off < newsize) + newsize = maxsize_off; + } + + /* Add enough room so that the buffer is aligned and has room + for byte sentinels fore and aft. */ + newalloc = newsize + pagesize + 1; + + newbuf = bufalloc < newalloc ? xmalloc (bufalloc = newalloc) : buffer; + readbuf = ALIGN_TO (newbuf + 1 + save, pagesize); + bufbeg = readbuf - save; + memmove (bufbeg, buffer + saved_offset, save); + bufbeg[-1] = eolbyte; + if (newbuf != buffer) + { + free (buffer); + buffer = newbuf; + } + } + + readsize = buffer + bufalloc - readbuf; + readsize -= readsize % pagesize; + +#if defined(HAVE_MMAP) + if (bufmapped) + { + size_t mmapsize = readsize; + + /* Don't mmap past the end of the file; some hosts don't allow this. + Use `read' on the last page. */ + if (stats->stat.st_size - bufoffset < mmapsize) + { + mmapsize = stats->stat.st_size - bufoffset; + mmapsize -= mmapsize % pagesize; + } + + if (mmapsize + && (mmap ((caddr_t) readbuf, mmapsize, + PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, + bufdesc, bufoffset) + != (caddr_t) -1)) + { + /* Do not bother to use madvise with MADV_SEQUENTIAL or + MADV_WILLNEED on the mmapped memory. One might think it + would help, but it slows us down about 30% on SunOS 4.1. */ + fillsize = mmapsize; + } + else + { + /* Stop using mmap on this file. Synchronize the file + offset. Do not warn about mmap failures. On some hosts + (e.g. Solaris 2.5) mmap can fail merely because some + other process has an advisory read lock on the file. + There's no point alarming the user about this misfeature. */ + bufmapped = 0; + if (bufoffset != initial_bufoffset + && lseek (bufdesc, bufoffset, SEEK_SET) < 0) + { + error (0, errno, "lseek"); + cc = 0; + } + } + } +#endif /*HAVE_MMAP*/ + + if (! fillsize) + { + ssize_t bytesread; + do + if (BZflag && bzbufdesc) + { + int bzerr; + bytesread = BZ2_bzRead (&bzerr, bzbufdesc, readbuf, readsize); + + switch (bzerr) + { + case BZ_OK: + case BZ_STREAM_END: + /* ok */ + break; + case BZ_DATA_ERROR_MAGIC: + BZ2_bzReadClose (&bzerr, bzbufdesc); bzbufdesc = NULL; + lseek (bufdesc, 0, SEEK_SET); + bytesread = read (bufdesc, readbuf, readsize); + break; + default: + bytesread = 0; + break; + } + } + else +#if HAVE_LIBZ > 0 + if (Zflag) + bytesread = gzread (gzbufdesc, readbuf, readsize); + else +#endif + bytesread = read (bufdesc, readbuf, readsize); + while (bytesread < 0 && errno == EINTR); + if (bytesread < 0) + cc = 0; + else + fillsize = bytesread; + } + + bufoffset += fillsize; +#if defined(HAVE_DOS_FILE_CONTENTS) + if (fillsize) + fillsize = undossify_input (readbuf, fillsize); +#endif + buflim = readbuf + fillsize; + return cc; +} + +/* Flags controlling the style of output. */ +static enum +{ + BINARY_BINARY_FILES, + TEXT_BINARY_FILES, + WITHOUT_MATCH_BINARY_FILES +} binary_files; /* How to handle binary files. */ + +static int filename_mask; /* If zero, output nulls after filenames. */ +static int out_quiet; /* Suppress all normal output. */ +static int out_invert; /* Print nonmatching stuff. */ +static int out_file; /* Print filenames. */ +static int out_line; /* Print line numbers. */ +static int out_byte; /* Print byte offsets. */ +static int out_before; /* Lines of leading context. */ +static int out_after; /* Lines of trailing context. */ +static int count_matches; /* Count matching lines. */ +static int list_files; /* List matching files. */ +static int no_filenames; /* Suppress file names. */ +static off_t max_count; /* Stop after outputting this many + lines from an input file. */ +static int line_buffered; /* If nonzero, use line buffering, i.e. + fflush everyline out. */ +static char *label = NULL; /* Fake filename for stdin */ + + +/* Internal variables to keep track of byte count, context, etc. */ +static uintmax_t totalcc; /* Total character count before bufbeg. */ +static char const *lastnl; /* Pointer after last newline counted. */ +static char const *lastout; /* Pointer after last character output; + NULL if no character has been output + or if it's conceptually before bufbeg. */ +static uintmax_t totalnl; /* Total newline count before lastnl. */ +static off_t outleft; /* Maximum number of lines to be output. */ +static int pending; /* Pending lines of output. + Always kept 0 if out_quiet is true. */ +static int done_on_match; /* Stop scanning file on first match. */ +static int exit_on_match; /* Exit on first match. */ + +#if defined(HAVE_DOS_FILE_CONTENTS) +# include "dosbuf.c" +#endif + +/* Add two numbers that count input bytes or lines, and report an + error if the addition overflows. */ +static uintmax_t +add_count (uintmax_t a, uintmax_t b) +{ + uintmax_t sum = a + b; + if (sum < a) + error (2, 0, _("input is too large to count")); + return sum; +} + +static void +nlscan (char const *lim) +{ + size_t newlines = 0; + char const *beg; + for (beg = lastnl; beg != lim; beg = memchr (beg, eolbyte, lim - beg), beg++) + newlines++; + totalnl = add_count (totalnl, newlines); + lastnl = lim; +} + +/* Print a byte offset, followed by a character separator. */ +static void +print_offset_sep (uintmax_t pos, char sep) +{ + /* Do not rely on printf to print pos, since uintmax_t may be longer + than long, and long long is not portable. */ + + char buf[sizeof pos * CHAR_BIT]; + char *p = buf + sizeof buf - 1; + *p = sep; + + do + *--p = '0' + pos % 10; + while ((pos /= 10) != 0); + + fwrite (p, 1, buf + sizeof buf - p, stdout); +} + +static void +prline (char const *beg, char const *lim, int sep) +{ + if (out_file) + printf ("%s%c", filename, sep & filename_mask); + if (out_line) + { + nlscan (beg); + totalnl = add_count (totalnl, 1); + print_offset_sep (totalnl, sep); + lastnl = lim; + } + if (out_byte) + { + uintmax_t pos = add_count (totalcc, beg - bufbeg); +#if defined(HAVE_DOS_FILE_CONTENTS) + pos = dossified_pos (pos); +#endif + print_offset_sep (pos, sep); + } + if (only_matching) + { + size_t match_size; + size_t match_offset; + while ((match_offset = (*execute) (beg, lim - beg, &match_size, 1)) + != (size_t) -1) + { + char const *b = beg + match_offset; + if (b == lim) + break; + if (match_size == 0) + break; + if(color_option) + printf("\33[%sm", grep_color); + fwrite(b, sizeof (char), match_size, stdout); + if(color_option) + fputs("\33[00m", stdout); + fputs("\n", stdout); + beg = b + match_size; + } + lastout = lim; + if(line_buffered) + fflush(stdout); + return; + } + if (color_option) + { + size_t match_size; + size_t match_offset; + while (lim-beg && (match_offset = (*execute) (beg, lim - beg, &match_size, 1)) + != (size_t) -1) + { + char const *b = beg + match_offset; + /* Avoid matching the empty line at the end of the buffer. */ + if (b == lim) + break; + /* Avoid hanging on grep --color "" foo */ + if (match_size == 0) + break; + fwrite (beg, sizeof (char), match_offset, stdout); + printf ("\33[%sm", grep_color); + fwrite (b, sizeof (char), match_size, stdout); + fputs ("\33[00m", stdout); + beg = b + match_size; + } + fputs ("\33[K", stdout); + } + fwrite (beg, 1, lim - beg, stdout); + if (ferror (stdout)) + error (0, errno, _("writing output")); + lastout = lim; + if (line_buffered) + fflush (stdout); +} + +/* Print pending lines of trailing context prior to LIM. Trailing context ends + at the next matching line when OUTLEFT is 0. */ +static void +prpending (char const *lim) +{ + if (!lastout) + lastout = bufbeg; + while (pending > 0 && lastout < lim) + { + char const *nl = memchr (lastout, eolbyte, lim - lastout); + size_t match_size; + --pending; + if (outleft + || (((*execute) (lastout, nl - lastout, &match_size, 0) == (size_t) -1) + == !out_invert)) + prline (lastout, nl + 1, '-'); + else + pending = 0; + } +} + +/* Print the lines between BEG and LIM. Deal with context crap. + If NLINESP is non-null, store a count of lines between BEG and LIM. */ +static void +prtext (char const *beg, char const *lim, int *nlinesp) +{ + static int used; /* avoid printing "--" before any output */ + char const *bp, *p; + char eol = eolbyte; + int i, n; + + if (!out_quiet && pending > 0) + prpending (beg); + + p = beg; + + if (!out_quiet) + { + /* Deal with leading context crap. */ + + bp = lastout ? lastout : bufbeg; + for (i = 0; i < out_before; ++i) + if (p > bp) + do + --p; + while (p[-1] != eol); + + /* We only print the "--" separator if our output is + discontiguous from the last output in the file. */ + if ((out_before || out_after) && used && p != lastout) + puts ("--"); + + while (p < beg) + { + char const *nl = memchr (p, eol, beg - p); + nl++; + prline (p, nl, '-'); + p = nl; + } + } + + if (nlinesp) + { + /* Caller wants a line count. */ + for (n = 0; p < lim && n < outleft; n++) + { + char const *nl = memchr (p, eol, lim - p); + nl++; + if (!out_quiet) + prline (p, nl, ':'); + p = nl; + } + *nlinesp = n; + + /* relying on it that this function is never called when outleft = 0. */ + after_last_match = bufoffset - (buflim - p); + } + else + if (!out_quiet) + prline (beg, lim, ':'); + + pending = out_quiet ? 0 : out_after; + used = 1; +} + +/* Scan the specified portion of the buffer, matching lines (or + between matching lines if OUT_INVERT is true). Return a count of + lines printed. */ +static int +grepbuf (char const *beg, char const *lim) +{ + int nlines, n; + register char const *p; + size_t match_offset; + size_t match_size; + + nlines = 0; + p = beg; + while ((match_offset = (*execute) (p, lim - p, &match_size, 0)) != (size_t) -1) + { + char const *b = p + match_offset; + char const *endp = b + match_size; + /* Avoid matching the empty line at the end of the buffer. */ + if (b == lim) + break; + if (!out_invert) + { + prtext (b, endp, (int *) 0); + nlines++; + outleft--; + if (!outleft || done_on_match) + { + if (exit_on_match) + exit (0); + after_last_match = bufoffset - (buflim - endp); + return nlines; + } + } + else if (p < b) + { + prtext (p, b, &n); + nlines += n; + outleft -= n; + if (!outleft) + return nlines; + } + p = endp; + } + if (out_invert && p < lim) + { + prtext (p, lim, &n); + nlines += n; + outleft -= n; + } + return nlines; +} + +/* Search a given file. Normally, return a count of lines printed; + but if the file is a directory and we search it recursively, then + return -2 if there was a match, and -1 otherwise. */ +static int +grep (int fd, char const *file, struct stats *stats) +{ + int nlines, i; + int not_text; + size_t residue, save; + char oldc; + char *beg; + char *lim; + char eol = eolbyte; + + if (!reset (fd, file, stats)) + return 0; + + if (file && directories == RECURSE_DIRECTORIES + && S_ISDIR (stats->stat.st_mode)) + { + /* Close fd now, so that we don't open a lot of file descriptors + when we recurse deeply. */ + if (BZflag && bzbufdesc) + BZ2_bzclose(bzbufdesc); + else +#if HAVE_LIBZ > 0 + if (Zflag) + gzclose(gzbufdesc); + else +#endif + if (close (fd) != 0) + error (0, errno, "%s", file); + return grepdir (file, stats) - 2; + } + + totalcc = 0; + lastout = 0; + totalnl = 0; + outleft = max_count; + after_last_match = 0; + pending = 0; + + nlines = 0; + residue = 0; + save = 0; + + if (! fillbuf (save, stats)) + { + if (! is_EISDIR (errno, file)) + suppressible_error (filename, errno); + return 0; + } + + not_text = (((binary_files == BINARY_BINARY_FILES && !out_quiet) + || binary_files == WITHOUT_MATCH_BINARY_FILES) + && memchr (bufbeg, eol ? '\0' : '\200', buflim - bufbeg)); + if (not_text && binary_files == WITHOUT_MATCH_BINARY_FILES) + return 0; + done_on_match += not_text; + out_quiet += not_text; + + for (;;) + { + lastnl = bufbeg; + if (lastout) + lastout = bufbeg; + + beg = bufbeg + save; + + /* no more data to scan (eof) except for maybe a residue -> break */ + if (beg == buflim) + break; + + /* Determine new residue (the length of an incomplete line at the end of + the buffer, 0 means there is no incomplete last line). */ + oldc = beg[-1]; + beg[-1] = eol; + for (lim = buflim; lim[-1] != eol; lim--) + continue; + beg[-1] = oldc; + if (lim == beg) + lim = beg - residue; + beg -= residue; + residue = buflim - lim; + + if (beg < lim) + { + if (outleft) + nlines += grepbuf (beg, lim); + if (pending) + prpending (lim); + if((!outleft && !pending) || (nlines && done_on_match && !out_invert)) + goto finish_grep; + } + + /* The last OUT_BEFORE lines at the end of the buffer will be needed as + leading context if there is a matching line at the begin of the + next data. Make beg point to their begin. */ + i = 0; + beg = lim; + while (i < out_before && beg > bufbeg && beg != lastout) + { + ++i; + do + --beg; + while (beg[-1] != eol); + } + + /* detect if leading context is discontinuous from last printed line. */ + if (beg != lastout) + lastout = 0; + + /* Handle some details and read more data to scan. */ + save = residue + lim - beg; + if (out_byte) + totalcc = add_count (totalcc, buflim - bufbeg - save); + if (out_line) + nlscan (beg); + if (! fillbuf (save, stats)) + { + if (! is_EISDIR (errno, file)) + suppressible_error (filename, errno); + goto finish_grep; + } + } + if (residue) + { + *buflim++ = eol; + if (outleft) + nlines += grepbuf (bufbeg + save - residue, buflim); + if (pending) + prpending (buflim); + } + + finish_grep: + done_on_match -= not_text; + out_quiet -= not_text; + if ((not_text & ~out_quiet) && nlines != 0) + printf (_("Binary file %s matches\n"), filename); + return nlines; +} + +static int +grepfile (char const *file, struct stats *stats) +{ + int desc; + int count; + int status; + int flags; + + if (! file) + { + desc = 0; + filename = label ? label : _("(standard input)"); + } + else + { + while ((desc = open (file, O_RDONLY | O_NONBLOCK)) < 0 && errno == EINTR) + continue; + + if (desc < 0) + { + int e = errno; + + if (is_EISDIR (e, file) && directories == RECURSE_DIRECTORIES) + { + if (stat (file, &stats->stat) != 0) + { + error (0, errno, "%s", file); + return 1; + } + + return grepdir (file, stats); + } + + if (!suppress_errors) + { + if (directories == SKIP_DIRECTORIES) + switch (e) + { +#if defined(EISDIR) + case EISDIR: + return 1; +#endif + case EACCES: + /* When skipping directories, don't worry about + directories that can't be opened. */ + if (isdir (file)) + return 1; + break; + } + } + + suppressible_error (file, e); + return 1; + } + + flags = fcntl(desc, F_GETFL); + flags &= ~O_NONBLOCK; + fcntl(desc, F_SETFL, flags); + filename = file; + } + +#if defined(SET_BINARY) + /* Set input to binary mode. Pipes are simulated with files + on DOS, so this includes the case of "foo | grep bar". */ + if (!isatty (desc)) + SET_BINARY (desc); +#endif + + count = grep (desc, file, stats); + if (count < 0) + status = count + 2; + else + { + if (count_matches) + { + if (out_file) + printf ("%s%c", filename, ':' & filename_mask); + printf ("%d\n", count); + } + + status = !count; + if (list_files == 1 - 2 * status) + printf ("%s%c", filename, '\n' & filename_mask); + + if (BZflag && bzbufdesc) + BZ2_bzclose(bzbufdesc); + else +#if HAVE_LIBZ > 0 + if (Zflag) + gzclose(gzbufdesc); + else +#endif + if (! file) + { + off_t required_offset = outleft ? bufoffset : after_last_match; + if ((bufmapped || required_offset != bufoffset) + && lseek (desc, required_offset, SEEK_SET) < 0 + && S_ISREG (stats->stat.st_mode)) + error (0, errno, "%s", filename); + } + else + while (close (desc) != 0) + if (errno != EINTR) + { + error (0, errno, "%s", file); + break; + } + } + + return status; +} + +static int +grepdir (char const *dir, struct stats const *stats) +{ + int status = 1; + struct stats const *ancestor; + char *name_space; + + /* Mingw32 does not support st_ino. No known working hosts use zero + for st_ino, so assume that the Mingw32 bug applies if it's zero. */ + if (stats->stat.st_ino) + for (ancestor = stats; (ancestor = ancestor->parent) != 0; ) + if (ancestor->stat.st_ino == stats->stat.st_ino + && ancestor->stat.st_dev == stats->stat.st_dev) + { + if (!suppress_errors) + error (0, 0, _("warning: %s: %s"), dir, + _("recursive directory loop")); + return 1; + } + + name_space = savedir (dir, stats->stat.st_size, included_patterns, + excluded_patterns); + + if (! name_space) + { + if (errno) + suppressible_error (dir, errno); + else + xalloc_die (); + } + else + { + size_t dirlen = strlen (dir); + int needs_slash = ! (dirlen == FILESYSTEM_PREFIX_LEN (dir) + || IS_SLASH (dir[dirlen - 1])); + char *file = NULL; + char const *namep = name_space; + struct stats child; + child.parent = stats; + out_file += !no_filenames; + while (*namep) + { + size_t namelen = strlen (namep); + file = xrealloc (file, dirlen + 1 + namelen + 1); + strcpy (file, dir); + file[dirlen] = '/'; + strcpy (file + dirlen + needs_slash, namep); + namep += namelen + 1; + status &= grepfile (file, &child); + } + out_file -= !no_filenames; + if (file) + free (file); + free (name_space); + } + + return status; +} + +static void +usage (int status) +{ + if (status != 0) + { + fprintf (stderr, _("Usage: %s [OPTION]... PATTERN [FILE]...\n"), + program_name); + fprintf (stderr, _("Try `%s --help' for more information.\n"), + program_name); + } + else + { + printf (_("Usage: %s [OPTION]... PATTERN [FILE] ...\n"), program_name); + printf (_("\ +Search for PATTERN in each FILE or standard input.\n\ +Example: %s -i 'hello world' menu.h main.c\n\ +\n\ +Regexp selection and interpretation:\n"), program_name); + printf (_("\ + -E, --extended-regexp PATTERN is an extended regular expression\n\ + -F, --fixed-strings PATTERN is a set of newline-separated strings\n\ + -G, --basic-regexp PATTERN is a basic regular expression\n\ + -P, --perl-regexp PATTERN is a Perl regular expression\n")); + printf (_("\ + -e, --regexp=PATTERN use PATTERN as a regular expression\n\ + -f, --file=FILE obtain PATTERN from FILE\n\ + -i, --ignore-case ignore case distinctions\n\ + -w, --word-regexp force PATTERN to match only whole words\n\ + -x, --line-regexp force PATTERN to match only whole lines\n\ + -z, --null-data a data line ends in 0 byte, not newline\n")); + printf (_("\ +\n\ +Miscellaneous:\n\ + -s, --no-messages suppress error messages\n\ + -v, --invert-match select non-matching lines\n\ + -V, --version print version information and exit\n\ + --help display this help and exit\n\ + -J, --bz2decompress decompress bzip2'ed input before searching\n\ + -Z, --decompress decompress input before searching (HAVE_LIBZ=1)\n\ + --mmap use memory-mapped input if possible\n")); + printf (_("\ +\n\ +Output control:\n\ + -m, --max-count=NUM stop after NUM matches\n\ + -b, --byte-offset print the byte offset with output lines\n\ + -n, --line-number print line number with output lines\n\ + --line-buffered flush output on every line\n\ + -H, --with-filename print the filename for each match\n\ + -h, --no-filename suppress the prefixing filename on output\n\ + --label=LABEL print LABEL as filename for standard input\n\ + -o, --only-matching show only the part of a line matching PATTERN\n\ + -q, --quiet, --silent suppress all normal output\n\ + --binary-files=TYPE assume that binary files are TYPE\n\ + TYPE is 'binary', 'text', or 'without-match'\n\ + -a, --text equivalent to --binary-files=text\n\ + -I equivalent to --binary-files=without-match\n\ + -d, --directories=ACTION how to handle directories\n\ + ACTION is 'read', 'recurse', or 'skip'\n\ + -D, --devices=ACTION how to handle devices, FIFOs and sockets\n\ + ACTION is 'read' or 'skip'\n\ + -R, -r, --recursive equivalent to --directories=recurse\n\ + --include=PATTERN files that match PATTERN will be examined\n\ + --exclude=PATTERN files that match PATTERN will be skipped.\n\ + --exclude-from=FILE files that match PATTERN in FILE will be skipped.\n\ + -L, --files-without-match only print FILE names containing no match\n\ + -l, --files-with-matches only print FILE names containing matches\n\ + -c, --count only print a count of matching lines per FILE\n\ + --null print 0 byte after FILE name\n")); + printf (_("\ +\n\ +Context control:\n\ + -B, --before-context=NUM print NUM lines of leading context\n\ + -A, --after-context=NUM print NUM lines of trailing context\n\ + -C, --context=NUM print NUM lines of output context\n\ + -NUM same as --context=NUM\n\ + --color[=WHEN],\n\ + --colour[=WHEN] use markers to distinguish the matching string\n\ + WHEN may be `always', `never' or `auto'.\n\ + -U, --binary do not strip CR characters at EOL (MSDOS)\n\ + -u, --unix-byte-offsets report offsets as if CRs were not there (MSDOS)\n\ +\n\ +`egrep' means `grep -E'. `fgrep' means `grep -F'.\n\ +With no FILE, or when FILE is -, read standard input. If less than\n\ +two FILEs given, assume -h. Exit status is 0 if match, 1 if no match,\n\ +and 2 if trouble.\n")); + printf (_("\nReport bugs to <bug-gnu-utils@gnu.org>.\n")); + } + exit (status); +} + +/* Set the matcher to M, reporting any conflicts. */ +static void +setmatcher (char const *m) +{ + if (matcher && strcmp (matcher, m) != 0) + error (2, 0, _("conflicting matchers specified")); + matcher = m; +} + +/* Go through the matchers vector and look for the specified matcher. + If we find it, install it in compile and execute, and return 1. */ +static int +install_matcher (char const *name) +{ + int i; +#if defined(HAVE_SETRLIMIT) + struct rlimit rlim; +#endif + + for (i = 0; matchers[i].compile; i++) + if (strcmp (name, matchers[i].name) == 0) + { + compile = matchers[i].compile; + execute = matchers[i].execute; +#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_STACK) + /* I think every platform needs to do this, so that regex.c + doesn't oveflow the stack. The default value of + `re_max_failures' is too large for some platforms: it needs + more than 3MB-large stack. + + The test for HAVE_SETRLIMIT should go into `configure'. */ + if (!getrlimit (RLIMIT_STACK, &rlim)) + { + long newlim; + extern long int re_max_failures; /* from regex.c */ + + /* Approximate the amount regex.c needs, plus some more. */ + newlim = re_max_failures * 2 * 20 * sizeof (char *); + if (newlim > rlim.rlim_max) + { + newlim = rlim.rlim_max; + re_max_failures = newlim / (2 * 20 * sizeof (char *)); + } + if (rlim.rlim_cur < newlim) + { + rlim.rlim_cur = newlim; + setrlimit (RLIMIT_STACK, &rlim); + } + } +#endif + return 1; + } + return 0; +} + +/* Find the white-space-separated options specified by OPTIONS, and + using BUF to store copies of these options, set ARGV[0], ARGV[1], + etc. to the option copies. Return the number N of options found. + Do not set ARGV[N] to NULL. If ARGV is NULL, do not store ARGV[0] + etc. Backslash can be used to escape whitespace (and backslashes). */ +static int +prepend_args (char const *options, char *buf, char **argv) +{ + char const *o = options; + char *b = buf; + int n = 0; + + for (;;) + { + while (ISSPACE ((unsigned char) *o)) + o++; + if (!*o) + return n; + if (argv) + argv[n] = b; + n++; + + do + if ((*b++ = *o++) == '\\' && *o) + b[-1] = *o++; + while (*o && ! ISSPACE ((unsigned char) *o)); + + *b++ = '\0'; + } +} + +/* Prepend the whitespace-separated options in OPTIONS to the argument + vector of a main program with argument count *PARGC and argument + vector *PARGV. */ +static void +prepend_default_options (char const *options, int *pargc, char ***pargv) +{ + if (options) + { + char *buf = xmalloc (strlen (options) + 1); + int prepended = prepend_args (options, buf, (char **) NULL); + int argc = *pargc; + char * const *argv = *pargv; + char **pp = (char **) xmalloc ((prepended + argc + 1) * sizeof *pp); + *pargc = prepended + argc; + *pargv = pp; + *pp++ = *argv++; + pp += prepend_args (options, buf, pp); + while ((*pp++ = *argv++)) + continue; + } +} + +/* Get the next non-digit option from ARGC and ARGV. + Return -1 if there are no more options. + Process any digit options that were encountered on the way, + and store the resulting integer into *DEFAULT_CONTEXT. */ +static int +get_nondigit_option (int argc, char *const *argv, int *default_context) +{ + int opt; + char buf[sizeof (uintmax_t) * CHAR_BIT + 4]; + char *p = buf; + + /* Set buf[0] to anything but '0', for the leading-zero test below. */ + buf[0] = '\0'; + + while (opt = getopt_long (argc, argv, short_options, long_options, NULL), + '0' <= opt && opt <= '9') + { + /* Suppress trivial leading zeros, to avoid incorrect + diagnostic on strings like 00000000000. */ + p -= buf[0] == '0'; + + *p++ = opt; + if (p == buf + sizeof buf - 4) + { + /* Too many digits. Append "..." to make context_length_arg + complain about "X...", where X contains the digits seen + so far. */ + strcpy (p, "..."); + p += 3; + break; + } + } + if (p != buf) + { + *p = '\0'; + context_length_arg (buf, default_context); + } + + return opt; +} + +int +main (int argc, char **argv) +{ + char *keys; + size_t cc, keycc, oldcc, keyalloc; + int with_filenames; + int opt, status; + int default_context; + FILE *fp; + extern char *optarg; + extern int optind; + + initialize_main (&argc, &argv); + program_name = argv[0]; + if (program_name && strrchr (program_name, '/')) + program_name = strrchr (program_name, '/') + 1; + + if (program_name[0] == 'b' && program_name[1] == 'z') { + BZflag = 1; + program_name += 2; + } +#if HAVE_LIBZ > 0 + else if (program_name[0] == 'z') { + Zflag = 1; + ++program_name; + } +#endif + +#if defined(__MSDOS__) || defined(_WIN32) + /* DOS and MS-Windows use backslashes as directory separators, and usually + have an .exe suffix. They also have case-insensitive filesystems. */ + if (program_name) + { + char *p = program_name; + char *bslash = strrchr (argv[0], '\\'); + + if (bslash && bslash >= program_name) /* for mixed forward/backslash case */ + program_name = bslash + 1; + else if (program_name == argv[0] + && argv[0][0] && argv[0][1] == ':') /* "c:progname" */ + program_name = argv[0] + 2; + + /* Collapse the letter-case, so `strcmp' could be used hence. */ + for ( ; *p; p++) + if (*p >= 'A' && *p <= 'Z') + *p += 'a' - 'A'; + + /* Remove the .exe extension, if any. */ + if ((p = strrchr (program_name, '.')) && strcmp (p, ".exe") == 0) + *p = '\0'; + } +#endif + + keys = NULL; + keycc = 0; + with_filenames = 0; + eolbyte = '\n'; + filename_mask = ~0; + + max_count = TYPE_MAXIMUM (off_t); + + /* The value -1 means to use DEFAULT_CONTEXT. */ + out_after = out_before = -1; + /* Default before/after context: chaged by -C/-NUM options */ + default_context = 0; + /* Changed by -o option */ + only_matching = 0; + + /* Internationalization. */ +#if defined(HAVE_SETLOCALE) + setlocale (LC_ALL, ""); +#endif +#if defined(ENABLE_NLS) + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); +#endif + + atexit (close_stdout); + + prepend_default_options (getenv ("GREP_OPTIONS"), &argc, &argv); + + while ((opt = get_nondigit_option (argc, argv, &default_context)) != -1) + switch (opt) + { + case 'A': + context_length_arg (optarg, &out_after); + break; + + case 'B': + context_length_arg (optarg, &out_before); + break; + + case 'C': + /* Set output match context, but let any explicit leading or + trailing amount specified with -A or -B stand. */ + context_length_arg (optarg, &default_context); + break; + + case 'D': + if (strcmp (optarg, "read") == 0) + devices = READ_DEVICES; + else if (strcmp (optarg, "skip") == 0) + devices = SKIP_DEVICES; + else + error (2, 0, _("unknown devices method")); + break; + + case 'E': + setmatcher ("egrep"); + break; + + case 'F': + setmatcher ("fgrep"); + break; + + case 'P': + setmatcher ("perl"); + break; + + case 'G': + setmatcher ("grep"); + break; + + case 'H': + with_filenames = 1; + break; + + case 'I': + binary_files = WITHOUT_MATCH_BINARY_FILES; + break; + case 'J': + if (Zflag) + { + printf (_("Cannot mix -Z and -J.\n")); + usage (2); + } + BZflag = 1; + break; + + case 'U': +#if defined(HAVE_DOS_FILE_CONTENTS) + dos_use_file_type = DOS_BINARY; +#endif + break; + + case 'u': +#if defined(HAVE_DOS_FILE_CONTENTS) + dos_report_unix_offset = 1; +#endif + break; + + case 'V': + show_version = 1; + break; + + case 'X': + setmatcher (optarg); + break; + + case 'a': + binary_files = TEXT_BINARY_FILES; + break; + + case 'b': + out_byte = 1; + break; + + case 'c': + count_matches = 1; + break; + + case 'd': + if (strcmp (optarg, "read") == 0) + directories = READ_DIRECTORIES; + else if (strcmp (optarg, "skip") == 0) + directories = SKIP_DIRECTORIES; + else if (strcmp (optarg, "recurse") == 0) + directories = RECURSE_DIRECTORIES; + else + error (2, 0, _("unknown directories method")); + break; + + case 'e': + cc = strlen (optarg); + keys = xrealloc (keys, keycc + cc + 1); + strcpy (&keys[keycc], optarg); + keycc += cc; + keys[keycc++] = '\n'; + break; + + case 'f': + fp = strcmp (optarg, "-") != 0 ? fopen (optarg, "r") : stdin; + if (!fp) + error (2, errno, "%s", optarg); + for (keyalloc = 1; keyalloc <= keycc + 1; keyalloc *= 2) + ; + keys = xrealloc (keys, keyalloc); + oldcc = keycc; + while (!feof (fp) + && (cc = fread (keys + keycc, 1, keyalloc - 1 - keycc, fp)) > 0) + { + keycc += cc; + if (keycc == keyalloc - 1) + keys = xrealloc (keys, keyalloc *= 2); + } + if (fp != stdin) + fclose(fp); + /* Append final newline if file ended in non-newline. */ + if (oldcc != keycc && keys[keycc - 1] != '\n') + keys[keycc++] = '\n'; + break; + + case 'h': + no_filenames = 1; + break; + + case 'i': + case 'y': /* For old-timers . . . */ + match_icase = 1; + break; + + case 'L': + /* Like -l, except list files that don't contain matches. + Inspired by the same option in Hume's gre. */ + list_files = -1; + break; + + case 'l': + list_files = 1; + break; + + case 'm': + { + uintmax_t value; + switch (xstrtoumax (optarg, 0, 10, &value, "")) + { + case LONGINT_OK: + max_count = value; + if (0 <= max_count && max_count == value) + break; + /* Fall through. */ + case LONGINT_OVERFLOW: + max_count = TYPE_MAXIMUM (off_t); + break; + + default: + error (2, 0, _("invalid max count")); + } + } + break; + + case 'n': + out_line = 1; + break; + + case 'o': + only_matching = 1; + break; + + case 'q': + exit_on_match = 1; + close_stdout_set_status(0); + break; + + case 'R': + case 'r': + directories = RECURSE_DIRECTORIES; + break; + + case 's': + suppress_errors = 1; + break; + + case 'v': + out_invert = 1; + break; + + case 'w': + match_words = 1; + break; + + case 'x': + match_lines = 1; + break; + + case 'Z': +#if HAVE_LIBZ > 0 + if (BZflag) + { + printf (_("Cannot mix -J and -Z.\n")); + usage (2); + } + Zflag = 1; +#else + filename_mask = 0; +#endif + break; + + case 'z': + eolbyte = '\0'; + break; + + case BINARY_FILES_OPTION: + if (strcmp (optarg, "binary") == 0) + binary_files = BINARY_BINARY_FILES; + else if (strcmp (optarg, "text") == 0) + binary_files = TEXT_BINARY_FILES; + else if (strcmp (optarg, "without-match") == 0) + binary_files = WITHOUT_MATCH_BINARY_FILES; + else + error (2, 0, _("unknown binary-files type")); + break; + + case COLOR_OPTION: + if(optarg) { + if(!strcasecmp(optarg, "always") || !strcasecmp(optarg, "yes") || + !strcasecmp(optarg, "force")) + color_option = 1; + else if(!strcasecmp(optarg, "never") || !strcasecmp(optarg, "no") || + !strcasecmp(optarg, "none")) + color_option = 0; + else if(!strcasecmp(optarg, "auto") || !strcasecmp(optarg, "tty") || + !strcasecmp(optarg, "if-tty")) + color_option = 2; + else + show_help = 1; + } else + color_option = 2; + if(color_option == 2) { + if(isatty(STDOUT_FILENO) && getenv("TERM") && + strcmp(getenv("TERM"), "dumb")) + color_option = 1; + else + color_option = 0; + } + break; + + case EXCLUDE_OPTION: + if (!excluded_patterns) + excluded_patterns = new_exclude (); + add_exclude (excluded_patterns, optarg); + break; + + case EXCLUDE_FROM_OPTION: + if (!excluded_patterns) + excluded_patterns = new_exclude (); + if (add_exclude_file (add_exclude, excluded_patterns, optarg, '\n') + != 0) + { + error (2, errno, "%s", optarg); + } + break; + + case INCLUDE_OPTION: + if (!included_patterns) + included_patterns = new_exclude (); + add_exclude (included_patterns, optarg); + break; + + case LINE_BUFFERED_OPTION: + line_buffered = 1; + break; + + case LABEL_OPTION: + label = optarg; + break; + + case 0: + /* long options */ + break; + + default: + usage (2); + break; + + } + + /* POSIX.2 says that -q overrides -l, which in turn overrides the + other output options. */ + if (exit_on_match) + list_files = 0; + if (exit_on_match | list_files) + { + count_matches = 0; + done_on_match = 1; + } + out_quiet = count_matches | done_on_match; + + if (out_after < 0) + out_after = default_context; + if (out_before < 0) + out_before = default_context; + + if (color_option) + { + char *userval = getenv ("GREP_COLOR"); + if (userval != NULL && *userval != '\0') + grep_color = userval; + } + + if (! matcher) + matcher = program_name; + + if (show_version) + { + printf (_("%s (GNU grep) %s\n"), matcher, VERSION); + printf ("\n"); + printf (_("\ +Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.\n")); + printf (_("\ +This is free software; see the source for copying conditions. There is NO\n\ +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n")); + printf ("\n"); + exit (0); + } + + if (show_help) + usage (0); + + if (keys) + { + if (keycc == 0) + { + /* No keys were specified (e.g. -f /dev/null). Match nothing. */ + out_invert ^= 1; + match_lines = match_words = 0; + } + else + /* Strip trailing newline. */ + --keycc; + } + else + if (optind < argc) + { + keys = argv[optind++]; + keycc = strlen (keys); + } + else + usage (2); + + if (!install_matcher (matcher) && !install_matcher ("default")) + abort (); + +#ifdef MBS_SUPPORT + if (MB_CUR_MAX != 1 && match_icase) + { + wchar_t wc; + mbstate_t cur_state, prev_state; + int i, len = strlen(keys); + + memset(&cur_state, 0, sizeof(mbstate_t)); + for (i = 0; i <= len ;) + { + size_t mbclen; + mbclen = mbrtowc(&wc, keys + i, len - i, &cur_state); + if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0) + { + /* An invalid sequence, or a truncated multibyte character. + We treat it as a singlebyte character. */ + mbclen = 1; + } + else + { + if (iswupper((wint_t)wc)) + { + wc = towlower((wint_t)wc); + wcrtomb(keys + i, wc, &cur_state); + } + } + i += mbclen; + } + } +#endif /* MBS_SUPPORT */ + + (*compile)(keys, keycc); + + if ((argc - optind > 1 && !no_filenames) || with_filenames) + out_file = 1; + +#ifdef SET_BINARY + /* Output is set to binary mode because we shouldn't convert + NL to CR-LF pairs, especially when grepping binary files. */ + if (!isatty (1)) + SET_BINARY (1); +#endif + + if (max_count == 0) + exit (1); + + if (optind < argc) + { + status = 1; + do + { + char *file = argv[optind]; + if ((included_patterns || excluded_patterns) + && !isdir (file)) + { + if (included_patterns && + ! excluded_filename (included_patterns, file, 0)) + continue; + if (excluded_patterns && + excluded_filename (excluded_patterns, file, 0)) + continue; + } + status &= grepfile (strcmp (file, "-") == 0 ? (char *) NULL : file, + &stats_base); + } + while ( ++optind < argc); + } + else + status = grepfile ((char *) NULL, &stats_base); + + /* We register via atexit() to test stdout. */ + exit (errseen ? 2 : status); +} +/* vim:set shiftwidth=2: */ diff --git a/gnu/usr.bin/grep/grep.h b/gnu/usr.bin/grep/grep.h new file mode 100644 index 000000000000..f4937e763833 --- /dev/null +++ b/gnu/usr.bin/grep/grep.h @@ -0,0 +1,44 @@ +/* grep.h - interface to grep driver for searching subroutines. + Copyright (C) 1992, 1998, 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +/* $FreeBSD$ */ + +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__ +# define __attribute__(x) +#endif + +/* Grep.c expects the matchers vector to be terminated + by an entry with a NULL compile, and to contain at least + an entry named "default". */ + +extern struct matcher +{ + char name[8]; + void (*compile) PARAMS ((char const *, size_t)); + size_t (*execute) PARAMS ((char const *, size_t, size_t *, int)); +} const matchers[]; + +/* Exported from fgrepmat.c, egrepmat.c, grepmat.c. */ +extern char const *matcher; + +/* The following flags are exported from grep for the matchers + to look at. */ +extern int match_icase; /* -i */ +extern int match_words; /* -w */ +extern int match_lines; /* -x */ +extern unsigned char eolbyte; /* -z */ diff --git a/gnu/usr.bin/grep/grepmat.c b/gnu/usr.bin/grep/grepmat.c new file mode 100644 index 000000000000..7947a657445c --- /dev/null +++ b/gnu/usr.bin/grep/grepmat.c @@ -0,0 +1,6 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#include "system.h" +#include "grep.h" +char const *matcher; diff --git a/gnu/usr.bin/grep/hard-locale.c b/gnu/usr.bin/grep/hard-locale.c new file mode 100644 index 000000000000..9c5da2b3ea8b --- /dev/null +++ b/gnu/usr.bin/grep/hard-locale.c @@ -0,0 +1,87 @@ +/* hard-locale.c -- Determine whether a locale is hard. + Copyright 1997, 1998, 1999 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* $FreeBSD$ */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#ifndef __GNUC__ +# ifdef HAVE_ALLOCA_H +# include <alloca.h> +# else +# ifdef _AIX + # pragma alloca +# else +# ifdef _WIN32 +# include <malloc.h> +# include <io.h> +# else +# ifndef alloca +char *alloca (); +# endif +# endif +# endif +# endif +#endif + +#if HAVE_LOCALE_H +# include <locale.h> +#endif + +#if HAVE_STRING_H +# include <string.h> +#endif + +/* Return nonzero if the current CATEGORY locale is hard, i.e. if you + can't get away with assuming traditional C or POSIX behavior. */ +int +hard_locale (int category) +{ +#if ! HAVE_SETLOCALE + return 0; +#else + + int hard = 1; + char const *p = setlocale (category, 0); + + if (p) + { +# if defined(__FreeBSD__) || (defined __GLIBC__ && __GLIBC__ >= 2) + if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0) + hard = 0; +# else + char *locale = alloca (strlen (p) + 1); + strcpy (locale, p); + + /* Temporarily set the locale to the "C" and "POSIX" locales to + find their names, so that we can determine whether one or the + other is the caller's locale. */ + if (((p = setlocale (category, "C")) && strcmp (p, locale) == 0) + || ((p = setlocale (category, "POSIX")) && strcmp (p, locale) == 0)) + hard = 0; + + /* Restore the caller's locale. */ + setlocale (category, locale); +# endif + } + + return hard; + +#endif +} diff --git a/gnu/usr.bin/grep/hard-locale.h b/gnu/usr.bin/grep/hard-locale.h new file mode 100644 index 000000000000..5b054d9a5cb9 --- /dev/null +++ b/gnu/usr.bin/grep/hard-locale.h @@ -0,0 +1,18 @@ +#ifndef HARD_LOCALE_H_ +# define HARD_LOCALE_H_ 1 + +# if HAVE_CONFIG_H +# include <config.h> +# endif + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +int hard_locale PARAMS ((int)); + +#endif /* HARD_LOCALE_H_ */ diff --git a/gnu/usr.bin/grep/isdir.c b/gnu/usr.bin/grep/isdir.c new file mode 100644 index 000000000000..01cf8d5e4af2 --- /dev/null +++ b/gnu/usr.bin/grep/isdir.c @@ -0,0 +1,42 @@ +/* isdir.c -- determine whether a directory exists + Copyright (C) 1990, 1998 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include <sys/types.h> +#include <sys/stat.h> + +#if STAT_MACROS_BROKEN +# undef S_ISDIR +#endif + +#if !defined S_ISDIR && defined S_IFDIR +# define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR) +#endif + +/* If PATH is an existing directory or symbolic link to a directory, + return nonzero, else 0. */ + +int +isdir (const char *path) +{ + struct stat stats; + + return stat (path, &stats) == 0 && S_ISDIR (stats.st_mode); +} diff --git a/gnu/usr.bin/grep/kwset.c b/gnu/usr.bin/grep/kwset.c new file mode 100644 index 000000000000..79025396d1b9 --- /dev/null +++ b/gnu/usr.bin/grep/kwset.c @@ -0,0 +1,773 @@ +/* kwset.c - search for any of a set of keywords. + Copyright 1989, 1998, 2000 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +/* $FreeBSD$ */ + +/* Written August 1989 by Mike Haertel. + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +/* The algorithm implemented by these routines bears a startling resemblence + to one discovered by Beate Commentz-Walter, although it is not identical. + See "A String Matching Algorithm Fast on the Average," Technical Report, + IBM-Germany, Scientific Center Heidelberg, Tiergartenstrasse 15, D-6900 + Heidelberg, Germany. See also Aho, A.V., and M. Corasick, "Efficient + String Matching: An Aid to Bibliographic Search," CACM June 1975, + Vol. 18, No. 6, which describes the failure function used below. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#include <sys/types.h> +#include "system.h" +#include "kwset.h" +#include "obstack.h" + +#ifdef GREP +extern char *xmalloc(); +# undef malloc +# define malloc xmalloc +#endif + +#define NCHAR (UCHAR_MAX + 1) +#define obstack_chunk_alloc malloc +#define obstack_chunk_free free + +/* Balanced tree of edges and labels leaving a given trie node. */ +struct tree +{ + struct tree *llink; /* Left link; MUST be first field. */ + struct tree *rlink; /* Right link (to larger labels). */ + struct trie *trie; /* Trie node pointed to by this edge. */ + unsigned char label; /* Label on this edge. */ + char balance; /* Difference in depths of subtrees. */ +}; + +/* Node of a trie representing a set of reversed keywords. */ +struct trie +{ + unsigned int accepting; /* Word index of accepted word, or zero. */ + struct tree *links; /* Tree of edges leaving this node. */ + struct trie *parent; /* Parent of this node. */ + struct trie *next; /* List of all trie nodes in level order. */ + struct trie *fail; /* Aho-Corasick failure function. */ + int depth; /* Depth of this node from the root. */ + int shift; /* Shift function for search failures. */ + int maxshift; /* Max shift of self and descendents. */ +}; + +/* Structure returned opaquely to the caller, containing everything. */ +struct kwset +{ + struct obstack obstack; /* Obstack for node allocation. */ + int words; /* Number of words in the trie. */ + struct trie *trie; /* The trie itself. */ + int mind; /* Minimum depth of an accepting node. */ + int maxd; /* Maximum depth of any node. */ + unsigned char delta[NCHAR]; /* Delta table for rapid search. */ + struct trie *next[NCHAR]; /* Table of children of the root. */ + char *target; /* Target string if there's only one. */ + int mind2; /* Used in Boyer-Moore search for one string. */ + char const *trans; /* Character translation table. */ +}; + +/* Allocate and initialize a keyword set object, returning an opaque + pointer to it. Return NULL if memory is not available. */ +kwset_t +kwsalloc (char const *trans) +{ + struct kwset *kwset; + + kwset = (struct kwset *) malloc(sizeof (struct kwset)); + if (!kwset) + return 0; + + obstack_init(&kwset->obstack); + kwset->words = 0; + kwset->trie + = (struct trie *) obstack_alloc(&kwset->obstack, sizeof (struct trie)); + if (!kwset->trie) + { + kwsfree((kwset_t) kwset); + return 0; + } + kwset->trie->accepting = 0; + kwset->trie->links = 0; + kwset->trie->parent = 0; + kwset->trie->next = 0; + kwset->trie->fail = 0; + kwset->trie->depth = 0; + kwset->trie->shift = 0; + kwset->mind = INT_MAX; + kwset->maxd = -1; + kwset->target = 0; + kwset->trans = trans; + + return (kwset_t) kwset; +} + +/* Add the given string to the contents of the keyword set. Return NULL + for success, an error message otherwise. */ +char * +kwsincr (kwset_t kws, char const *text, size_t len) +{ + struct kwset *kwset; + register struct trie *trie; + register unsigned char label; + register struct tree *link; + register int depth; + struct tree *links[12]; + enum { L, R } dirs[12]; + struct tree *t, *r, *l, *rl, *lr; + + kwset = (struct kwset *) kws; + trie = kwset->trie; + text += len; + + /* Descend the trie (built of reversed keywords) character-by-character, + installing new nodes when necessary. */ + while (len--) + { + label = kwset->trans ? kwset->trans[(unsigned char) *--text] : *--text; + + /* Descend the tree of outgoing links for this trie node, + looking for the current character and keeping track + of the path followed. */ + link = trie->links; + links[0] = (struct tree *) &trie->links; + dirs[0] = L; + depth = 1; + + while (link && label != link->label) + { + links[depth] = link; + if (label < link->label) + dirs[depth++] = L, link = link->llink; + else + dirs[depth++] = R, link = link->rlink; + } + + /* The current character doesn't have an outgoing link at + this trie node, so build a new trie node and install + a link in the current trie node's tree. */ + if (!link) + { + link = (struct tree *) obstack_alloc(&kwset->obstack, + sizeof (struct tree)); + if (!link) + return _("memory exhausted"); + link->llink = 0; + link->rlink = 0; + link->trie = (struct trie *) obstack_alloc(&kwset->obstack, + sizeof (struct trie)); + if (!link->trie) + return _("memory exhausted"); + link->trie->accepting = 0; + link->trie->links = 0; + link->trie->parent = trie; + link->trie->next = 0; + link->trie->fail = 0; + link->trie->depth = trie->depth + 1; + link->trie->shift = 0; + link->label = label; + link->balance = 0; + + /* Install the new tree node in its parent. */ + if (dirs[--depth] == L) + links[depth]->llink = link; + else + links[depth]->rlink = link; + + /* Back up the tree fixing the balance flags. */ + while (depth && !links[depth]->balance) + { + if (dirs[depth] == L) + --links[depth]->balance; + else + ++links[depth]->balance; + --depth; + } + + /* Rebalance the tree by pointer rotations if necessary. */ + if (depth && ((dirs[depth] == L && --links[depth]->balance) + || (dirs[depth] == R && ++links[depth]->balance))) + { + switch (links[depth]->balance) + { + case (char) -2: + switch (dirs[depth + 1]) + { + case L: + r = links[depth], t = r->llink, rl = t->rlink; + t->rlink = r, r->llink = rl; + t->balance = r->balance = 0; + break; + case R: + r = links[depth], l = r->llink, t = l->rlink; + rl = t->rlink, lr = t->llink; + t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl; + l->balance = t->balance != 1 ? 0 : -1; + r->balance = t->balance != (char) -1 ? 0 : 1; + t->balance = 0; + break; + default: + abort (); + } + break; + case 2: + switch (dirs[depth + 1]) + { + case R: + l = links[depth], t = l->rlink, lr = t->llink; + t->llink = l, l->rlink = lr; + t->balance = l->balance = 0; + break; + case L: + l = links[depth], r = l->rlink, t = r->llink; + lr = t->llink, rl = t->rlink; + t->llink = l, l->rlink = lr, t->rlink = r, r->llink = rl; + l->balance = t->balance != 1 ? 0 : -1; + r->balance = t->balance != (char) -1 ? 0 : 1; + t->balance = 0; + break; + default: + abort (); + } + break; + default: + abort (); + } + + if (dirs[depth - 1] == L) + links[depth - 1]->llink = t; + else + links[depth - 1]->rlink = t; + } + } + + trie = link->trie; + } + + /* Mark the node we finally reached as accepting, encoding the + index number of this word in the keyword set so far. */ + if (!trie->accepting) + trie->accepting = 1 + 2 * kwset->words; + ++kwset->words; + + /* Keep track of the longest and shortest string of the keyword set. */ + if (trie->depth < kwset->mind) + kwset->mind = trie->depth; + if (trie->depth > kwset->maxd) + kwset->maxd = trie->depth; + + return 0; +} + +/* Enqueue the trie nodes referenced from the given tree in the + given queue. */ +static void +enqueue (struct tree *tree, struct trie **last) +{ + if (!tree) + return; + enqueue(tree->llink, last); + enqueue(tree->rlink, last); + (*last) = (*last)->next = tree->trie; +} + +/* Compute the Aho-Corasick failure function for the trie nodes referenced + from the given tree, given the failure function for their parent as + well as a last resort failure node. */ +static void +treefails (register struct tree const *tree, struct trie const *fail, + struct trie *recourse) +{ + register struct tree *link; + + if (!tree) + return; + + treefails(tree->llink, fail, recourse); + treefails(tree->rlink, fail, recourse); + + /* Find, in the chain of fails going back to the root, the first + node that has a descendent on the current label. */ + while (fail) + { + link = fail->links; + while (link && tree->label != link->label) + if (tree->label < link->label) + link = link->llink; + else + link = link->rlink; + if (link) + { + tree->trie->fail = link->trie; + return; + } + fail = fail->fail; + } + + tree->trie->fail = recourse; +} + +/* Set delta entries for the links of the given tree such that + the preexisting delta value is larger than the current depth. */ +static void +treedelta (register struct tree const *tree, + register unsigned int depth, + unsigned char delta[]) +{ + if (!tree) + return; + treedelta(tree->llink, depth, delta); + treedelta(tree->rlink, depth, delta); + if (depth < delta[tree->label]) + delta[tree->label] = depth; +} + +/* Return true if A has every label in B. */ +static int +hasevery (register struct tree const *a, register struct tree const *b) +{ + if (!b) + return 1; + if (!hasevery(a, b->llink)) + return 0; + if (!hasevery(a, b->rlink)) + return 0; + while (a && b->label != a->label) + if (b->label < a->label) + a = a->llink; + else + a = a->rlink; + return !!a; +} + +/* Compute a vector, indexed by character code, of the trie nodes + referenced from the given tree. */ +static void +treenext (struct tree const *tree, struct trie *next[]) +{ + if (!tree) + return; + treenext(tree->llink, next); + treenext(tree->rlink, next); + next[tree->label] = tree->trie; +} + +/* Compute the shift for each trie node, as well as the delta + table and next cache for the given keyword set. */ +char * +kwsprep (kwset_t kws) +{ + register struct kwset *kwset; + register int i; + register struct trie *curr, *fail; + register char const *trans; + unsigned char delta[NCHAR]; + struct trie *last, *next[NCHAR]; + + kwset = (struct kwset *) kws; + + /* Initial values for the delta table; will be changed later. The + delta entry for a given character is the smallest depth of any + node at which an outgoing edge is labeled by that character. */ + if (kwset->mind < 256) + for (i = 0; i < NCHAR; ++i) + delta[i] = kwset->mind; + else + for (i = 0; i < NCHAR; ++i) + delta[i] = 255; + + /* Check if we can use the simple boyer-moore algorithm, instead + of the hairy commentz-walter algorithm. */ + if (kwset->words == 1 && kwset->trans == 0) + { + /* Looking for just one string. Extract it from the trie. */ + kwset->target = obstack_alloc(&kwset->obstack, kwset->mind); + for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i) + { + kwset->target[i] = curr->links->label; + curr = curr->links->trie; + } + /* Build the Boyer Moore delta. Boy that's easy compared to CW. */ + for (i = 0; i < kwset->mind; ++i) + delta[(unsigned char) kwset->target[i]] = kwset->mind - (i + 1); + kwset->mind2 = kwset->mind; + /* Find the minimal delta2 shift that we might make after + a backwards match has failed. */ + for (i = 0; i < kwset->mind - 1; ++i) + if (kwset->target[i] == kwset->target[kwset->mind - 1]) + kwset->mind2 = kwset->mind - (i + 1); + } + else + { + /* Traverse the nodes of the trie in level order, simultaneously + computing the delta table, failure function, and shift function. */ + for (curr = last = kwset->trie; curr; curr = curr->next) + { + /* Enqueue the immediate descendents in the level order queue. */ + enqueue(curr->links, &last); + + curr->shift = kwset->mind; + curr->maxshift = kwset->mind; + + /* Update the delta table for the descendents of this node. */ + treedelta(curr->links, curr->depth, delta); + + /* Compute the failure function for the decendents of this node. */ + treefails(curr->links, curr->fail, kwset->trie); + + /* Update the shifts at each node in the current node's chain + of fails back to the root. */ + for (fail = curr->fail; fail; fail = fail->fail) + { + /* If the current node has some outgoing edge that the fail + doesn't, then the shift at the fail should be no larger + than the difference of their depths. */ + if (!hasevery(fail->links, curr->links)) + if (curr->depth - fail->depth < fail->shift) + fail->shift = curr->depth - fail->depth; + + /* If the current node is accepting then the shift at the + fail and its descendents should be no larger than the + difference of their depths. */ + if (curr->accepting && fail->maxshift > curr->depth - fail->depth) + fail->maxshift = curr->depth - fail->depth; + } + } + + /* Traverse the trie in level order again, fixing up all nodes whose + shift exceeds their inherited maxshift. */ + for (curr = kwset->trie->next; curr; curr = curr->next) + { + if (curr->maxshift > curr->parent->maxshift) + curr->maxshift = curr->parent->maxshift; + if (curr->shift > curr->maxshift) + curr->shift = curr->maxshift; + } + + /* Create a vector, indexed by character code, of the outgoing links + from the root node. */ + for (i = 0; i < NCHAR; ++i) + next[i] = 0; + treenext(kwset->trie->links, next); + + if ((trans = kwset->trans) != 0) + for (i = 0; i < NCHAR; ++i) + kwset->next[i] = next[(unsigned char) trans[i]]; + else + for (i = 0; i < NCHAR; ++i) + kwset->next[i] = next[i]; + } + + /* Fix things up for any translation table. */ + if ((trans = kwset->trans) != 0) + for (i = 0; i < NCHAR; ++i) + kwset->delta[i] = delta[(unsigned char) trans[i]]; + else + for (i = 0; i < NCHAR; ++i) + kwset->delta[i] = delta[i]; + + return 0; +} + +#define U(C) ((unsigned char) (C)) + +/* Fast boyer-moore search. */ +static size_t +bmexec (kwset_t kws, char const *text, size_t size) +{ + struct kwset const *kwset; + register unsigned char const *d1; + register char const *ep, *sp, *tp; + register int d, gc, i, len, md2; + + kwset = (struct kwset const *) kws; + len = kwset->mind; + + if (len == 0) + return 0; + if (len > size) + return -1; + if (len == 1) + { + tp = memchr (text, kwset->target[0], size); + return tp ? tp - text : -1; + } + + d1 = kwset->delta; + sp = kwset->target + len; + gc = U(sp[-2]); + md2 = kwset->mind2; + tp = text + len; + + /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */ + if (size > 12 * len) + /* 11 is not a bug, the initial offset happens only once. */ + for (ep = text + size - 11 * len;;) + { + while (tp <= ep) + { + d = d1[U(tp[-1])], tp += d; + d = d1[U(tp[-1])], tp += d; + if (d == 0) + goto found; + d = d1[U(tp[-1])], tp += d; + d = d1[U(tp[-1])], tp += d; + d = d1[U(tp[-1])], tp += d; + if (d == 0) + goto found; + d = d1[U(tp[-1])], tp += d; + d = d1[U(tp[-1])], tp += d; + d = d1[U(tp[-1])], tp += d; + if (d == 0) + goto found; + d = d1[U(tp[-1])], tp += d; + d = d1[U(tp[-1])], tp += d; + } + break; + found: + if (U(tp[-2]) == gc) + { + for (i = 3; i <= len && U(tp[-i]) == U(sp[-i]); ++i) + ; + if (i > len) + return tp - len - text; + } + tp += md2; + } + + /* Now we have only a few characters left to search. We + carefully avoid ever producing an out-of-bounds pointer. */ + ep = text + size; + d = d1[U(tp[-1])]; + while (d <= ep - tp) + { + d = d1[U((tp += d)[-1])]; + if (d != 0) + continue; + if (U(tp[-2]) == gc) + { + for (i = 3; i <= len && U(tp[-i]) == U(sp[-i]); ++i) + ; + if (i > len) + return tp - len - text; + } + d = md2; + } + + return -1; +} + +/* Hairy multiple string search. */ +static size_t +cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch) +{ + struct kwset const *kwset; + struct trie * const *next; + struct trie const *trie; + struct trie const *accept; + char const *beg, *lim, *mch, *lmch; + register unsigned char c; + register unsigned char const *delta; + register int d; + register char const *end, *qlim; + register struct tree const *tree; + register char const *trans; + +#ifdef lint + accept = NULL; +#endif + + /* Initialize register copies and look for easy ways out. */ + kwset = (struct kwset *) kws; + if (len < kwset->mind) + return -1; + next = kwset->next; + delta = kwset->delta; + trans = kwset->trans; + lim = text + len; + end = text; + if ((d = kwset->mind) != 0) + mch = 0; + else + { + mch = text, accept = kwset->trie; + goto match; + } + + if (len >= 4 * kwset->mind) + qlim = lim - 4 * kwset->mind; + else + qlim = 0; + + while (lim - end >= d) + { + if (qlim && end <= qlim) + { + end += d - 1; + while ((d = delta[c = *end]) && end < qlim) + { + end += d; + end += delta[(unsigned char) *end]; + end += delta[(unsigned char) *end]; + } + ++end; + } + else + d = delta[c = (end += d)[-1]]; + if (d) + continue; + beg = end - 1; + trie = next[c]; + if (trie->accepting) + { + mch = beg; + accept = trie; + } + d = trie->shift; + while (beg > text) + { + c = trans ? trans[(unsigned char) *--beg] : *--beg; + tree = trie->links; + while (tree && c != tree->label) + if (c < tree->label) + tree = tree->llink; + else + tree = tree->rlink; + if (tree) + { + trie = tree->trie; + if (trie->accepting) + { + mch = beg; + accept = trie; + } + } + else + break; + d = trie->shift; + } + if (mch) + goto match; + } + return -1; + + match: + /* Given a known match, find the longest possible match anchored + at or before its starting point. This is nearly a verbatim + copy of the preceding main search loops. */ + if (lim - mch > kwset->maxd) + lim = mch + kwset->maxd; + lmch = 0; + d = 1; + while (lim - end >= d) + { + if ((d = delta[c = (end += d)[-1]]) != 0) + continue; + beg = end - 1; + if (!(trie = next[c])) + { + d = 1; + continue; + } + if (trie->accepting && beg <= mch) + { + lmch = beg; + accept = trie; + } + d = trie->shift; + while (beg > text) + { + c = trans ? trans[(unsigned char) *--beg] : *--beg; + tree = trie->links; + while (tree && c != tree->label) + if (c < tree->label) + tree = tree->llink; + else + tree = tree->rlink; + if (tree) + { + trie = tree->trie; + if (trie->accepting && beg <= mch) + { + lmch = beg; + accept = trie; + } + } + else + break; + d = trie->shift; + } + if (lmch) + { + mch = lmch; + goto match; + } + if (!d) + d = 1; + } + + if (kwsmatch) + { + kwsmatch->index = accept->accepting / 2; + kwsmatch->offset[0] = mch - text; + kwsmatch->size[0] = accept->depth; + } + return mch - text; +} + +/* Search through the given text for a match of any member of the + given keyword set. Return a pointer to the first character of + the matching substring, or NULL if no match is found. If FOUNDLEN + is non-NULL store in the referenced location the length of the + matching substring. Similarly, if FOUNDIDX is non-NULL, store + in the referenced location the index number of the particular + keyword matched. */ +size_t +kwsexec (kwset_t kws, char const *text, size_t size, + struct kwsmatch *kwsmatch) +{ + struct kwset const *kwset = (struct kwset *) kws; + if (kwset->words == 1 && kwset->trans == 0) + { + size_t ret = bmexec (kws, text, size); + if (kwsmatch != 0 && ret != (size_t) -1) + { + kwsmatch->index = 0; + kwsmatch->offset[0] = ret; + kwsmatch->size[0] = kwset->mind; + } + return ret; + } + else + return cwexec(kws, text, size, kwsmatch); +} + +/* Free the components of the given keyword set. */ +void +kwsfree (kwset_t kws) +{ + struct kwset *kwset; + + kwset = (struct kwset *) kws; + obstack_free(&kwset->obstack, 0); + free(kws); +} diff --git a/gnu/usr.bin/grep/kwset.h b/gnu/usr.bin/grep/kwset.h new file mode 100644 index 000000000000..1724f68de11b --- /dev/null +++ b/gnu/usr.bin/grep/kwset.h @@ -0,0 +1,59 @@ +/* kwset.h - header declaring the keyword set library. + Copyright (C) 1989, 1998 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +/* Written August 1989 by Mike Haertel. + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +/* $FreeBSD$ */ + +struct kwsmatch +{ + int index; /* Index number of matching keyword. */ + size_t offset[1]; /* Offset of each submatch. */ + size_t size[1]; /* Length of each submatch. */ +}; + +typedef ptr_t kwset_t; + +/* Return an opaque pointer to a newly allocated keyword set, or NULL + if enough memory cannot be obtained. The argument if non-NULL + specifies a table of character translations to be applied to all + pattern and search text. */ +extern kwset_t kwsalloc PARAMS((char const *)); + +/* Incrementally extend the keyword set to include the given string. + Return NULL for success, or an error message. Remember an index + number for each keyword included in the set. */ +extern char *kwsincr PARAMS((kwset_t, char const *, size_t)); + +/* When the keyword set has been completely built, prepare it for + use. Return NULL for success, or an error message. */ +extern char *kwsprep PARAMS((kwset_t)); + +/* Search through the given buffer for a member of the keyword set. + Return a pointer to the leftmost longest match found, or NULL if + no match is found. If foundlen is non-NULL, store the length of + the matching substring in the integer it points to. Similarly, + if foundindex is non-NULL, store the index of the particular + keyword found therein. */ +extern size_t kwsexec PARAMS((kwset_t, char const *, size_t, struct kwsmatch *)); + +/* Deallocate the given keyword set and all its associated storage. */ +extern void kwsfree PARAMS((kwset_t)); + diff --git a/gnu/usr.bin/grep/obstack.c b/gnu/usr.bin/grep/obstack.c new file mode 100644 index 000000000000..17c63134315a --- /dev/null +++ b/gnu/usr.bin/grep/obstack.c @@ -0,0 +1,598 @@ +/* obstack.c - subroutines used implicitly by object stack macros + Copyright (C) 1988-1994,96,97,98,99 Free Software Foundation, Inc. + + This file is part of the GNU C Library. Its master source is NOT part of + the C library, however. The master source lives in /gd/gnu/lib. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "obstack.h" + +/* NOTE BEFORE MODIFYING THIS FILE: This version number must be + incremented whenever callers compiled using an old obstack.h can no + longer properly call the functions in this obstack.c. */ +#define OBSTACK_INTERFACE_VERSION 1 + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself, and the installed library + supports the same library interface we do. This code is part of the GNU + C Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object + files, it is simpler to just do this in the source for each such file. */ + +#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */ +#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 +#include <gnu-versions.h> +#if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION +#define ELIDE_CODE +#endif +#endif + + +#ifndef ELIDE_CODE + + +#if defined (__STDC__) && __STDC__ +#define POINTER void * +#else +#define POINTER char * +#endif + +/* Determine default alignment. */ +struct fooalign {char x; double d;}; +#define DEFAULT_ALIGNMENT \ + ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0)) +/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. + But in fact it might be less smart and round addresses to as much as + DEFAULT_ROUNDING. So we prepare for it to do that. */ +union fooround {long x; double d;}; +#define DEFAULT_ROUNDING (sizeof (union fooround)) + +/* When we copy a long block of data, this is the unit to do it with. + On some machines, copying successive ints does not work; + in such a case, redefine COPYING_UNIT to `long' (if that works) + or `char' as a last resort. */ +#ifndef COPYING_UNIT +#define COPYING_UNIT int +#endif + + +/* The functions allocating more room by calling `obstack_chunk_alloc' + jump to the handler pointed to by `obstack_alloc_failed_handler'. + This can be set to a user defined function which should either + abort gracefully or use longjump - but shouldn't return. This + variable by default points to the internal function + `print_and_abort'. */ +#if defined (__STDC__) && __STDC__ +static void print_and_abort (void); +void (*obstack_alloc_failed_handler) (void) = print_and_abort; +#else +static void print_and_abort (); +void (*obstack_alloc_failed_handler) () = print_and_abort; +#endif + +/* Exit value used when `print_and_abort' is used. */ +#if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifndef EXIT_FAILURE +#define EXIT_FAILURE 1 +#endif +int obstack_exit_failure = EXIT_FAILURE; + +/* The non-GNU-C macros copy the obstack into this global variable + to avoid multiple evaluation. */ + +struct obstack *_obstack; + +/* Define a macro that either calls functions with the traditional malloc/free + calling interface, or calls functions with the mmalloc/mfree interface + (that adds an extra first argument), based on the state of use_extra_arg. + For free, do not use ?:, since some compilers, like the MIPS compilers, + do not allow (expr) ? void : void. */ + +#if defined (__STDC__) && __STDC__ +#define CALL_CHUNKFUN(h, size) \ + (((h) -> use_extra_arg) \ + ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ + : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size))) + +#define CALL_FREEFUN(h, old_chunk) \ + do { \ + if ((h) -> use_extra_arg) \ + (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ + else \ + (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \ + } while (0) +#else +#define CALL_CHUNKFUN(h, size) \ + (((h) -> use_extra_arg) \ + ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ + : (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size))) + +#define CALL_FREEFUN(h, old_chunk) \ + do { \ + if ((h) -> use_extra_arg) \ + (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ + else \ + (*(void (*) ()) (h)->freefun) ((old_chunk)); \ + } while (0) +#endif + + +/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). + Objects start on multiples of ALIGNMENT (0 means use default). + CHUNKFUN is the function to use to allocate chunks, + and FREEFUN the function to free them. + + Return nonzero if successful, calls obstack_alloc_failed_handler if + allocation fails. */ + +int +_obstack_begin (h, size, alignment, chunkfun, freefun) + struct obstack *h; + int size; + int alignment; +#if defined (__STDC__) && __STDC__ + POINTER (*chunkfun) (long); + void (*freefun) (void *); +#else + POINTER (*chunkfun) (); + void (*freefun) (); +#endif +{ + register struct _obstack_chunk *chunk; /* points to new chunk */ + + if (alignment == 0) + alignment = (int) DEFAULT_ALIGNMENT; + if (size == 0) + /* Default size is what GNU malloc can fit in a 4096-byte block. */ + { + /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. + Use the values for range checking, because if range checking is off, + the extra bytes won't be missed terribly, but if range checking is on + and we used a larger request, a whole extra 4096 bytes would be + allocated. + + These number are irrelevant to the new GNU malloc. I suspect it is + less sensitive to the size of the request. */ + int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) + + 4 + DEFAULT_ROUNDING - 1) + & ~(DEFAULT_ROUNDING - 1)); + size = 4096 - extra; + } + +#if defined (__STDC__) && __STDC__ + h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun; + h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; +#else + h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; + h->freefun = freefun; +#endif + h->chunk_size = size; + h->alignment_mask = alignment - 1; + h->use_extra_arg = 0; + + chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); + if (!chunk) + (*obstack_alloc_failed_handler) (); + h->next_free = h->object_base = chunk->contents; + h->chunk_limit = chunk->limit + = (char *) chunk + h->chunk_size; + chunk->prev = 0; + /* The initial chunk now contains no empty object. */ + h->maybe_empty_object = 0; + h->alloc_failed = 0; + return 1; +} + +int +_obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg) + struct obstack *h; + int size; + int alignment; +#if defined (__STDC__) && __STDC__ + POINTER (*chunkfun) (POINTER, long); + void (*freefun) (POINTER, POINTER); +#else + POINTER (*chunkfun) (); + void (*freefun) (); +#endif + POINTER arg; +{ + register struct _obstack_chunk *chunk; /* points to new chunk */ + + if (alignment == 0) + alignment = (int) DEFAULT_ALIGNMENT; + if (size == 0) + /* Default size is what GNU malloc can fit in a 4096-byte block. */ + { + /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. + Use the values for range checking, because if range checking is off, + the extra bytes won't be missed terribly, but if range checking is on + and we used a larger request, a whole extra 4096 bytes would be + allocated. + + These number are irrelevant to the new GNU malloc. I suspect it is + less sensitive to the size of the request. */ + int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) + + 4 + DEFAULT_ROUNDING - 1) + & ~(DEFAULT_ROUNDING - 1)); + size = 4096 - extra; + } + +#if defined(__STDC__) && __STDC__ + h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun; + h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; +#else + h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; + h->freefun = freefun; +#endif + h->chunk_size = size; + h->alignment_mask = alignment - 1; + h->extra_arg = arg; + h->use_extra_arg = 1; + + chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); + if (!chunk) + (*obstack_alloc_failed_handler) (); + h->next_free = h->object_base = chunk->contents; + h->chunk_limit = chunk->limit + = (char *) chunk + h->chunk_size; + chunk->prev = 0; + /* The initial chunk now contains no empty object. */ + h->maybe_empty_object = 0; + h->alloc_failed = 0; + return 1; +} + +/* Allocate a new current chunk for the obstack *H + on the assumption that LENGTH bytes need to be added + to the current object, or a new object of length LENGTH allocated. + Copies any partial object from the end of the old chunk + to the beginning of the new one. */ + +void +_obstack_newchunk (h, length) + struct obstack *h; + int length; +{ + register struct _obstack_chunk *old_chunk = h->chunk; + register struct _obstack_chunk *new_chunk; + register long new_size; + register long obj_size = h->next_free - h->object_base; + register long i; + long already; + + /* Compute size for new chunk. */ + new_size = (obj_size + length) + (obj_size >> 3) + 100; + if (new_size < h->chunk_size) + new_size = h->chunk_size; + + /* Allocate and initialize the new chunk. */ + new_chunk = CALL_CHUNKFUN (h, new_size); + if (!new_chunk) + (*obstack_alloc_failed_handler) (); + h->chunk = new_chunk; + new_chunk->prev = old_chunk; + new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; + + /* Move the existing object to the new chunk. + Word at a time is fast and is safe if the object + is sufficiently aligned. */ + if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) + { + for (i = obj_size / sizeof (COPYING_UNIT) - 1; + i >= 0; i--) + ((COPYING_UNIT *)new_chunk->contents)[i] + = ((COPYING_UNIT *)h->object_base)[i]; + /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, + but that can cross a page boundary on a machine + which does not do strict alignment for COPYING_UNITS. */ + already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); + } + else + already = 0; + /* Copy remaining bytes one by one. */ + for (i = already; i < obj_size; i++) + new_chunk->contents[i] = h->object_base[i]; + + /* If the object just copied was the only data in OLD_CHUNK, + free that chunk and remove it from the chain. + But not if that chunk might contain an empty object. */ + if (h->object_base == old_chunk->contents && ! h->maybe_empty_object) + { + new_chunk->prev = old_chunk->prev; + CALL_FREEFUN (h, old_chunk); + } + + h->object_base = new_chunk->contents; + h->next_free = h->object_base + obj_size; + /* The new chunk certainly contains no empty object yet. */ + h->maybe_empty_object = 0; +} + +/* Return nonzero if object OBJ has been allocated from obstack H. + This is here for debugging. + If you use it in a program, you are probably losing. */ + +#if defined (__STDC__) && __STDC__ +/* Suppress -Wmissing-prototypes warning. We don't want to declare this in + obstack.h because it is just for debugging. */ +int _obstack_allocated_p (struct obstack *h, POINTER obj); +#endif + +int +_obstack_allocated_p (h, obj) + struct obstack *h; + POINTER obj; +{ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ + + lp = (h)->chunk; + /* We use >= rather than > since the object cannot be exactly at + the beginning of the chunk but might be an empty object exactly + at the end of an adjacent chunk. */ + while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) + { + plp = lp->prev; + lp = plp; + } + return lp != 0; +} + +/* Free objects in obstack H, including OBJ and everything allocate + more recently than OBJ. If OBJ is zero, free everything in H. */ + +#undef obstack_free + +/* This function has two names with identical definitions. + This is the first one, called from non-ANSI code. */ + +void +_obstack_free (h, obj) + struct obstack *h; + POINTER obj; +{ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ + + lp = h->chunk; + /* We use >= because there cannot be an object at the beginning of a chunk. + But there can be an empty object at that address + at the end of another chunk. */ + while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) + { + plp = lp->prev; + CALL_FREEFUN (h, lp); + lp = plp; + /* If we switch chunks, we can't tell whether the new current + chunk contains an empty object, so assume that it may. */ + h->maybe_empty_object = 1; + } + if (lp) + { + h->object_base = h->next_free = (char *) (obj); + h->chunk_limit = lp->limit; + h->chunk = lp; + } + else if (obj != 0) + /* obj is not in any of the chunks! */ + abort (); +} + +/* This function is used from ANSI code. */ + +void +obstack_free (h, obj) + struct obstack *h; + POINTER obj; +{ + register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ + register struct _obstack_chunk *plp; /* point to previous chunk if any */ + + lp = h->chunk; + /* We use >= because there cannot be an object at the beginning of a chunk. + But there can be an empty object at that address + at the end of another chunk. */ + while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) + { + plp = lp->prev; + CALL_FREEFUN (h, lp); + lp = plp; + /* If we switch chunks, we can't tell whether the new current + chunk contains an empty object, so assume that it may. */ + h->maybe_empty_object = 1; + } + if (lp) + { + h->object_base = h->next_free = (char *) (obj); + h->chunk_limit = lp->limit; + h->chunk = lp; + } + else if (obj != 0) + /* obj is not in any of the chunks! */ + abort (); +} + +int +_obstack_memory_used (h) + struct obstack *h; +{ + register struct _obstack_chunk* lp; + register int nbytes = 0; + + for (lp = h->chunk; lp != 0; lp = lp->prev) + { + nbytes += lp->limit - (char *) lp; + } + return nbytes; +} + +/* Define the error handler. */ +#ifndef _ +# ifdef HAVE_LIBINTL_H +# include <libintl.h> +# ifndef _ +# define _(Str) gettext (Str) +# endif +# else +# define _(Str) (Str) +# endif +#endif +#if defined _LIBC && defined USE_IN_LIBIO +# include <libio/iolibio.h> +# define fputs(s, f) _IO_fputs (s, f) +#endif + +static void +print_and_abort () +{ + fputs (_("memory exhausted"), stderr); + fputc ('\n', stderr); + exit (obstack_exit_failure); +} + +#if 0 +/* These are now turned off because the applications do not use it + and it uses bcopy via obstack_grow, which causes trouble on sysV. */ + +/* Now define the functional versions of the obstack macros. + Define them to simply use the corresponding macros to do the job. */ + +#if defined (__STDC__) && __STDC__ +/* These function definitions do not work with non-ANSI preprocessors; + they won't pass through the macro names in parentheses. */ + +/* The function names appear in parentheses in order to prevent + the macro-definitions of the names from being expanded there. */ + +POINTER (obstack_base) (obstack) + struct obstack *obstack; +{ + return obstack_base (obstack); +} + +POINTER (obstack_next_free) (obstack) + struct obstack *obstack; +{ + return obstack_next_free (obstack); +} + +int (obstack_object_size) (obstack) + struct obstack *obstack; +{ + return obstack_object_size (obstack); +} + +int (obstack_room) (obstack) + struct obstack *obstack; +{ + return obstack_room (obstack); +} + +int (obstack_make_room) (obstack, length) + struct obstack *obstack; + int length; +{ + return obstack_make_room (obstack, length); +} + +void (obstack_grow) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + obstack_grow (obstack, pointer, length); +} + +void (obstack_grow0) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + obstack_grow0 (obstack, pointer, length); +} + +void (obstack_1grow) (obstack, character) + struct obstack *obstack; + int character; +{ + obstack_1grow (obstack, character); +} + +void (obstack_blank) (obstack, length) + struct obstack *obstack; + int length; +{ + obstack_blank (obstack, length); +} + +void (obstack_1grow_fast) (obstack, character) + struct obstack *obstack; + int character; +{ + obstack_1grow_fast (obstack, character); +} + +void (obstack_blank_fast) (obstack, length) + struct obstack *obstack; + int length; +{ + obstack_blank_fast (obstack, length); +} + +POINTER (obstack_finish) (obstack) + struct obstack *obstack; +{ + return obstack_finish (obstack); +} + +POINTER (obstack_alloc) (obstack, length) + struct obstack *obstack; + int length; +{ + return obstack_alloc (obstack, length); +} + +POINTER (obstack_copy) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + return obstack_copy (obstack, pointer, length); +} + +POINTER (obstack_copy0) (obstack, pointer, length) + struct obstack *obstack; + POINTER pointer; + int length; +{ + return obstack_copy0 (obstack, pointer, length); +} + +#endif /* __STDC__ */ + +#endif /* 0 */ + +#endif /* !ELIDE_CODE */ diff --git a/gnu/usr.bin/grep/obstack.h b/gnu/usr.bin/grep/obstack.h new file mode 100644 index 000000000000..4d49ce024b15 --- /dev/null +++ b/gnu/usr.bin/grep/obstack.h @@ -0,0 +1,593 @@ +/* obstack.h - object stack macros + Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc. + + This file is part of the GNU C Library. Its master source is NOT part of + the C library, however. The master source lives in /gd/gnu/lib. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Summary: + +All the apparent functions defined here are macros. The idea +is that you would use these pre-tested macros to solve a +very specific set of problems, and they would run fast. +Caution: no side-effects in arguments please!! They may be +evaluated MANY times!! + +These macros operate a stack of objects. Each object starts life +small, and may grow to maturity. (Consider building a word syllable +by syllable.) An object can move while it is growing. Once it has +been "finished" it never changes address again. So the "top of the +stack" is typically an immature growing object, while the rest of the +stack is of mature, fixed size and fixed address objects. + +These routines grab large chunks of memory, using a function you +supply, called `obstack_chunk_alloc'. On occasion, they free chunks, +by calling `obstack_chunk_free'. You must define them and declare +them before using any obstack macros. + +Each independent stack is represented by a `struct obstack'. +Each of the obstack macros expects a pointer to such a structure +as the first argument. + +One motivation for this package is the problem of growing char strings +in symbol tables. Unless you are "fascist pig with a read-only mind" +--Gosper's immortal quote from HAKMEM item 154, out of context--you +would not like to put any arbitrary upper limit on the length of your +symbols. + +In practice this often means you will build many short symbols and a +few long symbols. At the time you are reading a symbol you don't know +how long it is. One traditional method is to read a symbol into a +buffer, realloc()ating the buffer every time you try to read a symbol +that is longer than the buffer. This is beaut, but you still will +want to copy the symbol from the buffer to a more permanent +symbol-table entry say about half the time. + +With obstacks, you can work differently. Use one obstack for all symbol +names. As you read a symbol, grow the name in the obstack gradually. +When the name is complete, finalize it. Then, if the symbol exists already, +free the newly read name. + +The way we do this is to take a large chunk, allocating memory from +low addresses. When you want to build a symbol in the chunk you just +add chars above the current "high water mark" in the chunk. When you +have finished adding chars, because you got to the end of the symbol, +you know how long the chars are, and you can create a new object. +Mostly the chars will not burst over the highest address of the chunk, +because you would typically expect a chunk to be (say) 100 times as +long as an average object. + +In case that isn't clear, when we have enough chars to make up +the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) +so we just point to it where it lies. No moving of chars is +needed and this is the second win: potentially long strings need +never be explicitly shuffled. Once an object is formed, it does not +change its address during its lifetime. + +When the chars burst over a chunk boundary, we allocate a larger +chunk, and then copy the partly formed object from the end of the old +chunk to the beginning of the new larger chunk. We then carry on +accreting characters to the end of the object as we normally would. + +A special macro is provided to add a single char at a time to a +growing object. This allows the use of register variables, which +break the ordinary 'growth' macro. + +Summary: + We allocate large chunks. + We carve out one object at a time from the current chunk. + Once carved, an object never moves. + We are free to append data of any size to the currently + growing object. + Exactly one object is growing in an obstack at any one time. + You can run one obstack per control block. + You may have as many control blocks as you dare. + Because of the way we do it, you can `unwind' an obstack + back to a previous state. (You may remove objects much + as you would with a stack.) +*/ + + +/* Don't do the contents of this file more than once. */ + +#ifndef _OBSTACK_H +#define _OBSTACK_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* We use subtraction of (char *) 0 instead of casting to int + because on word-addressable machines a simple cast to int + may ignore the byte-within-word field of the pointer. */ + +#ifndef __PTR_TO_INT +# define __PTR_TO_INT(P) ((P) - (char *) 0) +#endif + +#ifndef __INT_TO_PTR +# define __INT_TO_PTR(P) ((P) + (char *) 0) +#endif + +/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is + defined, as with GNU C, use that; that way we don't pollute the + namespace with <stddef.h>'s symbols. Otherwise, if <stddef.h> is + available, include it and use ptrdiff_t. In traditional C, long is + the best that we can do. */ + +#ifdef __PTRDIFF_TYPE__ +# define PTR_INT_TYPE __PTRDIFF_TYPE__ +#else +# ifdef HAVE_STDDEF_H +# include <stddef.h> +# define PTR_INT_TYPE ptrdiff_t +# else +# define PTR_INT_TYPE long +# endif +#endif + +#if defined _LIBC || defined HAVE_STRING_H +# include <string.h> +# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) +#else +# ifdef memcpy +# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) +# else +# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N)) +# endif +#endif + +struct _obstack_chunk /* Lives at front of each chunk. */ +{ + char *limit; /* 1 past end of this chunk */ + struct _obstack_chunk *prev; /* address of prior chunk or NULL */ + char contents[4]; /* objects begin here */ +}; + +struct obstack /* control current object in current chunk */ +{ + long chunk_size; /* preferred size to allocate chunks in */ + struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ + char *object_base; /* address of object we are building */ + char *next_free; /* where to add next char to current object */ + char *chunk_limit; /* address of char after current chunk */ + PTR_INT_TYPE temp; /* Temporary for some macros. */ + int alignment_mask; /* Mask of alignment for each object. */ +#if defined __STDC__ && __STDC__ + /* These prototypes vary based on `use_extra_arg', and we use + casts to the prototypeless function type in all assignments, + but having prototypes here quiets -Wstrict-prototypes. */ + struct _obstack_chunk *(*chunkfun) (void *, long); + void (*freefun) (void *, struct _obstack_chunk *); + void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ +#else + struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ + void (*freefun) (); /* User's function to free a chunk. */ + char *extra_arg; /* first arg for chunk alloc/dealloc funcs */ +#endif + unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ + unsigned maybe_empty_object:1;/* There is a possibility that the current + chunk contains a zero-length object. This + prevents freeing the chunk if we allocate + a bigger chunk to replace it. */ + unsigned alloc_failed:1; /* No longer used, as we now call the failed + handler on error, but retained for binary + compatibility. */ +}; + +/* Declare the external functions we use; they are in obstack.c. */ + +#if defined __STDC__ && __STDC__ +extern void _obstack_newchunk (struct obstack *, int); +extern void _obstack_free (struct obstack *, void *); +extern int _obstack_begin (struct obstack *, int, int, + void *(*) (long), void (*) (void *)); +extern int _obstack_begin_1 (struct obstack *, int, int, + void *(*) (void *, long), + void (*) (void *, void *), void *); +extern int _obstack_memory_used (struct obstack *); +#else +extern void _obstack_newchunk (); +extern void _obstack_free (); +extern int _obstack_begin (); +extern int _obstack_begin_1 (); +extern int _obstack_memory_used (); +#endif + +#if defined __STDC__ && __STDC__ + +/* Do the function-declarations after the structs + but before defining the macros. */ + +void obstack_init (struct obstack *obstack); + +void * obstack_alloc (struct obstack *obstack, int size); + +void * obstack_copy (struct obstack *obstack, void *address, int size); +void * obstack_copy0 (struct obstack *obstack, void *address, int size); + +void obstack_free (struct obstack *obstack, void *block); + +void obstack_blank (struct obstack *obstack, int size); + +void obstack_grow (struct obstack *obstack, void *data, int size); +void obstack_grow0 (struct obstack *obstack, void *data, int size); + +void obstack_1grow (struct obstack *obstack, int data_char); +void obstack_ptr_grow (struct obstack *obstack, void *data); +void obstack_int_grow (struct obstack *obstack, int data); + +void * obstack_finish (struct obstack *obstack); + +int obstack_object_size (struct obstack *obstack); + +int obstack_room (struct obstack *obstack); +void obstack_make_room (struct obstack *obstack, int size); +void obstack_1grow_fast (struct obstack *obstack, int data_char); +void obstack_ptr_grow_fast (struct obstack *obstack, void *data); +void obstack_int_grow_fast (struct obstack *obstack, int data); +void obstack_blank_fast (struct obstack *obstack, int size); + +void * obstack_base (struct obstack *obstack); +void * obstack_next_free (struct obstack *obstack); +int obstack_alignment_mask (struct obstack *obstack); +int obstack_chunk_size (struct obstack *obstack); +int obstack_memory_used (struct obstack *obstack); + +#endif /* __STDC__ */ + +/* Non-ANSI C cannot really support alternative functions for these macros, + so we do not declare them. */ + +/* Error handler called when `obstack_chunk_alloc' failed to allocate + more memory. This can be set to a user defined function which + should either abort gracefully or use longjump - but shouldn't + return. The default action is to print a message and abort. */ +#if defined __STDC__ && __STDC__ +extern void (*obstack_alloc_failed_handler) (void); +#else +extern void (*obstack_alloc_failed_handler) (); +#endif + +/* Exit value used when `print_and_abort' is used. */ +extern int obstack_exit_failure; + +/* Pointer to beginning of object being allocated or to be allocated next. + Note that this might not be the final address of the object + because a new chunk might be needed to hold the final size. */ + +#define obstack_base(h) ((h)->object_base) + +/* Size for allocating ordinary chunks. */ + +#define obstack_chunk_size(h) ((h)->chunk_size) + +/* Pointer to next byte not yet allocated in current chunk. */ + +#define obstack_next_free(h) ((h)->next_free) + +/* Mask specifying low bits that should be clear in address of an object. */ + +#define obstack_alignment_mask(h) ((h)->alignment_mask) + +/* To prevent prototype warnings provide complete argument list in + standard C version. */ +#if defined __STDC__ && __STDC__ + +# define obstack_init(h) \ + _obstack_begin ((h), 0, 0, \ + (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free) + +# define obstack_begin(h, size) \ + _obstack_begin ((h), (size), 0, \ + (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free) + +# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ + _obstack_begin ((h), (size), (alignment), \ + (void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun)) + +# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ + _obstack_begin_1 ((h), (size), (alignment), \ + (void *(*) (void *, long)) (chunkfun), \ + (void (*) (void *, void *)) (freefun), (arg)) + +# define obstack_chunkfun(h, newchunkfun) \ + ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) + +# define obstack_freefun(h, newfreefun) \ + ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) + +#else + +# define obstack_init(h) \ + _obstack_begin ((h), 0, 0, \ + (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free) + +# define obstack_begin(h, size) \ + _obstack_begin ((h), (size), 0, \ + (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free) + +# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ + _obstack_begin ((h), (size), (alignment), \ + (void *(*) ()) (chunkfun), (void (*) ()) (freefun)) + +# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ + _obstack_begin_1 ((h), (size), (alignment), \ + (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg)) + +# define obstack_chunkfun(h, newchunkfun) \ + ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun)) + +# define obstack_freefun(h, newfreefun) \ + ((h) -> freefun = (void (*)()) (newfreefun)) + +#endif + +#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) + +#define obstack_blank_fast(h,n) ((h)->next_free += (n)) + +#define obstack_memory_used(h) _obstack_memory_used (h) + +#if defined __GNUC__ && defined __STDC__ && __STDC__ +/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and + does not implement __extension__. But that compiler doesn't define + __GNUC_MINOR__. */ +# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) +# define __extension__ +# endif + +/* For GNU C, if not -traditional, + we can define these macros to compute all args only once + without using a global variable. + Also, we can avoid using the `temp' slot, to make faster code. */ + +# define obstack_object_size(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + (unsigned) (__o->next_free - __o->object_base); }) + +# define obstack_room(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + (unsigned) (__o->chunk_limit - __o->next_free); }) + +# define obstack_make_room(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->chunk_limit - __o->next_free < __len) \ + _obstack_newchunk (__o, __len); \ + (void) 0; }) + +# define obstack_empty_p(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); }) + +# define obstack_grow(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->next_free + __len > __o->chunk_limit) \ + _obstack_newchunk (__o, __len); \ + _obstack_memcpy (__o->next_free, (char *) (where), __len); \ + __o->next_free += __len; \ + (void) 0; }) + +# define obstack_grow0(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->next_free + __len + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, __len + 1); \ + _obstack_memcpy (__o->next_free, (char *) (where), __len); \ + __o->next_free += __len; \ + *(__o->next_free)++ = 0; \ + (void) 0; }) + +# define obstack_1grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, 1); \ + *(__o->next_free)++ = (datum); \ + (void) 0; }) + +/* These assume that the obstack alignment is good enough for pointers or ints, + and that the data added so far to the current object + shares that much alignment. */ + +# define obstack_ptr_grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ + _obstack_newchunk (__o, sizeof (void *)); \ + *((void **)__o->next_free)++ = ((void *)datum); \ + (void) 0; }) + +# define obstack_int_grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + sizeof (int) > __o->chunk_limit) \ + _obstack_newchunk (__o, sizeof (int)); \ + *((int *)__o->next_free)++ = ((int)datum); \ + (void) 0; }) + +# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr) +# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint) + +# define obstack_blank(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->chunk_limit - __o->next_free < __len) \ + _obstack_newchunk (__o, __len); \ + __o->next_free += __len; \ + (void) 0; }) + +# define obstack_alloc(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_blank (__h, (length)); \ + obstack_finish (__h); }) + +# define obstack_copy(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow (__h, (where), (length)); \ + obstack_finish (__h); }) + +# define obstack_copy0(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow0 (__h, (where), (length)); \ + obstack_finish (__h); }) + +/* The local variable is named __o1 to avoid a name conflict + when obstack_blank is called. */ +# define obstack_finish(OBSTACK) \ +__extension__ \ +({ struct obstack *__o1 = (OBSTACK); \ + void *value; \ + value = (void *) __o1->object_base; \ + if (__o1->next_free == value) \ + __o1->maybe_empty_object = 1; \ + __o1->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ + & ~ (__o1->alignment_mask)); \ + if (__o1->next_free - (char *)__o1->chunk \ + > __o1->chunk_limit - (char *)__o1->chunk) \ + __o1->next_free = __o1->chunk_limit; \ + __o1->object_base = __o1->next_free; \ + value; }) + +# define obstack_free(OBSTACK, OBJ) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + void *__obj = (OBJ); \ + if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ + __o->next_free = __o->object_base = (char *)__obj; \ + else (obstack_free) (__o, __obj); }) + +#else /* not __GNUC__ or not __STDC__ */ + +# define obstack_object_size(h) \ + (unsigned) ((h)->next_free - (h)->object_base) + +# define obstack_room(h) \ + (unsigned) ((h)->chunk_limit - (h)->next_free) + +# define obstack_empty_p(h) \ + ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0) + +/* Note that the call to _obstack_newchunk is enclosed in (..., 0) + so that we can avoid having void expressions + in the arms of the conditional expression. + Casting the third operand to void was tried before, + but some compilers won't accept it. */ + +# define obstack_make_room(h,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp), 0) : 0)) + +# define obstack_grow(h,where,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ + _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \ + (h)->next_free += (h)->temp) + +# define obstack_grow0(h,where,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ + _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \ + (h)->next_free += (h)->temp, \ + *((h)->next_free)++ = 0) + +# define obstack_1grow(h,datum) \ +( (((h)->next_free + 1 > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), 1), 0) : 0), \ + (*((h)->next_free)++ = (datum))) + +# define obstack_ptr_grow(h,datum) \ +( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ + (*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum))) + +# define obstack_int_grow(h,datum) \ +( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ + (*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum))) + +# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr) +# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint) + +# define obstack_blank(h,length) \ +( (h)->temp = (length), \ + (((h)->chunk_limit - (h)->next_free < (h)->temp) \ + ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ + ((h)->next_free += (h)->temp)) + +# define obstack_alloc(h,length) \ + (obstack_blank ((h), (length)), obstack_finish ((h))) + +# define obstack_copy(h,where,length) \ + (obstack_grow ((h), (where), (length)), obstack_finish ((h))) + +# define obstack_copy0(h,where,length) \ + (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) + +# define obstack_finish(h) \ +( ((h)->next_free == (h)->object_base \ + ? (((h)->maybe_empty_object = 1), 0) \ + : 0), \ + (h)->temp = __PTR_TO_INT ((h)->object_base), \ + (h)->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ + & ~ ((h)->alignment_mask)), \ + (((h)->next_free - (char *) (h)->chunk \ + > (h)->chunk_limit - (char *) (h)->chunk) \ + ? ((h)->next_free = (h)->chunk_limit) : 0), \ + (h)->object_base = (h)->next_free, \ + __INT_TO_PTR ((h)->temp)) + +# if defined __STDC__ && __STDC__ +# define obstack_free(h,obj) \ +( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ + (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0))) +# else +# define obstack_free(h,obj) \ +( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ + (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0))) +# endif + +#endif /* not __GNUC__ or not __STDC__ */ + +#ifdef __cplusplus +} /* C++ */ +#endif + +#endif /* obstack.h */ diff --git a/gnu/usr.bin/grep/quotearg.c b/gnu/usr.bin/grep/quotearg.c new file mode 100644 index 000000000000..2a7ba4c445ba --- /dev/null +++ b/gnu/usr.bin/grep/quotearg.c @@ -0,0 +1,613 @@ +/* quotearg.c - quote arguments for output + Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Paul Eggert <eggert@twinsun.com> */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#if HAVE_STDDEF_H +# include <stddef.h> /* For the definition of size_t on windows w/MSVC. */ +#endif +#include <sys/types.h> +#include <quotearg.h> +#include <xalloc.h> + +#include <ctype.h> + +#if ENABLE_NLS +# include <libintl.h> +# define _(text) gettext (text) +#else +# define _(text) text +#endif +#define N_(text) text + +#if HAVE_LIMITS_H +# include <limits.h> +#endif +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif +#ifndef UCHAR_MAX +# define UCHAR_MAX ((unsigned char) -1) +#endif + +#if HAVE_C_BACKSLASH_A +# define ALERT_CHAR '\a' +#else +# define ALERT_CHAR '\7' +#endif + +#if HAVE_STDLIB_H +# include <stdlib.h> +#endif + +#if HAVE_STRING_H +# include <string.h> +#endif + +#if HAVE_WCHAR_H +# include <wchar.h> +#endif + +#if !HAVE_MBRTOWC +/* Disable multibyte processing entirely. Since MB_CUR_MAX is 1, the + other macros are defined only for documentation and to satisfy C + syntax. */ +# undef MB_CUR_MAX +# define MB_CUR_MAX 1 +# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0) +# define mbsinit(ps) 1 +# define iswprint(wc) ISPRINT ((unsigned char) (wc)) +#endif + +#ifndef iswprint +# if HAVE_WCTYPE_H +# include <wctype.h> +# endif +# if !defined iswprint && !HAVE_ISWPRINT +# define iswprint(wc) 1 +# endif +#endif + +#define INT_BITS (sizeof (int) * CHAR_BIT) + +#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) +# define IN_CTYPE_DOMAIN(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) isascii(c) +#endif + +/* Undefine to protect against the definition in wctype.h of solaris2.6. */ +#undef ISPRINT +#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) + +struct quoting_options +{ + /* Basic quoting style. */ + enum quoting_style style; + + /* Quote the characters indicated by this bit vector even if the + quoting style would not normally require them to be quoted. */ + int quote_these_too[(UCHAR_MAX / INT_BITS) + 1]; +}; + +/* Names of quoting styles. */ +char const *const quoting_style_args[] = +{ + "literal", + "shell", + "shell-always", + "c", + "escape", + "locale", + "clocale", + 0 +}; + +/* Correspondences to quoting style names. */ +enum quoting_style const quoting_style_vals[] = +{ + literal_quoting_style, + shell_quoting_style, + shell_always_quoting_style, + c_quoting_style, + escape_quoting_style, + locale_quoting_style, + clocale_quoting_style +}; + +/* The default quoting options. */ +static struct quoting_options default_quoting_options; + +/* Allocate a new set of quoting options, with contents initially identical + to O if O is not null, or to the default if O is null. + It is the caller's responsibility to free the result. */ +struct quoting_options * +clone_quoting_options (struct quoting_options *o) +{ + struct quoting_options *p + = (struct quoting_options *) xmalloc (sizeof (struct quoting_options)); + *p = *(o ? o : &default_quoting_options); + return p; +} + +/* Get the value of O's quoting style. If O is null, use the default. */ +enum quoting_style +get_quoting_style (struct quoting_options *o) +{ + return (o ? o : &default_quoting_options)->style; +} + +/* In O (or in the default if O is null), + set the value of the quoting style to S. */ +void +set_quoting_style (struct quoting_options *o, enum quoting_style s) +{ + (o ? o : &default_quoting_options)->style = s; +} + +/* In O (or in the default if O is null), + set the value of the quoting options for character C to I. + Return the old value. Currently, the only values defined for I are + 0 (the default) and 1 (which means to quote the character even if + it would not otherwise be quoted). */ +int +set_char_quoting (struct quoting_options *o, char c, int i) +{ + unsigned char uc = c; + int *p = (o ? o : &default_quoting_options)->quote_these_too + uc / INT_BITS; + int shift = uc % INT_BITS; + int r = (*p >> shift) & 1; + *p ^= ((i & 1) ^ r) << shift; + return r; +} + +/* MSGID approximates a quotation mark. Return its translation if it + has one; otherwise, return either it or "\"", depending on S. */ +static char const * +gettext_quote (char const *msgid, enum quoting_style s) +{ + char const *translation = _(msgid); + if (translation == msgid && s == clocale_quoting_style) + translation = "\""; + return translation; +} + +/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of + argument ARG (of size ARGSIZE), using QUOTING_STYLE and the + non-quoting-style part of O to control quoting. + Terminate the output with a null character, and return the written + size of the output, not counting the terminating null. + If BUFFERSIZE is too small to store the output string, return the + value that would have been returned had BUFFERSIZE been large enough. + If ARGSIZE is -1, use the string length of the argument for ARGSIZE. + + This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG, + ARGSIZE, O), except it uses QUOTING_STYLE instead of the quoting + style specified by O, and O may not be null. */ + +static size_t +quotearg_buffer_restyled (char *buffer, size_t buffersize, + char const *arg, size_t argsize, + enum quoting_style quoting_style, + struct quoting_options const *o) +{ + size_t i; + size_t len = 0; + char const *quote_string = 0; + size_t quote_string_len = 0; + int backslash_escapes = 0; + int unibyte_locale = MB_CUR_MAX == 1; + +#define STORE(c) \ + do \ + { \ + if (len < buffersize) \ + buffer[len] = (c); \ + len++; \ + } \ + while (0) + + switch (quoting_style) + { + case c_quoting_style: + STORE ('"'); + backslash_escapes = 1; + quote_string = "\""; + quote_string_len = 1; + break; + + case escape_quoting_style: + backslash_escapes = 1; + break; + + case locale_quoting_style: + case clocale_quoting_style: + { + /* Get translations for open and closing quotation marks. + + The message catalog should translate "`" to a left + quotation mark suitable for the locale, and similarly for + "'". If the catalog has no translation, + locale_quoting_style quotes `like this', and + clocale_quoting_style quotes "like this". + + For example, an American English Unicode locale should + translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and + should translate "'" to U+201D (RIGHT DOUBLE QUOTATION + MARK). A British English Unicode locale should instead + translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and + U+2019 (RIGHT SINGLE QUOTATION MARK), respectively. */ + + char const *left = gettext_quote (N_("`"), quoting_style); + char const *right = gettext_quote (N_("'"), quoting_style); + for (quote_string = left; *quote_string; quote_string++) + STORE (*quote_string); + backslash_escapes = 1; + quote_string = right; + quote_string_len = strlen (quote_string); + } + break; + + case shell_always_quoting_style: + STORE ('\''); + quote_string = "'"; + quote_string_len = 1; + break; + + default: + break; + } + + for (i = 0; ! (argsize == (size_t) -1 ? arg[i] == '\0' : i == argsize); i++) + { + unsigned char c; + unsigned char esc; + + if (backslash_escapes + && quote_string_len + && i + quote_string_len <= argsize + && memcmp (arg + i, quote_string, quote_string_len) == 0) + STORE ('\\'); + + c = arg[i]; + switch (c) + { + case '?': + switch (quoting_style) + { + case shell_quoting_style: + goto use_shell_always_quoting_style; + + case c_quoting_style: + if (i + 2 < argsize && arg[i + 1] == '?') + switch (arg[i + 2]) + { + case '!': case '\'': + case '(': case ')': case '-': case '/': + case '<': case '=': case '>': + /* Escape the second '?' in what would otherwise be + a trigraph. */ + i += 2; + c = arg[i + 2]; + STORE ('?'); + STORE ('\\'); + STORE ('?'); + break; + } + break; + + default: + break; + } + break; + + case ALERT_CHAR: esc = 'a'; goto c_escape; + case '\b': esc = 'b'; goto c_escape; + case '\f': esc = 'f'; goto c_escape; + case '\n': esc = 'n'; goto c_and_shell_escape; + case '\r': esc = 'r'; goto c_and_shell_escape; + case '\t': esc = 't'; goto c_and_shell_escape; + case '\v': esc = 'v'; goto c_escape; + case '\\': esc = c; goto c_and_shell_escape; + + c_and_shell_escape: + if (quoting_style == shell_quoting_style) + goto use_shell_always_quoting_style; + c_escape: + if (backslash_escapes) + { + c = esc; + goto store_escape; + } + break; + + case '#': case '~': + if (i != 0) + break; + /* Fall through. */ + case ' ': + case '!': /* special in bash */ + case '"': case '$': case '&': + case '(': case ')': case '*': case ';': + case '<': case '>': case '[': + case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */ + case '`': case '|': + /* A shell special character. In theory, '$' and '`' could + be the first bytes of multibyte characters, which means + we should check them with mbrtowc, but in practice this + doesn't happen so it's not worth worrying about. */ + if (quoting_style == shell_quoting_style) + goto use_shell_always_quoting_style; + break; + + case '\'': + switch (quoting_style) + { + case shell_quoting_style: + goto use_shell_always_quoting_style; + + case shell_always_quoting_style: + STORE ('\''); + STORE ('\\'); + STORE ('\''); + break; + + default: + break; + } + break; + + case '%': case '+': case ',': case '-': case '.': case '/': + case '0': case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': case ':': case '=': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': + case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': + case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': + case 'Y': case 'Z': case ']': case '_': case 'a': case 'b': + case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': + case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': + case 'o': case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': + case '{': case '}': + /* These characters don't cause problems, no matter what the + quoting style is. They cannot start multibyte sequences. */ + break; + + default: + /* If we have a multibyte sequence, copy it until we reach + its end, find an error, or come back to the initial shift + state. For C-like styles, if the sequence has + unprintable characters, escape the whole sequence, since + we can't easily escape single characters within it. */ + { + /* Length of multibyte sequence found so far. */ + size_t m; + + int printable; + + if (unibyte_locale) + { + m = 1; + printable = ISPRINT (c); + } + else + { + mbstate_t mbstate; + memset (&mbstate, 0, sizeof mbstate); + + m = 0; + printable = 1; + if (argsize == (size_t) -1) + argsize = strlen (arg); + + do + { + wchar_t w; + size_t bytes = mbrtowc (&w, &arg[i + m], + argsize - (i + m), &mbstate); + if (bytes == 0) + break; + else if (bytes == (size_t) -1) + { + printable = 0; + break; + } + else if (bytes == (size_t) -2) + { + printable = 0; + while (i + m < argsize && arg[i + m]) + m++; + break; + } + else + { + if (! iswprint (w)) + printable = 0; + m += bytes; + } + } + while (! mbsinit (&mbstate)); + } + + if (1 < m || (backslash_escapes && ! printable)) + { + /* Output a multibyte sequence, or an escaped + unprintable unibyte character. */ + size_t ilim = i + m; + + for (;;) + { + if (backslash_escapes && ! printable) + { + STORE ('\\'); + STORE ('0' + (c >> 6)); + STORE ('0' + ((c >> 3) & 7)); + c = '0' + (c & 7); + } + if (ilim <= i + 1) + break; + STORE (c); + c = arg[++i]; + } + + goto store_c; + } + } + } + + if (! (backslash_escapes + && o->quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS)))) + goto store_c; + + store_escape: + STORE ('\\'); + + store_c: + STORE (c); + } + + if (quote_string) + for (; *quote_string; quote_string++) + STORE (*quote_string); + + if (len < buffersize) + buffer[len] = '\0'; + return len; + + use_shell_always_quoting_style: + return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, + shell_always_quoting_style, o); +} + +/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of + argument ARG (of size ARGSIZE), using O to control quoting. + If O is null, use the default. + Terminate the output with a null character, and return the written + size of the output, not counting the terminating null. + If BUFFERSIZE is too small to store the output string, return the + value that would have been returned had BUFFERSIZE been large enough. + If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */ +size_t +quotearg_buffer (char *buffer, size_t buffersize, + char const *arg, size_t argsize, + struct quoting_options const *o) +{ + struct quoting_options const *p = o ? o : &default_quoting_options; + return quotearg_buffer_restyled (buffer, buffersize, arg, argsize, + p->style, p); +} + +/* Use storage slot N to return a quoted version of the string ARG. + OPTIONS specifies the quoting options. + The returned value points to static storage that can be + reused by the next call to this function with the same value of N. + N must be nonnegative. N is deliberately declared with type "int" + to allow for future extensions (using negative values). */ +static char * +quotearg_n_options (int n, char const *arg, + struct quoting_options const *options) +{ + /* Preallocate a slot 0 buffer, so that the caller can always quote + one small component of a "memory exhausted" message in slot 0. */ + static char slot0[256]; + static unsigned int nslots = 1; + struct slotvec + { + size_t size; + char *val; + }; + static struct slotvec slotvec0 = {sizeof slot0, slot0}; + static struct slotvec *slotvec = &slotvec0; + + if (nslots <= n) + { + int n1 = n + 1; + size_t s = n1 * sizeof (struct slotvec); + if (! (0 < n1 && n1 == s / sizeof (struct slotvec))) + abort (); + if (slotvec == &slotvec0) + { + slotvec = (struct slotvec *) xmalloc (sizeof (struct slotvec)); + *slotvec = slotvec0; + } + slotvec = (struct slotvec *) xrealloc (slotvec, s); + memset (slotvec + nslots, 0, (n1 - nslots) * sizeof (struct slotvec)); + nslots = n; + } + + { + size_t size = slotvec[n].size; + char *val = slotvec[n].val; + size_t qsize = quotearg_buffer (val, size, arg, (size_t) -1, options); + + if (size <= qsize) + { + slotvec[n].size = size = qsize + 1; + slotvec[n].val = val = xrealloc (val == slot0 ? 0 : val, size); + quotearg_buffer (val, size, arg, (size_t) -1, options); + } + + return val; + } +} + +char * +quotearg_n (unsigned int n, char const *arg) +{ + return quotearg_n_options (n, arg, &default_quoting_options); +} + +char * +quotearg (char const *arg) +{ + return quotearg_n (0, arg); +} + +char * +quotearg_n_style (unsigned int n, enum quoting_style s, char const *arg) +{ + struct quoting_options o; + o.style = s; + memset (o.quote_these_too, 0, sizeof o.quote_these_too); + return quotearg_n_options (n, arg, &o); +} + +char * +quotearg_style (enum quoting_style s, char const *arg) +{ + return quotearg_n_style (0, s, arg); +} + +char * +quotearg_char (char const *arg, char ch) +{ + struct quoting_options options; + options = default_quoting_options; + set_char_quoting (&options, ch, 1); + return quotearg_n_options (0, arg, &options); +} + +char * +quotearg_colon (char const *arg) +{ + return quotearg_char (arg, ':'); +} diff --git a/gnu/usr.bin/grep/quotearg.h b/gnu/usr.bin/grep/quotearg.h new file mode 100644 index 000000000000..f6463b1aa3bb --- /dev/null +++ b/gnu/usr.bin/grep/quotearg.h @@ -0,0 +1,110 @@ +/* quotearg.h - quote arguments for output + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Paul Eggert <eggert@twinsun.com> */ + +/* Basic quoting styles. */ +enum quoting_style + { + literal_quoting_style, /* --quoting-style=literal */ + shell_quoting_style, /* --quoting-style=shell */ + shell_always_quoting_style, /* --quoting-style=shell-always */ + c_quoting_style, /* --quoting-style=c */ + escape_quoting_style, /* --quoting-style=escape */ + locale_quoting_style, /* --quoting-style=locale */ + clocale_quoting_style /* --quoting-style=clocale */ + }; + +/* For now, --quoting-style=literal is the default, but this may change. */ +#ifndef DEFAULT_QUOTING_STYLE +# define DEFAULT_QUOTING_STYLE literal_quoting_style +#endif + +/* Names of quoting styles and their corresponding values. */ +extern char const *const quoting_style_args[]; +extern enum quoting_style const quoting_style_vals[]; + +struct quoting_options; + +#ifndef PARAMS +# if defined PROTOTYPES || defined __STDC__ +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +/* The functions listed below set and use a hidden variable + that contains the default quoting style options. */ + +/* Allocate a new set of quoting options, with contents initially identical + to O if O is not null, or to the default if O is null. + It is the caller's responsibility to free the result. */ +struct quoting_options *clone_quoting_options + PARAMS ((struct quoting_options *o)); + +/* Get the value of O's quoting style. If O is null, use the default. */ +enum quoting_style get_quoting_style PARAMS ((struct quoting_options *o)); + +/* In O (or in the default if O is null), + set the value of the quoting style to S. */ +void set_quoting_style PARAMS ((struct quoting_options *o, + enum quoting_style s)); + +/* In O (or in the default if O is null), + set the value of the quoting options for character C to I. + Return the old value. Currently, the only values defined for I are + 0 (the default) and 1 (which means to quote the character even if + it would not otherwise be quoted). */ +int set_char_quoting PARAMS ((struct quoting_options *o, char c, int i)); + +/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of + argument ARG (of size ARGSIZE), using O to control quoting. + If O is null, use the default. + Terminate the output with a null character, and return the written + size of the output, not counting the terminating null. + If BUFFERSIZE is too small to store the output string, return the + value that would have been returned had BUFFERSIZE been large enough. + If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */ +size_t quotearg_buffer PARAMS ((char *buffer, size_t buffersize, + char const *arg, size_t argsize, + struct quoting_options const *o)); + +/* Use storage slot N to return a quoted version of the string ARG. + Use the default quoting options. + The returned value points to static storage that can be + reused by the next call to this function with the same value of N. + N must be nonnegative. */ +char *quotearg_n PARAMS ((unsigned int n, char const *arg)); + +/* Equivalent to quotearg_n (0, ARG). */ +char *quotearg PARAMS ((char const *arg)); + +/* Use style S and storage slot N to return a quoted version of the string ARG. + This is like quotearg_n (N, ARG), except that it uses S with no other + options to specify the quoting method. */ +char *quotearg_n_style PARAMS ((unsigned int n, enum quoting_style s, + char const *arg)); + +/* Equivalent to quotearg_n_style (0, S, ARG). */ +char *quotearg_style PARAMS ((enum quoting_style s, char const *arg)); + +/* Like quotearg (ARG), except also quote any instances of CH. */ +char *quotearg_char PARAMS ((char const *arg, char ch)); + +/* Equivalent to quotearg_char (ARG, ':'). */ +char *quotearg_colon PARAMS ((char const *arg)); diff --git a/gnu/usr.bin/grep/savedir.c b/gnu/usr.bin/grep/savedir.c new file mode 100644 index 000000000000..6aabe31e793c --- /dev/null +++ b/gnu/usr.bin/grep/savedir.c @@ -0,0 +1,183 @@ +/* savedir.c -- save the list of files in a directory in a string + Copyright (C) 1990, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include <sys/types.h> + +#if HAVE_UNISTD_H +# include <unistd.h> +#endif + +#if HAVE_DIRENT_H +# include <dirent.h> +# define NAMLEN(dirent) strlen((dirent)->d_name) +#else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include <sys/ndir.h> +# endif +# if HAVE_SYS_DIR_H +# include <sys/dir.h> +# endif +# if HAVE_NDIR_H +# include <ndir.h> +# endif +#endif + +#ifdef CLOSEDIR_VOID +/* Fake a return value. */ +# define CLOSEDIR(d) (closedir (d), 0) +#else +# define CLOSEDIR(d) closedir (d) +#endif + +#ifdef STDC_HEADERS +# include <stdlib.h> +# include <string.h> +#else +char *malloc (); +char *realloc (); +#endif +#ifndef NULL +# define NULL 0 +#endif + +#ifndef stpcpy +char *stpcpy (); +#endif + +#include <fnmatch.h> +#include "savedir.h" +#include "system.h" + +char *path; +size_t pathlen; + +static int +isdir1 (const char *dir, const char *file) +{ + int status; + int slash; + size_t dirlen = strlen (dir); + size_t filelen = strlen (file); + if ((dirlen + filelen + 2) > pathlen) + { + path = calloc (dirlen + 1 + filelen + 1, sizeof (*path)); + pathlen = dirlen + filelen + 2; + } + strcpy (path, dir); + slash = (path[dirlen] != '/'); + path[dirlen] = '/'; + strcpy (path + dirlen + slash , file); + status = isdir (path); + return status; +} + +/* Return a freshly allocated string containing the filenames + in directory DIR, separated by '\0' characters; + the end is marked by two '\0' characters in a row. + NAME_SIZE is the number of bytes to initially allocate + for the string; it will be enlarged as needed. + Return NULL if DIR cannot be opened or if out of memory. */ +char * +savedir (const char *dir, off_t name_size, struct exclude *included_patterns, + struct exclude *excluded_patterns) +{ + DIR *dirp; + struct dirent *dp; + char *name_space; + char *namep; + + dirp = opendir (dir); + if (dirp == NULL) + return NULL; + + /* Be sure name_size is at least `1' so there's room for + the final NUL byte. */ + if (name_size <= 0) + name_size = 1; + + name_space = (char *) malloc (name_size); + if (name_space == NULL) + { + closedir (dirp); + return NULL; + } + namep = name_space; + + while ((dp = readdir (dirp)) != NULL) + { + /* Skip "." and ".." (some NFS filesystems' directories lack them). */ + if (dp->d_name[0] != '.' + || (dp->d_name[1] != '\0' + && (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) + { + off_t size_needed = (namep - name_space) + NAMLEN (dp) + 2; + + if ((included_patterns || excluded_patterns) + && !isdir1 (dir, dp->d_name)) + { + if (included_patterns + && !excluded_filename (included_patterns, path, 0)) + continue; + if (excluded_patterns + && excluded_filename (excluded_patterns, path, 0)) + continue; + } + + if (size_needed > name_size) + { + char *new_name_space; + + while (size_needed > name_size) + name_size += 1024; + + new_name_space = realloc (name_space, name_size); + if (new_name_space == NULL) + { + closedir (dirp); + return NULL; + } + namep += new_name_space - name_space; + name_space = new_name_space; + } + namep = stpcpy (namep, dp->d_name) + 1; + } + } + *namep = '\0'; + if (CLOSEDIR (dirp)) + { + free (name_space); + return NULL; + } + if (path) + { + free (path); + path = NULL; + pathlen = 0; + } + return name_space; +} diff --git a/gnu/usr.bin/grep/savedir.h b/gnu/usr.bin/grep/savedir.h new file mode 100644 index 000000000000..49c331b587b6 --- /dev/null +++ b/gnu/usr.bin/grep/savedir.h @@ -0,0 +1,18 @@ +#if !defined SAVEDIR_H_ +# define SAVEDIR_H_ + +#include "exclude.h" + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +extern char * +savedir PARAMS ((const char *dir, off_t name_size, + struct exclude *, struct exclude *)); + +#endif diff --git a/gnu/usr.bin/grep/search.c b/gnu/usr.bin/grep/search.c new file mode 100644 index 000000000000..96ee18197434 --- /dev/null +++ b/gnu/usr.bin/grep/search.c @@ -0,0 +1,1290 @@ +/* search.c - searching subroutines using dfa, kwset and regex for grep. + Copyright 1992, 1998, 2000 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +/* Written August 1992 by Mike Haertel. */ + +/* $FreeBSD$ */ + +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#include <assert.h> +#include <sys/types.h> +#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC +/* We can handle multibyte string. */ +# define MBS_SUPPORT +# include <wchar.h> +# include <wctype.h> +#endif + +#include "system.h" +#include "grep.h" +#include "regex.h" +#include "dfa.h" +#include "kwset.h" +#include "error.h" +#include "xalloc.h" +#ifdef HAVE_LIBPCRE +# include <pcre.h> +#endif +#ifdef HAVE_LANGINFO_CODESET +# include <langinfo.h> +#endif + +#define NCHAR (UCHAR_MAX + 1) + +/* For -w, we also consider _ to be word constituent. */ +#define WCHAR(C) (ISALNUM(C) || (C) == '_') + +/* DFA compiled regexp. */ +static struct dfa dfa; + +/* The Regex compiled patterns. */ +static struct patterns +{ + /* Regex compiled regexp. */ + struct re_pattern_buffer regexbuf; + struct re_registers regs; /* This is here on account of a BRAIN-DEAD + Q@#%!# library interface in regex.c. */ +} patterns0; + +struct patterns *patterns; +size_t pcount; + +/* KWset compiled pattern. For Ecompile and Gcompile, we compile + a list of strings, at least one of which is known to occur in + any string matching the regexp. */ +static kwset_t kwset; + +/* Number of compiled fixed strings known to exactly match the regexp. + If kwsexec returns < kwset_exact_matches, then we don't need to + call the regexp matcher at all. */ +static int kwset_exact_matches; + +/* UTF-8 encoding allows some optimizations that we can't otherwise + assume in a multibyte encoding. */ +static int using_utf8; + +static void kwsinit PARAMS ((void)); +static void kwsmusts PARAMS ((void)); +static void Gcompile PARAMS ((char const *, size_t)); +static void Ecompile PARAMS ((char const *, size_t)); +static size_t EGexecute PARAMS ((char const *, size_t, size_t *, int )); +static void Fcompile PARAMS ((char const *, size_t)); +static size_t Fexecute PARAMS ((char const *, size_t, size_t *, int)); +static void Pcompile PARAMS ((char const *, size_t )); +static size_t Pexecute PARAMS ((char const *, size_t, size_t *, int)); + +void +check_utf8 (void) +{ +#ifdef HAVE_LANGINFO_CODESET + if (strcmp (nl_langinfo (CODESET), "UTF-8") == 0) + using_utf8 = 1; +#endif +} + +void +dfaerror (char const *mesg) +{ + error (2, 0, mesg); +} + +static void +kwsinit (void) +{ + static char trans[NCHAR]; + size_t i; + + if (match_icase) + for (i = 0; i < NCHAR; ++i) + trans[i] = TOLOWER (i); + + if (!(kwset = kwsalloc (match_icase ? trans : (char *) 0))) + error (2, 0, _("memory exhausted")); +} + +/* If the DFA turns out to have some set of fixed strings one of + which must occur in the match, then we build a kwset matcher + to find those strings, and thus quickly filter out impossible + matches. */ +static void +kwsmusts (void) +{ + struct dfamust const *dm; + char const *err; + + if (dfa.musts) + { + kwsinit (); + /* First, we compile in the substrings known to be exact + matches. The kwset matcher will return the index + of the matching string that it chooses. */ + for (dm = dfa.musts; dm; dm = dm->next) + { + if (!dm->exact) + continue; + ++kwset_exact_matches; + if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != 0) + error (2, 0, err); + } + /* Now, we compile the substrings that will require + the use of the regexp matcher. */ + for (dm = dfa.musts; dm; dm = dm->next) + { + if (dm->exact) + continue; + if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != 0) + error (2, 0, err); + } + if ((err = kwsprep (kwset)) != 0) + error (2, 0, err); + } +} + +static void +Gcompile (char const *pattern, size_t size) +{ + const char *err; + char const *sep; + size_t total = size; + char const *motif = pattern; + + check_utf8 (); + re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE | (match_icase ? RE_ICASE : 0)); + dfasyntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE, match_icase, eolbyte); + + /* For GNU regex compiler we have to pass the patterns separately to detect + errors like "[\nallo\n]\n". The patterns here are "[", "allo" and "]" + GNU regex should have raise a syntax error. The same for backref, where + the backref should have been local to each pattern. */ + do + { + size_t len; + sep = memchr (motif, '\n', total); + if (sep) + { + len = sep - motif; + sep++; + total -= (len + 1); + } + else + { + len = total; + total = 0; + } + + patterns = realloc (patterns, (pcount + 1) * sizeof (*patterns)); + if (patterns == NULL) + error (2, errno, _("memory exhausted")); + + patterns[pcount] = patterns0; + + if ((err = re_compile_pattern (motif, len, + &(patterns[pcount].regexbuf))) != 0) + error (2, 0, err); + pcount++; + + motif = sep; + } while (sep && total != 0); + + /* In the match_words and match_lines cases, we use a different pattern + for the DFA matcher that will quickly throw out cases that won't work. + Then if DFA succeeds we do some hairy stuff using the regex matcher + to decide whether the match should really count. */ + if (match_words || match_lines) + { + /* In the whole-word case, we use the pattern: + \(^\|[^[:alnum:]_]\)\(userpattern\)\([^[:alnum:]_]|$\). + In the whole-line case, we use the pattern: + ^\(userpattern\)$. */ + + static char const line_beg[] = "^\\("; + static char const line_end[] = "\\)$"; + static char const word_beg[] = "\\(^\\|[^[:alnum:]_]\\)\\("; + static char const word_end[] = "\\)\\([^[:alnum:]_]\\|$\\)"; + char *n = xmalloc (sizeof word_beg - 1 + size + sizeof word_end); + size_t i; + strcpy (n, match_lines ? line_beg : word_beg); + i = strlen (n); + memcpy (n + i, pattern, size); + i += size; + strcpy (n + i, match_lines ? line_end : word_end); + i += strlen (n + i); + pattern = n; + size = i; + } + + dfacomp (pattern, size, &dfa, 1); + kwsmusts (); +} + +static void +Ecompile (char const *pattern, size_t size) +{ + const char *err; + const char *sep; + size_t total = size; + char const *motif = pattern; + + check_utf8 (); + if (strcmp (matcher, "awk") == 0) + { + re_set_syntax (RE_SYNTAX_AWK | (match_icase ? RE_ICASE : 0)); + dfasyntax (RE_SYNTAX_AWK, match_icase, eolbyte); + } + else + { + re_set_syntax (RE_SYNTAX_POSIX_EGREP | (match_icase ? RE_ICASE : 0)); + dfasyntax (RE_SYNTAX_POSIX_EGREP, match_icase, eolbyte); + } + + /* For GNU regex compiler we have to pass the patterns separately to detect + errors like "[\nallo\n]\n". The patterns here are "[", "allo" and "]" + GNU regex should have raise a syntax error. The same for backref, where + the backref should have been local to each pattern. */ + do + { + size_t len; + sep = memchr (motif, '\n', total); + if (sep) + { + len = sep - motif; + sep++; + total -= (len + 1); + } + else + { + len = total; + total = 0; + } + + patterns = realloc (patterns, (pcount + 1) * sizeof (*patterns)); + if (patterns == NULL) + error (2, errno, _("memory exhausted")); + patterns[pcount] = patterns0; + + if ((err = re_compile_pattern (motif, len, + &(patterns[pcount].regexbuf))) != 0) + error (2, 0, err); + pcount++; + + motif = sep; + } while (sep && total != 0); + + /* In the match_words and match_lines cases, we use a different pattern + for the DFA matcher that will quickly throw out cases that won't work. + Then if DFA succeeds we do some hairy stuff using the regex matcher + to decide whether the match should really count. */ + if (match_words || match_lines) + { + /* In the whole-word case, we use the pattern: + (^|[^[:alnum:]_])(userpattern)([^[:alnum:]_]|$). + In the whole-line case, we use the pattern: + ^(userpattern)$. */ + + static char const line_beg[] = "^("; + static char const line_end[] = ")$"; + static char const word_beg[] = "(^|[^[:alnum:]_])("; + static char const word_end[] = ")([^[:alnum:]_]|$)"; + char *n = xmalloc (sizeof word_beg - 1 + size + sizeof word_end); + size_t i; + strcpy (n, match_lines ? line_beg : word_beg); + i = strlen(n); + memcpy (n + i, pattern, size); + i += size; + strcpy (n + i, match_lines ? line_end : word_end); + i += strlen (n + i); + pattern = n; + size = i; + } + + dfacomp (pattern, size, &dfa, 1); + kwsmusts (); +} + +static size_t +EGexecute (char const *buf, size_t size, size_t *match_size, int exact) +{ + register char const *buflim, *beg, *end; + char eol = eolbyte; + int backref; + ptrdiff_t start, len; + struct kwsmatch kwsm; + size_t i, ret_val; + static int use_dfa; + static int use_dfa_checked = 0; +#ifdef MBS_SUPPORT + const char *last_char = NULL; + int mb_cur_max = MB_CUR_MAX; + mbstate_t mbs; + memset (&mbs, '\0', sizeof (mbstate_t)); +#endif /* MBS_SUPPORT */ + + if (!use_dfa_checked) + { + char *grep_use_dfa = getenv ("GREP_USE_DFA"); + if (!grep_use_dfa) + { +#ifdef MBS_SUPPORT + /* Turn off DFA when processing multibyte input. */ + use_dfa = (MB_CUR_MAX == 1); +#else + use_dfa = 1; +#endif /* MBS_SUPPORT */ + } + else + { + use_dfa = atoi (grep_use_dfa); + } + + use_dfa_checked = 1; + } + + buflim = buf + size; + + for (beg = end = buf; end < buflim; beg = end) + { + if (!exact) + { + if (kwset) + { + /* Find a possible match using the KWset matcher. */ +#ifdef MBS_SUPPORT + size_t bytes_left = 0; +#endif /* MBS_SUPPORT */ + size_t offset; +#ifdef MBS_SUPPORT + /* kwsexec doesn't work with match_icase and multibyte input. */ + if (match_icase && mb_cur_max > 1) + /* Avoid kwset */ + offset = 0; + else +#endif /* MBS_SUPPORT */ + offset = kwsexec (kwset, beg, buflim - beg, &kwsm); + if (offset == (size_t) -1) + goto failure; +#ifdef MBS_SUPPORT + if (mb_cur_max > 1 && !using_utf8) + { + bytes_left = offset; + while (bytes_left) + { + size_t mlen = mbrlen (beg, bytes_left, &mbs); + + last_char = beg; + if (mlen == (size_t) -1 || mlen == 0) + { + /* Incomplete character: treat as single-byte. */ + memset (&mbs, '\0', sizeof (mbstate_t)); + beg++; + bytes_left--; + continue; + } + + if (mlen == (size_t) -2) + /* Offset points inside multibyte character: + * no good. */ + break; + + beg += mlen; + bytes_left -= mlen; + } + } + else +#endif /* MBS_SUPPORT */ + beg += offset; + /* Narrow down to the line containing the candidate, and + run it through DFA. */ + end = memchr(beg, eol, buflim - beg); + end++; +#ifdef MBS_SUPPORT + if (mb_cur_max > 1 && bytes_left) + continue; +#endif /* MBS_SUPPORT */ + while (beg > buf && beg[-1] != eol) + --beg; + if ( +#ifdef MBS_SUPPORT + !(match_icase && mb_cur_max > 1) && +#endif /* MBS_SUPPORT */ + (kwsm.index < kwset_exact_matches)) + goto success_in_beg_and_end; + if (use_dfa && + dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1) + continue; + } + else + { + /* No good fixed strings; start with DFA. */ +#ifdef MBS_SUPPORT + size_t bytes_left = 0; +#endif /* MBS_SUPPORT */ + size_t offset = 0; + if (use_dfa) + offset = dfaexec (&dfa, beg, buflim - beg, &backref); + if (offset == (size_t) -1) + break; + /* Narrow down to the line we've found. */ +#ifdef MBS_SUPPORT + if (mb_cur_max > 1 && !using_utf8) + { + bytes_left = offset; + while (bytes_left) + { + size_t mlen = mbrlen (beg, bytes_left, &mbs); + + last_char = beg; + if (mlen == (size_t) -1 || mlen == 0) + { + /* Incomplete character: treat as single-byte. */ + memset (&mbs, '\0', sizeof (mbstate_t)); + beg++; + bytes_left--; + continue; + } + + if (mlen == (size_t) -2) + /* Offset points inside multibyte character: + * no good. */ + break; + + beg += mlen; + bytes_left -= mlen; + } + } + else +#endif /* MBS_SUPPORT */ + beg += offset; + end = memchr (beg, eol, buflim - beg); + end++; +#ifdef MBS_SUPPORT + if (mb_cur_max > 1 && bytes_left) + continue; +#endif /* MBS_SUPPORT */ + while (beg > buf && beg[-1] != eol) + --beg; + } + /* Successful, no backreferences encountered! */ + if (use_dfa && !backref) + goto success_in_beg_and_end; + } + else + end = beg + size; + + /* If we've made it to this point, this means DFA has seen + a probable match, and we need to run it through Regex. */ + for (i = 0; i < pcount; i++) + { + patterns[i].regexbuf.not_eol = 0; + if (0 <= (start = re_search (&(patterns[i].regexbuf), beg, + end - beg - 1, 0, + end - beg - 1, &(patterns[i].regs)))) + { + len = patterns[i].regs.end[0] - start; + if (exact && !match_words) + goto success_in_start_and_len; + if ((!match_lines && !match_words) + || (match_lines && len == end - beg - 1)) + goto success_in_beg_and_end; + /* If -w, check if the match aligns with word boundaries. + We do this iteratively because: + (a) the line may contain more than one occurence of the + pattern, and + (b) Several alternatives in the pattern might be valid at a + given point, and we may need to consider a shorter one to + find a word boundary. */ + if (match_words) + while (start >= 0) + { + int lword_match = 0; + if (start == 0) + lword_match = 1; + else + { + assert (start > 0); +#ifdef MBS_SUPPORT + if (mb_cur_max > 1) + { + const char *s; + size_t mr; + wchar_t pwc; + + /* Locate the start of the multibyte character + before the match position (== beg + start). */ + if (using_utf8) + { + /* UTF-8 is a special case: scan backwards + until we find a 7-bit character or a + lead byte. */ + s = beg + start - 1; + while (s > buf + && (unsigned char) *s >= 0x80 + && (unsigned char) *s <= 0xbf) + --s; + } + else + { + /* Scan forwards to find the start of the + last complete character before the + match position. */ + size_t bytes_left = start - 1; + s = beg; + while (bytes_left > 0) + { + mr = mbrlen (s, bytes_left, &mbs); + if (mr == (size_t) -1 || mr == 0) + { + memset (&mbs, '\0', sizeof (mbs)); + s++; + bytes_left--; + continue; + } + if (mr == (size_t) -2) + { + memset (&mbs, '\0', sizeof (mbs)); + break; + } + s += mr; + bytes_left -= mr; + } + } + mr = mbrtowc (&pwc, s, beg + start - s, &mbs); + if (mr == (size_t) -2 || mr == (size_t) -1 || + mr == 0) + { + memset (&mbs, '\0', sizeof (mbstate_t)); + lword_match = 1; + } + else if (!(iswalnum (pwc) || pwc == L'_') + && mr == beg + start - s) + lword_match = 1; + } + else +#endif /* MBS_SUPPORT */ + if (!WCHAR ((unsigned char) beg[start - 1])) + lword_match = 1; + } + + if (lword_match) + { + int rword_match = 0; + if (start + len == end - beg - 1) + rword_match = 1; + else + { +#ifdef MBS_SUPPORT + if (mb_cur_max > 1) + { + wchar_t nwc; + int mr; + + mr = mbtowc (&nwc, beg + start + len, + end - beg - start - len - 1); + if (mr <= 0) + { + memset (&mbs, '\0', sizeof (mbstate_t)); + rword_match = 1; + } + else if (!iswalnum (nwc) && nwc != L'_') + rword_match = 1; + } + else +#endif /* MBS_SUPPORT */ + if (!WCHAR ((unsigned char) beg[start + len])) + rword_match = 1; + } + + if (rword_match) + { + if (!exact) + /* Returns the whole line. */ + goto success_in_beg_and_end; + else + /* Returns just this word match. */ + goto success_in_start_and_len; + } + } + if (len > 0) + { + /* Try a shorter length anchored at the same place. */ + --len; + patterns[i].regexbuf.not_eol = 1; + len = re_match (&(patterns[i].regexbuf), beg, + start + len, start, + &(patterns[i].regs)); + } + if (len <= 0) + { + /* Try looking further on. */ + if (start == end - beg - 1) + break; + ++start; + patterns[i].regexbuf.not_eol = 0; + start = re_search (&(patterns[i].regexbuf), beg, + end - beg - 1, + start, end - beg - 1 - start, + &(patterns[i].regs)); + len = patterns[i].regs.end[0] - start; + } + } + } + } /* for Regex patterns. */ + } /* for (beg = end ..) */ + + failure: + return (size_t) -1; + + success_in_beg_and_end: + len = end - beg; + start = beg - buf; + /* FALLTHROUGH */ + + success_in_start_and_len: + *match_size = len; + return start; +} + +#ifdef MBS_SUPPORT +static int f_i_multibyte; /* whether we're using the new -Fi MB method */ +static struct +{ + wchar_t **patterns; + size_t count, maxlen; + unsigned char *match; +} Fimb; +#endif + +static void +Fcompile (char const *pattern, size_t size) +{ + int mb_cur_max = MB_CUR_MAX; + char const *beg, *lim, *err; + + check_utf8 (); +#ifdef MBS_SUPPORT + /* Support -F -i for UTF-8 input. */ + if (match_icase && mb_cur_max > 1) + { + mbstate_t mbs; + wchar_t *wcpattern = xmalloc ((size + 1) * sizeof (wchar_t)); + const char *patternend = pattern; + size_t wcsize; + kwset_t fimb_kwset = NULL; + char *starts = NULL; + wchar_t *wcbeg, *wclim; + size_t allocated = 0; + + memset (&mbs, '\0', sizeof (mbs)); +# ifdef __GNU_LIBRARY__ + wcsize = mbsnrtowcs (wcpattern, &patternend, size, size, &mbs); + if (patternend != pattern + size) + wcsize = (size_t) -1; +# else + { + char *patterncopy = xmalloc (size + 1); + + memcpy (patterncopy, pattern, size); + patterncopy[size] = '\0'; + patternend = patterncopy; + wcsize = mbsrtowcs (wcpattern, &patternend, size, &mbs); + if (patternend != patterncopy + size) + wcsize = (size_t) -1; + free (patterncopy); + } +# endif + if (wcsize + 2 <= 2) + { +fimb_fail: + free (wcpattern); + free (starts); + if (fimb_kwset) + kwsfree (fimb_kwset); + free (Fimb.patterns); + Fimb.patterns = NULL; + } + else + { + if (!(fimb_kwset = kwsalloc (NULL))) + error (2, 0, _("memory exhausted")); + + starts = xmalloc (mb_cur_max * 3); + wcbeg = wcpattern; + do + { + int i; + size_t wclen; + + if (Fimb.count >= allocated) + { + if (allocated == 0) + allocated = 128; + else + allocated *= 2; + Fimb.patterns = xrealloc (Fimb.patterns, + sizeof (wchar_t *) * allocated); + } + Fimb.patterns[Fimb.count++] = wcbeg; + for (wclim = wcbeg; + wclim < wcpattern + wcsize && *wclim != L'\n'; ++wclim) + *wclim = towlower (*wclim); + *wclim = L'\0'; + wclen = wclim - wcbeg; + if (wclen > Fimb.maxlen) + Fimb.maxlen = wclen; + if (wclen > 3) + wclen = 3; + if (wclen == 0) + { + if ((err = kwsincr (fimb_kwset, "", 0)) != 0) + error (2, 0, err); + } + else + for (i = 0; i < (1 << wclen); i++) + { + char *p = starts; + int j, k; + + for (j = 0; j < wclen; ++j) + { + wchar_t wc = wcbeg[j]; + if (i & (1 << j)) + { + wc = towupper (wc); + if (wc == wcbeg[j]) + continue; + } + k = wctomb (p, wc); + if (k <= 0) + goto fimb_fail; + p += k; + } + if ((err = kwsincr (fimb_kwset, starts, p - starts)) != 0) + error (2, 0, err); + } + if (wclim < wcpattern + wcsize) + ++wclim; + wcbeg = wclim; + } + while (wcbeg < wcpattern + wcsize); + f_i_multibyte = 1; + kwset = fimb_kwset; + free (starts); + Fimb.match = xmalloc (Fimb.count); + if ((err = kwsprep (kwset)) != 0) + error (2, 0, err); + return; + } + } +#endif /* MBS_SUPPORT */ + + + kwsinit (); + beg = pattern; + do + { + for (lim = beg; lim < pattern + size && *lim != '\n'; ++lim) + ; + if ((err = kwsincr (kwset, beg, lim - beg)) != 0) + error (2, 0, err); + if (lim < pattern + size) + ++lim; + beg = lim; + } + while (beg < pattern + size); + + if ((err = kwsprep (kwset)) != 0) + error (2, 0, err); +} + +#ifdef MBS_SUPPORT +static int +Fimbexec (const char *buf, size_t size, size_t *plen, int exact) +{ + size_t len, letter, i; + int ret = -1; + mbstate_t mbs; + wchar_t wc; + int patterns_left; + + assert (match_icase && f_i_multibyte == 1); + assert (MB_CUR_MAX > 1); + + memset (&mbs, '\0', sizeof (mbs)); + memset (Fimb.match, '\1', Fimb.count); + letter = len = 0; + patterns_left = 1; + while (patterns_left && len <= size) + { + size_t c; + + patterns_left = 0; + if (len < size) + { + c = mbrtowc (&wc, buf + len, size - len, &mbs); + if (c + 2 <= 2) + return ret; + + wc = towlower (wc); + } + else + { + c = 1; + wc = L'\0'; + } + + for (i = 0; i < Fimb.count; i++) + { + if (Fimb.match[i]) + { + if (Fimb.patterns[i][letter] == L'\0') + { + /* Found a match. */ + *plen = len; + if (!exact && !match_words) + return 0; + else + { + /* For -w or exact look for longest match. */ + ret = 0; + Fimb.match[i] = '\0'; + continue; + } + } + + if (Fimb.patterns[i][letter] == wc) + patterns_left = 1; + else + Fimb.match[i] = '\0'; + } + } + + len += c; + letter++; + } + + return ret; +} +#endif /* MBS_SUPPORT */ + +static size_t +Fexecute (char const *buf, size_t size, size_t *match_size, int exact) +{ + register char const *beg, *try, *end; + register size_t len; + char eol = eolbyte; + struct kwsmatch kwsmatch; + size_t ret_val; +#ifdef MBS_SUPPORT + int mb_cur_max = MB_CUR_MAX; + mbstate_t mbs; + memset (&mbs, '\0', sizeof (mbstate_t)); + const char *last_char = NULL; +#endif /* MBS_SUPPORT */ + + for (beg = buf; beg <= buf + size; ++beg) + { + size_t offset; + offset = kwsexec (kwset, beg, buf + size - beg, &kwsmatch); + + if (offset == (size_t) -1) + goto failure; +#ifdef MBS_SUPPORT + if (mb_cur_max > 1 && !using_utf8) + { + size_t bytes_left = offset; + while (bytes_left) + { + size_t mlen = mbrlen (beg, bytes_left, &mbs); + + last_char = beg; + if (mlen == (size_t) -1 || mlen == 0) + { + /* Incomplete character: treat as single-byte. */ + memset (&mbs, '\0', sizeof (mbstate_t)); + beg++; + bytes_left--; + continue; + } + + if (mlen == (size_t) -2) + /* Offset points inside multibyte character: no good. */ + break; + + beg += mlen; + bytes_left -= mlen; + } + + if (bytes_left) + continue; + } + else +#endif /* MBS_SUPPORT */ + beg += offset; +#ifdef MBS_SUPPORT + /* For f_i_multibyte, the string at beg now matches first 3 chars of + one of the search strings (less if there are shorter search strings). + See if this is a real match. */ + if (f_i_multibyte + && Fimbexec (beg, buf + size - beg, &kwsmatch.size[0], exact)) + goto next_char; +#endif /* MBS_SUPPORT */ + len = kwsmatch.size[0]; + if (exact && !match_words) + goto success_in_beg_and_len; + if (match_lines) + { + if (beg > buf && beg[-1] != eol) + goto next_char; + if (beg + len < buf + size && beg[len] != eol) + goto next_char; + goto success; + } + else if (match_words) + { + while (1) + { + int word_match = 0; + if (beg > buf) + { +#ifdef MBS_SUPPORT + if (mb_cur_max > 1) + { + const char *s; + int mr; + wchar_t pwc; + + if (using_utf8) + { + s = beg - 1; + while (s > buf + && (unsigned char) *s >= 0x80 + && (unsigned char) *s <= 0xbf) + --s; + } + else + s = last_char; + mr = mbtowc (&pwc, s, beg - s); + if (mr <= 0) + memset (&mbs, '\0', sizeof (mbstate_t)); + else if ((iswalnum (pwc) || pwc == L'_') + && mr == (int) (beg - s)) + goto next_char; + } + else +#endif /* MBS_SUPPORT */ + if (WCHAR ((unsigned char) beg[-1])) + goto next_char; + } +#ifdef MBS_SUPPORT + if (mb_cur_max > 1) + { + wchar_t nwc; + int mr; + + mr = mbtowc (&nwc, beg + len, buf + size - beg - len); + if (mr <= 0) + { + memset (&mbs, '\0', sizeof (mbstate_t)); + word_match = 1; + } + else if (!iswalnum (nwc) && nwc != L'_') + word_match = 1; + } + else +#endif /* MBS_SUPPORT */ + if (beg + len >= buf + size || !WCHAR ((unsigned char) beg[len])) + word_match = 1; + if (word_match) + { + if (!exact) + /* Returns the whole line now we know there's a word match. */ + goto success; + else + /* Returns just this word match. */ + goto success_in_beg_and_len; + } + if (len > 0) + { + /* Try a shorter length anchored at the same place. */ + --len; + offset = kwsexec (kwset, beg, len, &kwsmatch); + + if (offset == -1) + goto next_char; /* Try a different anchor. */ +#ifdef MBS_SUPPORT + if (mb_cur_max > 1 && !using_utf8) + { + size_t bytes_left = offset; + while (bytes_left) + { + size_t mlen = mbrlen (beg, bytes_left, &mbs); + + last_char = beg; + if (mlen == (size_t) -1 || mlen == 0) + { + /* Incomplete character: treat as single-byte. */ + memset (&mbs, '\0', sizeof (mbstate_t)); + beg++; + bytes_left--; + continue; + } + + if (mlen == (size_t) -2) + { + /* Offset points inside multibyte character: + * no good. */ + break; + } + + beg += mlen; + bytes_left -= mlen; + } + + if (bytes_left) + { + memset (&mbs, '\0', sizeof (mbstate_t)); + goto next_char; /* Try a different anchor. */ + } + } + else +#endif /* MBS_SUPPORT */ + beg += offset; +#ifdef MBS_SUPPORT + /* The string at beg now matches first 3 chars of one of + the search strings (less if there are shorter search + strings). See if this is a real match. */ + if (f_i_multibyte + && Fimbexec (beg, len - offset, &kwsmatch.size[0], + exact)) + goto next_char; +#endif /* MBS_SUPPORT */ + len = kwsmatch.size[0]; + } + } + } + else + goto success; +next_char:; +#ifdef MBS_SUPPORT + /* Advance to next character. For MB_CUR_MAX == 1 case this is handled + by ++beg above. */ + if (mb_cur_max > 1) + { + if (using_utf8) + { + unsigned char c = *beg; + if (c >= 0xc2) + { + if (c < 0xe0) + ++beg; + else if (c < 0xf0) + beg += 2; + else if (c < 0xf8) + beg += 3; + else if (c < 0xfc) + beg += 4; + else if (c < 0xfe) + beg += 5; + } + } + else + { + size_t l = mbrlen (beg, buf + size - beg, &mbs); + + last_char = beg; + if (l + 2 >= 2) + beg += l - 1; + else + memset (&mbs, '\0', sizeof (mbstate_t)); + } + } +#endif /* MBS_SUPPORT */ + } + + failure: + return -1; + + success: +#ifdef MBS_SUPPORT + if (mb_cur_max > 1 && !using_utf8) + { + end = beg + len; + while (end < buf + size) + { + size_t mlen = mbrlen (end, buf + size - end, &mbs); + if (mlen == (size_t) -1 || mlen == (size_t) -2 || mlen == 0) + { + memset (&mbs, '\0', sizeof (mbstate_t)); + mlen = 1; + } + if (mlen == 1 && *end == eol) + break; + + end += mlen; + } + } + else +#endif /* MBS_SUPPORT */ + end = memchr (beg + len, eol, (buf + size) - (beg + len)); + + end++; + while (buf < beg && beg[-1] != eol) + --beg; + len = end - beg; + /* FALLTHROUGH */ + + success_in_beg_and_len: + *match_size = len; + return beg - buf; +} + +#if HAVE_LIBPCRE +/* Compiled internal form of a Perl regular expression. */ +static pcre *cre; + +/* Additional information about the pattern. */ +static pcre_extra *extra; +#endif + +static void +Pcompile (char const *pattern, size_t size) +{ +#if !HAVE_LIBPCRE + error (2, 0, _("The -P option is not supported")); +#else + int e; + char const *ep; + char *re = xmalloc (4 * size + 7); + int flags = PCRE_MULTILINE | (match_icase ? PCRE_CASELESS : 0); + char const *patlim = pattern + size; + char *n = re; + char const *p; + char const *pnul; + + /* FIXME: Remove this restriction. */ + if (eolbyte != '\n') + error (2, 0, _("The -P and -z options cannot be combined")); + + *n = '\0'; + if (match_lines) + strcpy (n, "^("); + if (match_words) + strcpy (n, "\\b("); + n += strlen (n); + + /* The PCRE interface doesn't allow NUL bytes in the pattern, so + replace each NUL byte in the pattern with the four characters + "\000", removing a preceding backslash if there are an odd + number of backslashes before the NUL. + + FIXME: This method does not work with some multibyte character + encodings, notably Shift-JIS, where a multibyte character can end + in a backslash byte. */ + for (p = pattern; (pnul = memchr (p, '\0', patlim - p)); p = pnul + 1) + { + memcpy (n, p, pnul - p); + n += pnul - p; + for (p = pnul; pattern < p && p[-1] == '\\'; p--) + continue; + n -= (pnul - p) & 1; + strcpy (n, "\\000"); + n += 4; + } + + memcpy (n, p, patlim - p); + n += patlim - p; + *n = '\0'; + if (match_words) + strcpy (n, ")\\b"); + if (match_lines) + strcpy (n, ")$"); + + cre = pcre_compile (re, flags, &ep, &e, pcre_maketables ()); + if (!cre) + error (2, 0, ep); + + extra = pcre_study (cre, 0, &ep); + if (ep) + error (2, 0, ep); + + free (re); +#endif +} + +static size_t +Pexecute (char const *buf, size_t size, size_t *match_size, int exact) +{ +#if !HAVE_LIBPCRE + abort (); + return -1; +#else + /* This array must have at least two elements; everything after that + is just for performance improvement in pcre_exec. */ + int sub[300]; + + int e = pcre_exec (cre, extra, buf, size, 0, 0, + sub, sizeof sub / sizeof *sub); + + if (e <= 0) + { + switch (e) + { + case PCRE_ERROR_NOMATCH: + return -1; + + case PCRE_ERROR_NOMEMORY: + error (2, 0, _("Memory exhausted")); + + default: + abort (); + } + } + else + { + /* Narrow down to the line we've found. */ + char const *beg = buf + sub[0]; + char const *end = buf + sub[1]; + char const *buflim = buf + size; + char eol = eolbyte; + if (!exact) + { + end = memchr (end, eol, buflim - end); + end++; + while (buf < beg && beg[-1] != eol) + --beg; + } + + *match_size = end - beg; + return beg - buf; + } +#endif +} + +struct matcher const matchers[] = { + { "default", Gcompile, EGexecute }, + { "grep", Gcompile, EGexecute }, + { "egrep", Ecompile, EGexecute }, + { "awk", Ecompile, EGexecute }, + { "fgrep", Fcompile, Fexecute }, + { "perl", Pcompile, Pexecute }, + { "", 0, 0 }, +}; diff --git a/gnu/usr.bin/grep/system.h b/gnu/usr.bin/grep/system.h new file mode 100644 index 000000000000..99906d8aaf70 --- /dev/null +++ b/gnu/usr.bin/grep/system.h @@ -0,0 +1,206 @@ +/* Portability cruft. Include after config.h and sys/types.h. + Copyright 1996, 1998, 1999, 2000 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#undef PARAMS +#if defined (__STDC__) && __STDC__ +# ifndef _PTR_T +# define _PTR_T + typedef void * ptr_t; +# endif +# define PARAMS(x) x +#else +# ifndef _PTR_T +# define _PTR_T + typedef char * ptr_t; +# endif +# define PARAMS(x) () +#endif + +#ifdef HAVE_UNISTD_H +# include <fcntl.h> +# include <unistd.h> +#else +# define O_RDONLY 0 +# define SEEK_SET 0 +# define SEEK_CUR 1 +int open(), read(), close(); +#endif + +#include <errno.h> +#ifndef errno +extern int errno; +#endif + +#ifndef HAVE_STRERROR +extern int sys_nerr; +extern char *sys_errlist[]; +# define strerror(E) (0 <= (E) && (E) < sys_nerr ? _(sys_errlist[E]) : _("Unknown system error")) +#endif + +/* Some operating systems treat text and binary files differently. */ +#ifdef __BEOS__ +# undef O_BINARY /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */ +#endif +#ifdef HAVE_DOS_FILE_CONTENTS +# include <io.h> +# ifdef HAVE_SETMODE +# define SET_BINARY(fd) setmode (fd, O_BINARY) +# else +# define SET_BINARY(fd) _setmode (fd, O_BINARY) +# endif +#endif + +#ifdef HAVE_DOS_FILE_NAMES +# define IS_SLASH(c) ((c) == '/' || (c) == '\\') +# define FILESYSTEM_PREFIX_LEN(f) ((f)[0] && (f)[1] == ':' ? 2 : 0) +#endif + +#ifndef IS_SLASH +# define IS_SLASH(c) ((c) == '/') +#endif + +#ifndef FILESYSTEM_PREFIX_LEN +# define FILESYSTEM_PREFIX_LEN(f) 0 +#endif + +int isdir PARAMS ((char const *)); + +#ifdef HAVE_DIR_EACCES_BUG +# ifdef EISDIR +# define is_EISDIR(e, f) \ + ((e) == EISDIR \ + || ((e) == EACCES && isdir (f) && ((e) = EISDIR, 1))) +# else +# define is_EISDIR(e, f) ((e) == EACCES && isdir (f)) +# endif +#endif + +#ifndef is_EISDIR +# ifdef EISDIR +# define is_EISDIR(e, f) ((e) == EISDIR) +# else +# define is_EISDIR(e, f) 0 +# endif +#endif + +#if STAT_MACROS_BROKEN +# undef S_ISDIR +# undef S_ISREG +#endif +#if !defined(S_ISDIR) && defined(S_IFDIR) +# define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR) +#endif +#if !defined(S_ISREG) && defined(S_IFREG) +# define S_ISREG(Mode) (((Mode) & S_IFMT) == S_IFREG) +#endif + +#ifdef STDC_HEADERS +# include <stdlib.h> +#else +char *getenv (); +ptr_t malloc(), realloc(), calloc(); +void free(); +#endif + +#if __STDC__ +# include <stddef.h> +#endif +#ifdef STDC_HEADERS +# include <limits.h> +#endif +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif +/* The extra casts work around common compiler bugs. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ + ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \ + : (t) 0)) +#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) +#ifndef CHAR_MAX +# define CHAR_MAX TYPE_MAXIMUM (char) +#endif +#ifndef INT_MAX +# define INT_MAX TYPE_MAXIMUM (int) +#endif +#ifndef UCHAR_MAX +# define UCHAR_MAX TYPE_MAXIMUM (unsigned char) +#endif + +#if !defined(STDC_HEADERS) && defined(HAVE_STRING_H) && defined(HAVE_MEMORY_H) +# include <memory.h> +#endif +#if defined(STDC_HEADERS) || defined(HAVE_STRING_H) +# include <string.h> +#else +# include <strings.h> +# undef strchr +# define strchr index +# undef strrchr +# define strrchr rindex +# undef memcpy +# define memcpy(d, s, n) bcopy (s, d, n) +#endif +#ifndef HAVE_MEMCHR +ptr_t memchr(); +#endif +#if ! defined HAVE_MEMMOVE && ! defined memmove +# define memmove(d, s, n) bcopy (s, d, n) +#endif + +#include <ctype.h> + +#ifndef isgraph +# define isgraph(C) (isprint(C) && !isspace(C)) +#endif + +#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) +# define IN_CTYPE_DOMAIN(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) isascii(c) +#endif + +#define ISALPHA(C) (IN_CTYPE_DOMAIN (C) && isalpha (C)) +#define ISUPPER(C) (IN_CTYPE_DOMAIN (C) && isupper (C)) +#define ISLOWER(C) (IN_CTYPE_DOMAIN (C) && islower (C)) +#define ISDIGIT(C) (IN_CTYPE_DOMAIN (C) && isdigit (C)) +#define ISXDIGIT(C) (IN_CTYPE_DOMAIN (C) && isxdigit (C)) +#define ISSPACE(C) (IN_CTYPE_DOMAIN (C) && isspace (C)) +#define ISPUNCT(C) (IN_CTYPE_DOMAIN (C) && ispunct (C)) +#define ISALNUM(C) (IN_CTYPE_DOMAIN (C) && isalnum (C)) +#define ISPRINT(C) (IN_CTYPE_DOMAIN (C) && isprint (C)) +#define ISGRAPH(C) (IN_CTYPE_DOMAIN (C) && isgraph (C)) +#define ISCNTRL(C) (IN_CTYPE_DOMAIN (C) && iscntrl (C)) + +#define TOLOWER(C) (ISUPPER(C) ? tolower(C) : (C)) + +#if ENABLE_NLS +# include <libintl.h> +# define _(String) gettext (String) +#else +# define _(String) String +#endif +#define N_(String) String + +#if HAVE_SETLOCALE +# include <locale.h> +#endif + +#ifndef initialize_main +#define initialize_main(argcp, argvp) +#endif diff --git a/gnu/usr.bin/grep/tests/backref.sh b/gnu/usr.bin/grep/tests/backref.sh new file mode 100755 index 000000000000..83f6dcc9408a --- /dev/null +++ b/gnu/usr.bin/grep/tests/backref.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Test that backrefs are local to regex. +# +# + +: ${srcdir=.} + +failures=0 + +# checking for a palindrome +echo "radar" | ${GREP} -e '\(.\)\(.\).\2\1' > /dev/null 2>&1 +if test $? -ne 0 ; then + echo "backref: palindrome, test \#1 failed" + failures=1 +fi + +# hit hard with the `Bond' tests +echo "civic" | ${GREP} -E -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' > /dev/null 2>&1 +if test $? -ne 0 ; then + echo "Options: Bond, test \#2 failed" + failures=1 +fi + +# backref are local should be error +echo "123" | ${GREP} -e 'a\(.\)' -e 'b\1' > /dev/null 2>&1 +if test $? -ne 2 ; then + echo "Options: Backref not local, test \#3 failed" + failures=1 +fi + +# Pattern should faile +echo "123" | ${GREP} -e '[' -e ']' > /dev/null 2>&1 +if test $? -ne 2 ; then + echo "Options: Compiled not local, test \#3 failed" + failures=1 +fi + +exit $failures diff --git a/gnu/usr.bin/grep/tests/bre.awk b/gnu/usr.bin/grep/tests/bre.awk new file mode 100644 index 000000000000..16a58147a39b --- /dev/null +++ b/gnu/usr.bin/grep/tests/bre.awk @@ -0,0 +1,27 @@ +BEGIN { + FS="@"; + n = 0; + printf ("# Generated Spencer BRE Test\n"); + printf ("failures=0\n"); +} + +$0 ~ /^#/ { next; } + +NF == 3 { +# printf ("status=`echo '%s' | { ${GREP} -e '%s' > /dev/null 2>&1; echo $?; cat >/dev/null; }`\n",$3, $2); + printf ("status=`echo '%s' | { ${GREP} -e '%s' > /dev/null 2>&1; echo $? ; }`\n",$3, $2); + printf ("if test $status -ne %s ; then\n", $1); + printf ("\techo Spencer bre test \\#%d failed\n", ++n); + printf ("\tfailures=1\n"); + printf ("fi\n"); +} + +NF == 4 { +#don't alarm users +# printf ("echo '%s' | ${GREP} -e '%s' > /dev/null 2>&1\n",$3, $2); +# printf ("if test $? -ne %s ; then\n", $1); +# printf ("\techo Expected non conformance \\#%d ... continuing\n", ++n); +# printf ("fi\n"); +} + +END { printf ("exit $failures\n"); } diff --git a/gnu/usr.bin/grep/tests/bre.sh b/gnu/usr.bin/grep/tests/bre.sh new file mode 100755 index 000000000000..e7ccf0a037cc --- /dev/null +++ b/gnu/usr.bin/grep/tests/bre.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# Regression test for GNU grep. + +: ${srcdir=.} + +failures=0 + +# . . . and the following by Henry Spencer. + +${AWK-awk} -f $srcdir/bre.awk $srcdir/bre.tests > bre.script + +sh bre.script && exit $failures +exit 1 diff --git a/gnu/usr.bin/grep/tests/bre.tests b/gnu/usr.bin/grep/tests/bre.tests new file mode 100644 index 000000000000..33d1689b85ae --- /dev/null +++ b/gnu/usr.bin/grep/tests/bre.tests @@ -0,0 +1,62 @@ +0@a\(b\)c@abc +0@a(@a( +2@a\(@EPAREN +2@a\(b@EPAREN +0@a(b@a(b +0@a)@a) +2@a\)@EPAREN +2@\)@EPAREN +0@a\(\)b@ab +0@a^b@a^b@TO CORRECT +0@a$b@a$b +0@\($\)\(^\)@@ +0@a*\(^b$\)c*@b +0@|@| +0@*@* +0@\(\)@abc +2@\(\{1\}a\)@BADRPT@TO CORRECT +0@^*@* +2@^\{1\}@BADRPT@TO CORRECT +0@{@{ +1@a\(b*\)c\1d@abbcbd +1@a\(b*\)c\1d@abbcbbbd +1@^\(.\)\1@abc +0@a\(\([bc]\)\2\)*d@abbccd +1@a\(\([bc]\)\2\)*d@abbcbd +0@a\(\(b\)*\2\)*d@abbbd +0@\(a\)\1bcd@aabcd +0@\(a\)\1bc*d@aabcd +0@\(a\)\1bc*d@aabd +0@\(a\)\1bc*d@aabcccd +0@\(a\)\1bc*[ce]d@aabcccd@TO CORRECT +0@^\(a\)\1b\(c\)*cd$@aabcccd +0@a\(*\)b@a*b +0@a\(**\)b@ab +2@a\(***\)b@BADRPT@TO CORRECT +0@*a@*a +0@**a@a +2@***a@BADRPT@TO CORRECT +0@a\{1\}b@ab +0@a\{1,\}b@ab +0@a\{1,2\}b@aab +2@a\{1@EBRACE +2@a\{1a@EBRACE +2@a\{1a\}@BADBR +2@a\{,2\}@BADBR +2@a\{,\}@BADBR +2@a\{1,x\}@BADBR +2@a\{1,x@EBRACE +2@a\{32768\}@BADBR +2@a\{1,0\}@BADBR +0@ab\{0,0\}c@abcac +0@ab\{0,1\}c@abcac +0@ab\{0,3\}c@abbcac +0@ab\{1,1\}c@acabc +0@ab\{1,3\}c@acabc +0@ab\{2,2\}c@abcabbc +0@ab\{2,4\}c@abcabbc +2@a\{1\}\{1\}@BADRPT@TO CORRECT +2@a*\{1\}@BADRPT@TO CORRECT +2@a\{1\}*@BADRPT@TO CORRECT +1@a\(b\)?c\1d@acd +0@-\{0,1\}[0-9]*$@-5 diff --git a/gnu/usr.bin/grep/tests/empty.sh b/gnu/usr.bin/grep/tests/empty.sh new file mode 100755 index 000000000000..d4225fecd02d --- /dev/null +++ b/gnu/usr.bin/grep/tests/empty.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# test that the empty file means no pattern +# and an empty pattern means match all. + +: ${srcdir=.} + +failures=0 + +for options in '-E' '-E -w' '-F -x' '-G -w -x'; do + + # should return 0 found a match + echo "" | ${GREP} $options -e '' > /dev/null 2>&1 + if test $? -ne 0 ; then + echo "Status: Wrong status code, test \#1 failed ($options)" + failures=1 + fi + + # should return 1 found no match + echo "abcd" | ${GREP} $options -f /dev/null > /dev/null 2>&1 + if test $? -ne 1 ; then + echo "Status: Wrong status code, test \#2 failed ($options)" + failures=1 + fi + + # should return 0 found a match + echo "abcd" | ${GREP} $options -f /dev/null -e "abcd" > /dev/null 2>&1 + if test $? -ne 0 ; then + echo "Status: Wrong status code, test \#3 failed ($options)" + failures=1 + fi +done + +exit $failures diff --git a/gnu/usr.bin/grep/tests/ere.awk b/gnu/usr.bin/grep/tests/ere.awk new file mode 100644 index 000000000000..234d219e8488 --- /dev/null +++ b/gnu/usr.bin/grep/tests/ere.awk @@ -0,0 +1,32 @@ +BEGIN { + FS="@"; + n = 0; + printf ("# Generated Spencer ERE Test\n"); + printf ("failures=0\n"); +} + +$0 ~ /^#/ { next; } + +NF == 3 { +# printf ("status=`echo '%s' | { ${GREP} -E -e '%s' > /dev/null 2>&1; echo $?; cat >/dev/null; }`\n",$3, $2); + printf ("status=`echo '%s' | { ${GREP} -E -e '%s' > /dev/null 2>&1; echo $?; }`\n",$3, $2); + printf ("if test $status -ne %s ; then\n", $1); + printf ("\techo Spencer ere test \\#%d failed\n", ++n); + printf ("\tfailures=1\n"); + printf ("fi\n"); +} + +NF == 4 { +# don't alarm the user for now +# printf ("echo '%s'|${GREP} -E -e '%s' > /dev/null 2>&1\n",$3, $2); +# printf ("if test $? -ne %s ; then\n", $1); +# printf ("\techo Expected non conformance \\#%d ... continuing\n", ++n); +# printf ("fi\n"); +} + +NF == 5 { +# don't alarm the user for now + next; +} + +END { printf ("exit $failures\n"); } diff --git a/gnu/usr.bin/grep/tests/ere.sh b/gnu/usr.bin/grep/tests/ere.sh new file mode 100755 index 000000000000..d57e2fae5ab1 --- /dev/null +++ b/gnu/usr.bin/grep/tests/ere.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# Regression test for GNU grep. + +: ${srcdir=.} + +failures=0 + +# . . . and the following by Henry Spencer. + +${AWK-awk} -f $srcdir/ere.awk $srcdir/ere.tests > ere.script + +sh ere.script && exit $failures +exit 1 diff --git a/gnu/usr.bin/grep/tests/ere.tests b/gnu/usr.bin/grep/tests/ere.tests new file mode 100644 index 000000000000..20ef2b1b2bf7 --- /dev/null +++ b/gnu/usr.bin/grep/tests/ere.tests @@ -0,0 +1,215 @@ +0@a@a +0@abc@abc +0@abc|de@abc +0@a|b|c@abc +0@a(b)c@abc +2@a(@EPAREN +0@a\(@a( +2@a(b@EPAREN +0@a)@a)@POSIX BOTCH +0@)@)@POSIX BOTCH +0@a()b@ab +0@^abc$@abc +1@a^b@a^b +1@a$b@a$b +0@^@abc +0@$@abc +0@^$@@ +0@$^@@ +0@^^@@ +0@$$@@ +0@a*(^b$)c*@b +2@|@EMPTY@NO ALTERNATION +2@*@BADRPT@TO CORRECT +2@+@BADRPT@TO CORRECT +2@?@BADRPT@TO CORRECT +1@&C@PASS +0@()@abc +2@a||b@EMPTY@NO ALTERNATION +2@|ab@EMPTY@NO ALTERNATION +2@ab|@EMPTY@NO ALTERNATION +2@(|a)b@EMPTY@NO ALTERNATION +2@(a|)b@EMPTY@NO ALTERNATION +2@(*a)@BADRPT@TO CORRECT +2@(+a)@BADRPT@TO CORRECT +2@(?a)@BADRPT@TO CORRECT +2@({1}a)@BADRPT@TO CORRECT +2@(a|*b)@BADRPT@NO ALTERNATION +2@(a|+b)@BADRPT@NO ALTERNATION +2@(a|?b)@BADRPT@NO ALTERNATION +2@(a|{1}b)@BADRPT@NO ALTERNATION +2@^*@BADRPT@TO CORRECT +2@^+@BADRPT@TO CORRECT +2@^?@BADRPT@TO CORRECT +2@^{1}@BADRPT@TO CORRECT +0@a.c@abc +0@a[bc]d@abd +0@a\*c@a*c +0@a\\b@a\b@TO CORRECT +0@a\\\*b@a\*b@SHELL TROUBLE +0@a\bc@abc@TO CORRECT +2@a\@EESCAPE@SHELL TROUBLE +0@a\\bc@a\bc@TO CORRECT +0@a\[b@a[b +2@a[b@EBRACK +0@a$@a +1@a$@a$ +1@a\$@a@SHELL TROUBLE +0@a\$@a$@SHELL TROUBLE +1@a\\$@a +1@a\\$@a$@SHELL TROUBLE +1@a\\$@a\$@SHELL TROUBLE +0@a\\$@a\@SHEL TROUBLE +0@ab*c@abc +0@ab+c@abc +0@ab?c@abc +0@{@{@TO CORRECT +0@{abc@{abc@TO CORRECT +0@{1@{1 +2@{1}@BADRPT@TO CORRECT +0@a{b@a{b@TO CORRECT +0@a{1}b@ab +0@a{1,}b@ab +0@a{1,2}b@aab +0@a{1@a{1 +1@a{1a@aa +0@a{1a}@a{1a} +0@a{,2}@a{,2} +0@a{,}@a{,} +0@a{1,*}@a{1,,,} +2@a{1,x@EBRACE@TO CORRECT +2@a{300}@BADBR@TO CORRECT +2@a{1,0}@BADBR@TO CORRECT +0@ab{0,0}c@abcac +0@ab{0,1}c@abcac +0@ab{0,3}c@abbcac +0@ab{1,1}c@acabc +0@ab{1,3}c@acabc +0@ab{2,2}c@abcabbc +0@ab{2,4}c@abcabbc +2@a**@BADRPT@TO CORRECT +2@a++@BADRPT@TO CORRECT +2@a??@BADRPT@TO CORRECT +2@a*+@BADRPT@TO CORRECT +2@a*?@BADRPT@TO CORRECT +2@a+*@BADRPT@TO CORRECT +2@a+?@BADRPT@TO CORRECT +2@a?*@BADRPT@TO CORRECT +2@a?+@BADRPT@TO CORRECT +2@a{1}{1}@BADRPT@TO CORRECT +2@a*{1}@BADRPT@TO CORRECT +2@a+{1}@BADRPT@TO CORRECT +2@a?{1}@BADRPT@TO CORRECT +2@a{1}*@BADRPT@TO CORRECT +2@a{1}+@BADRPT@TO CORRECT +2@a{1}?@BADRPT@TO CORRECT +0@a*{b}@a{b}@TO CORRECT +0@a[b]c@abc +0@a[ab]c@abc +0@a[^ab]c@adc +0@a[]b]c@a]c +0@a[[b]c@a[c +0@a[-b]c@a-c +0@a[^]b]c@adc +0@a[^-b]c@adc +0@a[b-]c@a-c +2@a[b@EBRACK +2@a[]@EBRACK +0@a[1-3]c@a2c +2@a[3-1]c@ERANGE@TO CORRECT +2@a[1-3-5]c@ERANGE@TO CORRECT +0@a[[.-.]--]c@a-c@TO CORRECT +2@a[1-@ERANGE +2@a[[.@EBRACK +2@a[[.x@EBRACK +2@a[[.x.@EBRACK +2@a[[.x.]@EBRACK@TO CORRECT +0@a[[.x.]]@ax@TO CORRECT +2@a[[.x,.]]@ECOLLATE@TO CORRECT +0@a[[.one.]]b@a1b@TO CORRECT +2@a[[.notdef.]]b@ECOLLATE@TO CORRECT +0@a[[.].]]b@a]b@TO CORRECT +0@a[[:alpha:]]c@abc +2@a[[:notdef:]]c@ECTYPE +2@a[[:@EBRACK +2@a[[:alpha@EBRACK +2@a[[:alpha:]@EBRACK +2@a[[:alpha,:]@ECTYPE +2@a[[:]:]]b@ECTYPE +2@a[[:-:]]b@ECTYPE +2@a[[:alph:]]@ECTYPE +2@a[[:alphabet:]]@ECTYPE +0@[[:digit:]]+@a019b +0@[[:lower:]]+@AabC +0@[[:upper:]]+@aBCd +0@[[:xdigit:]]+@p0f3Cq +0@a[[=b=]]c@abc@TO CORRECT +2@a[[=@EBRACK +2@a[[=b@EBRACK +2@a[[=b=@EBRACK +2@a[[=b=]@EBRACK@TO CORRECT +2@a[[=b,=]]@ECOLLATE@TO CORRECT +0@a[[=one=]]b@a1b@TO CORRECT +0@a(((b)))c@abc +0@a(b|(c))d@abd +0@a(b*|c)d@abbd +0@a[ab]{20}@aaaaabaaaabaaaabaaaab +0@a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab]@aaaaabaaaabaaaabaaaab +0@a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night)@aaaaabaaaabaaaabaaaabweeknights +0@12345678901234567890123456789@a12345678901234567890123456789b +0@123456789012345678901234567890@a123456789012345678901234567890b +0@1234567890123456789012345678901@a1234567890123456789012345678901b +0@12345678901234567890123456789012@a12345678901234567890123456789012b +0@123456789012345678901234567890123@a123456789012345678901234567890123b +0@1234567890123456789012345678901234567890123456789012345678901234567890@a1234567890123456789012345678901234567890123456789012345678901234567890b +0@[ab][cd][ef][gh][ij][kl][mn]@xacegikmoq +0@[ab][cd][ef][gh][ij][kl][mn][op]@xacegikmoq +0@[ab][cd][ef][gh][ij][kl][mn][op][qr]@xacegikmoqy +0@[ab][cd][ef][gh][ij][kl][mn][op][q]@xacegikmoqy +0@abc@xabcy +0@aBc@Abc@TO CORRECT +0@a[Bc]*d@abBCcd@TO CORRECT +0@0[[:upper:]]1@0a1@TO CORRECT +0@0[[:lower:]]1@0A1@TO CORRECT +1@a[^b]c@abc +1@a[^b]c@aBc@TO CORRECT +0@a[^b]c@adc +0@[a]b[c]@abc +0@[a]b[a]@aba +0@[abc]b[abc]@abc +0@[abc]b[abd]@abd +0@a(b?c)+d@accd +0@(wee|week)(knights|night)@weeknights +0@(we|wee|week|frob)(knights|night|day)@weeknights +0@a[bc]d@xyzaaabcaababdacd +0@a[ab]c@aaabc +0@a*@b +0@/\*.*\*/@/*x*/ +0@/\*.*\*/@/*x*/y/*z*/ +0@/\*([^*]|\*[^/])*\*/@/*x*/ +0@/\*([^*]|\*[^/])*\*/@/*x*/y/*z*/ +0@/\*([^*]|\*[^/])*\*/@/*x**/y/*z*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x*/y/*z*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x**/y/*z*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x****/y/*z*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x**x*/y/*z*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x***x/y/*z*/ +0@aZb@a@TO CORRECT +0@[[:<:]]a@a@TO CORRECT +1@[[:<:]]a@ba@TO CORRECT +0@[[:<:]]a@-a@TO CORRECT +0@a[[:>:]]@a@TO CORRECT +1@a[[:>:]]@ab@TO CORRECT +0@a[[:>:]]@a-@TO CORRECT +0@[[:<:]]a.c[[:>:]]@axcd-dayc-dazce-abc@TO CORRECT +0@[[:<:]]a.c[[:>:]]@axcd-dayc-dazce-abc-q@TO CORRECT +0@[[:<:]]a.c[[:>:]]@axc-dayc-dazce-abc@TO CORRECT +0@[[:<:]]b.c[[:>:]]@a_bxc-byc_d-bzc-q@TO CORRECT +0@[[:<:]].x..[[:>:]]@y_xa_-_xb_y-_xc_-axdc@TO CORRECT +1@[[:<:]]a_b[[:>:]]@x_a_b@TO CORRECT +0@(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A])@A1 +0@abcdefghijklmnop@abcdefghijklmnop +0@abcdefghijklmnopqrstuv@abcdefghijklmnopqrstuv +0@CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a@CC11 +0@a?b@ab diff --git a/gnu/usr.bin/grep/tests/file.sh b/gnu/usr.bin/grep/tests/file.sh new file mode 100755 index 000000000000..3db95bed6827 --- /dev/null +++ b/gnu/usr.bin/grep/tests/file.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# Test for POSIX.2 options for grep +# +# grep -E -f pattern_file file +# grep -F -f pattern_file file +# grep -G -f pattern_file file +# + +: ${srcdir=.} + +failures=0 + +cat <<EOF >patfile +radar +MILES +GNU +EOF + +# match +echo "miles" | ${GREP} -i -E -f patfile > /dev/null 2>&1 +if test $? -ne 0 ; then + echo "File_pattern: Wrong status code, test \#1 failed" + failures=1 +fi + +# match +echo "GNU" | ${GREP} -G -f patfile > /dev/null 2>&1 +if test $? -ne 0 ; then + echo "File_pattern: Wrong status code, test \#2 failed" + failures=1 +fi + +# checking for no match +echo "ridar" | ${GREP} -F -f patfile > /dev/null 2>&1 +if test $? -ne 1 ; then + echo "File_pattern: Wrong status code, test \#3 failed" + failures=1 +fi + +cat <<EOF >patfile + +EOF +# empty pattern : every match +echo "abbcd" | ${GREP} -F -f patfile > /dev/null 2>&1 +if test $? -ne 0 ; then + echo "File_pattern: Wrong status code, test \#4 failed" + failures=1 +fi + +cp /dev/null patfile + +# null pattern : no match +echo "abbcd" | ${GREP} -F -f patfile > /dev/null 2>&1 +if test $? -ne 1 ; then + echo "File_pattern: Wrong status code, test \#5 failed" + failures=1 +fi + +exit $failures diff --git a/gnu/usr.bin/grep/tests/formatbre.awk b/gnu/usr.bin/grep/tests/formatbre.awk new file mode 100644 index 000000000000..68a9c6266030 --- /dev/null +++ b/gnu/usr.bin/grep/tests/formatbre.awk @@ -0,0 +1,55 @@ +# +# Basic Regular Expression + +# kip comments +$0 ~ /^#/ { next; } + +# skip those option specific to regexec/regcomp +$2 ~ /[msnr$#p^]/ { next; } + +# skip empty lines +$0 ~ /^$/ { next; } + +# debug +#{ printf ("<%s> <%s> <%s> <%s>\n", $1, $2, $3, $4); } + +# subreg expresion +NF >= 5 { next; } + +# errors +NF == 3 { +# gsub (/@/, ","); +# it means empty lines + gsub (/\"\"/, ""); +# escapes + gsub (/\\\'/, "\\\'\'"); +# error in regex + if (index ($2, "C") != 0) + { + if (index ($2, "b") != 0) + printf ("2@%s@%s\n", $1, $3); + } +# erro no match + else + { + if (index ($2, "b") != 0) + printf ("1@%s@%s\n", $1, $3); + } + next; +} + +# ok +NF == 4 { +# skip those magic cookies can't rely on echo to gnerate them + if (match($3, /[NSTZ]/)) + next; + +# gsub (/@/, ","); +# it means empty lines + gsub (/\"\"/, ""); +# escape escapes + gsub (/\\\'/, "\\\'\'"); + + if (index ($2, "b") != 0) + printf ("0@%s@%s\n", $1, $3); +} diff --git a/gnu/usr.bin/grep/tests/formatere.awk b/gnu/usr.bin/grep/tests/formatere.awk new file mode 100644 index 000000000000..ba60439a1894 --- /dev/null +++ b/gnu/usr.bin/grep/tests/formatere.awk @@ -0,0 +1,60 @@ +# +# Extended Regular Expression + +# skip comments +$0 ~ /^#/ { next; } + +# skip specifics to regcomp/regexec +$2 ~ /[msnr$#p^]/ { next; } + +# jump empty lines +$0 ~ /^$/ { next; } + +# subreg skip +NF >= 5 { next; } + +# debug +#{ printf ("<%s> <%s> <%s> <%s>\n", $1, $2, $3, $4); } + +# errors +NF == 3 { +# nuke any remaining '@' +# gsub (/@/, ","); +# it means empty lines + gsub (/\"\"/, ""); +# escapes + gsub (/\\\'/, "\\\'\'"); +# error in regex + if (index ($2, "C") != 0) + { + if (index ($2, "b") == 0) + printf ("2@%s@%s\n", $1, $3); + } +# error not matching + else + { + if (index ($2, "b") == 0) + printf ("1@%s@%s\n", $1, $3); + } + next; +} + +# ok +NF == 4 { +# skip those magic cookies can't rely on echo to gnerate them + if (match($3, /[NSTZ]/)) + next; + +# nuke any remaining '@' +# gsub (/@/, ","); +# it means empty lines + gsub (/\"\"/, ""); +# escape escapes + gsub (/\\\'/, "\\\'\'"); + + if (index ($2, "b") == 0) + { + printf ("0@%s@%s\n", $1, $3); + } + next; +} diff --git a/gnu/usr.bin/grep/tests/khadafy.lines b/gnu/usr.bin/grep/tests/khadafy.lines new file mode 100644 index 000000000000..57e21a17948d --- /dev/null +++ b/gnu/usr.bin/grep/tests/khadafy.lines @@ -0,0 +1,32 @@ +1) Muammar Qaddafi +2) Mo'ammar Gadhafi +3) Muammar Kaddafi +4) Muammar Qadhafi +5) Moammar El Kadhafi +6) Muammar Gadafi +7) Mu'ammar al-Qadafi +8) Moamer El Kazzafi +9) Moamar al-Gaddafi +10) Mu'ammar Al Qathafi +11) Muammar Al Qathafi +12) Mo'ammar el-Gadhafi +13) Moamar El Kadhafi +14) Muammar al-Qadhafi +15) Mu'ammar al-Qadhdhafi +16) Mu'ammar Qadafi +17) Moamar Gaddafi +18) Mu'ammar Qadhdhafi +19) Muammar Khaddafi +20) Muammar al-Khaddafi +21) Mu'amar al-Kadafi +22) Muammar Ghaddafy +23) Muammar Ghadafi +24) Muammar Ghaddafi +25) Muamar Kaddafi +26) Muammar Quathafi +27) Muammar Gheddafi +28) Muamar Al-Kaddafi +29) Moammar Khadafy +30) Moammar Qudhafi +31) Mu'ammar al-Qaddafi +32) Mulazim Awwal Mu'ammar Muhammad Abu Minyar al-Qadhafi diff --git a/gnu/usr.bin/grep/tests/khadafy.regexp b/gnu/usr.bin/grep/tests/khadafy.regexp new file mode 100644 index 000000000000..46fe8ddd6dad --- /dev/null +++ b/gnu/usr.bin/grep/tests/khadafy.regexp @@ -0,0 +1 @@ +M[ou]'?am+[ae]r .*([AEae]l[- ])?[GKQ]h?[aeu]+([dtz][dhz]?)+af[iy] diff --git a/gnu/usr.bin/grep/tests/khadafy.sh b/gnu/usr.bin/grep/tests/khadafy.sh new file mode 100755 index 000000000000..e3d2cde4c082 --- /dev/null +++ b/gnu/usr.bin/grep/tests/khadafy.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# Regression test for GNU grep. + +: ${srcdir=.} +: ${GREP=../src/grep} + +failures=0 + +# The Khadafy test is brought to you by Scott Anderson . . . + +${GREP} -E -f $srcdir/khadafy.regexp $srcdir/khadafy.lines > khadafy.out +if cmp $srcdir/khadafy.lines khadafy.out +then + : +else + echo Khadafy test failed -- output left on khadafy.out + failures=1 +fi + +exit $failures diff --git a/gnu/usr.bin/grep/tests/options.sh b/gnu/usr.bin/grep/tests/options.sh new file mode 100755 index 000000000000..0f1852971d82 --- /dev/null +++ b/gnu/usr.bin/grep/tests/options.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Test for POSIX.2 options for grep +# +# grep [ -E| -F][ -c| -l| -q ][-insvx] -e pattern_list +# [-f pattern_file] ... [file. ..] +# grep [ -E| -F][ -c| -l| -q ][-insvx][-e pattern_list] +# -f pattern_file ... [file ...] +# grep [ -E| -F][ -c| -l| -q ][-insvx] pattern_list [file...] +# + +: ${srcdir=.} + +failures=0 + +# checking for -E extended regex +echo "abababccccccd" | ${GREP} -E -e 'c{3}' > /dev/null 2>&1 +if test $? -ne 0 ; then + echo "Options: Wrong status code, test \#1 failed" + failures=1 +fi + +# checking for basic regex +echo "abababccccccd" | ${GREP} -G -e 'c\{3\}' > /dev/null 2>&1 +if test $? -ne 0 ; then + echo "Options: Wrong status code, test \#2 failed" + failures=1 +fi + +# checking for fixed string +echo "abababccccccd" | ${GREP} -F -e 'c\{3\}' > /dev/null 2>&1 +if test $? -ne 1 ; then + echo "Options: Wrong status code, test \#3 failed" + failures=1 +fi + +exit $failures diff --git a/gnu/usr.bin/grep/tests/spencer1.awk b/gnu/usr.bin/grep/tests/spencer1.awk new file mode 100644 index 000000000000..ba7aeb66af79 --- /dev/null +++ b/gnu/usr.bin/grep/tests/spencer1.awk @@ -0,0 +1,15 @@ +BEGIN { + FS = "@"; + printf ("failures=0\n"); +} + +$0 !~ /^#/ && NF = 3 { +# printf ("status=`echo '%s'| { ${GREP} -E -e '%s' > /dev/null 2>&1; echo $?; cat >/dev/null; }`\n",$3, $2); + printf ("status=`echo '%s'| { ${GREP} -E -e '%s' >/dev/null 2>&1 ; echo $?; }`\n",$3, $2); + printf ("if test $status -ne %s ; then\n", $1); + printf ("\techo Spencer test \\#%d failed\n", ++n); + printf ("\tfailures=1\n"); + printf ("fi\n"); +} + +END { printf ("exit $failures\n"); } diff --git a/gnu/usr.bin/grep/tests/spencer1.sh b/gnu/usr.bin/grep/tests/spencer1.sh new file mode 100755 index 000000000000..2391761ab642 --- /dev/null +++ b/gnu/usr.bin/grep/tests/spencer1.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# Regression test for GNU grep. + +: ${srcdir=.} + +failures=0 + +# . . . and the following by Henry Spencer. + +${AWK-awk} -f $srcdir/spencer1.awk $srcdir/spencer1.tests > spencer1.script + +sh spencer1.script && exit $failures +exit 1 diff --git a/gnu/usr.bin/grep/tests/spencer1.tests b/gnu/usr.bin/grep/tests/spencer1.tests new file mode 100644 index 000000000000..2a60f00c1412 --- /dev/null +++ b/gnu/usr.bin/grep/tests/spencer1.tests @@ -0,0 +1,122 @@ +0@abc@abc +1@abc@xbc +1@abc@axc +1@abc@abx +0@abc@xabcy +0@abc@ababc +0@ab*c@abc +0@ab*bc@abc +0@ab*bc@abbc +0@ab*bc@abbbbc +0@ab+bc@abbc +1@ab+bc@abc +1@ab+bc@abq +0@ab+bc@abbbbc +0@ab?bc@abbc +0@ab?bc@abc +1@ab?bc@abbbbc +0@ab?c@abc +0@^abc$@abc +1@^abc$@abcc +0@^abc@abcc +1@^abc$@aabc +0@abc$@aabc +0@^@abc +0@$@abc +0@a.c@abc +0@a.c@axc +0@a.*c@axyzc +1@a.*c@axyzd +1@a[bc]d@abc +0@a[bc]d@abd +1@a[b-d]e@abd +0@a[b-d]e@ace +0@a[b-d]@aac +0@a[-b]@a- +0@a[b-]@a- +1@a[b-a]@- +2@a[]b@- +2@a[@- +0@a]@a] +0@a[]]b@a]b +0@a[^bc]d@aed +1@a[^bc]d@abd +0@a[^-b]c@adc +1@a[^-b]c@a-c +1@a[^]b]c@a]c +0@a[^]b]c@adc +0@ab|cd@abc +0@ab|cd@abcd +0@()ef@def +0@()*@- +1@*a@- +0@^*@- +0@$*@- +1@(*)b@- +1@$b@b +2@a\@- +0@a\(b@a(b +0@a\(*b@ab +0@a\(*b@a((b +1@a\x@a\x +2@abc)@- +2@(abc@- +0@((a))@abc +0@(a)b(c)@abc +0@a+b+c@aabbabc +0@a**@- +0@a*?@- +0@(a*)*@- +0@(a*)+@- +0@(a|)*@- +0@(a*|b)*@- +0@(a+|b)*@ab +0@(a+|b)+@ab +0@(a+|b)?@ab +0@[^ab]*@cde +0@(^)*@- +0@(ab|)*@- +2@)(@- +1@abc@ +1@abc@ +0@a*@ +0@([abc])*d@abbbcd +0@([abc])*bcd@abcd +0@a|b|c|d|e@e +0@(a|b|c|d|e)f@ef +0@((a*|b))*@- +0@abcd*efg@abcdefg +0@ab*@xabyabbbz +0@ab*@xayabbbz +0@(ab|cd)e@abcde +0@[abhgefdc]ij@hij +1@^(ab|cd)e@abcde +0@(abc|)ef@abcdef +0@(a|b)c*d@abcd +0@(ab|ab*)bc@abc +0@a([bc]*)c*@abc +0@a([bc]*)(c*d)@abcd +0@a([bc]+)(c*d)@abcd +0@a([bc]*)(c+d)@abcd +0@a[bcd]*dcdcde@adcdcde +1@a[bcd]+dcdcde@adcdcde +0@(ab|a)b*c@abc +0@((a)(b)c)(d)@abcd +0@[A-Za-z_][A-Za-z0-9_]*@alpha +0@^a(bc+|b[eh])g|.h$@abh +0@(bc+d$|ef*g.|h?i(j|k))@effgz +0@(bc+d$|ef*g.|h?i(j|k))@ij +1@(bc+d$|ef*g.|h?i(j|k))@effg +1@(bc+d$|ef*g.|h?i(j|k))@bcdd +0@(bc+d$|ef*g.|h?i(j|k))@reffgz +1@((((((((((a))))))))))@- +0@(((((((((a)))))))))@a +1@multiple words of text@uh-uh +0@multiple words@multiple words, yeah +0@(.*)c(.*)@abcde +1@\((.*),@(.*)\) +1@[k]@ab +0@abcd@abcd +0@a(bc)d@abcd +0@a[-]?c@ac +0@(....).*\1@beriberi diff --git a/gnu/usr.bin/grep/tests/spencer2.sh b/gnu/usr.bin/grep/tests/spencer2.sh new file mode 100755 index 000000000000..a26869c5121e --- /dev/null +++ b/gnu/usr.bin/grep/tests/spencer2.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# Regression test for GNU grep. + +: ${srcdir=.} + +failures=0 + +# . . . and the following by Henry Spencer. + +${AWK-awk} -f $srcdir/scriptgen.awk $srcdir/spencer2.tests > tmp2.script + +sh tmp2.script && exit $failures +exit 1 diff --git a/gnu/usr.bin/grep/tests/spencer2.tests b/gnu/usr.bin/grep/tests/spencer2.tests new file mode 100644 index 000000000000..47b61914c6e5 --- /dev/null +++ b/gnu/usr.bin/grep/tests/spencer2.tests @@ -0,0 +1,317 @@ +0@a@a +0@abc@abc +0@abc|de@abc +0@a|b|c@abc +0@a(b)c@abc +1@a\(b\)c@abc +2@a(@EPAREN +2@a(@a( +0@a\(@a( +1@a\(@EPAREN +1@a\(b@EPAREN +2@a(b@EPAREN +2@a(b@a(b +2@a)@a) +2@)@) +2@a)@a) +1@a\)@EPAREN +1@\)@EPAREN +0@a()b@ab +1@a\(\)b@ab +0@^abc$@abc +1@a^b@a^b +1@a^b@a^b +1@a$b@a$b +1@a$b@a$b +0@^@abc +0@$@abc +1@^$@"" +1@$^@"" +1@\($\)\(^\)@"" +0@^^@"" +0@$$@"" +1@b$@abNc +1@b$@abNc +1@^b$@aNbNc +1@^b$@aNbNc +1@^$@aNNb +1@^$@abc +1@^$@abcN +1@$^@aNNb +1@\($\)\(^\)@aNNb +0@^^@aNNb +0@$$@aNNb +0@^a@a +0@a$@a +0@^a@aNb +1@^b@aNb +0@a$@bNa +1@b$@bNa +0@a*(^b$)c*@b +1@a*\(^b$\)c*@b +0@|@EMPTY +0@|@| +0@*@BADRPT +0@*@* +0@+@BADRPT +0@?@BADRPT +1@""@EMPTY +0@()@abc +1@\(\)@abc +0@a||b@EMPTY +0@|ab@EMPTY +0@ab|@EMPTY +1@(|a)b@EMPTY +1@(a|)b@EMPTY +1@(*a)@BADRPT +1@(+a)@BADRPT +1@(?a)@BADRPT +1@({1}a)@BADRPT +1@\(\{1\}a\)@BADRPT +1@(a|*b)@BADRPT +1@(a|+b)@BADRPT +1@(a|?b)@BADRPT +1@(a|{1}b)@BADRPT +0@^*@BADRPT +0@^*@* +0@^+@BADRPT +0@^?@BADRPT +0@^{1}@BADRPT +1@^\{1\}@BADRPT +0@a.c@abc +0@a[bc]d@abd +0@a\*c@a*c +1@ac@abc +1@a\bc@ac +1@\{@BADRPT +0@a\[b@a[b +2@a[b@EBRACK +0@a$@a +1@a$@a$ +1@a\$@a +0@a\$@a$ +1@a\$@a +1@a\$@a\$ +2@a\(b\)\2c@ESUBREG +2@a\(b\1\)c@ESUBREG +2@a\(b*\)c\1d@abbcbd +2@a\(b*\)c\1d@abbcbbbd +2@^\(.\)\1@abc +2@a\(\([bc]\)\2\)*d@abbccd +2@a\(\([bc]\)\2\)*d@abbcbd +2@a\(\(b\)*\2\)*d@abbbd +2@\(a\)\1bcd@aabcd +2@\(a\)\1bc*d@aabcd +2@\(a\)\1bc*d@aabd +2@\(a\)\1bc*d@aabcccd +2@\(a\)\1bc*[ce]d@aabcccd +2@^\(a\)\1b\(c\)*cd$@aabcccd +0@ab*c@abc +0@ab+c@abc +0@ab?c@abc +1@a\(*\)b@a*b +1@a\(**\)b@ab +1@a\(***\)b@BADRPT +0@*a@*a +0@**a@a +1@***a@BADRPT +2@{@{ +2@{abc@{abc +2@{1@BADRPT +0@{1}@BADRPT +2@a{b@a{b +0@a{1}b@ab +1@a\{1\}b@ab +0@a{1,}b@ab +1@a\{1,\}b@ab +0@a{1,2}b@aab +1@a\{1,2\}b@aab +2@a{1@EBRACE +1@a\{1@EBRACE +2@a{1a@EBRACE +1@a\{1a@EBRACE +2@a{1a}@BADBR +1@a\{1a\}@BADBR +0@a{,2}@a{,2} +1@a\{,2\}@BADBR +0@a{,}@a{,} +1@a\{,\}@BADBR +2@a{1,x}@BADBR +1@a\{1,x\}@BADBR +2@a{1,x@EBRACE +1@a\{1,x@EBRACE +1@a{300}@BADBR +1@a\{300\}@BADBR +1@a{1,0}@BADBR +1@a\{1,0\}@BADBR +0@ab{0,0}c@abcac +1@ab\{0,0\}c@abcac +0@ab{0,1}c@abcac +1@ab\{0,1\}c@abcac +0@ab{0,3}c@abbcac +1@ab\{0,3\}c@abbcac +0@ab{1,1}c@acabc +1@ab\{1,1\}c@acabc +0@ab{1,3}c@acabc +1@ab\{1,3\}c@acabc +0@ab{2,2}c@abcabbc +1@ab\{2,2\}c@abcabbc +0@ab{2,4}c@abcabbc +1@ab\{2,4\}c@abcabbc +0@a**@BADRPT +1@a++@BADRPT +0@a??@BADRPT +0@a*+@BADRPT +0@a*?@BADRPT +0@a+*@BADRPT +0@a+?@BADRPT +0@a?*@BADRPT +0@a?+@BADRPT +1@a{1}{1}@BADRPT +0@a*{1}@BADRPT +1@a+{1}@BADRPT +0@a?{1}@BADRPT +0@a{1}*@BADRPT +1@a{1}+@BADRPT +0@a{1}?@BADRPT +2@a*{b}@a{b} +1@a\{1\}\{1\}@BADRPT +1@a*\{1\}@BADRPT +1@a\{1\}*@BADRPT +0@a[b]c@abc +0@a[ab]c@abc +0@a[^ab]c@adc +0@a[]b]c@a]c +0@a[[b]c@a[c +0@a[-b]c@a-c +0@a[^]b]c@adc +0@a[^-b]c@adc +0@a[b-]c@a-c +2@a[b@EBRACK +2@a[]@EBRACK +0@a[1-3]c@a2c +1@a[3-1]c@ERANGE +1@a[1-3-5]c@ERANGE +1@a[[.-.]--]c@a-c +2@a[1-@ERANGE +2@a[[.@EBRACK +2@a[[.x@EBRACK +2@a[[.x.@EBRACK +1@a[[.x.]@EBRACK +1@a[[.x.]]@ax +1@a[[.x,.]]@ECOLLATE +1@a[[.one.]]b@a1b +1@a[[.notdef.]]b@ECOLLATE +1@a[[.].]]b@a]b +0@a[[:alpha:]]c@abc +2@a[[:notdef:]]c@ECTYPE +2@a[[:@EBRACK +2@a[[:alpha@EBRACK +2@a[[:alpha:]@EBRACK +2@a[[:alpha,:]@ECTYPE +2@a[[:]:]]b@ECTYPE +2@a[[:-:]]b@ECTYPE +2@a[[:alph:]]@ECTYPE +2@a[[:alphabet:]]@ECTYPE +1@[[:blank:]]+@aSSTb +1@[[:cntrl:]]+@aNTb +0@[[:digit:]]+@a019b +0@[[:graph:]]+@Sa%bS +0@[[:lower:]]+@AabC +0@[[:print:]]+@NaSbN +0@[[:punct:]]+@S%-&T +1@[[:space:]]+@aSNTb +0@[[:upper:]]+@aBCd +0@[[:xdigit:]]+@p0f3Cq +1@a[[=b=]]c@abc +2@a[[=@EBRACK +2@a[[=b@EBRACK +2@a[[=b=@EBRACK +1@a[[=b=]@EBRACK +1@a[[=b,=]]@ECOLLATE +1@a[[=one=]]b@a1b +0@a(((b)))c@abc +0@a(b|(c))d@abd +0@a(b*|c)d@abbd +0@a[ab]{20}@aaaaabaaaabaaaabaaaab +0@a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab]@aaaaabaaaabaaaabaaaab +0@a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night)@aaaaabaaaabaaaabaaaabweeknights +0@12345678901234567890123456789@a12345678901234567890123456789b +0@123456789012345678901234567890@a123456789012345678901234567890b +0@1234567890123456789012345678901@a1234567890123456789012345678901b +0@12345678901234567890123456789012@a12345678901234567890123456789012b +0@123456789012345678901234567890123@a123456789012345678901234567890123b +0@1234567890123456789012345678901234567890123456789012345678901234567890@a1234567890123456789012345678901234567890123456789012345678901234567890b +0@[ab][cd][ef][gh][ij][kl][mn]@xacegikmoq +0@[ab][cd][ef][gh][ij][kl][mn][op]@xacegikmoq +0@[ab][cd][ef][gh][ij][kl][mn][op][qr]@xacegikmoqy +0@[ab][cd][ef][gh][ij][kl][mn][op][q]@xacegikmoqy +0@abc@xabcy +2@a\(b\)?c\1d@acd +1@aBc@Abc +1@a[Bc]*d@abBCcd +1@0[[:upper:]]1@0a1 +1@0[[:lower:]]1@0A1 +1@a[^b]c@abc +0@a[^b]c@aBc +0@a[^b]c@adc +0@[a]b[c]@abc +0@[a]b[a]@aba +0@[abc]b[abc]@abc +0@[abc]b[abd]@abd +0@a(b?c)+d@accd +0@(wee|week)(knights|night)@weeknights +0@(we|wee|week|frob)(knights|night|day)@weeknights +0@a[bc]d@xyzaaabcaababdacd +0@a[ab]c@aaabc +0@abc@abc +0@a*@b +0@/\*.*\*/@/*x*/ +0@/\*.*\*/@/*x*/y/*z*/ +0@/\*([^*]|\*[^/])*\*/@/*x*/ +0@/\*([^*]|\*[^/])*\*/@/*x*/y/*z*/ +0@/\*([^*]|\*[^/])*\*/@/*x**/y/*z*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x*/y/*z*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x**/y/*z*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x****/y/*z*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x**x*/y/*z*/ +0@/\*([^*]|\*+[^*/])*\*+/@/*x***x/y/*z*/ +0@[abc]@a(b)c +0@[abc]@a(d)c +0@[abc]@a(bc)d +0@[abc]@a(dc)d +0@.@a()c +0@b.*c@b(bc)c +0@b.*@b(bc)c +0@.*c@b(bc)c +0@abc@abc +0@abc@xabcy +1@abc@xyz +0@a*b@aba*b +0@a*b@ab +1@""@EMPTY +1@aZb@a +1@aZb@a +0@aZb@(aZb) +0@aZ*b@(ab) +0@a.b@(aZb) +0@a.*@(aZb)c +2@[[:<:]]a@a +2@[[:<:]]a@ba +2@[[:<:]]a@-a +2@a[[:>:]]@a +2@a[[:>:]]@ab +2@a[[:>:]]@a- +2@[[:<:]]a.c[[:>:]]@axcd-dayc-dazce-abc +2@[[:<:]]a.c[[:>:]]@axcd-dayc-dazce-abc-q +2@[[:<:]]a.c[[:>:]]@axc-dayc-dazce-abc +2@[[:<:]]b.c[[:>:]]@a_bxc-byc_d-bzc-q +2@[[:<:]].x..[[:>:]]@y_xa_-_xb_y-_xc_-axdc +2@[[:<:]]a_b[[:>:]]@x_a_b +0@(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A])@A1 +0@abcdefghijklmnop@abcdefghijklmnop +0@abcdefghijklmnopqrstuv@abcdefghijklmnopqrstuv +0@CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a@CC11 +0@a?b@ab +1@-\{0,1\}[0-9]*$@-5 diff --git a/gnu/usr.bin/grep/tests/status.sh b/gnu/usr.bin/grep/tests/status.sh new file mode 100755 index 000000000000..94f59294a905 --- /dev/null +++ b/gnu/usr.bin/grep/tests/status.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# Test for status code for GNU grep. +# status code +# 0 match found +# 1 no match +# 2 file not found + +: ${srcdir=.} + +failures=0 + +# should return 0 found a match +echo "abcd" | ${GREP} -E -e 'abc' > /dev/null 2>&1 +if test $? -ne 0 ; then + echo "Status: Wrong status code, test \#1 failed" + failures=1 +fi + +# should return 1 found no match +echo "abcd" | ${GREP} -E -e 'zbc' > /dev/null 2>&1 +if test $? -ne 1 ; then + echo "Status: Wrong status code, test \#2 failed" + failures=1 +fi + +# the filename MMMMMMMM.MMM should not exist hopefully +if test -r MMMMMMMM.MMM; then + echo "Please remove MMMMMMMM.MMM to run check" +else + # should return 2 file not found + ${GREP} -E -e 'abc' MMMMMMMM.MMM > /dev/null 2>&1 + if test $? -ne 2 ; then + echo "Status: Wrong status code, test \#3 failed" + failures=1 + fi + + # should return 2 file not found + ${GREP} -E -s -e 'abc' MMMMMMMM.MMM > /dev/null 2>&1 + if test $? -ne 2 ; then + echo "Status: Wrong status code, test \#4 failed" + failures=1 + fi + + # should return 0 found a match + echo "abcd" | ${GREP} -E -q -s 'abc' MMMMMMMM.MMM - > /dev/null 2>&1 + if test $? -ne 0 ; then + echo "Status: Wrong status code, test \#5 failed" + failures=1 + fi +fi + +exit $failures diff --git a/gnu/usr.bin/grep/tests/tests b/gnu/usr.bin/grep/tests/tests new file mode 100644 index 000000000000..8ed938d2d76a --- /dev/null +++ b/gnu/usr.bin/grep/tests/tests @@ -0,0 +1,475 @@ +# regular expression test set +# Lines are at least three fields, separated by one or more tabs. "" stands +# for an empty field. First field is an RE. Second field is flags. If +# C flag given, regcomp() is expected to fail, and the third field is the +# error name (minus the leading REG_). +# +# Otherwise it is expected to succeed, and the third field is the string to +# try matching it against. If there is no fourth field, the match is +# expected to fail. If there is a fourth field, it is the substring that +# the RE is expected to match. If there is a fifth field, it is a comma- +# separated list of what the subexpressions should match, with - indicating +# no match for that one. In both the fourth and fifth fields, a (sub)field +# starting with @ indicates that the (sub)expression is expected to match +# a null string followed by the stuff after the @; this provides a way to +# test where null strings match. The character `N' in REs and strings +# is newline, `S' is space, `T' is tab, `Z' is NUL. +# +# The full list of flags: +# - placeholder, does nothing +# b RE is a BRE, not an ERE +# & try it as both an ERE and a BRE +# C regcomp() error expected, third field is error name +# i REG_ICASE +# m ("mundane") REG_NOSPEC +# s REG_NOSUB (not really testable) +# n REG_NEWLINE +# ^ REG_NOTBOL +# $ REG_NOTEOL +# # REG_STARTEND (see below) +# p REG_PEND +# +# For REG_STARTEND, the start/end offsets are those of the substring +# enclosed in (). + +# basics +a & a a +abc & abc abc +abc|de - abc abc +a|b|c - abc a + +# parentheses and perversions thereof +a(b)c - abc abc +a\(b\)c b abc abc +a( C EPAREN +a( b a( a( +a\( - a( a( +a\( bC EPAREN +a\(b bC EPAREN +a(b C EPAREN +a(b b a(b a(b +# gag me with a right parenthesis -- 1003.2 goofed here (my fault, partly) +a) - a) a) +) - ) ) +# end gagging (in a just world, those *should* give EPAREN) +a) b a) a) +a\) bC EPAREN +\) bC EPAREN +a()b - ab ab +a\(\)b b ab ab + +# anchoring and REG_NEWLINE +^abc$ & abc abc +a^b - a^b +a^b b a^b a^b +a$b - a$b +a$b b a$b a$b +^ & abc @abc +$ & abc @ +^$ & "" @ +$^ - "" @ +\($\)\(^\) b "" @ +# stop retching, those are legitimate (although disgusting) +^^ - "" @ +$$ - "" @ +##b$ & abNc +##b$ &n abNc b +##^b$ & aNbNc +##^b$ &n aNbNc b +##^$ &n aNNb @Nb +^$ n abc +##^$ n abcN @ +##$^ n aNNb @Nb +##\($\)\(^\) bn aNNb @Nb +##^^ n^ aNNb @Nb +##$$ n aNNb @NN +^a ^ a +a$ $ a +##^a ^n aNb +##^b ^n aNb b +##a$ $n bNa +##b$ $n bNa b +a*(^b$)c* - b b +a*\(^b$\)c* b b b + +# certain syntax errors and non-errors +| C EMPTY +| b | | +* C BADRPT +* b * * ++ C BADRPT +? C BADRPT +"" &C EMPTY +() - abc @abc +\(\) b abc @abc +a||b C EMPTY +|ab C EMPTY +ab| C EMPTY +(|a)b C EMPTY +(a|)b C EMPTY +(*a) C BADRPT +(+a) C BADRPT +(?a) C BADRPT +({1}a) C BADRPT +\(\{1\}a\) bC BADRPT +(a|*b) C BADRPT +(a|+b) C BADRPT +(a|?b) C BADRPT +(a|{1}b) C BADRPT +^* C BADRPT +^* b * * +^+ C BADRPT +^? C BADRPT +^{1} C BADRPT +^\{1\} bC BADRPT + +# metacharacters, backslashes +a.c & abc abc +a[bc]d & abd abd +a\*c & a*c a*c +a\\b & a\b a\b +a\\\*b & a\*b a\*b +a\bc & abc abc +a\ &C EESCAPE +a\\bc & a\bc a\bc +\{ bC BADRPT +a\[b & a[b a[b +a[b &C EBRACK +# trailing $ is a peculiar special case for the BRE code +a$ & a a +a$ & a$ +a\$ & a +a\$ & a$ a$ +a\\$ & a +a\\$ & a$ +a\\$ & a\$ +a\\$ & a\ a\ + +# back references, ugh +##a\(b\)\2c bC ESUBREG +##a\(b\1\)c bC ESUBREG +a\(b*\)c\1d b abbcbbd abbcbbd bb +a\(b*\)c\1d b abbcbd +a\(b*\)c\1d b abbcbbbd +^\(.\)\1 b abc +a\([bc]\)\1d b abcdabbd abbd b +a\(\([bc]\)\2\)*d b abbccd abbccd +a\(\([bc]\)\2\)*d b abbcbd +# actually, this next one probably ought to fail, but the spec is unclear +a\(\(b\)*\2\)*d b abbbd abbbd +# here is a case that no NFA implementation does right +\(ab*\)[ab]*\1 b ababaaa ababaaa a +# check out normal matching in the presence of back refs +\(a\)\1bcd b aabcd aabcd +\(a\)\1bc*d b aabcd aabcd +\(a\)\1bc*d b aabd aabd +\(a\)\1bc*d b aabcccd aabcccd +\(a\)\1bc*[ce]d b aabcccd aabcccd +^\(a\)\1b\(c\)*cd$ b aabcccd aabcccd + +# ordinary repetitions +ab*c & abc abc +ab+c - abc abc +ab?c - abc abc +a\(*\)b b a*b a*b +a\(**\)b b ab ab +a\(***\)b bC BADRPT +*a b *a *a +**a b a a +***a bC BADRPT + +# the dreaded bounded repetitions +{ & { { +{abc & {abc {abc +{1 C BADRPT +{1} C BADRPT +a{b & a{b a{b +a{1}b - ab ab +a\{1\}b b ab ab +a{1,}b - ab ab +a\{1,\}b b ab ab +a{1,2}b - aab aab +a\{1,2\}b b aab aab +a{1 C EBRACE +a\{1 bC EBRACE +a{1a C EBRACE +a\{1a bC EBRACE +a{1a} C BADBR +a\{1a\} bC BADBR +a{,2} - a{,2} a{,2} +a\{,2\} bC BADBR +a{,} - a{,} a{,} +a\{,\} bC BADBR +a{1,x} C BADBR +a\{1,x\} bC BADBR +a{1,x C EBRACE +a\{1,x bC EBRACE +a{300} C BADBR +a\{300\} bC BADBR +a{1,0} C BADBR +a\{1,0\} bC BADBR +ab{0,0}c - abcac ac +ab\{0,0\}c b abcac ac +ab{0,1}c - abcac abc +ab\{0,1\}c b abcac abc +ab{0,3}c - abbcac abbc +ab\{0,3\}c b abbcac abbc +ab{1,1}c - acabc abc +ab\{1,1\}c b acabc abc +ab{1,3}c - acabc abc +ab\{1,3\}c b acabc abc +ab{2,2}c - abcabbc abbc +ab\{2,2\}c b abcabbc abbc +ab{2,4}c - abcabbc abbc +ab\{2,4\}c b abcabbc abbc +((a{1,10}){1,10}){1,10} - a a a,a + +# multiple repetitions +a** &C BADRPT +a++ C BADRPT +a?? C BADRPT +a*+ C BADRPT +a*? C BADRPT +a+* C BADRPT +a+? C BADRPT +a?* C BADRPT +a?+ C BADRPT +a{1}{1} C BADRPT +a*{1} C BADRPT +a+{1} C BADRPT +a?{1} C BADRPT +a{1}* C BADRPT +a{1}+ C BADRPT +a{1}? C BADRPT +a*{b} - a{b} a{b} +a\{1\}\{1\} bC BADRPT +a*\{1\} bC BADRPT +a\{1\}* bC BADRPT + +# brackets, and numerous perversions thereof +a[b]c & abc abc +a[ab]c & abc abc +a[^ab]c & adc adc +a[]b]c & a]c a]c +a[[b]c & a[c a[c +a[-b]c & a-c a-c +a[^]b]c & adc adc +a[^-b]c & adc adc +a[b-]c & a-c a-c +a[b &C EBRACK +a[] &C EBRACK +a[1-3]c & a2c a2c +a[3-1]c &C ERANGE +a[1-3-5]c &C ERANGE +a[[.-.]--]c & a-c a-c +a[1- &C ERANGE +a[[. &C EBRACK +a[[.x &C EBRACK +a[[.x. &C EBRACK +a[[.x.] &C EBRACK +a[[.x.]] & ax ax +a[[.x,.]] &C ECOLLATE +a[[.one.]]b & a1b a1b +a[[.notdef.]]b &C ECOLLATE +a[[.].]]b & a]b a]b +a[[:alpha:]]c & abc abc +a[[:notdef:]]c &C ECTYPE +a[[: &C EBRACK +a[[:alpha &C EBRACK +a[[:alpha:] &C EBRACK +a[[:alpha,:] &C ECTYPE +a[[:]:]]b &C ECTYPE +a[[:-:]]b &C ECTYPE +a[[:alph:]] &C ECTYPE +a[[:alphabet:]] &C ECTYPE +##[[:alnum:]]+ - -%@a0X- a0X +##[[:alpha:]]+ - -%@aX0- aX +[[:blank:]]+ - aSSTb SST +##[[:cntrl:]]+ - aNTb NT +[[:digit:]]+ - a019b 019 +##[[:graph:]]+ - Sa%bS a%b +[[:lower:]]+ - AabC ab +##[[:print:]]+ - NaSbN aSb +##[[:punct:]]+ - S%-&T %-& +[[:space:]]+ - aSNTb SNT +[[:upper:]]+ - aBCd BC +[[:xdigit:]]+ - p0f3Cq 0f3C +a[[=b=]]c & abc abc +a[[= &C EBRACK +a[[=b &C EBRACK +a[[=b= &C EBRACK +a[[=b=] &C EBRACK +a[[=b,=]] &C ECOLLATE +a[[=one=]]b & a1b a1b + +# complexities +a(((b)))c - abc abc +a(b|(c))d - abd abd +a(b*|c)d - abbd abbd +# just gotta have one DFA-buster, of course +a[ab]{20} - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab +# and an inline expansion in case somebody gets tricky +a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab +# and in case somebody just slips in an NFA... +a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) - aaaaabaaaabaaaabaaaabweeknights aaaaabaaaabaaaabaaaabweeknights +# fish for anomalies as the number of states passes 32 +12345678901234567890123456789 - a12345678901234567890123456789b 12345678901234567890123456789 +123456789012345678901234567890 - a123456789012345678901234567890b 123456789012345678901234567890 +1234567890123456789012345678901 - a1234567890123456789012345678901b 1234567890123456789012345678901 +12345678901234567890123456789012 - a12345678901234567890123456789012b 12345678901234567890123456789012 +123456789012345678901234567890123 - a123456789012345678901234567890123b 123456789012345678901234567890123 +# and one really big one, beyond any plausible word width +1234567890123456789012345678901234567890123456789012345678901234567890 - a1234567890123456789012345678901234567890123456789012345678901234567890b 1234567890123456789012345678901234567890123456789012345678901234567890 +# fish for problems as brackets go past 8 +[ab][cd][ef][gh][ij][kl][mn] - xacegikmoq acegikm +[ab][cd][ef][gh][ij][kl][mn][op] - xacegikmoq acegikmo +[ab][cd][ef][gh][ij][kl][mn][op][qr] - xacegikmoqy acegikmoq +[ab][cd][ef][gh][ij][kl][mn][op][q] - xacegikmoqy acegikmoq + +# subtleties of matching +abc & xabcy abc +a\(b\)?c\1d b acd +aBc i Abc Abc +a[Bc]*d i abBCcd abBCcd +0[[:upper:]]1 &i 0a1 0a1 +0[[:lower:]]1 &i 0A1 0A1 +a[^b]c &i abc +a[^b]c &i aBc +a[^b]c &i adc adc +[a]b[c] - abc abc +[a]b[a] - aba aba +[abc]b[abc] - abc abc +[abc]b[abd] - abd abd +a(b?c)+d - accd accd +(wee|week)(knights|night) - weeknights weeknights +(we|wee|week|frob)(knights|night|day) - weeknights weeknights +a[bc]d - xyzaaabcaababdacd abd +a[ab]c - aaabc abc +abc s abc abc +a* & b @b + +# Let's have some fun -- try to match a C comment. +# first the obvious, which looks okay at first glance... +/\*.*\*/ - /*x*/ /*x*/ +# but... +/\*.*\*/ - /*x*/y/*z*/ /*x*/y/*z*/ +# okay, we must not match */ inside; try to do that... +/\*([^*]|\*[^/])*\*/ - /*x*/ /*x*/ +/\*([^*]|\*[^/])*\*/ - /*x*/y/*z*/ /*x*/ +# but... +/\*([^*]|\*[^/])*\*/ - /*x**/y/*z*/ /*x**/y/*z*/ +# and a still fancier version, which does it right (I think)... +/\*([^*]|\*+[^*/])*\*+/ - /*x*/ /*x*/ +/\*([^*]|\*+[^*/])*\*+/ - /*x*/y/*z*/ /*x*/ +/\*([^*]|\*+[^*/])*\*+/ - /*x**/y/*z*/ /*x**/ +/\*([^*]|\*+[^*/])*\*+/ - /*x****/y/*z*/ /*x****/ +/\*([^*]|\*+[^*/])*\*+/ - /*x**x*/y/*z*/ /*x**x*/ +/\*([^*]|\*+[^*/])*\*+/ - /*x***x/y/*z*/ /*x***x/y/*z*/ + +# subexpressions +a(b)(c)d - abcd abcd b,c +a(((b)))c - abc abc b,b,b +a(b|(c))d - abd abd b,- +a(b*|c|e)d - abbd abbd bb +a(b*|c|e)d - acd acd c +a(b*|c|e)d - ad ad @d +a(b?)c - abc abc b +a(b?)c - ac ac @c +a(b+)c - abc abc b +a(b+)c - abbbc abbbc bbb +a(b*)c - ac ac @c +(a|ab)(bc([de]+)f|cde) - abcdef abcdef a,bcdef,de +# the regression tester only asks for 9 subexpressions +a(b)(c)(d)(e)(f)(g)(h)(i)(j)k - abcdefghijk abcdefghijk b,c,d,e,f,g,h,i,j +a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l - abcdefghijkl abcdefghijkl b,c,d,e,f,g,h,i,j,k +a([bc]?)c - abc abc b +a([bc]?)c - ac ac @c +a([bc]+)c - abc abc b +a([bc]+)c - abcc abcc bc +a([bc]+)bc - abcbc abcbc bc +a(bb+|b)b - abb abb b +a(bbb+|bb+|b)b - abb abb b +a(bbb+|bb+|b)b - abbb abbb bb +a(bbb+|bb+|b)bb - abbb abbb b +(.*).* - abcdef abcdef abcdef +##(a*)* - bc @b @b + +# do we get the right subexpression when it is used more than once? +a(b|c)*d - ad ad - +a(b|c)*d - abcd abcd c +a(b|c)+d - abd abd b +a(b|c)+d - abcd abcd c +a(b|c?)+d - ad ad @d +a(b|c?)+d - abcd abcd @d +a(b|c){0,0}d - ad ad - +a(b|c){0,1}d - ad ad - +a(b|c){0,1}d - abd abd b +a(b|c){0,2}d - ad ad - +a(b|c){0,2}d - abcd abcd c +a(b|c){0,}d - ad ad - +a(b|c){0,}d - abcd abcd c +a(b|c){1,1}d - abd abd b +a(b|c){1,1}d - acd acd c +a(b|c){1,2}d - abd abd b +a(b|c){1,2}d - abcd abcd c +a(b|c){1,}d - abd abd b +a(b|c){1,}d - abcd abcd c +a(b|c){2,2}d - acbd acbd b +a(b|c){2,2}d - abcd abcd c +a(b|c){2,4}d - abcd abcd c +a(b|c){2,4}d - abcbd abcbd b +a(b|c){2,4}d - abcbcd abcbcd c +a(b|c){2,}d - abcd abcd c +a(b|c){2,}d - abcbd abcbd b +##a(b+|((c)*))+d - abd abd @d,@d,- +##a(b+|((c)*))+d - abcd abcd @d,@d,- + +# check out the STARTEND option +[abc] &# a(b)c b +[abc] &# a(d)c +[abc] &# a(bc)d b +[abc] &# a(dc)d c +. &# a()c +b.*c &# b(bc)c bc +b.* &# b(bc)c bc +.*c &# b(bc)c bc + +# plain strings, with the NOSPEC flag +abc m abc abc +abc m xabcy abc +abc m xyz +a*b m aba*b a*b +a*b m ab +"" mC EMPTY + +# cases involving NULs +aZb & a a +aZb &p a +#aZb &p# (aZb) aZb +aZ*b &p# (ab) ab +#a.b &# (aZb) aZb +#a.* &# (aZb)c aZb + +# word boundaries (ick) +[[:<:]]a & a a +[[:<:]]a & ba +[[:<:]]a & -a a +a[[:>:]] & a a +a[[:>:]] & ab +a[[:>:]] & a- a +[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc abc +[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc-q abc +[[:<:]]a.c[[:>:]] & axc-dayc-dazce-abc axc +[[:<:]]b.c[[:>:]] & a_bxc-byc_d-bzc-q bzc +[[:<:]].x..[[:>:]] & y_xa_-_xb_y-_xc_-axdc _xc_ +[[:<:]]a_b[[:>:]] & x_a_b + +# past problems, and suspected problems +(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A]) - A1 A1 +abcdefghijklmnop i abcdefghijklmnop abcdefghijklmnop +abcdefghijklmnopqrstuv i abcdefghijklmnopqrstuv abcdefghijklmnopqrstuv +(ALAK)|(ALT[AB])|(CC[123]1)|(CM[123]1)|(GAMC)|(LC[23][EO ])|(SEM[1234])|(SL[ES][12])|(SLWW)|(SLF )|(SLDT)|(VWH[12])|(WH[34][EW])|(WP1[ESN]) - CC11 CC11 +CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a - CC11 CC11 +Char \([a-z0-9_]*\)\[.* b Char xyz[k Char xyz[k xyz +a?b - ab ab +-\{0,1\}[0-9]*$ b -5 -5 diff --git a/gnu/usr.bin/grep/tests/warning.sh b/gnu/usr.bin/grep/tests/warning.sh new file mode 100755 index 000000000000..bfca533a9675 --- /dev/null +++ b/gnu/usr.bin/grep/tests/warning.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# +# Tell them not to be alarmed. + +: ${srcdir=.} + +failures=0 + +# +cat <<\EOF + +Please, do not be alarmed if some of the tests failed. +Report them to <bug-gnu-utils@gnu.org>, +with the line number, the name of the file, +and grep version number 'grep --version'. +Make sure you have the word grep in the subject. +Thank You. + +EOF diff --git a/gnu/usr.bin/grep/xalloc.h b/gnu/usr.bin/grep/xalloc.h new file mode 100644 index 000000000000..098a6c2e0730 --- /dev/null +++ b/gnu/usr.bin/grep/xalloc.h @@ -0,0 +1,87 @@ +/* xalloc.h -- malloc with out-of-memory checking + Copyright (C) 1990-1998, 1999, 2000 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef XALLOC_H_ +# define XALLOC_H_ + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +# ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ +# define __attribute__(x) +# endif +# endif + +# ifndef ATTRIBUTE_NORETURN +# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# endif + +/* Exit value when the requested amount of memory is not available. + It is initialized to EXIT_FAILURE, but the caller may set it to + some other value. */ +extern int xalloc_exit_failure; + +/* If this pointer is non-zero, run the specified function upon each + allocation failure. It is initialized to zero. */ +extern void (*xalloc_fail_func) PARAMS ((void)); + +/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this + message is output. It is translated via gettext. + Its value is "memory exhausted". */ +extern char const xalloc_msg_memory_exhausted[]; + +/* This function is always triggered when memory is exhausted. It is + in charge of honoring the three previous items. This is the + function to call when one wants the program to die because of a + memory allocation failure. */ +extern void xalloc_die PARAMS ((void)) ATTRIBUTE_NORETURN; + +void *xmalloc PARAMS ((size_t n)); +void *xcalloc PARAMS ((size_t n, size_t s)); +void *xrealloc PARAMS ((void *p, size_t n)); +char *xstrdup PARAMS ((const char *str)); + +# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items))) +# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items))) +# define XREALLOC(Ptr, Type, N_items) \ + ((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items))) + +/* Declare and alloc memory for VAR of type TYPE. */ +# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1) + +/* Free VAR only if non NULL. */ +# define XFREE(Var) \ + do { \ + if (Var) \ + free (Var); \ + } while (0) + +/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */ +# define CCLONE(Src, Num) \ + (memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num))) + +/* Return a malloc'ed copy of SRC. */ +# define CLONE(Src) CCLONE (Src, 1) + + +#endif /* !XALLOC_H_ */ diff --git a/gnu/usr.bin/grep/xmalloc.c b/gnu/usr.bin/grep/xmalloc.c new file mode 100644 index 000000000000..2f103d604917 --- /dev/null +++ b/gnu/usr.bin/grep/xmalloc.c @@ -0,0 +1,116 @@ +/* xmalloc.c -- malloc with out of memory checking + Copyright (C) 1990-1999, 2000 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include <sys/types.h> + +#if STDC_HEADERS +# include <stdlib.h> +#else +void *calloc (); +void *malloc (); +void *realloc (); +void free (); +#endif + +#if ENABLE_NLS +# include <libintl.h> +# define _(Text) gettext (Text) +#else +# define textdomain(Domain) +# define _(Text) Text +#endif +#define N_(Text) Text + +#include "error.h" +#include "xalloc.h" + +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif + +#ifndef HAVE_DONE_WORKING_MALLOC_CHECK +"you must run the autoconf test for a properly working malloc -- see malloc.m4" +#endif + +#ifndef HAVE_DONE_WORKING_REALLOC_CHECK +"you must run the autoconf test for a properly working realloc --see realloc.m4" +#endif + +/* Exit value when the requested amount of memory is not available. + The caller may set it to some other value. */ +int xalloc_exit_failure = EXIT_FAILURE; + +/* If non NULL, call this function when memory is exhausted. */ +void (*xalloc_fail_func) PARAMS ((void)) = 0; + +/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message + before exiting when memory is exhausted. Goes through gettext. */ +char const xalloc_msg_memory_exhausted[] = N_("memory exhausted"); + +void +xalloc_die (void) +{ + if (xalloc_fail_func) + (*xalloc_fail_func) (); + error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted)); + /* The `noreturn' cannot be given to error, since it may return if + its first argument is 0. To help compilers understand the + xalloc_die does terminate, call exit. */ + exit (EXIT_FAILURE); +} + +/* Allocate N bytes of memory dynamically, with error checking. */ + +void * +xmalloc (size_t n) +{ + void *p; + + p = malloc (n); + if (p == 0) + xalloc_die (); + return p; +} + +/* Change the size of an allocated block of memory P to N bytes, + with error checking. */ + +void * +xrealloc (void *p, size_t n) +{ + p = realloc (p, n); + if (p == 0) + xalloc_die (); + return p; +} + +/* Allocate memory for N elements of S bytes, with error checking. */ + +void * +xcalloc (size_t n, size_t s) +{ + void *p; + + p = calloc (n, s); + if (p == 0) + xalloc_die (); + return p; +} diff --git a/gnu/usr.bin/grep/xstrtol.c b/gnu/usr.bin/grep/xstrtol.c new file mode 100644 index 000000000000..07023d9ffdb7 --- /dev/null +++ b/gnu/usr.bin/grep/xstrtol.c @@ -0,0 +1,282 @@ +/* A more useful interface to strtol. + Copyright (C) 1995, 1996, 1998-2000 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Jim Meyering. */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#ifndef __strtol +# define __strtol strtol +# define __strtol_t long int +# define __xstrtol xstrtol +#endif + +/* Some pre-ANSI implementations (e.g. SunOS 4) + need stderr defined if assertion checking is enabled. */ +#include <stdio.h> + +#if STDC_HEADERS +# include <stdlib.h> +#endif + +#if HAVE_STRING_H +# include <string.h> +#else +# include <strings.h> +# ifndef strchr +# define strchr index +# endif +#endif + +#include <assert.h> +#include <ctype.h> + +#include <errno.h> +#ifndef errno +extern int errno; +#endif + +#if HAVE_LIMITS_H +# include <limits.h> +#endif + +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif + +/* The extra casts work around common compiler bugs. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +/* The outer cast is needed to work around a bug in Cray C 5.0.3.0. + It is necessary at least when t == time_t. */ +#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ + ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) +#define TYPE_MAXIMUM(t) (~ (t) 0 - TYPE_MINIMUM (t)) + +#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) +# define IN_CTYPE_DOMAIN(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) isascii(c) +#endif + +#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c)) + +#include "xstrtol.h" + +#ifndef strtol +long int strtol (); +#endif + +#ifndef strtoul +unsigned long int strtoul (); +#endif + +#ifndef strtoumax +uintmax_t strtoumax (); +#endif + +static int +bkm_scale (__strtol_t *x, int scale_factor) +{ + __strtol_t product = *x * scale_factor; + if (*x != product / scale_factor) + return 1; + *x = product; + return 0; +} + +static int +bkm_scale_by_power (__strtol_t *x, int base, int power) +{ + while (power--) + if (bkm_scale (x, base)) + return 1; + + return 0; +} + +/* FIXME: comment. */ + +strtol_error +__xstrtol (const char *s, char **ptr, int strtol_base, + __strtol_t *val, const char *valid_suffixes) +{ + char *t_ptr; + char **p; + __strtol_t tmp; + + assert (0 <= strtol_base && strtol_base <= 36); + + p = (ptr ? ptr : &t_ptr); + + if (! TYPE_SIGNED (__strtol_t)) + { + const char *q = s; + while (ISSPACE ((unsigned char) *q)) + ++q; + if (*q == '-') + return LONGINT_INVALID; + } + + errno = 0; + tmp = __strtol (s, p, strtol_base); + if (errno != 0) + return LONGINT_OVERFLOW; + if (*p == s) + return LONGINT_INVALID; + + /* Let valid_suffixes == NULL mean `allow any suffix'. */ + /* FIXME: update all callers except the ones that allow suffixes + after the number, changing last parameter NULL to `""'. */ + if (!valid_suffixes) + { + *val = tmp; + return LONGINT_OK; + } + + if (**p != '\0') + { + int base = 1024; + int suffixes = 1; + int overflow; + + if (!strchr (valid_suffixes, **p)) + { + *val = tmp; + return LONGINT_INVALID_SUFFIX_CHAR; + } + + if (strchr (valid_suffixes, '0')) + { + /* The ``valid suffix'' '0' is a special flag meaning that + an optional second suffix is allowed, which can change + the base, e.g. "100MD" for 100 megabytes decimal. */ + + switch (p[0][1]) + { + case 'B': + suffixes++; + break; + + case 'D': + base = 1000; + suffixes++; + break; + } + } + + switch (**p) + { + case 'b': + overflow = bkm_scale (&tmp, 512); + break; + + case 'B': + overflow = bkm_scale (&tmp, 1024); + break; + + case 'c': + overflow = 0; + break; + + case 'E': /* Exa */ + overflow = bkm_scale_by_power (&tmp, base, 6); + break; + + case 'G': /* Giga */ + overflow = bkm_scale_by_power (&tmp, base, 3); + break; + + case 'k': /* kilo */ + overflow = bkm_scale_by_power (&tmp, base, 1); + break; + + case 'M': /* Mega */ + case 'm': /* 'm' is undocumented; for backward compatibility only */ + overflow = bkm_scale_by_power (&tmp, base, 2); + break; + + case 'P': /* Peta */ + overflow = bkm_scale_by_power (&tmp, base, 5); + break; + + case 'T': /* Tera */ + overflow = bkm_scale_by_power (&tmp, base, 4); + break; + + case 'w': + overflow = bkm_scale (&tmp, 2); + break; + + case 'Y': /* Yotta */ + overflow = bkm_scale_by_power (&tmp, base, 8); + break; + + case 'Z': /* Zetta */ + overflow = bkm_scale_by_power (&tmp, base, 7); + break; + + default: + *val = tmp; + return LONGINT_INVALID_SUFFIX_CHAR; + break; + } + + if (overflow) + return LONGINT_OVERFLOW; + + (*p) += suffixes; + } + + *val = tmp; + return LONGINT_OK; +} + +#ifdef TESTING_XSTRTO + +# include <stdio.h> +# include "error.h" + +char *program_name; + +int +main (int argc, char** argv) +{ + strtol_error s_err; + int i; + + program_name = argv[0]; + for (i=1; i<argc; i++) + { + char *p; + __strtol_t val; + + s_err = __xstrtol (argv[i], &p, 0, &val, "bckmw"); + if (s_err == LONGINT_OK) + { + printf ("%s->%lu (%s)\n", argv[i], val, p); + } + else + { + STRTOL_FATAL_ERROR (argv[i], "arg", s_err); + } + } + exit (0); +} + +#endif /* TESTING_XSTRTO */ diff --git a/gnu/usr.bin/grep/xstrtol.h b/gnu/usr.bin/grep/xstrtol.h new file mode 100644 index 000000000000..7a9a024457f5 --- /dev/null +++ b/gnu/usr.bin/grep/xstrtol.h @@ -0,0 +1,64 @@ +#ifndef XSTRTOL_H_ +# define XSTRTOL_H_ 1 + +# if HAVE_INTTYPES_H +# include <inttypes.h> /* for uintmax_t */ +# endif + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +# ifndef _STRTOL_ERROR +enum strtol_error + { + LONGINT_OK, LONGINT_INVALID, LONGINT_INVALID_SUFFIX_CHAR, LONGINT_OVERFLOW + }; +typedef enum strtol_error strtol_error; +# endif + +# define _DECLARE_XSTRTOL(name, type) \ + strtol_error \ + name PARAMS ((const char *s, char **ptr, int base, \ + type *val, const char *valid_suffixes)); +_DECLARE_XSTRTOL (xstrtol, long int) +_DECLARE_XSTRTOL (xstrtoul, unsigned long int) +_DECLARE_XSTRTOL (xstrtoumax, uintmax_t) + +# define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \ + do \ + { \ + switch ((Err)) \ + { \ + case LONGINT_OK: \ + abort (); \ + \ + case LONGINT_INVALID: \ + error ((Exit_code), 0, "invalid %s `%s'", \ + (Argument_type_string), (Str)); \ + break; \ + \ + case LONGINT_INVALID_SUFFIX_CHAR: \ + error ((Exit_code), 0, "invalid character following %s `%s'", \ + (Argument_type_string), (Str)); \ + break; \ + \ + case LONGINT_OVERFLOW: \ + error ((Exit_code), 0, "%s `%s' too large", \ + (Argument_type_string), (Str)); \ + break; \ + } \ + } \ + while (0) + +# define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \ + _STRTOL_ERROR (2, Str, Argument_type_string, Err) + +# define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \ + _STRTOL_ERROR (0, Str, Argument_type_string, Err) + +#endif /* not XSTRTOL_H_ */ diff --git a/gnu/usr.bin/grep/xstrtoumax.c b/gnu/usr.bin/grep/xstrtoumax.c new file mode 100644 index 000000000000..04d7cf98ae4c --- /dev/null +++ b/gnu/usr.bin/grep/xstrtoumax.c @@ -0,0 +1,31 @@ +/* xstrtoumax.c -- A more useful interface to strtoumax. + Copyright 1999 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Written by Paul Eggert. */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#if HAVE_INTTYPES_H +# include <inttypes.h> +#endif + +#define __strtol strtoumax +#define __strtol_t uintmax_t +#define __xstrtol xstrtoumax +#include "xstrtol.c" diff --git a/gnu/usr.bin/tests/Makefile b/gnu/usr.bin/tests/Makefile new file mode 100644 index 000000000000..3b3078f8612a --- /dev/null +++ b/gnu/usr.bin/tests/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/tests +KYUAFILE= yes + +.include <bsd.test.mk> diff --git a/gnu/usr.bin/tests/Makefile.depend b/gnu/usr.bin/tests/Makefile.depend new file mode 100644 index 000000000000..f80275d86ab1 --- /dev/null +++ b/gnu/usr.bin/tests/Makefile.depend @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif |