From af1fd536c2190e697784c654c9c4fa0a7e8d842f Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Mon, 6 Apr 2015 17:48:15 +0200 Subject: [PATCH] pdp10-tools: Add GPL License and a README, remove old 'as' prototype --- 8to9/8to9.c | 18 +- 8to9/Makefile | 18 + COPYING | 674 ++++++++++++++++++++++ Makefile | 18 + README | 42 ++ TODO | 24 + ar/Makefile | 18 + ar/ar.c | 18 +- as/0LD/Makefile | 22 - as/0LD/Notes.txt | 52 -- as/0LD/TODO | 28 - as/0LD/arrlst.c | 186 ------ as/0LD/arrlst.h | 20 - as/0LD/charbuf.c | 90 --- as/0LD/charbuf.h | 24 - as/0LD/emalloc.c | 20 - as/0LD/emalloc.h | 11 - as/0LD/expr.c | 168 ------ as/0LD/expr.h | 76 --- as/0LD/parse.c | 1155 -------------------------------------- as/0LD/pass1.c | 270 --------- as/0LD/pass1.h | 9 - as/0LD/scan.c | 636 --------------------- as/0LD/section.c | 59 -- as/0LD/section.h | 35 -- as/0LD/stmt.h | 122 ---- as/0LD/strtab.c | 65 --- as/0LD/strtab.h | 17 - as/Makefile | 18 + as/assemble.c | 16 + as/assemble.h | 16 + as/hashtab.c | 16 + as/hashtab.h | 16 + as/input.c | 16 + as/input.h | 16 + as/main.c | 18 +- as/output.c | 16 + as/output.h | 16 + as/parse.c | 16 + as/parse.h | 16 + as/scan.c | 16 + as/scan.h | 16 + as/test/test1.s | 19 + as/test/test2.c | 20 + as/test/test2.s | 20 + as/token.c | 16 + as/token.def | 20 +- as/token.h | 16 + as/tunit.c | 16 + as/tunit.h | 16 + doc/MUUO.txt | 20 + include/pdp10-ar.h | 17 + include/pdp10-arith.h | 19 +- include/pdp10-elf36.h | 19 +- include/pdp10-extint.h | 17 + include/pdp10-inttypes.h | 19 +- include/pdp10-stdint.h | 19 +- include/pdp10-stdio.h | 19 +- lib/Makefile | 18 + lib/pdp10-elf36.c | 18 +- lib/pdp10-extint.c | 17 + lib/pdp10-stdio.c | 19 +- nm/Makefile | 18 + nm/nm.c | 20 +- od/Makefile | 18 + od/od.c | 18 +- readelf/Makefile | 18 + readelf/gen-test1.c | 18 +- readelf/readelf.c | 18 +- 69 files changed, 1525 insertions(+), 3090 deletions(-) create mode 100644 COPYING create mode 100644 README delete mode 100644 as/0LD/Makefile delete mode 100644 as/0LD/Notes.txt delete mode 100644 as/0LD/TODO delete mode 100644 as/0LD/arrlst.c delete mode 100644 as/0LD/arrlst.h delete mode 100644 as/0LD/charbuf.c delete mode 100644 as/0LD/charbuf.h delete mode 100644 as/0LD/emalloc.c delete mode 100644 as/0LD/emalloc.h delete mode 100644 as/0LD/expr.c delete mode 100644 as/0LD/expr.h delete mode 100644 as/0LD/parse.c delete mode 100644 as/0LD/pass1.c delete mode 100644 as/0LD/pass1.h delete mode 100644 as/0LD/scan.c delete mode 100644 as/0LD/section.c delete mode 100644 as/0LD/section.h delete mode 100644 as/0LD/stmt.h delete mode 100644 as/0LD/strtab.c delete mode 100644 as/0LD/strtab.h diff --git a/8to9/8to9.c b/8to9/8to9.c index ac5cd18..1fca89f 100644 --- a/8to9/8to9.c +++ b/8to9/8to9.c @@ -1,7 +1,21 @@ /* - * 8to9.c + * 8to9.c -- convert octet files to nonet files + * Copyright (C) 2013-2015 Mikael Pettersson * - * Convert octet files to nonet files. + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/8to9/Makefile b/8to9/Makefile index 2eb264c..1a02877 100644 --- a/8to9/Makefile +++ b/8to9/Makefile @@ -1,3 +1,21 @@ +# 8to9/Makefile +# Copyright (C) 2013-2015 Mikael Pettersson +# +# This file is part of pdp10-tools. +# +# pdp10-tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pdp10-tools 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 pdp10-tools. If not, see . + CC=gcc CFLAGS=-O2 -g -Wall CPPFLAGS=-I../include diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Makefile b/Makefile index aae147b..d27d948 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,21 @@ +# Makefile for pdp10-tools +# Copyright (C) 2013-2015 Mikael Pettersson +# +# This file is part of pdp10-tools. +# +# pdp10-tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pdp10-tools 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 pdp10-tools. If not, see . + SUBDIRS= lib 8to9 ar as nm od readelf all: diff --git a/README b/README new file mode 100644 index 0000000..d186db2 --- /dev/null +++ b/README @@ -0,0 +1,42 @@ +# README for pdp10-tools +# Copyright (C) 2013-2015 Mikael Pettersson +# +# This file is part of pdp10-tools. +# +# pdp10-tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pdp10-tools 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 pdp10-tools. If not, see . + + +PDP10-TOOLS +=========== + +pdp10-tools is a collection of utilities for manipulating pdp10-elf +binary files. + +ar: an 'ar' clone for pdp10-elf object files +as: a pdp10 assembler producing pdp10-elf object files + intended primarily as an assembler for GCC output; + the syntax is modelled after normal UNIX/ELF syntax + rather than classic TOPS-10, TOPS-20, or ITS syntax +nm: an 'nm' clone for pdp10-elf object files +od: an 'od' clone for binary files with 9-bit bytes (nonets) +readelf: a 'readelf' clone for pdp10-elf object files, + extended with an option to disassemble .text sections +8to9: a utility to convert octet files to nonet files + +pdp10-stdio: a library for reading and writing nonet-based data + on an octet-based host +pdp10-elf36: a library for reading and writing Elf36 object files + + +See the TODO file for known omissions and planned improvements. diff --git a/TODO b/TODO index 76e2f1a..92839b8 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,22 @@ +# TODO notes for pdp10-tools +# Copyright (C) 2013-2015 Mikael Pettersson +# +# This file is part of pdp10-tools. +# +# pdp10-tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pdp10-tools 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 pdp10-tools. If not, see . + + Elf36 Specification: - Do we want to adjust SHN_LORESERVE up to SHN_HIRESERVE, including SHN_XINDEX, to @@ -20,7 +39,12 @@ Tools: - ld: implement it - readelf: add support for relocs - readelf: add support for program headers +- pdp10-opcodes.{h,c}: rewrite completely - as: + * add line-comment character, e.g. '#' + + use it in doc/MUUO.txt + + use it in as/tests/*.s + + add license boilerplate to the above files * support .ident: + change strtab to have a finalizer which returns an image array, + use standard output_section for strtab diff --git a/ar/Makefile b/ar/Makefile index 9ede0a0..4e5e89a 100644 --- a/ar/Makefile +++ b/ar/Makefile @@ -1,3 +1,21 @@ +# ar/Makefile +# Copyright (C) 2013-2015 Mikael Pettersson +# +# This file is part of pdp10-tools. +# +# pdp10-tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pdp10-tools 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 pdp10-tools. If not, see . + CC=gcc CFLAGS=-O2 -g -Wall CPPFLAGS=-I../include diff --git a/ar/ar.c b/ar/ar.c index 9dedf86..dab8e82 100644 --- a/ar/ar.c +++ b/ar/ar.c @@ -1,7 +1,21 @@ /* - * ar.c + * ar.c -- ar clone + * Copyright (C) 2013-2015 Mikael Pettersson * - * ar clone for PDP10 files with 9-bit bytes + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/as/0LD/Makefile b/as/0LD/Makefile deleted file mode 100644 index 7e0ef85..0000000 --- a/as/0LD/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -CC=gcc -CFLAGS=-O2 -g -Wall -CPPFLAGS=-I../include - -OBJS= arrlst.o charbuf.o emalloc.o htab.o main.o parse.o pass1.o scan.o section.o strtab.o token.o - -all: $(OBJS) - -arrlst.o: arrlst.h emalloc.h -charbuf.o: charbuf.h emalloc.h -emalloc.o: emalloc.h -htab.o: emalloc.h htab.h -main.o: pass1.h -parse.o: emalloc.h parse.h scan.h token.h token.def stmt.h expr.h strtab.h section.h ../include/pdp10-stdint.h ../include/pdp10-elf36.h -pass1.o: parse.h pass1.h scan.h section.h stmt.h expr.h token.h ../include/pdp10-elf36.h arrlst.h htab.h strtab.h ../include/pdp10-stdint.h -scan.o: charbuf.h scan.h token.h token.def ../include/pdp10-stdint.h -section.o: emalloc.h htab.h section.h arrlst.h stmt.h expr.h strtab.h ../include/pdp10-elf36.h ../include/pdp10-stdint.h -strtab.o: emalloc.h htab.h strtab.h -token.o: ../include/pdp10-inttypes.h token.h token.def - -clean: - rm -f $(OBJS) a.out core core.* diff --git a/as/0LD/Notes.txt b/as/0LD/Notes.txt deleted file mode 100644 index cacd4bf..0000000 --- a/as/0LD/Notes.txt +++ /dev/null @@ -1,52 +0,0 @@ -* strip whitespace, leave one space before a keyword on a line, compress any - other whitespace to a single space -* white is blank, tab, /* ... */ -* target-spec line comment, .e.g. # -* symbol = [letter | _ | . | $] [letter | _ | . | $ | digit]* -* stmt: {label}* { directive | instruction | empty } - -* %r0..%r15 with %sp == %r15 ? (no, % is also an operator) -* $0..$15 with $sp == $15? (yes, these are just symbols) - - -* PDP10 syntax: - -mnemonic accumulator,address - - movem 1,foo - -mnemonic accumulator, - - popj 17, - -mnemonic address - - setzm foo - - skipe 0(16) - -address prefixed by "@" makes it indirect - - setzm @foo - -address suffixed by "(ixreg)" makes it indexed - - setzm 3(16) - - -";" is line comment char - - foo ;comment - -radix is 8 by default; a single-digit number is always decimal -radix can be changed by the RADIX directive -a number can indicate its radix by a ^B, ^O, or ^D prefix (XXX: add ^X for hex) - -symbols can use letters, digits, dot, dollar, and percent signs - -exp1,,exp2 assembles two 18-bit expressions into a 36-bit value - -< expr > parenteses - -there is no "semi-colon" like symbol for putting multiple statements -on a single line diff --git a/as/0LD/TODO b/as/0LD/TODO deleted file mode 100644 index 0ccb75b..0000000 --- a/as/0LD/TODO +++ /dev/null @@ -1,28 +0,0 @@ -section text -* subsection text0 -** frag0, frag1, ... each being sth that generates object code -* subsection test1 -** frag... -section data -* subsection data0 -** frag... - -array of sections (ELF allows user-defined ones) -a section is array of subsections, sorted and concatenated during output, ld sees no subsections -a subsection is array of fragments -a fragment describes a directive, an insn, a label defn - -pass1 parses .s text, creates frags, and appends them to subsections - -pass2 computes labels - -pass3 outputs concatenated data in ELF form - -helpers -* string table -* symbol table -* section table - -copy ELF32 headers and use them throughout, esp. for symbol/section types etc - -Look up section group and comdat in sco elf draft html pages. diff --git a/as/0LD/arrlst.c b/as/0LD/arrlst.c deleted file mode 100644 index 503f6e7..0000000 --- a/as/0LD/arrlst.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - * arrlst.c - */ -#include -#include -#include "arrlst.h" -#include "emalloc.h" - -enum { - ARRLST_CHUNK_NRELEM = 128, -}; - -struct arrlst { - void *head; - void *tail; - unsigned int eltsz; - unsigned int tailpos; - - /* We only allow a single iterator per arrlst, so we - allocate the iterator in the arrlst itself. */ - struct { - void *chunk; - unsigned int chunkpos; - unsigned int chunklen; - } iter; -}; - -static void **arrlst_chunk_nextp(const void *chunk) -{ - return (void**)chunk; -} - -static unsigned int eltsz_chunk_header_nrelem(unsigned int eltsz) -{ - unsigned int nrelem; - - /* compute how may eltsz elements are needed to cover a void* */ - nrelem = sizeof(void*) / eltsz; - if (nrelem * eltsz < sizeof(void*)) - ++nrelem; - - return nrelem; -} - -static unsigned int arrlst_chunk_header_nrelem(const struct arrlst *arrlst) -{ - return eltsz_chunk_header_nrelem(arrlst->eltsz); -} - -static void *arrlst_chunk_element(const struct arrlst *arrlst, void *chunk, unsigned int eltnr) -{ - return (char*)chunk + eltnr * arrlst->eltsz; -} - -static void *arrlst_alloc_chunk(const struct arrlst *arrlst) -{ - unsigned int nrbytes; - void *chunk; - - nrbytes = arrlst->eltsz * ARRLST_CHUNK_NRELEM; - chunk = emalloc(nrbytes); - return chunk; -} - -struct arrlst *arrlst_alloc(size_t eltsz) -{ - struct arrlst *arrlst; - - if (eltsz == 0 - || eltsz > (unsigned int)-1 - || eltsz_chunk_header_nrelem(eltsz) >= ARRLST_CHUNK_NRELEM) - return NULL; - - arrlst = emalloc(sizeof *arrlst); - - /* these fields will be adjusted in the first call to append() */ - arrlst->head = NULL; - arrlst->tail = NULL; - arrlst->eltsz = eltsz; - arrlst->tailpos = ARRLST_CHUNK_NRELEM; - - return arrlst; -} - -void arrlst_free(struct arrlst *arrlst) -{ - void *chunk, *next; - - chunk = arrlst->head; - while (chunk) { - next = *arrlst_chunk_nextp(chunk); - free(chunk); - chunk = next; - } - - free(arrlst); -} - -size_t arrlst_length(const struct arrlst *arrlst) -{ - const void *chunk; - size_t length; - size_t chunk_header_nrelem; - - chunk = arrlst->head; - if (!chunk) - return 0; - length = 0; - chunk_header_nrelem = arrlst_chunk_header_nrelem(arrlst); - for (;;) { - chunk = *arrlst_chunk_nextp(chunk); - if (!chunk) - break; - length += ARRLST_CHUNK_NRELEM - chunk_header_nrelem; - } - return length + arrlst->tailpos - chunk_header_nrelem; -} - -void *arrlst_append(struct arrlst *arrlst) -{ - void *tail; - void *elt; - - tail = arrlst->tail; - - if (arrlst->tailpos >= ARRLST_CHUNK_NRELEM) { - void *new_tail; - - new_tail = arrlst_alloc_chunk(arrlst); - if (!new_tail) - return NULL; - - if (tail) - *arrlst_chunk_nextp(tail) = new_tail; - else { - arrlst->head = new_tail; - arrlst->tail = new_tail; - } - - arrlst->tailpos = arrlst_chunk_header_nrelem(arrlst); - - tail = new_tail; - } - - elt = arrlst_chunk_element(arrlst, tail, arrlst->tailpos); - ++arrlst->tailpos; - - return elt; -} - -void arrlst_iter_rewind(struct arrlst *arrlst) -{ - /* these fields will be adjusted in the first call to next() */ - arrlst->iter.chunk = NULL; - arrlst->iter.chunklen = 0; - arrlst->iter.chunkpos = 0; -} - -void *arrlst_iter_next(struct arrlst *arrlst) -{ - void *chunk; - void *elt; - - chunk = arrlst->iter.chunk; - if (arrlst->iter.chunkpos >= arrlst->iter.chunklen) { - if (!chunk) - chunk = arrlst->head; - else - chunk = *arrlst_chunk_nextp(chunk); - if (!chunk) - return NULL; - arrlst->iter.chunk = chunk; - - if (*arrlst_chunk_nextp(chunk)) - arrlst->iter.chunklen = ARRLST_CHUNK_NRELEM; - else - arrlst->iter.chunklen = arrlst->tailpos; - - arrlst->iter.chunkpos = arrlst_chunk_header_nrelem(arrlst); - } - - elt = arrlst_chunk_element(arrlst, chunk, arrlst->iter.chunkpos); - ++arrlst->iter.chunkpos; - - return elt; -} diff --git a/as/0LD/arrlst.h b/as/0LD/arrlst.h deleted file mode 100644 index 6baaf92..0000000 --- a/as/0LD/arrlst.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * arrlst.h - */ -#ifndef ARRLST_H -#define ARRLST_H - -#include /* size_t */ - -struct arrlst; - -struct arrlst *arrlst_alloc(size_t eltsz); -void arrlst_free(struct arrlst *arrlst); -size_t arrlst_length(const struct arrlst *arrlst); -void *arrlst_append(struct arrlst *arrlst); - -/* for now there is only one iterator per arrlst */ -void arrlst_iter_rewind(struct arrlst *arrlst); -void *arrlst_iter_next(struct arrlst *arrlst); - -#endif /* ARRLST_H */ diff --git a/as/0LD/charbuf.c b/as/0LD/charbuf.c deleted file mode 100644 index 11929da..0000000 --- a/as/0LD/charbuf.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * charbuf.c - */ -#include -#include -#include "charbuf.h" -#include "emalloc.h" - -void charbuf_init(struct charbuf *charbuf) -{ - charbuf->head.next = NULL; - charbuf->tail = &charbuf->head; - charbuf->pos = 0; -} - -void charbuf_fini(struct charbuf *charbuf) -{ - struct charbuf_chunk *chunk, *next; - - chunk = charbuf->head.next; - while (chunk != NULL) { - next = chunk->next; - free(chunk); - chunk = next; - } -} - -void charbuf_append(struct charbuf *charbuf, int ch) -{ - struct charbuf_chunk *tail, *next; - unsigned int pos; - - tail = charbuf->tail; - pos = charbuf->pos; - if (pos >= sizeof tail->buf) { - next = emalloc(sizeof *next); - next->next = NULL; - tail->next = next; - tail = next; - charbuf->tail = tail; - pos = 0; - } - tail->buf[pos] = ch; - charbuf->pos = pos + 1; -} - -int charbuf_strcmp(const struct charbuf *charbuf, const char *string) -{ - const struct charbuf_chunk *chunk; - int cmp; - - chunk = &charbuf->head; - while (chunk->next != NULL) { - cmp = strncmp(chunk->buf, string, sizeof chunk->buf); - if (cmp) - return cmp; - string += sizeof chunk->buf; - chunk = chunk->next; - } - return strncmp(chunk->buf, string, charbuf->pos); -} - -char *charbuf_string(const struct charbuf *charbuf) -{ - const struct charbuf_chunk *chunk; - size_t nrbytes; - char *string, *strp; - - chunk = &charbuf->head; - nrbytes = 0; - while (chunk->next != NULL) { - nrbytes += sizeof chunk->buf; - chunk = chunk->next; - } - nrbytes = nrbytes + charbuf->pos + 1; - - string = emalloc(nrbytes); - - chunk = &charbuf->head; - strp = string; - while (chunk->next != NULL) { - memcpy(strp, chunk->buf, sizeof chunk->buf); - strp += sizeof chunk->buf; - chunk = chunk->next; - } - memcpy(strp, chunk->buf, charbuf->pos); - strp[charbuf->pos] = '\0'; - - return string; -} diff --git a/as/0LD/charbuf.h b/as/0LD/charbuf.h deleted file mode 100644 index b38ea32..0000000 --- a/as/0LD/charbuf.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * charbuf.h - */ -#ifndef CHARBUF_H -#define CHARBUF_H - -struct charbuf_chunk { - char buf[128 - sizeof(struct charbuf_chunk*)]; - struct charbuf_chunk *next; -}; - -struct charbuf { - struct charbuf_chunk head; - struct charbuf_chunk *tail; /* INV: tail->next == NULL */ - unsigned int pos; /* in tail chunk */ -}; - -void charbuf_init(struct charbuf *charbuf); -void charbuf_fini(struct charbuf *charbuf); -void charbuf_append(struct charbuf *charbuf, int ch); -int charbuf_strcmp(const struct charbuf *charbuf, const char *string); -char *charbuf_string(const struct charbuf *charbuf); - -#endif /* CHARBUF_H */ diff --git a/as/0LD/emalloc.c b/as/0LD/emalloc.c deleted file mode 100644 index 7ae6ba5..0000000 --- a/as/0LD/emalloc.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * emalloc.c - */ -#include -#include -#include -#include -#include "emalloc.h" - -void *emalloc(size_t nrbytes) -{ - void *p; - - p = malloc(nrbytes); - if (!p) { - fprintf(stderr, "malloc(%zu) failed: %s\n", nrbytes, strerror(errno)); - exit(1); - } - return p; -} diff --git a/as/0LD/emalloc.h b/as/0LD/emalloc.h deleted file mode 100644 index c24d065..0000000 --- a/as/0LD/emalloc.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * emalloc.h - */ -#ifndef EMALLOC_H -#define EMALLOC_H - -#include /* size_t */ - -void *emalloc(size_t nrbytes); - -#endif /* EMALLOC_H */ diff --git a/as/0LD/expr.c b/as/0LD/expr.c deleted file mode 100644 index 7e72838..0000000 --- a/as/0LD/expr.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * expr.c - */ -#include -#include "pdp10-arith.h" -#include "expr.h" - -int eval(const struct expr *expr, struct value *value, int quiet) -{ - switch (expr->tag) { - case E_UINTEGER: - value->section = SECTION_ABS; - value->offset = expr->u.e_uinteger.val; - break; - case E_SYMBOL: - xxx; - break; - case E_UNARY: - if (eval(expr->u.e_unary.expr, value, quiet) < 0) - return -1; - if (value->section != SECTION_ABS) { - if (!quiet) - fprintf(stderr, "as: %s(): unary operand is not absolute\n", __FUNCTION__); - return -1; - } - switch (expr->u.e_unary.unop) { - case E_UMINUS: - value->offset = pdp10_neg_int36(value->offset); - break; - case E_NOT: - value->offset = pdp10_not_int36(value->offset); - break; - } - break; - case E_BINARY: - { - struct value value2; - - if (eval(expr->u.e_binary.expr1, value, quiet) < 0 - || eval(expr->u.e_binary.expr2, &value2, quiet) < 0) - return -1; - - switch (expr->u.e_binary.binop) { - case E_ADD: - if (value->section == SECTION_ABS) - value->section = value2.section; - else if (value2.section == SECTION_ABS) - ; - else if (value->section == value2.section) - ; - else { - if (!quiet) - fprintf(stderr, "as: %s(): adding operands from different sections\n", __FUNCTION__); - return -1; - } - value->offset = pdp10_add_int36(value->offset, value2.offset); - return 0; - case E_SUB: - if (value2.section == SECTION_ABS) - ; - else if (value->section == value2.section) - value->section = SECTION_ABS; - else { - if (!quiet) - fprintf(stderr, "as: %s(): subtracting operands from different sections\n", __FUNCTION__); - return -1; - } - value->offset = pdp10_sub_int36(value->offset, value2.offset); - return 0; - default: - break; - } - if (value->section != SECTION_ABS - || value2.section != SECTION_ABS) { - if (!quiet) - fprintf(stderr, "as: %s(): binary sub- is not absolute\n", __FUNCTION__); - return -1; - } - switch (expr->u.e_binary.binop) { - case E_MUL: - value->offset = pdp10_mul_int36(value->offset, value2.offset); - break; - case E_DIV: - /* XXX: div-by-zero check */ - value->offset = pdp10_div_int36(value->offset, value2.offset); - break; - case E_REM: - /* XXX: div-by-zero check */ - value->offset = pdp10_rem_int36(value->offset, value2.offset); - break; - case E_LSHIFT: - /* XXX: range check */ - value->offset = pdp10_asl_int36(value->offset, value2.offset); - break; - case E_RSHIFT: - /* XXX: range check */ - value->offset = pdp10_asr_int36(value->offset, value2.offset); - break; - case E_OR: - value->offset = pdp10_or_int36(value->offset, value2.offset); - break; - case E_AND: - value->offset = pdp10_and_int36(value->offset, value2.offset); - break; - case E_XOR: - value->offset = pdp10_xor_int36(value->offset, value2.offset); - break; - case E_ORNOT: - value->offset = pdp10_or_int36(value->offset, pdp10_not_int36(value2.offset)); - break; - case E_EQ: - value->offset = pdp10_eq_int36(value->offset, value2.offset) ? PDP10_UINT36_MAX : 0; - break; - case E_NE: - value->offset = pdp10_ne_int36(value->offset, value2.offset) ? PDP10_UINT36_MAX : 0; - break; - case E_LT: - value->offset = pdp10_lt_int36(value->offset, value2.offset) ? PDP10_UINT36_MAX : 0; - break; - case E_GT: - value->offset = pdp10_gt_int36(value->offset, value2.offset) ? PDP10_UINT36_MAX : 0; - break; - case E_GE: - value->offset = pdp10_ge_int36(value->offset, value2.offset) ? PDP10_UINT36_MAX : 0; - break; - case E_LE: - value->offset = pdp10_le_int36(value->offset, value2.offset) ? PDP10_UINT36_MAX : 0; - break; - case E_ANDAND: - value->offset = (pdp10_nonzero_int36(value->offset) && pdp10_nonzero_int36(value2.offset)) ? 1 : 0; - break; - case E_OROR: - value->offset = (pdp10_nonzero_int36(value->offset) || pdp10_nonzero_int36(value2.offset)) ? 1 : 0; - break; - default: - /* E_ADD / E_SUB cannot occur here, but the compiler may not see that */ - break; - } - break; - } - } - return 0; -} - -int eval_abs(const struct expr *expr, pdp10_uint36_t *offset, int quiet) -{ - struct value value; - - if (eval(expr, &value, quiet) < 0) - return -1; - if (value.section != SECTION_ABS) { - if (!quiet) - fprintf(stderr, "as: non-absolute expression\n"); - return -1; - } - *offset = value.offset; - return 0; -} - -int eval_abs_verbose(const struct expr *expr, pdp10_uint36_t *offset) -{ - return eval_abs(expr, offset, 0); -} - -int eval_abs_quiet(const struct expr *expr, pdp10_uint36_t *offset) -{ - return eval_abs(expr, offset, 1); -} diff --git a/as/0LD/expr.h b/as/0LD/expr.h deleted file mode 100644 index 70bf4bf..0000000 --- a/as/0LD/expr.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * expr.h - */ -#ifndef EXPR_H -#define EXPR_H - -#include "pdp10-elf36.h" -#include "section.h" -#include "strtab.h" - -enum expr_tag { - E_UINTEGER, - E_SYMBOL, - E_UNARY, - E_BINARY, -}; - -enum expr_unop { - E_UMINUS, - E_NOT, -}; - -enum expr_binop { - E_MUL, - E_DIV, - E_REM, - E_LSHIFT, - E_RSHIFT, - E_OR, - E_AND, - E_XOR, - E_ORNOT, - E_ADD, - E_SUB, - E_EQ, - E_NE, - E_LT, - E_GT, - E_GE, - E_LE, - E_ANDAND, - E_OROR, -}; - -struct expr { - enum expr_tag tag; - union { - struct { - pdp10_uint36_t val; - } e_uinteger; - struct { - const struct strnode *name; - } e_symbol; - struct { - enum expr_unop unop; - struct expr *expr; - } e_unary; - struct { - enum expr_binop binop; - struct expr *expr1; - struct expr *expr2; - } e_binary; - } u; -}; - -struct value { - struct section *section; - pdp10_uint36_t offset; -}; - -int eval(const struct expr *expr, struct value *value, int quiet); -int eval_abs(const struct expr *expr, pdp10_uint36_t *offset, int quiet); -int eval_abs_verbose(const struct expr *expr, pdp10_uint36_t *offset); -int eval_abs_quiet(const struct expr *expr, pdp10_uint36_t *offset); - -#endif /* EXPR_H */ diff --git a/as/0LD/parse.c b/as/0LD/parse.c deleted file mode 100644 index 074c2af..0000000 --- a/as/0LD/parse.c +++ /dev/null @@ -1,1155 +0,0 @@ -/* - * parse.c - */ -#include -#include -#include -#include "emalloc.h" -#include "parse.h" -#include "scan.h" -#include "token.h" - -static void error(const char *msg, enum token token, const union token_attribute *token_attr) -{ - fprintf(stderr, "Syntax error on line %u: %s; current token is ", scan_linenr, msg); - token_print(stderr, token, token_attr); - fprintf(stderr, "\n"); -} - -static enum token save_token = T_EOF; -static union token_attribute save_token_attr; - -static enum token token_get(union token_attribute *token_attr) -{ - enum token token; - - token = save_token; - if (token != T_EOF) { - *token_attr = save_token_attr; - save_token = T_EOF; - return token; - } - return scan(token_attr); -} - -static void token_unget(enum token token, const union token_attribute *token_attr) -{ - save_token = token; - save_token_attr = *token_attr; -} - -/* - * Expression grammar: - * The productions are listed from highest to lowest precedence. - * All infix operators are left-associative. - * - * E -> '(' E ')' | | | -E | ~E - * | E MOP E - * | E BOP E - * | E AOP E - * | E && E - * | E || E - * - * MOP -> * | / | % | << | >> - * BOP -> '|' | & | ^ | ! - * AOP -> + | - | == | <> | != | < | > | >= | <= - */ - -static struct expr *make_expr(enum expr_tag tag) -{ - struct expr *expr; - - expr = emalloc(sizeof *expr); - expr->tag = tag; - return expr; -} - -static void free_expr(struct expr *expr) -{ - if (expr) { - switch (expr->tag) { - case E_UNARY: - free_expr(expr->u.e_unary.expr); - break; - case E_BINARY: - free_expr(expr->u.e_binary.expr1); - free_expr(expr->u.e_binary.expr2); - break; - default: - break; - } - free(expr); - } -} - -static struct expr *make_uinteger_expr(pdp10_uint36_t val) -{ - struct expr *expr; - - expr = make_expr(E_UINTEGER); - expr->u.e_uinteger.val = val; - return expr; -} - -static struct expr *make_symbol_expr(const struct strnode *name) -{ - struct expr *expr; - - expr = make_expr(E_SYMBOL); - expr->u.e_symbol.name = name; - return expr; -} - -static struct expr *make_unary_expr(enum expr_unop unop, struct expr *expr1) -{ - struct expr *expr; - - expr = make_expr(E_UNARY); - expr->u.e_unary.unop = unop; - expr->u.e_unary.expr = expr1; - return expr; -} - -static struct expr *make_binary_expr(struct expr *expr1, enum expr_binop binop, struct expr *expr2) -{ - struct expr *expr; - - expr = make_expr(E_BINARY); - expr->u.e_binary.expr1 = expr1; - expr->u.e_binary.binop = binop; - expr->u.e_binary.expr2 = expr2; - return expr; -} - -static struct expr *parse_expr(void); /* forward */ - -static struct expr *parse_atomic_expr(void) -{ - enum token token; - union token_attribute token_attr; - struct expr *expr; - - token = token_get(&token_attr); - switch (token) { - case T_UINTEGER: - return make_uinteger_expr(token_attr.uint); - case T_SYMBOL: - return make_symbol_expr(strtab_enter(token_attr.text)); - case T_LPAREN: - expr = parse_expr(); - token = token_get(&token_attr); - if (token != T_RPAREN) { - error("junk after expression, expected right parenthesis", token, &token_attr); - return NULL; - } - return expr; - case T_MINUS: - return make_unary_expr(E_UMINUS, parse_atomic_expr()); - case T_TILDE: - return make_unary_expr(E_NOT, parse_atomic_expr()); - default: - error("bad expression, expected integer, symbol, unary operator, or left parenthesis", token, &token_attr); - return NULL; - } -} - -static struct expr *parse_multiplicative_expr(void) -{ - struct expr *expr1; - struct expr *expr2; - enum token token; - union token_attribute token_attr; - enum expr_binop binop; - - expr1 = parse_atomic_expr(); - if (!expr1) - return NULL; - - for (;;) { - token = token_get(&token_attr); - switch (token) { - case T_MUL: - binop = E_MUL; - break; - case T_DIV: - binop = E_DIV; - break; - case T_REM: - binop = E_REM; - break; - case T_LSHIFT: - binop = E_LSHIFT; - break; - case T_RSHIFT: - binop = E_RSHIFT; - break; - default: - token_unget(token, &token_attr); - return expr1; - } - expr2 = parse_atomic_expr(); - if (!expr2) - return NULL; - expr1 = make_binary_expr(expr1, binop, expr2); - } -} - -static struct expr *parse_bitwise_expr(void) -{ - struct expr *expr1; - struct expr *expr2; - enum token token; - union token_attribute token_attr; - enum expr_binop binop; - - expr1 = parse_multiplicative_expr(); - if (!expr1) - return NULL; - - for (;;) { - token = token_get(&token_attr); - switch (token) { - case T_OR: - binop = E_OR; - break; - case T_AND: - binop = E_AND; - break; - case T_CARET: - binop = E_XOR; - break; - case T_BANG: - binop = E_ORNOT; - break; - default: - token_unget(token, &token_attr); - return expr1; - } - expr2 = parse_multiplicative_expr(); - if (!expr2) - return NULL; - expr1 = make_binary_expr(expr1, binop, expr2); - } -} - -static struct expr *parse_additive_expr(void) -{ - struct expr *expr1; - struct expr *expr2; - enum token token; - union token_attribute token_attr; - enum expr_binop binop; - - expr1 = parse_bitwise_expr(); - if (!expr1) - return NULL; - - for (;;) { - token = token_get(&token_attr); - switch (token) { - case T_PLUS: - binop = E_ADD; - break; - case T_MINUS: - binop = E_SUB; - break; - case T_EQEQ: - binop = E_EQ; - break; - case T_NEQ: - binop = E_NE; - break; - case T_LT: - binop = E_LT; - break; - case T_GT: - binop = E_GT; - break; - case T_GE: - binop = E_GE; - break; - case T_LE: - binop = E_LE; - break; - default: - token_unget(token, &token_attr); - return expr1; - } - expr2 = parse_bitwise_expr(); - if (!expr2) - return NULL; - expr1 = make_binary_expr(expr1, binop, expr2); - } -} - -static struct expr *parse_andand_expr(void) -{ - struct expr *expr1; - struct expr *expr2; - enum token token; - union token_attribute token_attr; - - expr1 = parse_additive_expr(); - if (!expr1) - return NULL; - - for (;;) { - token = token_get(&token_attr); - if (token != T_ANDAND) { - token_unget(token, &token_attr); - return expr1; - } - expr2 = parse_additive_expr(); - if (!expr2) - return NULL; - expr1 = make_binary_expr(expr1, E_ANDAND, expr2); - } -} - -static struct expr *parse_oror_expr(void) -{ - struct expr *expr1; - struct expr *expr2; - enum token token; - union token_attribute token_attr; - - expr1 = parse_andand_expr(); - if (!expr1) - return NULL; - - for (;;) { - token = token_get(&token_attr); - if (token != T_OROR) { - token_unget(token, &token_attr); - return expr1; - } - expr2 = parse_andand_expr(); - if (!expr2) - return NULL; - expr1 = make_binary_expr(expr1, E_OROR, expr2); - } -} - -static struct expr *parse_expr(void) -{ - return parse_oror_expr(); -} - -static int parse_expr_opt(struct expr **exprp) -{ - enum token token; - union token_attribute token_attr; - - token = token_get(&token_attr); - token_unget(token, &token_attr); - switch (token) { - case T_UINTEGER: - case T_SYMBOL: - case T_LPAREN: - case T_MINUS: - case T_TILDE: - *exprp = parse_expr(); - return *exprp == NULL ? -1 : 1; - default: - return 0; - } -} - -static int parse_dot_align(struct stmt *stmt, unsigned int flags) -{ - enum token token; - union token_attribute token_attr; - struct expr *expr; - - stmt->tag = S_ALIGN; - stmt->u.s_align.flags = flags; - expr = parse_expr(); - if (!expr) - return -1; - stmt->u.s_align.balign = expr; - - token = token_get(&token_attr); - if (token == T_COMMA) { - expr = parse_expr(); - if (!expr) - return -1; - stmt->u.s_align.fill = expr; - token = token_get(&token_attr); - if (token == T_COMMA) { - expr = parse_expr(); - if (!expr) - return -1; - stmt->u.s_align.maxskip = expr; - token = token_get(&token_attr); - } - } - if (token != T_NEWLINE) { - error("junk after .{,b,p2}align{,w,l} directive", token, &token_attr); - return -1; - } - return 1; -} - -static struct string_list *make_string_list(const struct strnode *string, struct string_list *next) -{ - struct string_list *list; - - list = emalloc(sizeof *list); - list->string = string; - list->next = next; - return list; -} - -static int parse_string_list(struct stmt *stmt, enum stmt_tag tag) -{ - enum token token; - union token_attribute token_attr; - struct string_list **nextp; - struct string_list *temp; - - stmt->tag = tag; - stmt->u.s_string_list.list = NULL; - nextp = &stmt->u.s_string_list.list; - - token = token_get(&token_attr); - if (token == T_STRING) - for (;;) { - temp = make_string_list(strtab_enter(token_attr.text), NULL); - *nextp = temp; - nextp = &temp->next; - token = token_get(&token_attr); - if (token != T_COMMA) - break; - token = token_get(&token_attr); - if (token != T_STRING) { - error("junk after ',' in .asci{i,z} directive", token, &token_attr); - return -1; - } - } - - if (token != T_NEWLINE) { - error("junk after .asci{i,z} directive", token, &token_attr); - return -1; - } - return 1; -} - -static struct expr_list *make_expr_list(struct expr *expr, struct expr_list *next) -{ - struct expr_list *list; - - list = emalloc(sizeof *list); - list->expr = expr; - list->next = next; - return list; -} - -static int parse_expr_list(struct stmt *stmt, enum stmt_tag tag) -{ - enum token token; - union token_attribute token_attr; - struct expr_list **nextp; - struct expr_list *temp; - struct expr *expr; - int status; - - stmt->tag = tag; - stmt->u.s_expr_list.list = NULL; - nextp = &stmt->u.s_expr_list.list; - - status = parse_expr_opt(&expr); - if (status < 0) - return -1; - else if (status == 0) - token = token_get(&token_attr); - else - for (;;) { - temp = make_expr_list(expr, NULL); - *nextp = temp; - nextp = &temp->next; - token = token_get(&token_attr); - if (token != T_COMMA) - break; - expr = parse_expr(); - if (!expr) - return -1; - } - - if (token != T_NEWLINE) { - error("junk after .{byte,long,short} directive", token, &token_attr); - return -1; - } - return 1; -} - -static int parse_string(struct stmt *stmt, enum stmt_tag tag) -{ - enum token token; - union token_attribute token_attr; - - token = token_get(&token_attr); - if (token == T_STRING) { - stmt->u.s_string.string = strtab_enter(token_attr.text); - stmt->tag = tag; - token = token_get(&token_attr); - if (token == T_NEWLINE) - return 1; - } - error("junk after .file/.ident directive", token, &token_attr); - return -1; -} - -static int parse_dot_popsection(struct stmt *stmt) -{ - enum token token; - union token_attribute token_attr; - - token = token_get(&token_attr); - if (token == T_NEWLINE) { - stmt->tag = S_POPSECTION; - return 1; - } - error("junk after .popsection directive", token, &token_attr); - return -1; -} - -static int parse_dot_previous(struct stmt *stmt) -{ - enum token token; - union token_attribute token_attr; - - token = token_get(&token_attr); - if (token == T_NEWLINE) { - stmt->tag = S_PREVIOUS; - return 1; - } - error("junk after .previous directive", token, &token_attr); - return -1; -} - -static int parse_dot_subsection(struct stmt *stmt) -{ - struct expr *expr; - enum token token; - union token_attribute token_attr; - - expr = parse_expr(); - if (!expr) - return -1; - stmt->u.s_subsection.expr = expr; - - token = token_get(&token_attr); - if (token == T_NEWLINE) { - stmt->tag = S_SUBSECTION; - return 1; - } - error("junk after .subsection directive", token, &token_attr); - return -1; -} - -static int parse_name_list(struct stmt *stmt, enum stmt_tag tag) -{ - enum token token; - union token_attribute token_attr; - struct string_list **nextp; - struct string_list *temp; - - stmt->tag = tag; - stmt->u.s_string_list.list = NULL; - nextp = &stmt->u.s_string_list.list; - - token = token_get(&token_attr); - if (token == T_SYMBOL) - for (;;) { - temp = make_string_list(strtab_enter(token_attr.text), NULL); - *nextp = temp; - nextp = &temp->next; - token = token_get(&token_attr); - if (token != T_COMMA) - break; - token = token_get(&token_attr); - if (token != T_SYMBOL) { - error("junk after ',' in .globl/.hidden/.internal/.local/.protected directive", token, &token_attr); - return -1; - } - } - - if (token != T_NEWLINE) { - error("junk after .globl/.hidden/.internal/.local/.protected directive", token, &token_attr); - return -1; - } - return 1; -} - -static int parse_dot_comm(struct stmt *stmt) -{ - enum token token; - union token_attribute token_attr; - struct expr *expr; - - token = token_get(&token_attr); - if (token == T_SYMBOL) { - stmt->u.s_comm.name = strtab_enter(token_attr.text); - token = token_get(&token_attr); - if (token == T_COMMA) { - expr = parse_expr(); - if (!expr) - return -1; - stmt->u.s_comm.length = expr; - token = token_get(&token_attr); - if (token == T_COMMA) { - expr = parse_expr(); - if (!expr) - return -1; - stmt->u.s_comm.balign = expr; - token = token_get(&token_attr); - } else - stmt->u.s_comm.balign = NULL; - if (token == T_NEWLINE) { - stmt->tag = S_COMM; - return 1; - } - } - } - error("junk after .comm directive", token, &token_attr); - return -1; -} - -static int parse_dot_org(struct stmt *stmt) -{ - enum token token; - union token_attribute token_attr; - struct expr *expr; - - expr = parse_expr(); - if (!expr) - return -1; - stmt->u.s_org.newlc = expr; - token = token_get(&token_attr); - if (token == T_COMMA) { - expr = parse_expr(); - if (!expr) - return -1; - stmt->u.s_org.fill = expr; - token = token_get(&token_attr); - } else - stmt->u.s_org.fill = NULL; - if (token == T_NEWLINE) { - stmt->tag = S_ORG; - return 1; - } - error("junk after .org directive", token, &token_attr); - return -1; -} - -static int parse_setsize(struct stmt *stmt, enum stmt_tag tag) -{ - enum token token; - union token_attribute token_attr; - struct expr *expr; - - token = token_get(&token_attr); - if (token == T_SYMBOL) { - stmt->u.s_setsize.name = strtab_enter(token_attr.text); - token = token_get(&token_attr); - if (token == T_COMMA) { - expr = parse_expr(); - if (!expr) - return -1; - stmt->u.s_setsize.expr = expr; - token = token_get(&token_attr); - if (token == T_NEWLINE) { - stmt->tag = tag; - return 1; - } - } - } - error("junk after .set/.size directive", token, &token_attr); - return -1; -} - -static int parse_sh_flags(Elf36_Word *sh_flags) -{ - enum token token; - union token_attribute token_attr; - const char *f; - Elf36_Word flag; - - token = token_get(&token_attr); - if (token == T_STRING) { - f = token_attr.text; - for (; ; *sh_flags |= flag, ++f) { - switch (*f) { - case 'a': - flag = SHF_ALLOC; - continue; - case 'e': - flag = SHF_EXCLUDE; - continue; - case 'w': - flag = SHF_WRITE; - continue; - case 'M': - flag = SHF_MERGE; - continue; - case 'S': - flag = SHF_STRINGS; - continue; - case 'G': - if (*sh_flags & (1 << 19)) - break; - flag = SHF_GROUP; - continue; - case 'T': - flag = SHF_TLS; - continue; - case '?': - if (*sh_flags & SHF_GROUP) - break; - flag = 1 << 19; /* XXX: FAKE FAKE FAKE */ - continue; - case '\0': - /* XXX: free the string? */ - return 1; - default: - break; - } - break; - } - } - error("invalid section flags", token, &token_attr); - return -1; -} - -static int parse_sh_type(Elf36_Word *sh_type) -{ - enum token token; - union token_attribute token_attr; - Elf36_Word type; - - token = token_get(&token_attr); - if (token == T_AT) { - token = token_get(&token_attr); - if (token == T_SYMBOL) { - do { - if (strcmp(token_attr.text, "progbits") == 0) - type = SHT_PROGBITS; - else if (strcmp(token_attr.text, "nobits") == 0) - type = SHT_NOBITS; - else if (strcmp(token_attr.text, "note") == 0) - type = SHT_NOTE; - else if (strcmp(token_attr.text, "init_array") == 0) - type = SHT_INIT_ARRAY; - else if (strcmp(token_attr.text, "fini_array") == 0) - type = SHT_FINI_ARRAY; - else if (strcmp(token_attr.text, "preinit_array") == 0) - type = SHT_PREINIT_ARRAY; - else - break; - *sh_type = type; - return 1; - } while (0); - } - } - error("invalid section type", token, &token_attr); - return -1; -} - -static int parse_dot_section(struct stmt *stmt, int is_pushsection) -{ - enum token token; - union token_attribute token_attr; - - stmt->u.s_section.subsectnr = NULL; - stmt->u.s_section.sh_flags = 0; - stmt->u.s_section.sh_type = 0; - stmt->u.s_section.sh_entsize = NULL; - stmt->u.s_section.groupname = NULL; - stmt->u.s_section.linkage = NULL; - - token = token_get(&token_attr); - if (token == T_SYMBOL) { - stmt->u.s_section.name = strtab_enter(token_attr.text); - token = token_get(&token_attr); - do { - if (is_pushsection) { - if (token != T_COMMA) - break; - stmt->u.s_section.subsectnr = parse_expr(); - if (!stmt->u.s_section.subsectnr) - return -1; - token = token_get(&token_attr); - } - if (token != T_COMMA) - break; - if (parse_sh_flags(&stmt->u.s_section.sh_flags) < 1) - return -1; - token = token_get(&token_attr); - if (token != T_COMMA) { - if (stmt->u.s_section.sh_flags & (SHF_MERGE | SHF_GROUP)) { - error("section flags with M and/or G not followed by ,@type", token, &token_attr); - return -1; - } - break; - } - if (parse_sh_type(&stmt->u.s_section.sh_type) < 0) - return -1; - token = token_get(&token_attr); - if (stmt->u.s_section.sh_flags & SHF_MERGE) { - if (token != T_COMMA) { - error("section flags with M not followed by entsize", token, &token_attr); - return -1; - } - stmt->u.s_section.sh_entsize = parse_expr(); - if (!stmt->u.s_section.sh_entsize) - return -1; - token = token_get(&token_attr); - } - if (stmt->u.s_section.sh_flags & SHF_GROUP) { - if (token != T_COMMA) { - error("section flags with G not followed by groupname", token, &token_attr); - return -1; - } - token = token_get(&token_attr); - if (token != T_SYMBOL) { - error("section group with invalid groupname", token, &token_attr); - return -1; - } - stmt->u.s_section.groupname = strtab_enter(token_attr.text); - token = token_get(&token_attr); - if (token != T_COMMA) - break; - token = token_get(&token_attr); - if (token != T_SYMBOL) { - error("section group with invalid linkage", token, &token_attr); - return -1; - } - stmt->u.s_section.linkage = strtab_enter(token_attr.text); - token = token_get(&token_attr); - } - } while (0); - if (token == T_NEWLINE) { - stmt->tag = is_pushsection ? S_PUSHSECTION : S_SECTION; - return 1; - } - } - error("junk after .section/.pushsection directive", token, &token_attr); - return -1; -} - -static int parse_oldstyle_section(struct stmt *stmt, const char *name) -{ - enum token token; - union token_attribute token_attr; - - stmt->u.s_section.subsectnr = NULL; - stmt->u.s_section.sh_flags = 0; - stmt->u.s_section.sh_type = 0; - stmt->u.s_section.sh_entsize = NULL; - stmt->u.s_section.groupname = NULL; - stmt->u.s_section.linkage = NULL; - - stmt->u.s_section.name = strtab_enter(name); - - token = token_get(&token_attr); - if (token == T_COMMA) { - stmt->u.s_section.subsectnr = parse_expr(); - if (!stmt->u.s_section.subsectnr) - return -1; - token = token_get(&token_attr); - } - if (token == T_NEWLINE) { - stmt->tag = S_SECTION; - return 1; - } - error("junk after old-style section directive", token, &token_attr); - return -1; -} - -/* - * Recognize: - * - * ":" - * "=" "\n" - * (( | ) ",")? ("@"? ("(" ( | ) ")")?)? "\n" - * "\n" [equivalent to "," "\n"] - */ -static int make_insn(struct stmt *stmt, union token_attribute *symbol_attr, unsigned int accumulator, int at, struct expr *expr, unsigned int indexreg) -{ - stmt->tag = S_INSN; - stmt->u.s_insn.name = strtab_enter(symbol_attr->text); - stmt->u.s_insn.accumulator = accumulator; - stmt->u.s_insn.at = at; - stmt->u.s_insn.expr = expr; - stmt->u.s_insn.indexreg = indexreg; - return 1; -} - -static int parse_insn_after_lparen(struct stmt *stmt, union token_attribute *symbol_attr, unsigned int accumulator, int at, struct expr *expr) -{ - enum token token; - union token_attribute token_attr; - - token = token_get(&token_attr); - if (token == T_UINTEGER || token == T_REGISTER) { - unsigned int indexreg; - - indexreg = token_attr.uint; - - token = token_get(&token_attr); - if (token == T_RPAREN) { - token = token_get(&token_attr); - if (token == T_NEWLINE) - return make_insn(stmt, symbol_attr, accumulator, at, expr, indexreg); - } - } - error("junk in of after index expression", token, &token_attr); - return -1; -} - -static int parse_insn_expr(struct stmt *stmt, union token_attribute *symbol_attr, unsigned int accumulator, int at) -{ - struct expr *expr; - enum token token; - union token_attribute token_attr; - - expr = parse_expr(); - if (!expr) - return -1; - - token = token_get(&token_attr); - switch (token) { - case T_NEWLINE: - return make_insn(stmt, symbol_attr, accumulator, at, expr, 0); - case T_LPAREN: - return parse_insn_after_lparen(stmt, symbol_attr, accumulator, at, expr); - default: - error("junk after ", token, &token_attr); - return -1; - } -} - -static int parse_insn_after_comma(struct stmt *stmt, union token_attribute *symbol_attr, unsigned int accumulator) -{ - enum token token; - union token_attribute token_attr; - - token = token_get(&token_attr); - switch (token) { - case T_NEWLINE: - return make_insn(stmt, symbol_attr, accumulator, 0, NULL, 0); - case T_AT: - return parse_insn_expr(stmt, symbol_attr, accumulator, 1); - case T_UINTEGER: - case T_LPAREN: - case T_MINUS: - case T_TILDE: - token_unget(token, &token_attr); - return parse_insn_expr(stmt, symbol_attr, accumulator, 0); - default: - error("junk after ','", token, &token_attr); - return -1; - } -} - -static int parse_symbol(struct stmt *stmt, union token_attribute *symbol_attr) -{ - enum token token; - union token_attribute token_attr; - - token = token_get(&token_attr); - switch (token) { - case T_COLON: - stmt->u.s_string.string = strtab_enter(symbol_attr->text); - stmt->tag = S_LABEL; - return 1; - case T_EQ: /* =\n --> .set ,\n */ - { - stmt->u.s_setsize.expr = parse_expr(); - if (stmt->u.s_setsize.expr != NULL) { - token = token_get(&token_attr); - if (token == T_NEWLINE) { - stmt->u.s_setsize.name = strtab_enter(symbol_attr->text); - stmt->tag = S_SET; - return 1; - } - } - error("junk after =", token, &token_attr); - return -1; - } - case T_AT: - /* the part needs to be present to avoid ambiguities with the "()" index part */ - return parse_insn_expr(stmt, symbol_attr, 0, 1); - case T_REGISTER: - { - union token_attribute token_attr2; - - token = token_get(&token_attr2); - if (token == T_COMMA) - return parse_insn_after_comma(stmt, symbol_attr, token_attr.uint); - if (token == T_NEWLINE) - return make_insn(stmt, symbol_attr, token_attr.uint, 0, NULL, 0); - error("junk after ", token, &token_attr2); - return -1; - } - case T_NEWLINE: - return make_insn(stmt, symbol_attr, 0, 0, NULL, 0); - case T_UINTEGER: - { - /* - * This may be the part of the instruction, - * or the start of the part. In the first case it's followed - * by ",", and in the second case it's followed by , "(", - * or "\n", while the entire is followed by "(" or "\n". - * - * We could distinguish between these two cases by scanning another token, - * but then in the case we'd have to either push back two tokens, - * or rewrite parse_expr() so that it could be entered with the left-most - * already parsed. Both options are doable, but inefficient - * or requiring ugly code. - * - * Instead we push back the initial and parse . Afterwards - * we inspect the parse tree of and the next token, and from that we - * can identify which case applied, and complete the parse. - */ - struct expr *expr; - union token_attribute token_attr2; - - token_unget(token, &token_attr); - - expr = parse_expr(); - if (!expr) - return -1; - - token = token_get(&token_attr2); - switch (token) { - case T_COMMA: - if (expr->tag == E_UINTEGER) { /* "," ... */ - free_expr(expr); - return parse_insn_after_comma(stmt, symbol_attr, token_attr.uint); - } - break; /* "," ... is a syntax error */ - case T_NEWLINE: /* "\n" */ - return make_insn(stmt, symbol_attr, 0, 0, expr, 0); - case T_LPAREN: /* "(" ... */ - return parse_insn_after_lparen(stmt, symbol_attr, 0, 0, expr); - default: - break; - } - error("junk after ", token, &token_attr2); - return -1; - } - /* the following four are FIRST() \ {T_UINTEGER}, see parse_expr_opt() */ - case T_SYMBOL: - case T_LPAREN: - case T_MINUS: - case T_TILDE: - token_unget(token, &token_attr); - return parse_insn_expr(stmt, symbol_attr, 0, 0); - default: - error("junk after ", token, &token_attr); - return -1; - } -} - -int parse_stmt(struct stmt *stmt) -{ - enum token token; - union token_attribute token_attr; - - for (;;) { - token = token_get(&token_attr); - switch (token) { - /* - * directives - */ - case T_DOT_ALIGN: - return parse_dot_align(stmt, 0 | (0 << 1)); - case T_DOT_BALIGN: - return parse_dot_align(stmt, 0 | (0 << 1)); - case T_DOT_P2ALIGN: - return parse_dot_align(stmt, 1 | (0 << 1)); - case T_DOT_ASCII: - return parse_string_list(stmt, S_ASCII); - case T_DOT_ASCIZ: - return parse_string_list(stmt, S_ASCIZ); - case T_DOT_BYTE: - return parse_expr_list(stmt, S_BYTE); - case T_DOT_LONG: - return parse_expr_list(stmt, S_LONG); - case T_DOT_SHORT: - return parse_expr_list(stmt, S_SHORT); - case T_DOT_FILE: - return parse_string(stmt, S_FILE); - case T_DOT_IDENT: - return parse_string(stmt, S_IDENT); - case T_DOT_POPSECTION: - return parse_dot_popsection(stmt); - case T_DOT_PREVIOUS: - return parse_dot_previous(stmt); - case T_DOT_SUBSECTION: - return parse_dot_subsection(stmt); - case T_DOT_GLOBL: - return parse_name_list(stmt, S_GLOBL); - case T_DOT_HIDDEN: - return parse_name_list(stmt, S_HIDDEN); - case T_DOT_INTERNAL: - return parse_name_list(stmt, S_INTERNAL); - case T_DOT_LOCAL: - return parse_name_list(stmt, S_LOCAL); - case T_DOT_PROTECTED: - return parse_name_list(stmt, S_PROTECTED); - case T_DOT_WEAK: - return parse_name_list(stmt, S_WEAK); - case T_DOT_COMM: - return parse_dot_comm(stmt); - case T_DOT_ORG: - return parse_dot_org(stmt); - case T_DOT_SET: - return parse_setsize(stmt, S_SET); - case T_DOT_SIZE: - return parse_setsize(stmt, S_SIZE); - case T_DOT_SECTION: - return parse_dot_section(stmt, 0); - case T_DOT_PUSHSECTION: - return parse_dot_section(stmt, 1); - case T_DOT_BSS: - return parse_oldstyle_section(stmt, ".bss"); - case T_DOT_DATA: - return parse_oldstyle_section(stmt, ".data"); - case T_DOT_RODATA: - return parse_oldstyle_section(stmt, ".rodata"); - case T_DOT_TEXT: - return parse_oldstyle_section(stmt, ".text"); -#if 0 - case T_DOT_SYMVER: - case T_DOT_TYPE: - case T_DOT_WEAKREF: -#endif - /* - * other symbols - */ - case T_SYMBOL: /* start of label, insn, or symbol assignment */ - return parse_symbol(stmt, &token_attr); - - /* - * literals - */ -#if 0 - case T_UINTEGER: /* start of local label defn */ -#endif - /* - * misc - */ - case T_ERROR: - return -1; /* diagnostics already emitted by scan.c */ - case T_EOF: - return 0; - case T_NEWLINE: - continue; - default: - error("expected directive, label, or instruction", token, &token_attr); - return -1; - } - } -} diff --git a/as/0LD/pass1.c b/as/0LD/pass1.c deleted file mode 100644 index 2536f8b..0000000 --- a/as/0LD/pass1.c +++ /dev/null @@ -1,270 +0,0 @@ -/* - * pass1.c - */ -#include -#include -#include "emalloc.h" -#include "parse.h" -#include "pass1.h" -#include "scan.h" -#include "section.h" - -struct section_and_subsection { - struct section *section; - struct subsection *subsection; -}; - -struct current_and_previous_sections { - struct section_and_subsection cursec; - struct section_and_subsection prevsec; -}; - -struct sections_stack_element { - struct current_and_previous_sections sects; - struct sections_stack_element *next; -}; - -struct pass1_state { - struct current_and_previous_sections sects; - struct sections_stack_element *sects_stack; -}; - -static int pass1_s_popsection(struct pass1_state *state) -{ - struct sections_stack_element *top; - - top = state->sects_stack; - if (top == NULL) { - fprintf(stderr, "as: %s, line %u: .popsection with no previous .pushsection\n", scan_filename, scan_linenr); - return -1; - } - - state->sects = top->sects; - state->sects_stack = top->next; - free(top); - - return 0; -} - -static int pass1_s_previous(struct pass1_state *state) -{ - struct section_and_subsection prevsec; - - prevsec = state->sects.prevsec; - if (prevsec.section == NULL) { - fprintf(stderr, "as: %s, line %u: .previous with no previous .section\n", scan_filename, scan_linenr); - return -1; - } - - state->sects.prevsec = state->sects.cursec; - state->sects.cursec = prevsec; - - return 0; -} - -static int pass1_s_section(struct pass1_state *state, struct stmt *stmt, int push) -{ - struct section *section; - struct subsection *subsection; - int subsectnr; - - section = section_enter(stmt->u.s_section.name); - - if (stmt->u.s_section.sh_type != 0) { - if (section->e_shdr.sh_type == 0) - section->e_shdr.sh_type = stmt->u.s_section.sh_type; - else if (section->e_shdr.sh_type != stmt->u.s_section.sh_type) { - fprintf(stderr, "as: %s, line %u: section type mismatch\n", scan_filename, scan_linenr); - return -1; - } - } - - section->e_shdr.sh_flags |= stmt->u.s_section.sh_flags; - - if (stmt->u.s_section.sh_entsize != NULL) { - pdp10_uint36_t offset; - - if (eval_abs_verbose(stmt->u.s_section.sh_entsize, &offset) < 0) - return -1; - if (section->e_shdr.sh_entsize == 0) - section->e_shdr.sh_entsize = offset; - else if (section->e_shdr.sh_entsize != offset) { - fprintf(stderr, "as: %s, line %u: section mismatch\n", scan_filename, scan_linenr); - return -1; - } - } - - if (stmt->u.s_section.groupname != NULL) { - if (section->groupname == NULL) - section->groupname = stmt->u.s_section.groupname; - else if (stmt->u.s_section.groupname != section->groupname) { - fprintf(stderr, "as: %s, line %u: section mismatch\n", scan_filename, scan_linenr); - return -1; - } - } - - if (stmt->u.s_section.linkage != NULL) { - if (section->linkage == NULL) - section->linkage = stmt->u.s_section.linkage; - else if (stmt->u.s_section.linkage != section->linkage) { - fprintf(stderr, "as: %s, line %u: section mismatch\n", scan_filename, scan_linenr); - return -1; - } - } - - if (push && stmt->u.s_section.subsectnr != NULL) { - pdp10_uint36_t offset; - - if (eval_abs_verbose(stmt->u.s_section.subsectnr, &offset) < 0) - return -1; - subsectnr = offset; - } else - subsectnr = 0; - - subsection = subsection_enter(section, subsectnr); - - if (push) { - struct sections_stack_element *top; - - top = emalloc(sizeof *top); - top->sects = state->sects; - top->next = state->sects_stack; - state->sects_stack = top; - } - - state->sects.prevsec = state->sects.cursec; - state->sects.cursec.section = section; - state->sects.cursec.subsection = subsection; - - return 0; -} - -static int pass1_s_subsection(struct pass1_state *state, struct stmt *stmt) -{ - pdp10_uint36_t offset; - struct subsection *subsection; - - if (eval_abs_verbose(stmt->u.s_subsection.expr, &offset) < 0) - return -1; - - subsection = subsection_enter(state->sects.cursec.section, (int)(pdp10_int36_t)offset); - - state->sects.prevsec = state->sects.cursec; - state->sects.cursec.subsection = subsection; - - return 0; -} - -static int pass1_interpret(struct pass1_state *state, struct stmt *stmt) -{ - switch (stmt->tag) { - /* in pass1 we have to deal with section-altering directives */ - case S_POPSECTION: - return pass1_s_popsection(state); - case S_PREVIOUS: - return pass1_s_previous(state); - case S_PUSHSECTION: - return pass1_s_section(state, stmt, 1); - case S_SECTION: - return pass1_s_section(state, stmt, 0); - case S_SUBSECTION: - return pass1_s_subsection(state, stmt); - - /* remaining directives, and the non-directives, enter data - into sections or manipulate symbols; delay these for pass2 */ - XXX; - /* XXX: wrong, symbol values, even section-relative, are needed as soon - as possible, so all statements must be interpreted right away */ - case S_ALIGN: - case S_ASCII: - case S_ASCIZ: - case S_BYTE: - case S_COMM: - case S_FILE: - case S_GLOBL: - case S_HIDDEN: - case S_IDENT: - case S_INTERNAL: - case S_LOCAL: - case S_LONG: - case S_ORG: - case S_PROTECTED: - case S_SET: - case S_SHORT: - case S_SIZE: - case S_SYMVER: - case S_TYPE: - case S_WEAK: - case S_WEAKREF: - case S_LABEL: - case S_INSN: - { - struct stmt *stmt2; - - stmt2 = arrlst_append(state->sects.cursec.subsection->stmts); - /* XXX: error check */ - *stmt2 = *stmt; - return 0; - } - default: - fprintf(stderr, "as: %s, line %u: %s(): unknown stmt tag %u\n", scan_filename, scan_linenr, __FUNCTION__, stmt->tag); - return -1; - } -} - -static void pass1_init_state(struct pass1_state *state) -{ - struct section *text; - - text = section_enter(strtab_enter(".text")); - - text->e_shdr.sh_type = SHT_PROGBITS; - text->e_shdr.sh_flags = SHF_ALLOC | SHF_EXECINSTR; - text->e_shdr.sh_addralign = 4; /* XXX: PDP10-specific */ - - state->sects.cursec.section = text; - state->sects.cursec.subsection = subsection_enter(text, 0); - - state->sects.prevsec.section = NULL; - state->sects.prevsec.subsection = NULL; - - state->sects_stack = NULL; -} - -static void pass1_fini_state(struct pass1_state *state) -{ - struct sections_stack_element *here, *next; - - here = state->sects_stack; - while (here != NULL) { - next = here->next; - free(here); - here = next; - } -} - -int pass1(const char *filename) -{ - struct pass1_state state; - struct stmt stmt; - int status; - - if (scan_freopen(filename) < 0) - return -1; - - pass1_init_state(&state); - - for (;;) { - status = parse_stmt(&stmt); - if (status < 0) - return -1; - else if (status == 0) - break; - else if (pass1_interpret(&state, &stmt) < 0) - return -1; - } - - pass1_fini_state(&state); - - return 0; -} diff --git a/as/0LD/pass1.h b/as/0LD/pass1.h deleted file mode 100644 index 5c78965..0000000 --- a/as/0LD/pass1.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - * pass1.h - */ -#ifndef PASS1_H -#define PASS1_H - -int pass1(const char *filename); - -#endif /* PASS1_H */ diff --git a/as/0LD/scan.c b/as/0LD/scan.c deleted file mode 100644 index 10e58f1..0000000 --- a/as/0LD/scan.c +++ /dev/null @@ -1,636 +0,0 @@ -/* - * scan.c - */ -#include -#include /* host stdio since we're dealing with plain text */ -#include -#include -#include "charbuf.h" -#include "scan.h" -#include "token.h" - -/* XXX: we should have a pdp10-limits.h */ -#define PDP10_UCHAR_MAX PDP10_UINT9_MAX - -const char *scan_filename = ""; - -int scan_freopen(const char *filename) -{ - if (filename != NULL) { - if (freopen(filename, "r", stdin) == NULL) { - fprintf(stderr, "as: Error opening %s: %s\n", filename, strerror(errno)); - return -1; - } - scan_filename = filename; - } - return 0; -} - -unsigned int scan_linenr; - -static void scan_ungetc(int ch) -{ - if (ch != EOF && ungetc(ch, stdin) == EOF) - perror("ungetc"); -} - -static int scan_getchar(void) -{ - return fgetc(stdin); -} - -static void badchar(int ch, const char *context) -{ - char buf[7]; - - if (ch == EOF) { - buf[0] = '<'; - buf[1] = 'E'; - buf[2] = 'O'; - buf[3] = 'F'; - buf[4] = '>'; - buf[5] = '\0'; - } else if (' ' <= ch && ch <= '~') { - buf[0] = '\''; - buf[1] = ch; - buf[2] = '\''; - buf[3] = '\0'; - } else { - buf[0] = '\''; - buf[1] = '\\'; - buf[2] = '0' + ((ch >> 6) & 3); - buf[3] = '0' + ((ch >> 3) & 7); - buf[4] = '0' + (ch & 7); - buf[5] = '\''; - buf[6] = '\0'; - } - - fprintf(stderr, "as: %s, line %u: invalid character %s %s\n", scan_filename, scan_linenr, buf, context); -} - -static int is_decimal_digit(char ch) -{ - return '0' <= ch && ch <= '9'; -} - -static int is_octal_digit(char ch) -{ - return '0' <= ch && ch <= '7'; -} - -static unsigned int get_chval(int ch) -{ - if ('0' <= ch && ch <= '9') - return ch - '0'; - if ('A' <= ch && ch <= 'F') - return ch - ('A' - 10); - if ('a' <= ch && ch <= 'f') - return ch - ('a' - 10); - return -1U; -} - -static int do_escape(void) -{ - int ch; - - ch = scan_getchar(); - switch (ch) { - case 'n': - return '\n'; - case 't': - return '\t'; - case 'f': - return '\f'; - case 'r': - return '\r'; - case 'b': - return '\b'; - case '\\': - return ch; - case '\'': - return ch; - case '"': - return ch; - case 'x': - case 'X': - { - unsigned int chval; - - ch = scan_getchar(); - chval = get_chval(ch); - if (chval <= 15) { - unsigned int val = 0; - do { - val = val * 16 + chval; - ch = scan_getchar(); - chval = get_chval(ch); - } while (chval <= 15); - scan_ungetc(ch); - if (val > PDP10_UCHAR_MAX) - fprintf(stderr, "as: %s, line %u: truncating escaped value from %#x to %#x\n", scan_filename, scan_linenr, val, val & PDP10_UCHAR_MAX); - return val & PDP10_UCHAR_MAX; - } - break; - } - case EOF: - break; - default: - if (is_octal_digit(ch)) { - unsigned int val = ch - '0'; - ch = scan_getchar(); - if (is_octal_digit(ch)) { - val = val * 8 + (ch - '0'); - ch = scan_getchar(); - if (is_octal_digit(ch)) - val = val * 8 + (ch - '0'); - else - scan_ungetc(ch); - } else - scan_ungetc(ch); - if (val > PDP10_UCHAR_MAX) - fprintf(stderr, "as: %s, line %u: truncating escaped value from %#x to %#x\n", scan_filename, scan_linenr, val, val & PDP10_UCHAR_MAX); - return val & PDP10_UCHAR_MAX; - } - break; - } - badchar(ch, "in \\ character escape sequence"); - return ch; -} - -static enum token do_char(union token_attribute *token_attr) -{ - int ch; - - ch = scan_getchar(); - switch (ch) { - case '\\': - ch = do_escape(); - if (ch == EOF) - return T_ERROR; - break; - case '\'': - case EOF: - badchar(ch, "in character literal"); - return T_ERROR; - default: - break; - } - token_attr->uint = ch; - ch = scan_getchar(); - if (ch != '\'') { - badchar(ch, "after character literal"); - return T_ERROR; - } - return T_UINTEGER; -} - -/* XXX: strings should be sequences of uint9_t not sequences of unsigned char */ - -static enum token do_string(union token_attribute *token_attr, struct charbuf *charbuf) -{ - int ch; - - for (;;) { - ch = scan_getchar(); - switch (ch) { - case '"': - token_attr->text = charbuf_string(charbuf); - return T_STRING; - case '\\': - ch = do_escape(); - if (ch == EOF) - return T_ERROR; - break; - case EOF: - case '\n': - badchar(ch, "in string literal"); - if (ch == '\n') - ++scan_linenr; - return T_ERROR; - default: - break; - } - charbuf_append(charbuf, ch); - } -} - -static const struct { - enum token token; - const char *name; -} directives[] = { - { T_DOT_ALIGN, ".align" }, - { T_DOT_ASCII, ".ascii" }, - { T_DOT_ASCIZ, ".asciz" }, - { T_DOT_BALIGN, ".balign" }, - { T_DOT_BSS, ".bss" }, - { T_DOT_BYTE, ".byte" }, - { T_DOT_COMM, ".comm" }, - { T_DOT_DATA, ".data" }, - { T_DOT_FILE, ".file" }, - { T_DOT_GLOBL, ".globl" }, - { T_DOT_HIDDEN, ".hidden" }, - { T_DOT_IDENT, ".ident" }, - { T_DOT_INTERNAL, ".internal" }, - { T_DOT_LOCAL, ".local" }, - { T_DOT_LONG, ".long" }, - { T_DOT_ORG, ".org" }, - { T_DOT_P2ALIGN, ".p2align" }, - { T_DOT_POPSECTION, ".popsection" }, - { T_DOT_PREVIOUS, ".previous" }, - { T_DOT_PROTECTED, ".protected" }, - { T_DOT_PUSHSECTION, ".pushsection" }, - { T_DOT_RODATA, ".rodata" }, - { T_DOT_SECTION, ".section" }, - { T_DOT_SET, ".set" }, - { T_DOT_SHORT, ".short" }, - { T_DOT_SIZE, ".size" }, - { T_DOT_SUBSECTION, ".subsection" }, - { T_DOT_SYMVER, ".symver" }, - { T_DOT_TEXT, ".text" }, - { T_DOT_TYPE, ".type" }, - { T_DOT_WEAK, ".weak" }, - { T_DOT_WEAKREF, ".weakref" }, -}; - -static enum token mk_symbol(union token_attribute *token_attr, const struct charbuf *charbuf) -{ - if (charbuf->head.buf[0] == '.') { /* check for <.directive> */ - unsigned int low, high; - - low = 0; - high = sizeof directives / sizeof directives[0]; - - while (low < high) { - unsigned int middle; - int cmp; - - middle = (low + high) / 2; - cmp = charbuf_strcmp(charbuf, directives[middle].name); - - if (cmp < 0) - high = middle; - else if (cmp > 0) - low = middle + 1; - else - return directives[middle].token; - } - } else if (charbuf->head.buf[0] == '$' - && charbuf->head.next == NULL) { /* check for $ */ - if (charbuf->pos == 2 - && is_decimal_digit(charbuf->head.buf[1])) { - token_attr->uint = charbuf->head.buf[1] - '0'; - return T_REGISTER; - } else if (charbuf->pos == 3) { - if (is_decimal_digit(charbuf->head.buf[1]) - && is_decimal_digit(charbuf->head.buf[2])) { - unsigned int val; - - val = (charbuf->head.buf[1] - '0') * 10 + (charbuf->head.buf[2] - '0'); - if (val < 16) { - token_attr->uint = val; - return T_REGISTER; - } - } else if (charbuf->head.buf[1] == 's' - && charbuf->head.buf[2] == 'p') { - token_attr->uint = 15; - return T_REGISTER; - } - } - } - - token_attr->text = charbuf_string(charbuf); - return T_SYMBOL; -} - -static int is_symbol_internal_char(int ch) -{ - return - ('A' <= ch && ch <= 'Z') - || ('a' <= ch && ch <= 'z') - || ('0' <= ch && ch <= '9') - || ch == '_' - || ch == '$' - || ch == '.'; -} - -static enum token do_symbol(union token_attribute *token_attr, int ch, struct charbuf *charbuf) -{ - do { - charbuf_append(charbuf, ch); - ch = scan_getchar(); - } while (is_symbol_internal_char(ch)); - scan_ungetc(ch); - return mk_symbol(token_attr, charbuf); -} - -static enum token do_number(union token_attribute *token_attr, int ch) -{ - unsigned int base, chval; - pdp10_uint36_t numval; - - base = (ch == '0') ? 8 : 10; - numval = ch - '0'; - - ch = scan_getchar(); - /* handle 0x */ - if (ch == 'x' || ch == 'X') { - base = 16; - /* must have at least one hex digit after 0x */ - ch = scan_getchar(); - chval = get_chval(ch); - if (chval <= 15) - numval = chval; - else { - badchar(ch, "after 0x in hexadecimal literal"); - return T_ERROR; - } - ch = scan_getchar(); - } - /* the number is non-empty, consume and accumulate trailing - characters as long as they are valid in the base */ - for (;;) { - chval = get_chval(ch); - if (chval >= base) - break; - numval = numval * base + chval; - ch = scan_getchar(); - } - /* check for {b,f} */ - if (base <= 10 && (ch == 'b' || ch == 'f')) { - /* represent the local label + direction in sign-magnitude with - the sign in the least significant bit; using sign-magnitude - allows to distinguish 0f from 0b (i.e., +0 from -0); storing - the sign in the least significant bit makes us independent of - word size */ - token_attr->uint = (numval << 1) | (ch == 'f' ? 1 : 0); - return T_LOCAL_LABEL; - } - /* plain integer literal */ - scan_ungetc(ch); - token_attr->uint = numval; - return T_UINTEGER; -} - -static enum token do_eq(void) -{ - int ch; - - ch = scan_getchar(); - switch (ch) { - case '=': - return T_EQEQ; - default: - scan_ungetc(ch); - return T_EQ; - } -} - -static enum token do_ampersand(void) -{ - int ch; - - ch = scan_getchar(); - switch (ch) { - case '&': - return T_ANDAND; - default: - scan_ungetc(ch); - return T_AND; - } -} - -static enum token do_bar(void) -{ - int ch; - - ch = scan_getchar(); - switch (ch) { - case '|': - return T_OROR; - default: - scan_ungetc(ch); - return T_OR; - } -} - -static enum token do_gt(void) -{ - int ch; - - ch = scan_getchar(); - switch (ch) { - case '>': - return T_RSHIFT; - case '=': - return T_GE; - default: - scan_ungetc(ch); - return T_GT; - } -} - -static enum token do_lt(void) -{ - int ch; - - ch = scan_getchar(); - switch (ch) { - case '<': - return T_LSHIFT; - case '=': - return T_LE; - case '>': /* <> is the same as != */ - return T_NEQ; - default: - scan_ungetc(ch); - return T_LT; - } -} - -static enum token do_c_comment(void) -{ - int ch; - - for (;;) { - ch = scan_getchar(); - switch (ch) { - case EOF: - badchar(ch, "in /**/-style comment"); - return T_ERROR; - case '*': - for (;;) { - ch = scan_getchar(); - switch (ch) { - case '*': - continue; - case '/': - return T_EOF; /* fake token for a C comment */ - case EOF: - badchar(ch, "in /**/-style comment"); - return T_ERROR; - case '\n': - ++scan_linenr; - /*FALLTHROUGH*/ - default: - break; - } - break; - } - continue; - case '\n': - ++scan_linenr; - /*FALLTHROUGH*/ - default: - continue; - } - } -} - -static enum token do_slash(void) -{ - int ch; - - ch = scan_getchar(); - switch (ch) { - case '*': - return do_c_comment(); - default: - scan_ungetc(ch); - return T_DIV; - } -} - -static enum token do_bang(void) -{ - int ch; - - ch = scan_getchar(); - switch (ch) { - case '=': - return T_NEQ; - default: - scan_ungetc(ch); - return T_BANG; - } -} - -static int do_line_comment(void) -{ - int ch; - - for (;;) { - ch = scan_getchar(); - switch (ch) { - case '\n': - ++scan_linenr; - return 0; - case EOF: - badchar(ch, "in line comment"); - return -1; - default: - continue; - } - } -} - -static enum token do_scan(union token_attribute *token_attr, struct charbuf *charbuf) -{ - int ch; - - ch = scan_getchar(); - - for (;; ch = scan_getchar()) { - switch (ch) { - case ' ': - case '\t': - case '\r': - case '\f': - continue; - case '\n': - ++scan_linenr; - return T_NEWLINE; - case '#': - if (do_line_comment() != 0) - return T_ERROR; - return T_NEWLINE; - case ';': - return T_NEWLINE; - case EOF: - return T_EOF; - case '@': - return T_AT; - case ':': - return T_COLON; - case ',': - return T_COMMA; - case '(': - return T_LPAREN; - case ')': - return T_RPAREN; - case '~': - return T_TILDE; - case '*': - return T_MUL; - case '/': /* "/""*", "/" */ - switch (do_slash()) { - case T_DIV: - return T_DIV; - case T_EOF: /* fake token for a C comment */ - continue; - default: /* error, eof in comment */ - return T_ERROR; - } - case '%': - return T_REM; - case '<': /* <<, <=, < */ - return do_lt(); - case '>': /* >>, >=, > */ - return do_gt(); - case '|': /* ||, | */ - return do_bar(); - case '&': /* &&, & */ - return do_ampersand(); - case '^': - return T_CARET; - case '!': /* !=, ! */ - return do_bang(); - case '+': - return T_PLUS; - case '-': - return T_MINUS; - case '=': /* ==, = */ - return do_eq(); - case '"': - return do_string(token_attr, charbuf); - case '\'': - return do_char(token_attr); - case '.': - /* Dot may start a floating point literal, but tests show that - gcc always outputs floating point values as integer literals, - so we shouldn't have to support floating point literals at all. */ - case '$': - case '_': - return do_symbol(token_attr, ch, charbuf); - default: - if ('0' <= ch && ch <= '9') /* number or {b,f} */ - return do_number(token_attr, ch); - if (('A' <= ch && ch <= 'Z') || - ('a' <= ch && ch <= 'z')) - return do_symbol(token_attr, ch, charbuf); - } - badchar(ch, ""); - return T_ERROR; - } -} - -enum token scan(union token_attribute *token_attr) -{ - struct charbuf charbuf; - enum token token; - - charbuf_init(&charbuf); - token = do_scan(token_attr, &charbuf); - charbuf_fini(&charbuf); - - return token; -} diff --git a/as/0LD/section.c b/as/0LD/section.c deleted file mode 100644 index 0b84f3d..0000000 --- a/as/0LD/section.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * section.c - */ -#include -#include "emalloc.h" -#include "htab.h" -#include "section.h" - -static struct section *section_from_hnode(const struct hnode *hnode) -{ - /* hnode is first in section, so no need to mess with offsetof() */ - return (struct section*)hnode; -} - -static struct htab section_htab; - -void section_init(void) -{ - htab_init(§ion_htab, 8, NULL); -} - -struct section *section_enter(const struct strnode *strnode) -{ - struct section *section; - - section = section_from_hnode(htab_lookup(§ion_htab, (uintptr_t)strnode, NULL)); - - if (section == NULL) { - section = emalloc(sizeof *section); - memset(section, '\0', sizeof *section); - section->hnode.hval = (uintptr_t)strnode; - htab_init(§ion->subsects, 4, NULL); - htab_insert(§ion_htab, §ion->hnode); - } - - return section; -} - -static struct subsection *subsection_from_hnode(const struct hnode *hnode) -{ - /* hnode is first in subsection, so no need to mess with offsetof() */ - return (struct subsection*)hnode; -} - -struct subsection *subsection_enter(struct section *section, int subsectnr) -{ - struct subsection *subsection; - - subsection = subsection_from_hnode(htab_lookup(§ion->subsects, (uintptr_t)subsectnr, NULL)); - - if (subsection == NULL) { - subsection = emalloc(sizeof *subsection); - subsection->hnode.hval = (uintptr_t)subsectnr; - subsection->stmts = arrlst_alloc(sizeof(struct stmt)); - htab_insert(§ion->subsects, &subsection->hnode); - } - - return subsection; -} diff --git a/as/0LD/section.h b/as/0LD/section.h deleted file mode 100644 index 1e49e63..0000000 --- a/as/0LD/section.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * section.h - */ -#ifndef SECTION_H -#define SECTION_H - -#include "pdp10-elf36.h" - -#include "arrlst.h" -#include "htab.h" -#include "stmt.h" -#include "strtab.h" - -struct subsection { - struct hnode hnode; /* hnode.hval == subsect nr */ - struct arrlst *stmts; -}; - -struct section { - struct hnode hnode; /* hnode.hval == struct strnode* */ - Elf36_Shdr e_shdr; - struct htab subsects; - const struct strnode *groupname; - const struct strnode *linkage; - unsigned int dot; /* Elf36_Off? */ -}; - -#define SECTION_ABS ((struct section*)0) -#define SECTION_UNDEF ((struct section*)1) - -void section_init(void); -struct section *section_enter(const struct strnode *strnode); -struct subsection *subsection_enter(struct section *section, int subsectnr); - -#endif /* SECTION_H */ diff --git a/as/0LD/stmt.h b/as/0LD/stmt.h deleted file mode 100644 index 378bebd..0000000 --- a/as/0LD/stmt.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * stmt.h - */ -#ifndef STMT_H -#define STMT_H - -#include "pdp10-elf36.h" -#include "expr.h" -#include "strtab.h" - -struct expr_list { - struct expr *expr; - struct expr_list *next; -}; - -struct string_list { - const struct strnode *string; - struct string_list *next; -}; - -enum stmt_tag { - /* directives */ - S_ALIGN, /* .align, .balign, and .p2align map to this */ - S_ASCII, - S_ASCIZ, - S_BYTE, - S_COMM, - S_FILE, - S_GLOBL, - S_HIDDEN, - S_IDENT, - S_INTERNAL, - S_LOCAL, - S_LONG, - S_ORG, - S_POPSECTION, /* no attribute */ - S_PREVIOUS, /* no attribute */ - S_PROTECTED, - S_PUSHSECTION, - S_SECTION, /* .bss, .data, .rodata, and .text also map to this */ - S_SET, - S_SHORT, - S_SIZE, - S_SUBSECTION, - S_SYMVER, - S_TYPE, - S_WEAK, - S_WEAKREF, - /* non-directives */ - S_LABEL, - S_INSN, -}; - -struct stmt { - enum stmt_tag tag; - union { - struct { - unsigned char flags; /* p2 vs b, none/w/l */ - struct expr *balign; - struct expr *fill; - struct expr *maxskip; - } s_align; - struct { - struct string_list *list; - } s_string_list; - struct { - struct expr_list *list; - } s_expr_list; - struct { - const struct strnode *name; - struct expr *length; - struct expr *balign; - } s_comm; - struct { - const struct strnode *string; - } s_string; - struct { - struct expr *newlc; - struct expr *fill; - } s_org; - struct { - const struct strnode *name; - struct expr *subsectnr; - Elf36_Word sh_flags; - Elf36_Word sh_type; - struct expr *sh_entsize; - const struct strnode *groupname; - const struct strnode *linkage; - } s_section; - struct { - const struct strnode *name; - struct expr *expr; - } s_setsize; - struct { - struct expr *expr; - } s_subsection; - struct { - const struct strnode *name1; - const struct strnode *name2; - const struct strnode *name3; - unsigned char nrats; /* 1, 2, or 3 */ - } s_symver; - struct { - const struct strnode *name; - unsigned char st_type; - } s_type; - struct { - const struct strnode *alias; - const struct strnode *target; - } s_weakref; - struct { - const struct strnode *name; - unsigned int accumulator; - int at; - struct expr *expr; - unsigned int indexreg; - } s_insn; - - } u; -}; - -#endif /* STMT_H */ diff --git a/as/0LD/strtab.c b/as/0LD/strtab.c deleted file mode 100644 index 30a4330..0000000 --- a/as/0LD/strtab.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * strtab.c - */ -#include -#include "emalloc.h" -#include "htab.h" -#include "strtab.h" - -static struct strnode *strnode_from_hnode(const struct hnode *hnode) -{ - /* hnode is first in strnode, so no need to mess with offsetof() */ - return (struct strnode*)hnode; -} - -static int strtab_cmpfn(const struct hnode *hnode, const void *data) -{ - const struct strnode *strnode = strnode_from_hnode(hnode); - const char *string = data; - - return strcmp(strnode->string, string); -} - -static struct htab strtab_htab; - -void strtab_init(void) -{ - htab_init(&strtab_htab, 64, strtab_cmpfn); -} - -static uintptr_t strtab_hash(const char *string) -{ - const unsigned char *s; - uintptr_t h; - unsigned char c; - - s = (const unsigned char*)string; - h = 0; - - for (;;) { - c = *s++; - if (c == '\0') - break; - h = (h << 5) + h + c; - } - - return h; -} - -const struct strnode *strtab_enter(const char *string) -{ - uintptr_t hval; - struct strnode *strnode; - - hval = strtab_hash(string); - strnode = strnode_from_hnode(htab_lookup(&strtab_htab, hval, string)); - - if (strnode == NULL) { - strnode = emalloc(offsetof(struct strnode, string) + strlen(string) + 1); - strnode->hnode.hval = hval; - strcpy(strnode->string, string); - htab_insert(&strtab_htab, &strnode->hnode); - } - - return strnode; -} diff --git a/as/0LD/strtab.h b/as/0LD/strtab.h deleted file mode 100644 index 0629b29..0000000 --- a/as/0LD/strtab.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * strtab.h - */ -#ifndef STRTAB_H -#define STRTAB_H - -#include "htab.h" - -struct strnode { - struct hnode hnode; - char string[]; -}; - -void strtab_init(void); -const struct strnode *strtab_enter(const char *string); - -#endif /* STRTAB */ diff --git a/as/Makefile b/as/Makefile index 5feaa0e..19318b3 100644 --- a/as/Makefile +++ b/as/Makefile @@ -1,3 +1,21 @@ +# as/Makefile +# Copyright (C) 2013-2015 Mikael Pettersson +# +# This file is part of pdp10-tools. +# +# pdp10-tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pdp10-tools 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 pdp10-tools. If not, see . + CC=gcc CFLAGS=-O2 -g -Wall CPPFLAGS=-I../include diff --git a/as/assemble.c b/as/assemble.c index 09cd111..5d575ec 100644 --- a/as/assemble.c +++ b/as/assemble.c @@ -1,5 +1,21 @@ /* * assemble.c + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/as/assemble.h b/as/assemble.h index 6779908..03ebae0 100644 --- a/as/assemble.h +++ b/as/assemble.h @@ -1,5 +1,21 @@ /* * assemble.h + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #ifndef ASSEMBLE_H #define ASSEMBLE_H diff --git a/as/hashtab.c b/as/hashtab.c index f2f63b2..1b1445a 100644 --- a/as/hashtab.c +++ b/as/hashtab.c @@ -1,5 +1,21 @@ /* * hashtab.c + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/as/hashtab.h b/as/hashtab.h index 1e711e7..bfad267 100644 --- a/as/hashtab.h +++ b/as/hashtab.h @@ -1,5 +1,21 @@ /* * hashtab.h + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #ifndef HASHTAB_H #define HASHTAB_H diff --git a/as/input.c b/as/input.c index cc4e118..6022e82 100644 --- a/as/input.c +++ b/as/input.c @@ -1,5 +1,21 @@ /* * input.c + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/as/input.h b/as/input.h index 0e6e1ce..16090e4 100644 --- a/as/input.h +++ b/as/input.h @@ -1,5 +1,21 @@ /* * input.h + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #ifndef INPUT_H #define INPUT_H diff --git a/as/main.c b/as/main.c index 631ea41..02dec70 100644 --- a/as/main.c +++ b/as/main.c @@ -1,7 +1,21 @@ /* - * main.c + * main.c -- as clone for pdp10-elf + * Copyright (C) 2013-2015 Mikael Pettersson * - * as clone for PDP10 with Elf36 object files. + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/as/output.c b/as/output.c index d70be3b..057dcab 100644 --- a/as/output.c +++ b/as/output.c @@ -1,5 +1,21 @@ /* * output.c + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/as/output.h b/as/output.h index e59e4fe..c5b975e 100644 --- a/as/output.h +++ b/as/output.h @@ -1,5 +1,21 @@ /* * output.h + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #ifndef OUTPUT_H #define OUTPUT_H diff --git a/as/parse.c b/as/parse.c index 439570b..6d75cf0 100644 --- a/as/parse.c +++ b/as/parse.c @@ -1,5 +1,21 @@ /* * parse.c + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/as/parse.h b/as/parse.h index 1008c30..cf5dfff 100644 --- a/as/parse.h +++ b/as/parse.h @@ -1,5 +1,21 @@ /* * parse.h + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #ifndef PARSE_H #define PARSE_H diff --git a/as/scan.c b/as/scan.c index 6bcceb1..c2d9285 100644 --- a/as/scan.c +++ b/as/scan.c @@ -1,5 +1,21 @@ /* * scan.c + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include /* XXX: for UCHAR_MAX, deleteme */ diff --git a/as/scan.h b/as/scan.h index 6bf7457..28235ad 100644 --- a/as/scan.h +++ b/as/scan.h @@ -1,5 +1,21 @@ /* * scan.h + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #ifndef SCAN_H #define SCAN_H diff --git a/as/test/test1.s b/as/test/test1.s index 8785370..148be92 100644 --- a/as/test/test1.s +++ b/as/test/test1.s @@ -1,3 +1,22 @@ +/* + * test1.s + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ .text .globl start start: diff --git a/as/test/test2.c b/as/test/test2.c index 4d57313..9045e12 100644 --- a/as/test/test2.c +++ b/as/test/test2.c @@ -1 +1,21 @@ +/* + * test2.c + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ + int foo(void) { return 27; } diff --git a/as/test/test2.s b/as/test/test2.s index 60f4d23..b911ec3 100644 --- a/as/test/test2.s +++ b/as/test/test2.s @@ -1,3 +1,23 @@ +/* + * test2.s + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ + .file "z.c" .text .globl foo diff --git a/as/token.c b/as/token.c index d5ea0e3..77015c6 100644 --- a/as/token.c +++ b/as/token.c @@ -1,5 +1,21 @@ /* * token.c + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include "pdp10-inttypes.h" diff --git a/as/token.def b/as/token.def index b7e921e..2ab146d 100644 --- a/as/token.def +++ b/as/token.def @@ -1,6 +1,24 @@ /* - * token.def + * token.def -- token definitions for PDP10 assembler + * Copyright (C) 2013-2015 Mikael Pettersson * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ + +/* * TOKEN(T_, , ) */ diff --git a/as/token.h b/as/token.h index 7fcf81e..4cbad14 100644 --- a/as/token.h +++ b/as/token.h @@ -1,5 +1,21 @@ /* * token.h + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #ifndef TOKEN_H #define TOKEN_H diff --git a/as/tunit.c b/as/tunit.c index 610ad6d..313ab96 100644 --- a/as/tunit.c +++ b/as/tunit.c @@ -1,5 +1,21 @@ /* * tunit.c + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/as/tunit.h b/as/tunit.h index 8576241..0c32e45 100644 --- a/as/tunit.h +++ b/as/tunit.h @@ -1,5 +1,21 @@ /* * tunit.h + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #ifndef TUNIT_H #define TUNIT_H diff --git a/doc/MUUO.txt b/doc/MUUO.txt index 6c082f9..55b8048 100644 --- a/doc/MUUO.txt +++ b/doc/MUUO.txt @@ -1,3 +1,23 @@ +/* + * MUUO.txt + * Copyright (C) 2013-2015 Mikael Pettersson + * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ + .text .globl start diff --git a/include/pdp10-ar.h b/include/pdp10-ar.h index 7ead17d..ca6dfe3 100644 --- a/include/pdp10-ar.h +++ b/include/pdp10-ar.h @@ -1,6 +1,23 @@ /* * pdp10-ar.h + * Copyright (C) 2013-2015 Mikael Pettersson * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ +/* * This is essentially the standard SVR4/GNU AR format, with 'char' * replaced by 'pdp10_uint9_t' throughout. * Groups of 4 bytes in the symbol table denote pdp10_uint36_t diff --git a/include/pdp10-arith.h b/include/pdp10-arith.h index 6f9a8d7..cf5caa5 100644 --- a/include/pdp10-arith.h +++ b/include/pdp10-arith.h @@ -1,8 +1,21 @@ /* - * pdp10-arith.h + * pdp10-arith.h -- arithmetic on PDP10 integer types + * Copyright (C) 2013-2015 Mikael Pettersson * - * Provide functions for performing arithmetic operations on PDP10 integer types. - * Currently only 36-bit signed operations are supported. + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #ifndef PDP10_ARITH_H #define PDP10_ARITH_H diff --git a/include/pdp10-elf36.h b/include/pdp10-elf36.h index 0be824d..7f343ab 100644 --- a/include/pdp10-elf36.h +++ b/include/pdp10-elf36.h @@ -1,6 +1,23 @@ /* - * pdp10-elf36.h + * pdp10-elf36.h -- ELF definitions for PDP10 + * Copyright (C) 2013-2015 Mikael Pettersson * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ +/* * This is essentially the standard Elf32 declarations with 8/16/32-bit * primitive types replaced by 9/18/36-bit primitive types, and Elf32 * replaced by Elf36. diff --git a/include/pdp10-extint.h b/include/pdp10-extint.h index 1a469ea..784a05e 100644 --- a/include/pdp10-extint.h +++ b/include/pdp10-extint.h @@ -1,6 +1,23 @@ /* * pdp10-extint.h + * Copyright (C) 2013-2015 Mikael Pettersson * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ +/* * Provide types and procedures for converting 18 and 36-bit integers * to and from arrays of 9-bit bytes (nonets). Use these together with * pdp10_fread() and pdp10_fwrite() to convert 18 and 36-bit integers diff --git a/include/pdp10-inttypes.h b/include/pdp10-inttypes.h index 5e8ac6d..c87819c 100644 --- a/include/pdp10-inttypes.h +++ b/include/pdp10-inttypes.h @@ -1,6 +1,23 @@ /* - * pdp10-inttypes.h + * pdp10-inttypes.h -- inttypes.h clone for PDP10 + * Copyright (C) 2013-2015 Mikael Pettersson * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ +/* * Provide format conversions for 18 and 36-bit integers. * For 9-bit integers, pdp_uint9_t, just use the regular * int-sized d/o/u/x formats. diff --git a/include/pdp10-stdint.h b/include/pdp10-stdint.h index 4a1e861..866ef7e 100644 --- a/include/pdp10-stdint.h +++ b/include/pdp10-stdint.h @@ -1,6 +1,23 @@ /* - * pdp10-stdint.h + * pdp10-stdint.h -- stdint.h clone for PDP10 + * Copyright (C) 2013-2015 Mikael Pettersson * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ +/* * Provide stdint.h-like type names and macros for 9, 18, and 36-bit unsigned * integer types. * diff --git a/include/pdp10-stdio.h b/include/pdp10-stdio.h index 08cae31..366aa9c 100644 --- a/include/pdp10-stdio.h +++ b/include/pdp10-stdio.h @@ -1,6 +1,23 @@ /* - * pdp10-stdio.h + * pdp10-stdio.h -- I/O of nonet-based files on octet-based hosts + * Copyright (C) 2013-2015 Mikael Pettersson * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ +/* * Provide stdio.h-like interface for I/O to and from files with 9-bit logical bytes (nonets), * represented by native files with 8-bit physical bytes (octets). */ diff --git a/lib/Makefile b/lib/Makefile index 1842cf2..d67b5cf 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,3 +1,21 @@ +# lib/Makefile +# Copyright (C) 2013-2015 Mikael Pettersson +# +# This file is part of pdp10-tools. +# +# pdp10-tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pdp10-tools 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 pdp10-tools. If not, see . + CC=gcc CFLAGS=-O2 -g -Wall CPPFLAGS=-I../include diff --git a/lib/pdp10-elf36.c b/lib/pdp10-elf36.c index 17d9dcf..f5de8f8 100644 --- a/lib/pdp10-elf36.c +++ b/lib/pdp10-elf36.c @@ -1,7 +1,21 @@ /* - * pdp10-elf36.c + * pdp10-elf36.c -- I/O of Elf36 files + * Copyright (C) 2013-2015 Mikael Pettersson * - * Procedures for reading and writing ELf36 files. + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include "pdp10-elf36.h" #include "pdp10-extint.h" diff --git a/lib/pdp10-extint.c b/lib/pdp10-extint.c index acb8aa7..242ba7a 100644 --- a/lib/pdp10-extint.c +++ b/lib/pdp10-extint.c @@ -1,6 +1,23 @@ /* * pdp10-extint.c + * Copyright (C) 2013-2015 Mikael Pettersson * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ +/* * Provide types and procedures for converting 18 and 36-bit integers * to and from arrays of 9-bit bytes (nonets). Use these together with * pdp10_fread() and pdp10_fwrite() to convert 18 and 36-bit integers diff --git a/lib/pdp10-stdio.c b/lib/pdp10-stdio.c index f86673d..56ff19c 100644 --- a/lib/pdp10-stdio.c +++ b/lib/pdp10-stdio.c @@ -1,6 +1,23 @@ /* - * pdp10-stdio.h + * pdp10-stdio.c + * Copyright (C) 2013-2015 Mikael Pettersson * + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ +/* * Provide stdio.h-like interface for I/O to and from files with 9-bit logical bytes (nonets), * represented by native files with 8-bit physical bytes (octets). * diff --git a/nm/Makefile b/nm/Makefile index 5442ec8..8fc9dac 100644 --- a/nm/Makefile +++ b/nm/Makefile @@ -1,3 +1,21 @@ +# nm/Makefile +# Copyright (C) 2013-2015 Mikael Pettersson +# +# This file is part of pdp10-tools. +# +# pdp10-tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pdp10-tools 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 pdp10-tools. If not, see . + CC=gcc CFLAGS=-O2 -g -Wall CPPFLAGS=-I../include diff --git a/nm/nm.c b/nm/nm.c index 480f66e..c094ad5 100644 --- a/nm/nm.c +++ b/nm/nm.c @@ -1,7 +1,23 @@ /* - * nm.c + * nm.c -- nm clone for PDP10 Elf36 files + * Copyright (C) 2013-2015 Mikael Pettersson * - * nm clone for PDP10 Elf36 files. + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . + */ +/* * This is essentially a copy of readelf.c, adjusted to * process the symbol table differently. */ diff --git a/od/Makefile b/od/Makefile index f2f36fb..92b737a 100644 --- a/od/Makefile +++ b/od/Makefile @@ -1,3 +1,21 @@ +# od/Makefile +# Copyright (C) 2013-2015 Mikael Pettersson +# +# This file is part of pdp10-tools. +# +# pdp10-tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pdp10-tools 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 pdp10-tools. If not, see . + CC=gcc CFLAGS=-O2 -g -Wall CPPFLAGS=-I../include diff --git a/od/od.c b/od/od.c index 0c789cd..04ad006 100644 --- a/od/od.c +++ b/od/od.c @@ -1,7 +1,21 @@ /* - * od.c + * od.c -- od clone for binary files with 9-bit bytes + * Copyright (C) 2013-2015 Mikael Pettersson * - * od clone for PDP10 files with 9-bit bytes + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/readelf/Makefile b/readelf/Makefile index 6baa1c2..54e6d68 100644 --- a/readelf/Makefile +++ b/readelf/Makefile @@ -1,3 +1,21 @@ +# readelf/Makefile +# Copyright (C) 2013-2015 Mikael Pettersson +# +# This file is part of pdp10-tools. +# +# pdp10-tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pdp10-tools 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 pdp10-tools. If not, see . + CC=gcc CFLAGS=-O2 -g -Wall CPPFLAGS=-I../include diff --git a/readelf/gen-test1.c b/readelf/gen-test1.c index 0902179..ae900d6 100644 --- a/readelf/gen-test1.c +++ b/readelf/gen-test1.c @@ -1,7 +1,21 @@ /* - * gen-test1.c + * gen-test1.c -- generate test1.o for readelf + * Copyright (C) 2013-2015 Mikael Pettersson * - * Generate test1.o for PDP10 Elf36 readelf. + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #include #include diff --git a/readelf/readelf.c b/readelf/readelf.c index 89a4000..4ce0c9a 100644 --- a/readelf/readelf.c +++ b/readelf/readelf.c @@ -1,7 +1,21 @@ /* - * readelf.c + * readelf.c -- readelf clone for PDP10 Elf36 files + * Copyright (C) 2013-2015 Mikael Pettersson * - * readelf/objdump clone for PDP10 Elf36 files. + * This file is part of pdp10-tools. + * + * pdp10-tools is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * pdp10-tools 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 pdp10-tools. If not, see . */ #define _GNU_SOURCE /* for getopt_long() */ #include