├── .github └── workflows │ └── build-test-ci.yml ├── .gitignore ├── .travis.yml ├── LICENSE.TXT ├── Makefile.in ├── README.md ├── compress.c ├── compress.h ├── config.guess ├── config.sub ├── configure ├── configure.ac ├── e1-elf2flt.ld ├── elf2flt.c ├── elf2flt.ld.in ├── flat.h ├── flthdr.c ├── install-sh ├── ld-elf2flt.c ├── ld-elf2flt.in ├── stubs.c ├── stubs.h ├── tests ├── flthdr │ ├── .gitignore │ ├── basic.good │ ├── generate.c │ ├── multi.good │ └── test.sh └── lib.sh └── travis ├── arches.sh ├── lib.sh └── main.sh /.github/workflows/build-test-ci.yml: -------------------------------------------------------------------------------- 1 | # GitHub actions workflow. 2 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions 3 | 4 | name: Build+Test CI 5 | 6 | on: 7 | push: 8 | branches: [main] 9 | tags: [v*] 10 | pull_request: 11 | types: [opened] 12 | branches: [main] 13 | 14 | jobs: 15 | build-test: 16 | strategy: 17 | matrix: 18 | os: [ubuntu-latest] 19 | cc: [gcc] 20 | runs-on: ${{ matrix.os }} 21 | env: 22 | CC: ${{ matrix.cc }} 23 | steps: 24 | - name: Checkout elf2flt 25 | uses: actions/checkout@v2 26 | with: 27 | path: elf2flt 28 | - name: Checkout prebuilt binutils 29 | uses: actions/checkout@v2 30 | with: 31 | repository: uclinux-dev/prebuilts-binutils-libs 32 | path: prebuilts-binutils-libs 33 | - run: cd elf2flt && ./travis/main.sh 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # standard patterns 2 | *.a 3 | *.o 4 | *~ 5 | *.orig 6 | *.rej 7 | *.patch 8 | .deps 9 | 10 | a.out 11 | *.gdb 12 | *.exe 13 | 14 | # test files 15 | *.bin 16 | *.out 17 | 18 | # autotool files 19 | autom4te.cache 20 | config.cache 21 | config.log 22 | config.status 23 | Makefile 24 | 25 | # our generated files 26 | /build/ 27 | /elf2flt 28 | /elf2flt.ld 29 | /flthdr 30 | /ld-elf2flt 31 | /ld-elf2flt.sh 32 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Travis build integration. 2 | # https://docs.travis-ci.com/ 3 | 4 | language: c 5 | compiler: 6 | # TODO: Enable clang support. 7 | # - clang 8 | - gcc 9 | 10 | sudo: false 11 | 12 | os: 13 | - linux 14 | # TODO: Enable OS X support. 15 | # - osx 16 | 17 | script: ./travis/main.sh 18 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 309 | 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) year name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | srcdir = @srcdir@ 2 | abs_top_srcdir = @abs_top_srcdir@ 3 | abs_top_builddir = @abs_top_builddir@ 4 | VPATH = @srcdir@ 5 | prefix = @prefix@ 6 | exec_prefix = @exec_prefix@ 7 | 8 | bindir = @bindir@ 9 | libdir = @libdir@ 10 | includedir = @includedir@ 11 | 12 | CC = @CC@ 13 | CPU = @target_cpu@ 14 | TARGET = @target_alias@ 15 | SYMBOL_PREFIX = @SYMBOL_PREFIX@ 16 | CFLAGS = @CFLAGS@ 17 | INCLUDES = -I$(srcdir) -Ibfd-headers @zlib_include_dir@ 18 | BFD_INCLUDE_DIR = @bfd_include_dir@ 19 | BINUTILS_INCLUDE_DIR = @binutils_include_dir@ 20 | CPPFLAGS = @CPPFLAGS@ $(DEFS) $(INCLUDES) 21 | LDFLAGS = @LDFLAGS@ 22 | LDLIBS = @LIBS@ 23 | INSTALL = @INSTALL@ 24 | DEFS = @DEFS@ \ 25 | -DTARGET_$(CPU) \ 26 | -DTARGET_CPU=\"$(CPU)\" \ 27 | -DSYMBOL_PREFIX=\"$(SYMBOL_PREFIX)\" \ 28 | -DBINUTILS_LDSCRIPTDIR=\"@binutils_ldscript_dir@\" \ 29 | -DTARGET_ALIAS=\"$(TARGET)\" \ 30 | -DNO_GOT_CHECK=@got_check@ \ 31 | -DUSE_EMIT_RELOCS=@emit_relocs@ \ 32 | -DEMIT_CTOR_DTOR=@emit_ctor_dtor@ \ 33 | -DALWAYS_RELOC_TEXT=@always_reloc_text@ \ 34 | -DHAVE_BFD_XTENSA_PDIFF_RELOCS=@HAVE_BFD_XTENSA_PDIFF_RELOCS@ 35 | EXEEXT = @EXEEXT@ 36 | OBJEXT = @OBJEXT@ 37 | 38 | HOST = @host_alias@ 39 | 40 | ifneq (,$(findstring mingw32,$(HOST))) 41 | LDLIBS += -lws2_32 42 | endif 43 | 44 | LDFILE= elf2flt.ld 45 | ifeq ($(strip $(CPU)),e1) 46 | SRC_LDFILE= $(srcdir)/$(CPU)-elf2flt.ld 47 | else 48 | SRC_LDFILE= elf2flt.ld 49 | endif 50 | 51 | target_bindir = $(prefix)/$(TARGET)/bin 52 | target_libdir = $(prefix)/$(TARGET)/lib 53 | 54 | 55 | PROG_ELF2FLT = elf2flt$(EXEEXT) 56 | PROG_FLTHDR = flthdr$(EXEEXT) 57 | PROG_LD_ELF2FLT_C = ld-elf2flt$(EXEEXT) 58 | PROG_LD_ELF2FLT_SH = ld-elf2flt.sh 59 | 60 | ifeq (@use_ld_elf2flt_binary@,yes) 61 | PROG_LD_ELF2FLT = $(PROG_LD_ELF2FLT_C) 62 | else 63 | PROG_LD_ELF2FLT = $(PROG_LD_ELF2FLT_SH) 64 | endif 65 | 66 | PROGS = $(PROG_ELF2FLT) $(PROG_FLTHDR) $(PROG_LD_ELF2FLT_C) $(PROG_LD_ELF2FLT_SH) 67 | 68 | all: $(PROGS) 69 | 70 | # We need to declare the link explicitly because make only provides 71 | # implicit rules when EXEEXT is set to nothing 72 | link = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) 73 | 74 | $(PROG_ELF2FLT): elf2flt.o compress.o stubs.o 75 | $(link) 76 | 77 | $(PROG_FLTHDR): flthdr.o compress.o stubs.o 78 | $(link) 79 | 80 | ld-elf2flt$(EXEEXT): ld-elf2flt.o stubs.o 81 | $(link) 82 | 83 | ld-elf2flt.sh: $(srcdir)/ld-elf2flt.in 84 | ./config.status $@ 85 | chmod 755 $@ 86 | 87 | Makefile: $(srcdir)/Makefile.in 88 | ./config.status $@ 89 | 90 | tests/flthdr/generate: tests/flthdr/generate.o 91 | $(link) 92 | 93 | check-flthdr: 94 | mkdir -p tests/flthdr 95 | $(MAKE) tests/flthdr/generate 96 | abs_top_srcdir="$(abs_top_srcdir)" abs_top_builddir="$(abs_top_builddir)" \ 97 | $(srcdir)/tests/flthdr/test.sh 98 | 99 | check: check-flthdr 100 | 101 | clean: 102 | -rm -f $(PROGS) *.$(OBJEXT) .deps 103 | -rm -rf bfd-headers 104 | 105 | distclean: clean 106 | -rm -f Makefile config.log config.status config.cache ld-elf2flt 107 | 108 | install: 109 | $(INSTALL) -d $(DESTDIR)$(bindir) $(DESTDIR)$(target_bindir) $(DESTDIR)$(target_libdir) 110 | $(INSTALL) -m 755 $(PROG_FLTHDR) $(DESTDIR)$(bindir)/$(TARGET)-$(PROG_FLTHDR) 111 | $(INSTALL) -m 755 $(PROG_FLTHDR) $(DESTDIR)$(target_bindir)/$(PROG_FLTHDR) 112 | $(INSTALL) -m 755 $(PROG_ELF2FLT) $(DESTDIR)$(bindir)/$(TARGET)-$(PROG_ELF2FLT) 113 | $(INSTALL) -m 755 $(PROG_ELF2FLT) $(DESTDIR)$(target_bindir)/$(PROG_ELF2FLT) 114 | [ -f $(DESTDIR)$(bindir)/$(TARGET)-ld.real$(EXEEXT) ] || \ 115 | mv $(DESTDIR)$(bindir)/$(TARGET)-ld$(EXEEXT) $(DESTDIR)$(bindir)/$(TARGET)-ld.real$(EXEEXT) 116 | [ -f $(DESTDIR)$(target_bindir)/ld.real$(EXEEXT) ] || \ 117 | mv $(DESTDIR)$(target_bindir)/ld$(EXEEXT) $(DESTDIR)$(target_bindir)/ld.real$(EXEEXT) 118 | $(INSTALL) -m 755 $(PROG_LD_ELF2FLT) $(DESTDIR)$(bindir)/$(TARGET)-ld$(EXEEXT) 119 | $(INSTALL) -m 755 $(PROG_LD_ELF2FLT) $(DESTDIR)$(target_bindir)/ld$(EXEEXT) 120 | $(INSTALL) -m 644 $(SRC_LDFILE) $(DESTDIR)$(target_libdir)/$(LDFILE) 121 | 122 | sinclude .deps 123 | .deps: bfd-headers/.stamp 124 | $(CC) -MM $(CPPFLAGS) $(srcdir)/*.c > .deps 125 | 126 | 127 | # Some versions of binutils may not have all these headers (diagnostics.h 128 | # appeared in binutils 2.31; bfd_stdint.h in 2.32) so some symlinks may be 129 | # dangling. 130 | bfd-headers/.stamp: 131 | rm -rf bfd-headers 132 | mkdir bfd-headers 133 | for f in bfd bfd_stdint; do \ 134 | ln -sf $(BFD_INCLUDE_DIR)/$$f.h bfd-headers/$$f.h || exit 1; \ 135 | done 136 | for f in ansidecl diagnostics filenames hashtab libiberty symcat; do \ 137 | ln -sf $(BINUTILS_INCLUDE_DIR)/$$f.h bfd-headers/$$f.h || exit 1; \ 138 | done 139 | ln -sf $(BINUTILS_INCLUDE_DIR)/elf bfd-headers/elf 140 | touch $@ 141 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # elf2flt 2 | 3 | [![Build Status](https://travis-ci.org/uclinux-dev/elf2flt.svg?branch=main)](https://travis-ci.org/uclinux-dev/elf2flt) 4 | 5 | Copyright (C) 2001-2003, SnapGear (www.snapgear.com) 6 | David McCullough 7 | Greg Ungerer 8 | 9 | This is Free Software, under the GNU Public License v2 or greater. See 10 | [LICENSE.TXT](LICENSE.TXT) for more details. 11 | 12 | Elf2flt with PIC, ZFLAT and full reloc support. Currently supported 13 | targets include: m68k/ColdFire, ARM, Sparc, NEC v850, MicroBlaze, 14 | h8300, SuperH, and Blackfin. 15 | 16 | ## Compiling 17 | 18 | You need an appropriate libbfd.a and libiberty.a for your target to 19 | build this tool. They are normally part of the binutils package. 20 | 21 | To compile elf2flt do: 22 | 23 | ./configure --target= --with-libbfd= --with-libiberty= 24 | make 25 | make install 26 | 27 | The argument to configure specifies what the target architecture is. 28 | This should be the same target as you used to build the binutils and gcc 29 | cross development tools. The `--with-libbfd` and `--with-libiberty` arguments 30 | specify where the libbfd.a and libiberty.a library files are to use. 31 | 32 | ## Files 33 | 34 | * README.md - this file 35 | * configure - autoconf configuration shell script 36 | * configure.ac - original autoconf file 37 | * config.* - autoconf support scripts 38 | * Makefile.in - Makefile template used by configure 39 | * elf2flt.c - the source 40 | * flthdr.c - flat header manipulation program 41 | * flat.h - header from uClinux kernel sources 42 | * elf2flt.ld - An example [linker script](https://sourceware.org/binutils/docs/ld/Scripts.html) 43 | that works for C/C++ and uClinux. `ld-elf2flt` processes this 44 | on the fly before passing it to the real linker to use (in 45 | place of the default linker script provided by the normal 46 | toolchain). 47 | * ld-elf2flt - A linker replacement that implements a `-elf2flt` option for 48 | the linker and runs elf2flt automatically for you. It auto 49 | detects PIC/non-PIC code and adjusts its option accordingly. 50 | It uses the environment variable `FLTFLAGS` when running 51 | elf2flt. It runs /.../-ld.real to do the actual linking. 52 | * stubs.c - Support for various functions that your OS might be missing 53 | (e.g. Windows-vs-Linux). Only used by our programs above -- it 54 | is *not* included in the flat/ELF programs we produce. 55 | 56 | ## Tips 57 | 58 | The ld-elf2flt produces 2 files as output. The binary flat file X, and 59 | X.gdb which is used for debugging and PIC purposes. 60 | 61 | The `-p` option requires an elf executable linked at address 0. The 62 | elf2flt.ld provided will generate the correct format binary when linked 63 | with the real linker with *no* `-r` option for the linker. 64 | 65 | The `-r` flag can be added to PIC builds to get contiguous code/data. This 66 | is good for loading application symbols into gdb (add-symbol-file XXX.gdb). 67 | 68 | ## Support 69 | 70 | You can use the github site to file issues and send pull requests, and the 71 | [uclinux-dev@uclinux.org](http://mailman.uclinux.org/mailman/listinfo/uclinux-dev) 72 | mailing list to contact the developers. 73 | -------------------------------------------------------------------------------- /compress.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Helper functions to handle compression via zlib 3 | * 4 | * Copyright (C) 2007-2008 Julian Brown 5 | * Copyright (C) 2008 Mike Frysinger 6 | * 7 | * Licensed under the GPL-2 or later. 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include "compress.h" 16 | #include "stubs.h" 17 | 18 | /* Open an (uncompressed) file as a stream. Return 0 on success, 1 on 19 | error. 20 | NOTE: The MODE argument must remain valid for the lifetime of the stream, 21 | because it is referred to by reopen_stream_compressed() if it is called. 22 | String constants work fine. */ 23 | 24 | int 25 | fopen_stream_u(stream *fp, const char *path, const char *mode) 26 | { 27 | fp->u.filep = fopen(path, mode); 28 | fp->type = (fp->u.filep) ? UNCOMPRESSED : INVALID; 29 | fp->mode = mode; 30 | return (fp->u.filep) ? 0 : 1; 31 | } 32 | 33 | /* Read from stream. Return number of elements read. */ 34 | 35 | size_t 36 | fread_stream(void *ptr, size_t size, size_t nmemb, stream *str) 37 | { 38 | size_t read; 39 | 40 | switch (str->type) { 41 | case UNCOMPRESSED: 42 | read = fread(ptr, size, nmemb, str->u.filep); 43 | break; 44 | 45 | case COMPRESSED: 46 | read = gzread(str->u.gzfilep, ptr, size * nmemb) / size; 47 | break; 48 | 49 | default: 50 | abort(); 51 | } 52 | 53 | return read; 54 | } 55 | 56 | /* Write to stream. Return number of elements written. */ 57 | 58 | size_t 59 | fwrite_stream(const void *ptr, size_t size, size_t nmemb, stream *str) 60 | { 61 | size_t written; 62 | 63 | switch (str->type) { 64 | case UNCOMPRESSED: 65 | written = fwrite(ptr, size, nmemb, str->u.filep); 66 | break; 67 | 68 | case COMPRESSED: 69 | written = gzwrite(str->u.gzfilep, ptr, size * nmemb) / size; 70 | break; 71 | 72 | default: 73 | abort(); 74 | } 75 | 76 | return written; 77 | } 78 | 79 | /* Close stream. */ 80 | 81 | int 82 | fclose_stream(stream *str) 83 | { 84 | switch (str->type) { 85 | case UNCOMPRESSED: 86 | return fclose(str->u.filep); 87 | 88 | case COMPRESSED: 89 | return gzclose(str->u.gzfilep); 90 | 91 | default: 92 | abort(); 93 | } 94 | 95 | return 0; 96 | } 97 | 98 | int 99 | ferror_stream(stream *str) 100 | { 101 | switch (str->type) { 102 | case UNCOMPRESSED: 103 | return ferror(str->u.filep); 104 | 105 | case COMPRESSED: 106 | { 107 | const char *err; 108 | int errno; 109 | 110 | err = gzerror(str->u.gzfilep, &errno); 111 | if (errno == Z_OK || errno == Z_STREAM_END) 112 | return 0; 113 | else if (errno == Z_ERRNO) 114 | return 1; 115 | else { 116 | fprintf(stderr, "%s\n", err); 117 | return 1; 118 | } 119 | } 120 | break; 121 | 122 | default: 123 | abort(); 124 | } 125 | 126 | return 0; 127 | } 128 | 129 | int 130 | fseek_stream(stream *str, long offset, int whence) 131 | { 132 | switch (str->type) { 133 | case UNCOMPRESSED: 134 | return fseek(str->u.filep, offset, whence); 135 | 136 | case COMPRESSED: 137 | return gzseek(str->u.gzfilep, offset, whence); 138 | 139 | default: 140 | abort(); 141 | } 142 | } 143 | 144 | /* Reopen a stream at the current file position. */ 145 | 146 | void 147 | reopen_stream_compressed(stream *str) 148 | { 149 | int fd; 150 | long offset, roffset; 151 | 152 | /* Already a compressed stream, return immediately */ 153 | if (str->type == COMPRESSED) 154 | return; 155 | 156 | if (str->type == INVALID) 157 | abort(); 158 | 159 | fd = fileno(str->u.filep); 160 | /* Get current (buffered) file position. */ 161 | offset = ftell(str->u.filep); 162 | 163 | /* Make sure there's nothing left in buffers. */ 164 | fflush(str->u.filep); 165 | 166 | /* Reposition underlying FD. (Might be unnecessary?) */ 167 | roffset = lseek(fd, offset, SEEK_SET); 168 | 169 | assert(roffset == offset); 170 | 171 | /* Reopen as compressed stream. */ 172 | str->u.gzfilep = gzdopen(fd, str->mode); 173 | gzsetparams(str->u.gzfilep, 9, Z_DEFAULT_STRATEGY); 174 | str->type = COMPRESSED; 175 | } 176 | 177 | void 178 | transfer(stream *ifp, stream *ofp, int count) 179 | { 180 | char cmd[1024]; 181 | int n, num; 182 | 183 | while (count == -1 || count > 0) { 184 | if (count == -1 || count > sizeof(cmd)) 185 | num = sizeof(cmd); 186 | else 187 | num = count; 188 | n = fread_stream(cmd, 1, num, ifp); 189 | if (n == 0) 190 | break; 191 | if (fwrite_stream(cmd, n, 1, ofp) != 1) 192 | fatal_perror("Write failed :-(\n"); 193 | if (count != -1) 194 | count -= n; 195 | } 196 | if (count > 0) 197 | fatal("Failed to transfer %d bytes\n", count); 198 | } 199 | -------------------------------------------------------------------------------- /compress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Helper functions to handle compression via zlib 3 | * 4 | * Copyright (C) 2007-2008 Julian Brown 5 | * Copyright (C) 2008 Mike Frysinger 6 | * 7 | * Licensed under the GPL-2 or later. 8 | */ 9 | 10 | #ifndef __ELF2FLT_COMPRESS_H__ 11 | #define __ELF2FLT_COMPRESS_H__ 12 | 13 | #include 14 | 15 | typedef enum 16 | { 17 | INVALID, 18 | UNCOMPRESSED, 19 | COMPRESSED 20 | } stream_type; 21 | 22 | /* Tagged union holding either a regular FILE* handle or a zlib gzFile 23 | handle. */ 24 | typedef struct 25 | { 26 | stream_type type; 27 | const char *mode; 28 | union 29 | { 30 | FILE *filep; 31 | gzFile gzfilep; 32 | } u; 33 | } stream; 34 | 35 | int fopen_stream_u(stream *fp, const char *path, const char *mode); 36 | size_t fread_stream(void *ptr, size_t size, size_t nmemb, stream *str); 37 | size_t fwrite_stream(const void *ptr, size_t size, size_t nmemb, stream *str); 38 | int fclose_stream(stream *str); 39 | int ferror_stream(stream *str); 40 | int fseek_stream(stream *str, long offset, int whence); 41 | void reopen_stream_compressed(stream *str); 42 | void transfer(stream *ifp, stream *ofp, int count); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /config.guess: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Attempt to guess a canonical system name. 3 | # Copyright 1992-2015 Free Software Foundation, Inc. 4 | 5 | timestamp='2015-12-14' 6 | 7 | # This file is free software; you can redistribute it and/or modify it 8 | # under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, but 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, see . 19 | # 20 | # As a special exception to the GNU General Public License, if you 21 | # distribute this file as part of a program that contains a 22 | # configuration script generated by Autoconf, you may include it under 23 | # the same distribution terms that you use for the rest of that 24 | # program. This Exception is an additional permission under section 7 25 | # of the GNU General Public License, version 3 ("GPLv3"). 26 | # 27 | # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. 28 | # 29 | # You can get the latest version of this script from: 30 | # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD 31 | # 32 | # Please send patches to . 33 | 34 | 35 | me=`echo "$0" | sed -e 's,.*/,,'` 36 | 37 | usage="\ 38 | Usage: $0 [OPTION] 39 | 40 | Output the configuration name of the system \`$me' is run on. 41 | 42 | Operation modes: 43 | -h, --help print this help, then exit 44 | -t, --time-stamp print date of last modification, then exit 45 | -v, --version print version number, then exit 46 | 47 | Report bugs and patches to ." 48 | 49 | version="\ 50 | GNU config.guess ($timestamp) 51 | 52 | Originally written by Per Bothner. 53 | Copyright 1992-2015 Free Software Foundation, Inc. 54 | 55 | This is free software; see the source for copying conditions. There is NO 56 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 57 | 58 | help=" 59 | Try \`$me --help' for more information." 60 | 61 | # Parse command line 62 | while test $# -gt 0 ; do 63 | case $1 in 64 | --time-stamp | --time* | -t ) 65 | echo "$timestamp" ; exit ;; 66 | --version | -v ) 67 | echo "$version" ; exit ;; 68 | --help | --h* | -h ) 69 | echo "$usage"; exit ;; 70 | -- ) # Stop option processing 71 | shift; break ;; 72 | - ) # Use stdin as input. 73 | break ;; 74 | -* ) 75 | echo "$me: invalid option $1$help" >&2 76 | exit 1 ;; 77 | * ) 78 | break ;; 79 | esac 80 | done 81 | 82 | if test $# != 0; then 83 | echo "$me: too many arguments$help" >&2 84 | exit 1 85 | fi 86 | 87 | trap 'exit 1' 1 2 15 88 | 89 | # CC_FOR_BUILD -- compiler used by this script. Note that the use of a 90 | # compiler to aid in system detection is discouraged as it requires 91 | # temporary files to be created and, as you can see below, it is a 92 | # headache to deal with in a portable fashion. 93 | 94 | # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still 95 | # use `HOST_CC' if defined, but it is deprecated. 96 | 97 | # Portable tmp directory creation inspired by the Autoconf team. 98 | 99 | set_cc_for_build=' 100 | trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; 101 | trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; 102 | : ${TMPDIR=/tmp} ; 103 | { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || 104 | { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || 105 | { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || 106 | { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; 107 | dummy=$tmp/dummy ; 108 | tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; 109 | case $CC_FOR_BUILD,$HOST_CC,$CC in 110 | ,,) echo "int x;" > $dummy.c ; 111 | for c in cc gcc c89 c99 ; do 112 | if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then 113 | CC_FOR_BUILD="$c"; break ; 114 | fi ; 115 | done ; 116 | if test x"$CC_FOR_BUILD" = x ; then 117 | CC_FOR_BUILD=no_compiler_found ; 118 | fi 119 | ;; 120 | ,,*) CC_FOR_BUILD=$CC ;; 121 | ,*,*) CC_FOR_BUILD=$HOST_CC ;; 122 | esac ; set_cc_for_build= ;' 123 | 124 | # This is needed to find uname on a Pyramid OSx when run in the BSD universe. 125 | # (ghazi@noc.rutgers.edu 1994-08-24) 126 | if (test -f /.attbin/uname) >/dev/null 2>&1 ; then 127 | PATH=$PATH:/.attbin ; export PATH 128 | fi 129 | 130 | UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown 131 | UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown 132 | UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown 133 | UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown 134 | 135 | case "${UNAME_SYSTEM}" in 136 | Linux|GNU|GNU/*) 137 | # If the system lacks a compiler, then just pick glibc. 138 | # We could probably try harder. 139 | LIBC=gnu 140 | 141 | eval $set_cc_for_build 142 | cat <<-EOF > $dummy.c 143 | #include 144 | #if defined(__UCLIBC__) 145 | LIBC=uclibc 146 | #elif defined(__dietlibc__) 147 | LIBC=dietlibc 148 | #else 149 | LIBC=gnu 150 | #endif 151 | EOF 152 | eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` 153 | ;; 154 | esac 155 | 156 | # Note: order is significant - the case branches are not exclusive. 157 | 158 | case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in 159 | *:NetBSD:*:*) 160 | # NetBSD (nbsd) targets should (where applicable) match one or 161 | # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, 162 | # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently 163 | # switched to ELF, *-*-netbsd* would select the old 164 | # object file format. This provides both forward 165 | # compatibility and a consistent mechanism for selecting the 166 | # object file format. 167 | # 168 | # Note: NetBSD doesn't particularly care about the vendor 169 | # portion of the name. We always set it to "unknown". 170 | sysctl="sysctl -n hw.machine_arch" 171 | UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ 172 | /sbin/$sysctl 2>/dev/null || \ 173 | /usr/sbin/$sysctl 2>/dev/null || \ 174 | echo unknown)` 175 | case "${UNAME_MACHINE_ARCH}" in 176 | armeb) machine=armeb-unknown ;; 177 | arm*) machine=arm-unknown ;; 178 | sh3el) machine=shl-unknown ;; 179 | sh3eb) machine=sh-unknown ;; 180 | sh5el) machine=sh5le-unknown ;; 181 | earmv*) 182 | arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` 183 | endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` 184 | machine=${arch}${endian}-unknown 185 | ;; 186 | *) machine=${UNAME_MACHINE_ARCH}-unknown ;; 187 | esac 188 | # The Operating System including object format, if it has switched 189 | # to ELF recently, or will in the future. 190 | case "${UNAME_MACHINE_ARCH}" in 191 | arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) 192 | eval $set_cc_for_build 193 | if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ 194 | | grep -q __ELF__ 195 | then 196 | # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). 197 | # Return netbsd for either. FIX? 198 | os=netbsd 199 | else 200 | os=netbsdelf 201 | fi 202 | ;; 203 | *) 204 | os=netbsd 205 | ;; 206 | esac 207 | # Determine ABI tags. 208 | case "${UNAME_MACHINE_ARCH}" in 209 | earm*) 210 | expr='s/^earmv[0-9]/-eabi/;s/eb$//' 211 | abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` 212 | ;; 213 | esac 214 | # The OS release 215 | # Debian GNU/NetBSD machines have a different userland, and 216 | # thus, need a distinct triplet. However, they do not need 217 | # kernel version information, so it can be replaced with a 218 | # suitable tag, in the style of linux-gnu. 219 | case "${UNAME_VERSION}" in 220 | Debian*) 221 | release='-gnu' 222 | ;; 223 | *) 224 | release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` 225 | ;; 226 | esac 227 | # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: 228 | # contains redundant information, the shorter form: 229 | # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. 230 | echo "${machine}-${os}${release}${abi}" 231 | exit ;; 232 | *:Bitrig:*:*) 233 | UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` 234 | echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} 235 | exit ;; 236 | *:OpenBSD:*:*) 237 | UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` 238 | echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} 239 | exit ;; 240 | *:ekkoBSD:*:*) 241 | echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} 242 | exit ;; 243 | *:SolidBSD:*:*) 244 | echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} 245 | exit ;; 246 | macppc:MirBSD:*:*) 247 | echo powerpc-unknown-mirbsd${UNAME_RELEASE} 248 | exit ;; 249 | *:MirBSD:*:*) 250 | echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} 251 | exit ;; 252 | *:Sortix:*:*) 253 | echo ${UNAME_MACHINE}-unknown-sortix 254 | exit ;; 255 | alpha:OSF1:*:*) 256 | case $UNAME_RELEASE in 257 | *4.0) 258 | UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` 259 | ;; 260 | *5.*) 261 | UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` 262 | ;; 263 | esac 264 | # According to Compaq, /usr/sbin/psrinfo has been available on 265 | # OSF/1 and Tru64 systems produced since 1995. I hope that 266 | # covers most systems running today. This code pipes the CPU 267 | # types through head -n 1, so we only detect the type of CPU 0. 268 | ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` 269 | case "$ALPHA_CPU_TYPE" in 270 | "EV4 (21064)") 271 | UNAME_MACHINE="alpha" ;; 272 | "EV4.5 (21064)") 273 | UNAME_MACHINE="alpha" ;; 274 | "LCA4 (21066/21068)") 275 | UNAME_MACHINE="alpha" ;; 276 | "EV5 (21164)") 277 | UNAME_MACHINE="alphaev5" ;; 278 | "EV5.6 (21164A)") 279 | UNAME_MACHINE="alphaev56" ;; 280 | "EV5.6 (21164PC)") 281 | UNAME_MACHINE="alphapca56" ;; 282 | "EV5.7 (21164PC)") 283 | UNAME_MACHINE="alphapca57" ;; 284 | "EV6 (21264)") 285 | UNAME_MACHINE="alphaev6" ;; 286 | "EV6.7 (21264A)") 287 | UNAME_MACHINE="alphaev67" ;; 288 | "EV6.8CB (21264C)") 289 | UNAME_MACHINE="alphaev68" ;; 290 | "EV6.8AL (21264B)") 291 | UNAME_MACHINE="alphaev68" ;; 292 | "EV6.8CX (21264D)") 293 | UNAME_MACHINE="alphaev68" ;; 294 | "EV6.9A (21264/EV69A)") 295 | UNAME_MACHINE="alphaev69" ;; 296 | "EV7 (21364)") 297 | UNAME_MACHINE="alphaev7" ;; 298 | "EV7.9 (21364A)") 299 | UNAME_MACHINE="alphaev79" ;; 300 | esac 301 | # A Pn.n version is a patched version. 302 | # A Vn.n version is a released version. 303 | # A Tn.n version is a released field test version. 304 | # A Xn.n version is an unreleased experimental baselevel. 305 | # 1.2 uses "1.2" for uname -r. 306 | echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 307 | # Reset EXIT trap before exiting to avoid spurious non-zero exit code. 308 | exitcode=$? 309 | trap '' 0 310 | exit $exitcode ;; 311 | Alpha\ *:Windows_NT*:*) 312 | # How do we know it's Interix rather than the generic POSIX subsystem? 313 | # Should we change UNAME_MACHINE based on the output of uname instead 314 | # of the specific Alpha model? 315 | echo alpha-pc-interix 316 | exit ;; 317 | 21064:Windows_NT:50:3) 318 | echo alpha-dec-winnt3.5 319 | exit ;; 320 | Amiga*:UNIX_System_V:4.0:*) 321 | echo m68k-unknown-sysv4 322 | exit ;; 323 | *:[Aa]miga[Oo][Ss]:*:*) 324 | echo ${UNAME_MACHINE}-unknown-amigaos 325 | exit ;; 326 | *:[Mm]orph[Oo][Ss]:*:*) 327 | echo ${UNAME_MACHINE}-unknown-morphos 328 | exit ;; 329 | *:OS/390:*:*) 330 | echo i370-ibm-openedition 331 | exit ;; 332 | *:z/VM:*:*) 333 | echo s390-ibm-zvmoe 334 | exit ;; 335 | *:OS400:*:*) 336 | echo powerpc-ibm-os400 337 | exit ;; 338 | arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) 339 | echo arm-acorn-riscix${UNAME_RELEASE} 340 | exit ;; 341 | arm*:riscos:*:*|arm*:RISCOS:*:*) 342 | echo arm-unknown-riscos 343 | exit ;; 344 | SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) 345 | echo hppa1.1-hitachi-hiuxmpp 346 | exit ;; 347 | Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) 348 | # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. 349 | if test "`(/bin/universe) 2>/dev/null`" = att ; then 350 | echo pyramid-pyramid-sysv3 351 | else 352 | echo pyramid-pyramid-bsd 353 | fi 354 | exit ;; 355 | NILE*:*:*:dcosx) 356 | echo pyramid-pyramid-svr4 357 | exit ;; 358 | DRS?6000:unix:4.0:6*) 359 | echo sparc-icl-nx6 360 | exit ;; 361 | DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) 362 | case `/usr/bin/uname -p` in 363 | sparc) echo sparc-icl-nx7; exit ;; 364 | esac ;; 365 | s390x:SunOS:*:*) 366 | echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 367 | exit ;; 368 | sun4H:SunOS:5.*:*) 369 | echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 370 | exit ;; 371 | sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) 372 | echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 373 | exit ;; 374 | i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) 375 | echo i386-pc-auroraux${UNAME_RELEASE} 376 | exit ;; 377 | i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) 378 | eval $set_cc_for_build 379 | SUN_ARCH="i386" 380 | # If there is a compiler, see if it is configured for 64-bit objects. 381 | # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. 382 | # This test works for both compilers. 383 | if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then 384 | if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ 385 | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ 386 | grep IS_64BIT_ARCH >/dev/null 387 | then 388 | SUN_ARCH="x86_64" 389 | fi 390 | fi 391 | echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 392 | exit ;; 393 | sun4*:SunOS:6*:*) 394 | # According to config.sub, this is the proper way to canonicalize 395 | # SunOS6. Hard to guess exactly what SunOS6 will be like, but 396 | # it's likely to be more like Solaris than SunOS4. 397 | echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 398 | exit ;; 399 | sun4*:SunOS:*:*) 400 | case "`/usr/bin/arch -k`" in 401 | Series*|S4*) 402 | UNAME_RELEASE=`uname -v` 403 | ;; 404 | esac 405 | # Japanese Language versions have a version number like `4.1.3-JL'. 406 | echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` 407 | exit ;; 408 | sun3*:SunOS:*:*) 409 | echo m68k-sun-sunos${UNAME_RELEASE} 410 | exit ;; 411 | sun*:*:4.2BSD:*) 412 | UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` 413 | test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 414 | case "`/bin/arch`" in 415 | sun3) 416 | echo m68k-sun-sunos${UNAME_RELEASE} 417 | ;; 418 | sun4) 419 | echo sparc-sun-sunos${UNAME_RELEASE} 420 | ;; 421 | esac 422 | exit ;; 423 | aushp:SunOS:*:*) 424 | echo sparc-auspex-sunos${UNAME_RELEASE} 425 | exit ;; 426 | # The situation for MiNT is a little confusing. The machine name 427 | # can be virtually everything (everything which is not 428 | # "atarist" or "atariste" at least should have a processor 429 | # > m68000). The system name ranges from "MiNT" over "FreeMiNT" 430 | # to the lowercase version "mint" (or "freemint"). Finally 431 | # the system name "TOS" denotes a system which is actually not 432 | # MiNT. But MiNT is downward compatible to TOS, so this should 433 | # be no problem. 434 | atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) 435 | echo m68k-atari-mint${UNAME_RELEASE} 436 | exit ;; 437 | atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) 438 | echo m68k-atari-mint${UNAME_RELEASE} 439 | exit ;; 440 | *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) 441 | echo m68k-atari-mint${UNAME_RELEASE} 442 | exit ;; 443 | milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) 444 | echo m68k-milan-mint${UNAME_RELEASE} 445 | exit ;; 446 | hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) 447 | echo m68k-hades-mint${UNAME_RELEASE} 448 | exit ;; 449 | *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) 450 | echo m68k-unknown-mint${UNAME_RELEASE} 451 | exit ;; 452 | m68k:machten:*:*) 453 | echo m68k-apple-machten${UNAME_RELEASE} 454 | exit ;; 455 | powerpc:machten:*:*) 456 | echo powerpc-apple-machten${UNAME_RELEASE} 457 | exit ;; 458 | RISC*:Mach:*:*) 459 | echo mips-dec-mach_bsd4.3 460 | exit ;; 461 | RISC*:ULTRIX:*:*) 462 | echo mips-dec-ultrix${UNAME_RELEASE} 463 | exit ;; 464 | VAX*:ULTRIX*:*:*) 465 | echo vax-dec-ultrix${UNAME_RELEASE} 466 | exit ;; 467 | 2020:CLIX:*:* | 2430:CLIX:*:*) 468 | echo clipper-intergraph-clix${UNAME_RELEASE} 469 | exit ;; 470 | mips:*:*:UMIPS | mips:*:*:RISCos) 471 | eval $set_cc_for_build 472 | sed 's/^ //' << EOF >$dummy.c 473 | #ifdef __cplusplus 474 | #include /* for printf() prototype */ 475 | int main (int argc, char *argv[]) { 476 | #else 477 | int main (argc, argv) int argc; char *argv[]; { 478 | #endif 479 | #if defined (host_mips) && defined (MIPSEB) 480 | #if defined (SYSTYPE_SYSV) 481 | printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); 482 | #endif 483 | #if defined (SYSTYPE_SVR4) 484 | printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); 485 | #endif 486 | #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) 487 | printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); 488 | #endif 489 | #endif 490 | exit (-1); 491 | } 492 | EOF 493 | $CC_FOR_BUILD -o $dummy $dummy.c && 494 | dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && 495 | SYSTEM_NAME=`$dummy $dummyarg` && 496 | { echo "$SYSTEM_NAME"; exit; } 497 | echo mips-mips-riscos${UNAME_RELEASE} 498 | exit ;; 499 | Motorola:PowerMAX_OS:*:*) 500 | echo powerpc-motorola-powermax 501 | exit ;; 502 | Motorola:*:4.3:PL8-*) 503 | echo powerpc-harris-powermax 504 | exit ;; 505 | Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) 506 | echo powerpc-harris-powermax 507 | exit ;; 508 | Night_Hawk:Power_UNIX:*:*) 509 | echo powerpc-harris-powerunix 510 | exit ;; 511 | m88k:CX/UX:7*:*) 512 | echo m88k-harris-cxux7 513 | exit ;; 514 | m88k:*:4*:R4*) 515 | echo m88k-motorola-sysv4 516 | exit ;; 517 | m88k:*:3*:R3*) 518 | echo m88k-motorola-sysv3 519 | exit ;; 520 | AViiON:dgux:*:*) 521 | # DG/UX returns AViiON for all architectures 522 | UNAME_PROCESSOR=`/usr/bin/uname -p` 523 | if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] 524 | then 525 | if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ 526 | [ ${TARGET_BINARY_INTERFACE}x = x ] 527 | then 528 | echo m88k-dg-dgux${UNAME_RELEASE} 529 | else 530 | echo m88k-dg-dguxbcs${UNAME_RELEASE} 531 | fi 532 | else 533 | echo i586-dg-dgux${UNAME_RELEASE} 534 | fi 535 | exit ;; 536 | M88*:DolphinOS:*:*) # DolphinOS (SVR3) 537 | echo m88k-dolphin-sysv3 538 | exit ;; 539 | M88*:*:R3*:*) 540 | # Delta 88k system running SVR3 541 | echo m88k-motorola-sysv3 542 | exit ;; 543 | XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) 544 | echo m88k-tektronix-sysv3 545 | exit ;; 546 | Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) 547 | echo m68k-tektronix-bsd 548 | exit ;; 549 | *:IRIX*:*:*) 550 | echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` 551 | exit ;; 552 | ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. 553 | echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id 554 | exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' 555 | i*86:AIX:*:*) 556 | echo i386-ibm-aix 557 | exit ;; 558 | ia64:AIX:*:*) 559 | if [ -x /usr/bin/oslevel ] ; then 560 | IBM_REV=`/usr/bin/oslevel` 561 | else 562 | IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} 563 | fi 564 | echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} 565 | exit ;; 566 | *:AIX:2:3) 567 | if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then 568 | eval $set_cc_for_build 569 | sed 's/^ //' << EOF >$dummy.c 570 | #include 571 | 572 | main() 573 | { 574 | if (!__power_pc()) 575 | exit(1); 576 | puts("powerpc-ibm-aix3.2.5"); 577 | exit(0); 578 | } 579 | EOF 580 | if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` 581 | then 582 | echo "$SYSTEM_NAME" 583 | else 584 | echo rs6000-ibm-aix3.2.5 585 | fi 586 | elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then 587 | echo rs6000-ibm-aix3.2.4 588 | else 589 | echo rs6000-ibm-aix3.2 590 | fi 591 | exit ;; 592 | *:AIX:*:[4567]) 593 | IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` 594 | if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then 595 | IBM_ARCH=rs6000 596 | else 597 | IBM_ARCH=powerpc 598 | fi 599 | if [ -x /usr/bin/lslpp ] ; then 600 | IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | 601 | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` 602 | else 603 | IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} 604 | fi 605 | echo ${IBM_ARCH}-ibm-aix${IBM_REV} 606 | exit ;; 607 | *:AIX:*:*) 608 | echo rs6000-ibm-aix 609 | exit ;; 610 | ibmrt:4.4BSD:*|romp-ibm:BSD:*) 611 | echo romp-ibm-bsd4.4 612 | exit ;; 613 | ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and 614 | echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to 615 | exit ;; # report: romp-ibm BSD 4.3 616 | *:BOSX:*:*) 617 | echo rs6000-bull-bosx 618 | exit ;; 619 | DPX/2?00:B.O.S.:*:*) 620 | echo m68k-bull-sysv3 621 | exit ;; 622 | 9000/[34]??:4.3bsd:1.*:*) 623 | echo m68k-hp-bsd 624 | exit ;; 625 | hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) 626 | echo m68k-hp-bsd4.4 627 | exit ;; 628 | 9000/[34678]??:HP-UX:*:*) 629 | HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` 630 | case "${UNAME_MACHINE}" in 631 | 9000/31? ) HP_ARCH=m68000 ;; 632 | 9000/[34]?? ) HP_ARCH=m68k ;; 633 | 9000/[678][0-9][0-9]) 634 | if [ -x /usr/bin/getconf ]; then 635 | sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` 636 | sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` 637 | case "${sc_cpu_version}" in 638 | 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 639 | 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 640 | 532) # CPU_PA_RISC2_0 641 | case "${sc_kernel_bits}" in 642 | 32) HP_ARCH="hppa2.0n" ;; 643 | 64) HP_ARCH="hppa2.0w" ;; 644 | '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 645 | esac ;; 646 | esac 647 | fi 648 | if [ "${HP_ARCH}" = "" ]; then 649 | eval $set_cc_for_build 650 | sed 's/^ //' << EOF >$dummy.c 651 | 652 | #define _HPUX_SOURCE 653 | #include 654 | #include 655 | 656 | int main () 657 | { 658 | #if defined(_SC_KERNEL_BITS) 659 | long bits = sysconf(_SC_KERNEL_BITS); 660 | #endif 661 | long cpu = sysconf (_SC_CPU_VERSION); 662 | 663 | switch (cpu) 664 | { 665 | case CPU_PA_RISC1_0: puts ("hppa1.0"); break; 666 | case CPU_PA_RISC1_1: puts ("hppa1.1"); break; 667 | case CPU_PA_RISC2_0: 668 | #if defined(_SC_KERNEL_BITS) 669 | switch (bits) 670 | { 671 | case 64: puts ("hppa2.0w"); break; 672 | case 32: puts ("hppa2.0n"); break; 673 | default: puts ("hppa2.0"); break; 674 | } break; 675 | #else /* !defined(_SC_KERNEL_BITS) */ 676 | puts ("hppa2.0"); break; 677 | #endif 678 | default: puts ("hppa1.0"); break; 679 | } 680 | exit (0); 681 | } 682 | EOF 683 | (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` 684 | test -z "$HP_ARCH" && HP_ARCH=hppa 685 | fi ;; 686 | esac 687 | if [ ${HP_ARCH} = "hppa2.0w" ] 688 | then 689 | eval $set_cc_for_build 690 | 691 | # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating 692 | # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler 693 | # generating 64-bit code. GNU and HP use different nomenclature: 694 | # 695 | # $ CC_FOR_BUILD=cc ./config.guess 696 | # => hppa2.0w-hp-hpux11.23 697 | # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess 698 | # => hppa64-hp-hpux11.23 699 | 700 | if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | 701 | grep -q __LP64__ 702 | then 703 | HP_ARCH="hppa2.0w" 704 | else 705 | HP_ARCH="hppa64" 706 | fi 707 | fi 708 | echo ${HP_ARCH}-hp-hpux${HPUX_REV} 709 | exit ;; 710 | ia64:HP-UX:*:*) 711 | HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` 712 | echo ia64-hp-hpux${HPUX_REV} 713 | exit ;; 714 | 3050*:HI-UX:*:*) 715 | eval $set_cc_for_build 716 | sed 's/^ //' << EOF >$dummy.c 717 | #include 718 | int 719 | main () 720 | { 721 | long cpu = sysconf (_SC_CPU_VERSION); 722 | /* The order matters, because CPU_IS_HP_MC68K erroneously returns 723 | true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct 724 | results, however. */ 725 | if (CPU_IS_PA_RISC (cpu)) 726 | { 727 | switch (cpu) 728 | { 729 | case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; 730 | case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; 731 | case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; 732 | default: puts ("hppa-hitachi-hiuxwe2"); break; 733 | } 734 | } 735 | else if (CPU_IS_HP_MC68K (cpu)) 736 | puts ("m68k-hitachi-hiuxwe2"); 737 | else puts ("unknown-hitachi-hiuxwe2"); 738 | exit (0); 739 | } 740 | EOF 741 | $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && 742 | { echo "$SYSTEM_NAME"; exit; } 743 | echo unknown-hitachi-hiuxwe2 744 | exit ;; 745 | 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) 746 | echo hppa1.1-hp-bsd 747 | exit ;; 748 | 9000/8??:4.3bsd:*:*) 749 | echo hppa1.0-hp-bsd 750 | exit ;; 751 | *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) 752 | echo hppa1.0-hp-mpeix 753 | exit ;; 754 | hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) 755 | echo hppa1.1-hp-osf 756 | exit ;; 757 | hp8??:OSF1:*:*) 758 | echo hppa1.0-hp-osf 759 | exit ;; 760 | i*86:OSF1:*:*) 761 | if [ -x /usr/sbin/sysversion ] ; then 762 | echo ${UNAME_MACHINE}-unknown-osf1mk 763 | else 764 | echo ${UNAME_MACHINE}-unknown-osf1 765 | fi 766 | exit ;; 767 | parisc*:Lites*:*:*) 768 | echo hppa1.1-hp-lites 769 | exit ;; 770 | C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) 771 | echo c1-convex-bsd 772 | exit ;; 773 | C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) 774 | if getsysinfo -f scalar_acc 775 | then echo c32-convex-bsd 776 | else echo c2-convex-bsd 777 | fi 778 | exit ;; 779 | C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) 780 | echo c34-convex-bsd 781 | exit ;; 782 | C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) 783 | echo c38-convex-bsd 784 | exit ;; 785 | C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) 786 | echo c4-convex-bsd 787 | exit ;; 788 | CRAY*Y-MP:*:*:*) 789 | echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 790 | exit ;; 791 | CRAY*[A-Z]90:*:*:*) 792 | echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ 793 | | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ 794 | -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ 795 | -e 's/\.[^.]*$/.X/' 796 | exit ;; 797 | CRAY*TS:*:*:*) 798 | echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 799 | exit ;; 800 | CRAY*T3E:*:*:*) 801 | echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 802 | exit ;; 803 | CRAY*SV1:*:*:*) 804 | echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 805 | exit ;; 806 | *:UNICOS/mp:*:*) 807 | echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 808 | exit ;; 809 | F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) 810 | FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 811 | FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 812 | FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` 813 | echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" 814 | exit ;; 815 | 5000:UNIX_System_V:4.*:*) 816 | FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 817 | FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` 818 | echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" 819 | exit ;; 820 | i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) 821 | echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} 822 | exit ;; 823 | sparc*:BSD/OS:*:*) 824 | echo sparc-unknown-bsdi${UNAME_RELEASE} 825 | exit ;; 826 | *:BSD/OS:*:*) 827 | echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} 828 | exit ;; 829 | *:FreeBSD:*:*) 830 | UNAME_PROCESSOR=`/usr/bin/uname -p` 831 | case ${UNAME_PROCESSOR} in 832 | amd64) 833 | echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 834 | *) 835 | echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 836 | esac 837 | exit ;; 838 | i*:CYGWIN*:*) 839 | echo ${UNAME_MACHINE}-pc-cygwin 840 | exit ;; 841 | *:MINGW64*:*) 842 | echo ${UNAME_MACHINE}-pc-mingw64 843 | exit ;; 844 | *:MINGW*:*) 845 | echo ${UNAME_MACHINE}-pc-mingw32 846 | exit ;; 847 | *:MSYS*:*) 848 | echo ${UNAME_MACHINE}-pc-msys 849 | exit ;; 850 | i*:windows32*:*) 851 | # uname -m includes "-pc" on this system. 852 | echo ${UNAME_MACHINE}-mingw32 853 | exit ;; 854 | i*:PW*:*) 855 | echo ${UNAME_MACHINE}-pc-pw32 856 | exit ;; 857 | *:Interix*:*) 858 | case ${UNAME_MACHINE} in 859 | x86) 860 | echo i586-pc-interix${UNAME_RELEASE} 861 | exit ;; 862 | authenticamd | genuineintel | EM64T) 863 | echo x86_64-unknown-interix${UNAME_RELEASE} 864 | exit ;; 865 | IA64) 866 | echo ia64-unknown-interix${UNAME_RELEASE} 867 | exit ;; 868 | esac ;; 869 | [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) 870 | echo i${UNAME_MACHINE}-pc-mks 871 | exit ;; 872 | 8664:Windows_NT:*) 873 | echo x86_64-pc-mks 874 | exit ;; 875 | i*:Windows_NT*:* | Pentium*:Windows_NT*:*) 876 | # How do we know it's Interix rather than the generic POSIX subsystem? 877 | # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we 878 | # UNAME_MACHINE based on the output of uname instead of i386? 879 | echo i586-pc-interix 880 | exit ;; 881 | i*:UWIN*:*) 882 | echo ${UNAME_MACHINE}-pc-uwin 883 | exit ;; 884 | amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) 885 | echo x86_64-unknown-cygwin 886 | exit ;; 887 | p*:CYGWIN*:*) 888 | echo powerpcle-unknown-cygwin 889 | exit ;; 890 | prep*:SunOS:5.*:*) 891 | echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 892 | exit ;; 893 | *:GNU:*:*) 894 | # the GNU system 895 | echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` 896 | exit ;; 897 | *:GNU/*:*:*) 898 | # other systems with GNU libc and userland 899 | echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} 900 | exit ;; 901 | i*86:Minix:*:*) 902 | echo ${UNAME_MACHINE}-pc-minix 903 | exit ;; 904 | aarch64:Linux:*:*) 905 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 906 | exit ;; 907 | aarch64_be:Linux:*:*) 908 | UNAME_MACHINE=aarch64_be 909 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 910 | exit ;; 911 | alpha:Linux:*:*) 912 | case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in 913 | EV5) UNAME_MACHINE=alphaev5 ;; 914 | EV56) UNAME_MACHINE=alphaev56 ;; 915 | PCA56) UNAME_MACHINE=alphapca56 ;; 916 | PCA57) UNAME_MACHINE=alphapca56 ;; 917 | EV6) UNAME_MACHINE=alphaev6 ;; 918 | EV67) UNAME_MACHINE=alphaev67 ;; 919 | EV68*) UNAME_MACHINE=alphaev68 ;; 920 | esac 921 | objdump --private-headers /bin/sh | grep -q ld.so.1 922 | if test "$?" = 0 ; then LIBC="gnulibc1" ; fi 923 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 924 | exit ;; 925 | arc:Linux:*:* | arceb:Linux:*:*) 926 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 927 | exit ;; 928 | arm*:Linux:*:*) 929 | eval $set_cc_for_build 930 | if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ 931 | | grep -q __ARM_EABI__ 932 | then 933 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 934 | else 935 | if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ 936 | | grep -q __ARM_PCS_VFP 937 | then 938 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi 939 | else 940 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf 941 | fi 942 | fi 943 | exit ;; 944 | avr32*:Linux:*:*) 945 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 946 | exit ;; 947 | cris:Linux:*:*) 948 | echo ${UNAME_MACHINE}-axis-linux-${LIBC} 949 | exit ;; 950 | crisv32:Linux:*:*) 951 | echo ${UNAME_MACHINE}-axis-linux-${LIBC} 952 | exit ;; 953 | e2k:Linux:*:*) 954 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 955 | exit ;; 956 | frv:Linux:*:*) 957 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 958 | exit ;; 959 | hexagon:Linux:*:*) 960 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 961 | exit ;; 962 | i*86:Linux:*:*) 963 | echo ${UNAME_MACHINE}-pc-linux-${LIBC} 964 | exit ;; 965 | ia64:Linux:*:*) 966 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 967 | exit ;; 968 | k1om:Linux:*:*) 969 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 970 | exit ;; 971 | m32r*:Linux:*:*) 972 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 973 | exit ;; 974 | m68*:Linux:*:*) 975 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 976 | exit ;; 977 | mips:Linux:*:* | mips64:Linux:*:*) 978 | eval $set_cc_for_build 979 | sed 's/^ //' << EOF >$dummy.c 980 | #undef CPU 981 | #undef ${UNAME_MACHINE} 982 | #undef ${UNAME_MACHINE}el 983 | #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) 984 | CPU=${UNAME_MACHINE}el 985 | #else 986 | #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) 987 | CPU=${UNAME_MACHINE} 988 | #else 989 | CPU= 990 | #endif 991 | #endif 992 | EOF 993 | eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` 994 | test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } 995 | ;; 996 | openrisc*:Linux:*:*) 997 | echo or1k-unknown-linux-${LIBC} 998 | exit ;; 999 | or32:Linux:*:* | or1k*:Linux:*:*) 1000 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 1001 | exit ;; 1002 | padre:Linux:*:*) 1003 | echo sparc-unknown-linux-${LIBC} 1004 | exit ;; 1005 | parisc64:Linux:*:* | hppa64:Linux:*:*) 1006 | echo hppa64-unknown-linux-${LIBC} 1007 | exit ;; 1008 | parisc:Linux:*:* | hppa:Linux:*:*) 1009 | # Look for CPU level 1010 | case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in 1011 | PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; 1012 | PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; 1013 | *) echo hppa-unknown-linux-${LIBC} ;; 1014 | esac 1015 | exit ;; 1016 | ppc64:Linux:*:*) 1017 | echo powerpc64-unknown-linux-${LIBC} 1018 | exit ;; 1019 | ppc:Linux:*:*) 1020 | echo powerpc-unknown-linux-${LIBC} 1021 | exit ;; 1022 | ppc64le:Linux:*:*) 1023 | echo powerpc64le-unknown-linux-${LIBC} 1024 | exit ;; 1025 | ppcle:Linux:*:*) 1026 | echo powerpcle-unknown-linux-${LIBC} 1027 | exit ;; 1028 | s390:Linux:*:* | s390x:Linux:*:*) 1029 | echo ${UNAME_MACHINE}-ibm-linux-${LIBC} 1030 | exit ;; 1031 | sh64*:Linux:*:*) 1032 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 1033 | exit ;; 1034 | sh*:Linux:*:*) 1035 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 1036 | exit ;; 1037 | sparc:Linux:*:* | sparc64:Linux:*:*) 1038 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 1039 | exit ;; 1040 | tile*:Linux:*:*) 1041 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 1042 | exit ;; 1043 | vax:Linux:*:*) 1044 | echo ${UNAME_MACHINE}-dec-linux-${LIBC} 1045 | exit ;; 1046 | x86_64:Linux:*:*) 1047 | echo ${UNAME_MACHINE}-pc-linux-${LIBC} 1048 | exit ;; 1049 | xtensa*:Linux:*:*) 1050 | echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 1051 | exit ;; 1052 | i*86:DYNIX/ptx:4*:*) 1053 | # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. 1054 | # earlier versions are messed up and put the nodename in both 1055 | # sysname and nodename. 1056 | echo i386-sequent-sysv4 1057 | exit ;; 1058 | i*86:UNIX_SV:4.2MP:2.*) 1059 | # Unixware is an offshoot of SVR4, but it has its own version 1060 | # number series starting with 2... 1061 | # I am not positive that other SVR4 systems won't match this, 1062 | # I just have to hope. -- rms. 1063 | # Use sysv4.2uw... so that sysv4* matches it. 1064 | echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} 1065 | exit ;; 1066 | i*86:OS/2:*:*) 1067 | # If we were able to find `uname', then EMX Unix compatibility 1068 | # is probably installed. 1069 | echo ${UNAME_MACHINE}-pc-os2-emx 1070 | exit ;; 1071 | i*86:XTS-300:*:STOP) 1072 | echo ${UNAME_MACHINE}-unknown-stop 1073 | exit ;; 1074 | i*86:atheos:*:*) 1075 | echo ${UNAME_MACHINE}-unknown-atheos 1076 | exit ;; 1077 | i*86:syllable:*:*) 1078 | echo ${UNAME_MACHINE}-pc-syllable 1079 | exit ;; 1080 | i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) 1081 | echo i386-unknown-lynxos${UNAME_RELEASE} 1082 | exit ;; 1083 | i*86:*DOS:*:*) 1084 | echo ${UNAME_MACHINE}-pc-msdosdjgpp 1085 | exit ;; 1086 | i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) 1087 | UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` 1088 | if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then 1089 | echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} 1090 | else 1091 | echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} 1092 | fi 1093 | exit ;; 1094 | i*86:*:5:[678]*) 1095 | # UnixWare 7.x, OpenUNIX and OpenServer 6. 1096 | case `/bin/uname -X | grep "^Machine"` in 1097 | *486*) UNAME_MACHINE=i486 ;; 1098 | *Pentium) UNAME_MACHINE=i586 ;; 1099 | *Pent*|*Celeron) UNAME_MACHINE=i686 ;; 1100 | esac 1101 | echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} 1102 | exit ;; 1103 | i*86:*:3.2:*) 1104 | if test -f /usr/options/cb.name; then 1105 | UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then 1108 | UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` 1109 | (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 1110 | (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ 1111 | && UNAME_MACHINE=i586 1112 | (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ 1113 | && UNAME_MACHINE=i686 1114 | (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ 1115 | && UNAME_MACHINE=i686 1116 | echo ${UNAME_MACHINE}-pc-sco$UNAME_REL 1117 | else 1118 | echo ${UNAME_MACHINE}-pc-sysv32 1119 | fi 1120 | exit ;; 1121 | pc:*:*:*) 1122 | # Left here for compatibility: 1123 | # uname -m prints for DJGPP always 'pc', but it prints nothing about 1124 | # the processor, so we play safe by assuming i586. 1125 | # Note: whatever this is, it MUST be the same as what config.sub 1126 | # prints for the "djgpp" host, or else GDB configure will decide that 1127 | # this is a cross-build. 1128 | echo i586-pc-msdosdjgpp 1129 | exit ;; 1130 | Intel:Mach:3*:*) 1131 | echo i386-pc-mach3 1132 | exit ;; 1133 | paragon:*:*:*) 1134 | echo i860-intel-osf1 1135 | exit ;; 1136 | i860:*:4.*:*) # i860-SVR4 1137 | if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then 1138 | echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 1139 | else # Add other i860-SVR4 vendors below as they are discovered. 1140 | echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 1141 | fi 1142 | exit ;; 1143 | mini*:CTIX:SYS*5:*) 1144 | # "miniframe" 1145 | echo m68010-convergent-sysv 1146 | exit ;; 1147 | mc68k:UNIX:SYSTEM5:3.51m) 1148 | echo m68k-convergent-sysv 1149 | exit ;; 1150 | M680?0:D-NIX:5.3:*) 1151 | echo m68k-diab-dnix 1152 | exit ;; 1153 | M68*:*:R3V[5678]*:*) 1154 | test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 1155 | 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) 1156 | OS_REL='' 1157 | test -r /etc/.relid \ 1158 | && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` 1159 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1160 | && { echo i486-ncr-sysv4.3${OS_REL}; exit; } 1161 | /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ 1162 | && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 1163 | 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) 1164 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1165 | && { echo i486-ncr-sysv4; exit; } ;; 1166 | NCR*:*:4.2:* | MPRAS*:*:4.2:*) 1167 | OS_REL='.3' 1168 | test -r /etc/.relid \ 1169 | && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` 1170 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1171 | && { echo i486-ncr-sysv4.3${OS_REL}; exit; } 1172 | /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ 1173 | && { echo i586-ncr-sysv4.3${OS_REL}; exit; } 1174 | /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ 1175 | && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 1176 | m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) 1177 | echo m68k-unknown-lynxos${UNAME_RELEASE} 1178 | exit ;; 1179 | mc68030:UNIX_System_V:4.*:*) 1180 | echo m68k-atari-sysv4 1181 | exit ;; 1182 | TSUNAMI:LynxOS:2.*:*) 1183 | echo sparc-unknown-lynxos${UNAME_RELEASE} 1184 | exit ;; 1185 | rs6000:LynxOS:2.*:*) 1186 | echo rs6000-unknown-lynxos${UNAME_RELEASE} 1187 | exit ;; 1188 | PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) 1189 | echo powerpc-unknown-lynxos${UNAME_RELEASE} 1190 | exit ;; 1191 | SM[BE]S:UNIX_SV:*:*) 1192 | echo mips-dde-sysv${UNAME_RELEASE} 1193 | exit ;; 1194 | RM*:ReliantUNIX-*:*:*) 1195 | echo mips-sni-sysv4 1196 | exit ;; 1197 | RM*:SINIX-*:*:*) 1198 | echo mips-sni-sysv4 1199 | exit ;; 1200 | *:SINIX-*:*:*) 1201 | if uname -p 2>/dev/null >/dev/null ; then 1202 | UNAME_MACHINE=`(uname -p) 2>/dev/null` 1203 | echo ${UNAME_MACHINE}-sni-sysv4 1204 | else 1205 | echo ns32k-sni-sysv 1206 | fi 1207 | exit ;; 1208 | PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort 1209 | # says 1210 | echo i586-unisys-sysv4 1211 | exit ;; 1212 | *:UNIX_System_V:4*:FTX*) 1213 | # From Gerald Hewes . 1214 | # How about differentiating between stratus architectures? -djm 1215 | echo hppa1.1-stratus-sysv4 1216 | exit ;; 1217 | *:*:*:FTX*) 1218 | # From seanf@swdc.stratus.com. 1219 | echo i860-stratus-sysv4 1220 | exit ;; 1221 | i*86:VOS:*:*) 1222 | # From Paul.Green@stratus.com. 1223 | echo ${UNAME_MACHINE}-stratus-vos 1224 | exit ;; 1225 | *:VOS:*:*) 1226 | # From Paul.Green@stratus.com. 1227 | echo hppa1.1-stratus-vos 1228 | exit ;; 1229 | mc68*:A/UX:*:*) 1230 | echo m68k-apple-aux${UNAME_RELEASE} 1231 | exit ;; 1232 | news*:NEWS-OS:6*:*) 1233 | echo mips-sony-newsos6 1234 | exit ;; 1235 | R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) 1236 | if [ -d /usr/nec ]; then 1237 | echo mips-nec-sysv${UNAME_RELEASE} 1238 | else 1239 | echo mips-unknown-sysv${UNAME_RELEASE} 1240 | fi 1241 | exit ;; 1242 | BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. 1243 | echo powerpc-be-beos 1244 | exit ;; 1245 | BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. 1246 | echo powerpc-apple-beos 1247 | exit ;; 1248 | BePC:BeOS:*:*) # BeOS running on Intel PC compatible. 1249 | echo i586-pc-beos 1250 | exit ;; 1251 | BePC:Haiku:*:*) # Haiku running on Intel PC compatible. 1252 | echo i586-pc-haiku 1253 | exit ;; 1254 | x86_64:Haiku:*:*) 1255 | echo x86_64-unknown-haiku 1256 | exit ;; 1257 | SX-4:SUPER-UX:*:*) 1258 | echo sx4-nec-superux${UNAME_RELEASE} 1259 | exit ;; 1260 | SX-5:SUPER-UX:*:*) 1261 | echo sx5-nec-superux${UNAME_RELEASE} 1262 | exit ;; 1263 | SX-6:SUPER-UX:*:*) 1264 | echo sx6-nec-superux${UNAME_RELEASE} 1265 | exit ;; 1266 | SX-7:SUPER-UX:*:*) 1267 | echo sx7-nec-superux${UNAME_RELEASE} 1268 | exit ;; 1269 | SX-8:SUPER-UX:*:*) 1270 | echo sx8-nec-superux${UNAME_RELEASE} 1271 | exit ;; 1272 | SX-8R:SUPER-UX:*:*) 1273 | echo sx8r-nec-superux${UNAME_RELEASE} 1274 | exit ;; 1275 | Power*:Rhapsody:*:*) 1276 | echo powerpc-apple-rhapsody${UNAME_RELEASE} 1277 | exit ;; 1278 | *:Rhapsody:*:*) 1279 | echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} 1280 | exit ;; 1281 | *:Darwin:*:*) 1282 | UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown 1283 | eval $set_cc_for_build 1284 | if test "$UNAME_PROCESSOR" = unknown ; then 1285 | UNAME_PROCESSOR=powerpc 1286 | fi 1287 | if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then 1288 | if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then 1289 | if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ 1290 | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ 1291 | grep IS_64BIT_ARCH >/dev/null 1292 | then 1293 | case $UNAME_PROCESSOR in 1294 | i386) UNAME_PROCESSOR=x86_64 ;; 1295 | powerpc) UNAME_PROCESSOR=powerpc64 ;; 1296 | esac 1297 | fi 1298 | fi 1299 | elif test "$UNAME_PROCESSOR" = i386 ; then 1300 | # Avoid executing cc on OS X 10.9, as it ships with a stub 1301 | # that puts up a graphical alert prompting to install 1302 | # developer tools. Any system running Mac OS X 10.7 or 1303 | # later (Darwin 11 and later) is required to have a 64-bit 1304 | # processor. This is not true of the ARM version of Darwin 1305 | # that Apple uses in portable devices. 1306 | UNAME_PROCESSOR=x86_64 1307 | fi 1308 | echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} 1309 | exit ;; 1310 | *:procnto*:*:* | *:QNX:[0123456789]*:*) 1311 | UNAME_PROCESSOR=`uname -p` 1312 | if test "$UNAME_PROCESSOR" = "x86"; then 1313 | UNAME_PROCESSOR=i386 1314 | UNAME_MACHINE=pc 1315 | fi 1316 | echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} 1317 | exit ;; 1318 | *:QNX:*:4*) 1319 | echo i386-pc-qnx 1320 | exit ;; 1321 | NEO-?:NONSTOP_KERNEL:*:*) 1322 | echo neo-tandem-nsk${UNAME_RELEASE} 1323 | exit ;; 1324 | NSE-*:NONSTOP_KERNEL:*:*) 1325 | echo nse-tandem-nsk${UNAME_RELEASE} 1326 | exit ;; 1327 | NSR-?:NONSTOP_KERNEL:*:*) 1328 | echo nsr-tandem-nsk${UNAME_RELEASE} 1329 | exit ;; 1330 | *:NonStop-UX:*:*) 1331 | echo mips-compaq-nonstopux 1332 | exit ;; 1333 | BS2000:POSIX*:*:*) 1334 | echo bs2000-siemens-sysv 1335 | exit ;; 1336 | DS/*:UNIX_System_V:*:*) 1337 | echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} 1338 | exit ;; 1339 | *:Plan9:*:*) 1340 | # "uname -m" is not consistent, so use $cputype instead. 386 1341 | # is converted to i386 for consistency with other x86 1342 | # operating systems. 1343 | if test "$cputype" = "386"; then 1344 | UNAME_MACHINE=i386 1345 | else 1346 | UNAME_MACHINE="$cputype" 1347 | fi 1348 | echo ${UNAME_MACHINE}-unknown-plan9 1349 | exit ;; 1350 | *:TOPS-10:*:*) 1351 | echo pdp10-unknown-tops10 1352 | exit ;; 1353 | *:TENEX:*:*) 1354 | echo pdp10-unknown-tenex 1355 | exit ;; 1356 | KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) 1357 | echo pdp10-dec-tops20 1358 | exit ;; 1359 | XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) 1360 | echo pdp10-xkl-tops20 1361 | exit ;; 1362 | *:TOPS-20:*:*) 1363 | echo pdp10-unknown-tops20 1364 | exit ;; 1365 | *:ITS:*:*) 1366 | echo pdp10-unknown-its 1367 | exit ;; 1368 | SEI:*:*:SEIUX) 1369 | echo mips-sei-seiux${UNAME_RELEASE} 1370 | exit ;; 1371 | *:DragonFly:*:*) 1372 | echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` 1373 | exit ;; 1374 | *:*VMS:*:*) 1375 | UNAME_MACHINE=`(uname -p) 2>/dev/null` 1376 | case "${UNAME_MACHINE}" in 1377 | A*) echo alpha-dec-vms ; exit ;; 1378 | I*) echo ia64-dec-vms ; exit ;; 1379 | V*) echo vax-dec-vms ; exit ;; 1380 | esac ;; 1381 | *:XENIX:*:SysV) 1382 | echo i386-pc-xenix 1383 | exit ;; 1384 | i*86:skyos:*:*) 1385 | echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' 1386 | exit ;; 1387 | i*86:rdos:*:*) 1388 | echo ${UNAME_MACHINE}-pc-rdos 1389 | exit ;; 1390 | i*86:AROS:*:*) 1391 | echo ${UNAME_MACHINE}-pc-aros 1392 | exit ;; 1393 | x86_64:VMkernel:*:*) 1394 | echo ${UNAME_MACHINE}-unknown-esx 1395 | exit ;; 1396 | amd64:Isilon\ OneFS:*:*) 1397 | echo x86_64-unknown-onefs 1398 | exit ;; 1399 | esac 1400 | 1401 | cat >&2 < in order to provide the needed 1415 | information to handle your system. 1416 | 1417 | config.guess timestamp = $timestamp 1418 | 1419 | uname -m = `(uname -m) 2>/dev/null || echo unknown` 1420 | uname -r = `(uname -r) 2>/dev/null || echo unknown` 1421 | uname -s = `(uname -s) 2>/dev/null || echo unknown` 1422 | uname -v = `(uname -v) 2>/dev/null || echo unknown` 1423 | 1424 | /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` 1425 | /bin/uname -X = `(/bin/uname -X) 2>/dev/null` 1426 | 1427 | hostinfo = `(hostinfo) 2>/dev/null` 1428 | /bin/universe = `(/bin/universe) 2>/dev/null` 1429 | /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` 1430 | /bin/arch = `(/bin/arch) 2>/dev/null` 1431 | /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` 1432 | /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` 1433 | 1434 | UNAME_MACHINE = ${UNAME_MACHINE} 1435 | UNAME_RELEASE = ${UNAME_RELEASE} 1436 | UNAME_SYSTEM = ${UNAME_SYSTEM} 1437 | UNAME_VERSION = ${UNAME_VERSION} 1438 | EOF 1439 | 1440 | exit 1 1441 | 1442 | # Local variables: 1443 | # eval: (add-hook 'write-file-hooks 'time-stamp) 1444 | # time-stamp-start: "timestamp='" 1445 | # time-stamp-format: "%:y-%02m-%02d" 1446 | # time-stamp-end: "'" 1447 | # End: 1448 | -------------------------------------------------------------------------------- /config.sub: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Configuration validation subroutine script. 3 | # Copyright 1992-2015 Free Software Foundation, Inc. 4 | 5 | timestamp='2015-12-14' 6 | 7 | # This file is free software; you can redistribute it and/or modify it 8 | # under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, but 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, see . 19 | # 20 | # As a special exception to the GNU General Public License, if you 21 | # distribute this file as part of a program that contains a 22 | # configuration script generated by Autoconf, you may include it under 23 | # the same distribution terms that you use for the rest of that 24 | # program. This Exception is an additional permission under section 7 25 | # of the GNU General Public License, version 3 ("GPLv3"). 26 | 27 | 28 | # Please send patches to . 29 | # 30 | # Configuration subroutine to validate and canonicalize a configuration type. 31 | # Supply the specified configuration type as an argument. 32 | # If it is invalid, we print an error message on stderr and exit with code 1. 33 | # Otherwise, we print the canonical config type on stdout and succeed. 34 | 35 | # You can get the latest version of this script from: 36 | # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD 37 | 38 | # This file is supposed to be the same for all GNU packages 39 | # and recognize all the CPU types, system types and aliases 40 | # that are meaningful with *any* GNU software. 41 | # Each package is responsible for reporting which valid configurations 42 | # it does not support. The user should be able to distinguish 43 | # a failure to support a valid configuration from a meaningless 44 | # configuration. 45 | 46 | # The goal of this file is to map all the various variations of a given 47 | # machine specification into a single specification in the form: 48 | # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM 49 | # or in some cases, the newer four-part form: 50 | # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM 51 | # It is wrong to echo any other type of specification. 52 | 53 | me=`echo "$0" | sed -e 's,.*/,,'` 54 | 55 | usage="\ 56 | Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS 57 | 58 | Canonicalize a configuration name. 59 | 60 | Operation modes: 61 | -h, --help print this help, then exit 62 | -t, --time-stamp print date of last modification, then exit 63 | -v, --version print version number, then exit 64 | 65 | Report bugs and patches to ." 66 | 67 | version="\ 68 | GNU config.sub ($timestamp) 69 | 70 | Copyright 1992-2015 Free Software Foundation, Inc. 71 | 72 | This is free software; see the source for copying conditions. There is NO 73 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 74 | 75 | help=" 76 | Try \`$me --help' for more information." 77 | 78 | # Parse command line 79 | while test $# -gt 0 ; do 80 | case $1 in 81 | --time-stamp | --time* | -t ) 82 | echo "$timestamp" ; exit ;; 83 | --version | -v ) 84 | echo "$version" ; exit ;; 85 | --help | --h* | -h ) 86 | echo "$usage"; exit ;; 87 | -- ) # Stop option processing 88 | shift; break ;; 89 | - ) # Use stdin as input. 90 | break ;; 91 | -* ) 92 | echo "$me: invalid option $1$help" 93 | exit 1 ;; 94 | 95 | *local*) 96 | # First pass through any local machine types. 97 | echo $1 98 | exit ;; 99 | 100 | * ) 101 | break ;; 102 | esac 103 | done 104 | 105 | case $# in 106 | 0) echo "$me: missing argument$help" >&2 107 | exit 1;; 108 | 1) ;; 109 | *) echo "$me: too many arguments$help" >&2 110 | exit 1;; 111 | esac 112 | 113 | # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). 114 | # Here we must recognize all the valid KERNEL-OS combinations. 115 | maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` 116 | case $maybe_os in 117 | nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ 118 | linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ 119 | knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ 120 | kopensolaris*-gnu* | \ 121 | storm-chaos* | os2-emx* | rtmk-nova*) 122 | os=-$maybe_os 123 | basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` 124 | ;; 125 | android-linux) 126 | os=-linux-android 127 | basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown 128 | ;; 129 | *) 130 | basic_machine=`echo $1 | sed 's/-[^-]*$//'` 131 | if [ $basic_machine != $1 ] 132 | then os=`echo $1 | sed 's/.*-/-/'` 133 | else os=; fi 134 | ;; 135 | esac 136 | 137 | ### Let's recognize common machines as not being operating systems so 138 | ### that things like config.sub decstation-3100 work. We also 139 | ### recognize some manufacturers as not being operating systems, so we 140 | ### can provide default operating systems below. 141 | case $os in 142 | -sun*os*) 143 | # Prevent following clause from handling this invalid input. 144 | ;; 145 | -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ 146 | -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ 147 | -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ 148 | -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ 149 | -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ 150 | -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ 151 | -apple | -axis | -knuth | -cray | -microblaze*) 152 | os= 153 | basic_machine=$1 154 | ;; 155 | -bluegene*) 156 | os=-cnk 157 | ;; 158 | -sim | -cisco | -oki | -wec | -winbond) 159 | os= 160 | basic_machine=$1 161 | ;; 162 | -scout) 163 | ;; 164 | -wrs) 165 | os=-vxworks 166 | basic_machine=$1 167 | ;; 168 | -chorusos*) 169 | os=-chorusos 170 | basic_machine=$1 171 | ;; 172 | -chorusrdb) 173 | os=-chorusrdb 174 | basic_machine=$1 175 | ;; 176 | -hiux*) 177 | os=-hiuxwe2 178 | ;; 179 | -sco6) 180 | os=-sco5v6 181 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 182 | ;; 183 | -sco5) 184 | os=-sco3.2v5 185 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 186 | ;; 187 | -sco4) 188 | os=-sco3.2v4 189 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 190 | ;; 191 | -sco3.2.[4-9]*) 192 | os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` 193 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 194 | ;; 195 | -sco3.2v[4-9]*) 196 | # Don't forget version if it is 3.2v4 or newer. 197 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 198 | ;; 199 | -sco5v6*) 200 | # Don't forget version if it is 3.2v4 or newer. 201 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 202 | ;; 203 | -sco*) 204 | os=-sco3.2v2 205 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 206 | ;; 207 | -udk*) 208 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 209 | ;; 210 | -isc) 211 | os=-isc2.2 212 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 213 | ;; 214 | -clix*) 215 | basic_machine=clipper-intergraph 216 | ;; 217 | -isc*) 218 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 219 | ;; 220 | -lynx*178) 221 | os=-lynxos178 222 | ;; 223 | -lynx*5) 224 | os=-lynxos5 225 | ;; 226 | -lynx*) 227 | os=-lynxos 228 | ;; 229 | -ptx*) 230 | basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` 231 | ;; 232 | -windowsnt*) 233 | os=`echo $os | sed -e 's/windowsnt/winnt/'` 234 | ;; 235 | -psos*) 236 | os=-psos 237 | ;; 238 | -mint | -mint[0-9]*) 239 | basic_machine=m68k-atari 240 | os=-mint 241 | ;; 242 | esac 243 | 244 | # Decode aliases for certain CPU-COMPANY combinations. 245 | case $basic_machine in 246 | # Recognize the basic CPU types without company name. 247 | # Some are omitted here because they have special meanings below. 248 | 1750a | 580 \ 249 | | a29k \ 250 | | aarch64 | aarch64_be \ 251 | | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ 252 | | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ 253 | | am33_2.0 \ 254 | | arc | arceb \ 255 | | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ 256 | | avr | avr32 \ 257 | | ba \ 258 | | be32 | be64 \ 259 | | bfin \ 260 | | c4x | c8051 | clipper \ 261 | | d10v | d30v | dlx | dsp16xx \ 262 | | e2k | epiphany \ 263 | | fido | fr30 | frv | ft32 \ 264 | | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ 265 | | hexagon \ 266 | | i370 | i860 | i960 | ia64 \ 267 | | ip2k | iq2000 \ 268 | | k1om \ 269 | | le32 | le64 \ 270 | | lm32 \ 271 | | m32c | m32r | m32rle | m68000 | m68k | m88k \ 272 | | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ 273 | | mips | mipsbe | mipseb | mipsel | mipsle \ 274 | | mips16 \ 275 | | mips64 | mips64el \ 276 | | mips64octeon | mips64octeonel \ 277 | | mips64orion | mips64orionel \ 278 | | mips64r5900 | mips64r5900el \ 279 | | mips64vr | mips64vrel \ 280 | | mips64vr4100 | mips64vr4100el \ 281 | | mips64vr4300 | mips64vr4300el \ 282 | | mips64vr5000 | mips64vr5000el \ 283 | | mips64vr5900 | mips64vr5900el \ 284 | | mipsisa32 | mipsisa32el \ 285 | | mipsisa32r2 | mipsisa32r2el \ 286 | | mipsisa32r6 | mipsisa32r6el \ 287 | | mipsisa64 | mipsisa64el \ 288 | | mipsisa64r2 | mipsisa64r2el \ 289 | | mipsisa64r6 | mipsisa64r6el \ 290 | | mipsisa64sb1 | mipsisa64sb1el \ 291 | | mipsisa64sr71k | mipsisa64sr71kel \ 292 | | mipsr5900 | mipsr5900el \ 293 | | mipstx39 | mipstx39el \ 294 | | mn10200 | mn10300 \ 295 | | moxie \ 296 | | mt \ 297 | | msp430 \ 298 | | nds32 | nds32le | nds32be \ 299 | | nios | nios2 | nios2eb | nios2el \ 300 | | ns16k | ns32k \ 301 | | open8 | or1k | or1knd | or32 \ 302 | | pdp10 | pdp11 | pj | pjl \ 303 | | powerpc | powerpc64 | powerpc64le | powerpcle \ 304 | | pyramid \ 305 | | riscv32 | riscv64 \ 306 | | rl78 | rx \ 307 | | score \ 308 | | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ 309 | | sh64 | sh64le \ 310 | | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ 311 | | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ 312 | | spu \ 313 | | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ 314 | | ubicom32 \ 315 | | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ 316 | | visium \ 317 | | we32k \ 318 | | x86 | xc16x | xstormy16 | xtensa \ 319 | | z8k | z80) 320 | basic_machine=$basic_machine-unknown 321 | ;; 322 | c54x) 323 | basic_machine=tic54x-unknown 324 | ;; 325 | c55x) 326 | basic_machine=tic55x-unknown 327 | ;; 328 | c6x) 329 | basic_machine=tic6x-unknown 330 | ;; 331 | leon|leon[3-9]) 332 | basic_machine=sparc-$basic_machine 333 | ;; 334 | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) 335 | basic_machine=$basic_machine-unknown 336 | os=-none 337 | ;; 338 | m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) 339 | ;; 340 | ms1) 341 | basic_machine=mt-unknown 342 | ;; 343 | 344 | strongarm | thumb | xscale) 345 | basic_machine=arm-unknown 346 | ;; 347 | xgate) 348 | basic_machine=$basic_machine-unknown 349 | os=-none 350 | ;; 351 | xscaleeb) 352 | basic_machine=armeb-unknown 353 | ;; 354 | 355 | xscaleel) 356 | basic_machine=armel-unknown 357 | ;; 358 | 359 | # We use `pc' rather than `unknown' 360 | # because (1) that's what they normally are, and 361 | # (2) the word "unknown" tends to confuse beginning users. 362 | i*86 | x86_64) 363 | basic_machine=$basic_machine-pc 364 | ;; 365 | # Object if more than one company name word. 366 | *-*-*) 367 | echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 368 | exit 1 369 | ;; 370 | # Recognize the basic CPU types with company name. 371 | 580-* \ 372 | | a29k-* \ 373 | | aarch64-* | aarch64_be-* \ 374 | | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ 375 | | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ 376 | | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ 377 | | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ 378 | | avr-* | avr32-* \ 379 | | ba-* \ 380 | | be32-* | be64-* \ 381 | | bfin-* | bs2000-* \ 382 | | c[123]* | c30-* | [cjt]90-* | c4x-* \ 383 | | c8051-* | clipper-* | craynv-* | cydra-* \ 384 | | d10v-* | d30v-* | dlx-* \ 385 | | e2k-* | elxsi-* \ 386 | | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ 387 | | h8300-* | h8500-* \ 388 | | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ 389 | | hexagon-* \ 390 | | i*86-* | i860-* | i960-* | ia64-* \ 391 | | ip2k-* | iq2000-* \ 392 | | k1om-* \ 393 | | le32-* | le64-* \ 394 | | lm32-* \ 395 | | m32c-* | m32r-* | m32rle-* \ 396 | | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ 397 | | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ 398 | | microblaze-* | microblazeel-* \ 399 | | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ 400 | | mips16-* \ 401 | | mips64-* | mips64el-* \ 402 | | mips64octeon-* | mips64octeonel-* \ 403 | | mips64orion-* | mips64orionel-* \ 404 | | mips64r5900-* | mips64r5900el-* \ 405 | | mips64vr-* | mips64vrel-* \ 406 | | mips64vr4100-* | mips64vr4100el-* \ 407 | | mips64vr4300-* | mips64vr4300el-* \ 408 | | mips64vr5000-* | mips64vr5000el-* \ 409 | | mips64vr5900-* | mips64vr5900el-* \ 410 | | mipsisa32-* | mipsisa32el-* \ 411 | | mipsisa32r2-* | mipsisa32r2el-* \ 412 | | mipsisa32r6-* | mipsisa32r6el-* \ 413 | | mipsisa64-* | mipsisa64el-* \ 414 | | mipsisa64r2-* | mipsisa64r2el-* \ 415 | | mipsisa64r6-* | mipsisa64r6el-* \ 416 | | mipsisa64sb1-* | mipsisa64sb1el-* \ 417 | | mipsisa64sr71k-* | mipsisa64sr71kel-* \ 418 | | mipsr5900-* | mipsr5900el-* \ 419 | | mipstx39-* | mipstx39el-* \ 420 | | mmix-* \ 421 | | mt-* \ 422 | | msp430-* \ 423 | | nds32-* | nds32le-* | nds32be-* \ 424 | | nios-* | nios2-* | nios2eb-* | nios2el-* \ 425 | | none-* | np1-* | ns16k-* | ns32k-* \ 426 | | open8-* \ 427 | | or1k*-* \ 428 | | orion-* \ 429 | | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ 430 | | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ 431 | | pyramid-* \ 432 | | riscv32-* | riscv64-* \ 433 | | rl78-* | romp-* | rs6000-* | rx-* \ 434 | | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ 435 | | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ 436 | | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ 437 | | sparclite-* \ 438 | | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ 439 | | tahoe-* \ 440 | | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ 441 | | tile*-* \ 442 | | tron-* \ 443 | | ubicom32-* \ 444 | | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ 445 | | vax-* \ 446 | | visium-* \ 447 | | we32k-* \ 448 | | x86-* | x86_64-* | xc16x-* | xps100-* \ 449 | | xstormy16-* | xtensa*-* \ 450 | | ymp-* \ 451 | | z8k-* | z80-*) 452 | ;; 453 | # Recognize the basic CPU types without company name, with glob match. 454 | xtensa*) 455 | basic_machine=$basic_machine-unknown 456 | ;; 457 | # Recognize the various machine names and aliases which stand 458 | # for a CPU type and a company and sometimes even an OS. 459 | 386bsd) 460 | basic_machine=i386-unknown 461 | os=-bsd 462 | ;; 463 | 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) 464 | basic_machine=m68000-att 465 | ;; 466 | 3b*) 467 | basic_machine=we32k-att 468 | ;; 469 | a29khif) 470 | basic_machine=a29k-amd 471 | os=-udi 472 | ;; 473 | abacus) 474 | basic_machine=abacus-unknown 475 | ;; 476 | adobe68k) 477 | basic_machine=m68010-adobe 478 | os=-scout 479 | ;; 480 | alliant | fx80) 481 | basic_machine=fx80-alliant 482 | ;; 483 | altos | altos3068) 484 | basic_machine=m68k-altos 485 | ;; 486 | am29k) 487 | basic_machine=a29k-none 488 | os=-bsd 489 | ;; 490 | amd64) 491 | basic_machine=x86_64-pc 492 | ;; 493 | amd64-*) 494 | basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` 495 | ;; 496 | amdahl) 497 | basic_machine=580-amdahl 498 | os=-sysv 499 | ;; 500 | amiga | amiga-*) 501 | basic_machine=m68k-unknown 502 | ;; 503 | amigaos | amigados) 504 | basic_machine=m68k-unknown 505 | os=-amigaos 506 | ;; 507 | amigaunix | amix) 508 | basic_machine=m68k-unknown 509 | os=-sysv4 510 | ;; 511 | apollo68) 512 | basic_machine=m68k-apollo 513 | os=-sysv 514 | ;; 515 | apollo68bsd) 516 | basic_machine=m68k-apollo 517 | os=-bsd 518 | ;; 519 | aros) 520 | basic_machine=i386-pc 521 | os=-aros 522 | ;; 523 | asmjs) 524 | basic_machine=asmjs-unknown 525 | ;; 526 | aux) 527 | basic_machine=m68k-apple 528 | os=-aux 529 | ;; 530 | balance) 531 | basic_machine=ns32k-sequent 532 | os=-dynix 533 | ;; 534 | blackfin) 535 | basic_machine=bfin-unknown 536 | os=-linux 537 | ;; 538 | blackfin-*) 539 | basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` 540 | os=-linux 541 | ;; 542 | bluegene*) 543 | basic_machine=powerpc-ibm 544 | os=-cnk 545 | ;; 546 | c54x-*) 547 | basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` 548 | ;; 549 | c55x-*) 550 | basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` 551 | ;; 552 | c6x-*) 553 | basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` 554 | ;; 555 | c90) 556 | basic_machine=c90-cray 557 | os=-unicos 558 | ;; 559 | cegcc) 560 | basic_machine=arm-unknown 561 | os=-cegcc 562 | ;; 563 | convex-c1) 564 | basic_machine=c1-convex 565 | os=-bsd 566 | ;; 567 | convex-c2) 568 | basic_machine=c2-convex 569 | os=-bsd 570 | ;; 571 | convex-c32) 572 | basic_machine=c32-convex 573 | os=-bsd 574 | ;; 575 | convex-c34) 576 | basic_machine=c34-convex 577 | os=-bsd 578 | ;; 579 | convex-c38) 580 | basic_machine=c38-convex 581 | os=-bsd 582 | ;; 583 | cray | j90) 584 | basic_machine=j90-cray 585 | os=-unicos 586 | ;; 587 | craynv) 588 | basic_machine=craynv-cray 589 | os=-unicosmp 590 | ;; 591 | cr16 | cr16-*) 592 | basic_machine=cr16-unknown 593 | os=-elf 594 | ;; 595 | crds | unos) 596 | basic_machine=m68k-crds 597 | ;; 598 | crisv32 | crisv32-* | etraxfs*) 599 | basic_machine=crisv32-axis 600 | ;; 601 | cris | cris-* | etrax*) 602 | basic_machine=cris-axis 603 | ;; 604 | crx) 605 | basic_machine=crx-unknown 606 | os=-elf 607 | ;; 608 | da30 | da30-*) 609 | basic_machine=m68k-da30 610 | ;; 611 | decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) 612 | basic_machine=mips-dec 613 | ;; 614 | decsystem10* | dec10*) 615 | basic_machine=pdp10-dec 616 | os=-tops10 617 | ;; 618 | decsystem20* | dec20*) 619 | basic_machine=pdp10-dec 620 | os=-tops20 621 | ;; 622 | delta | 3300 | motorola-3300 | motorola-delta \ 623 | | 3300-motorola | delta-motorola) 624 | basic_machine=m68k-motorola 625 | ;; 626 | delta88) 627 | basic_machine=m88k-motorola 628 | os=-sysv3 629 | ;; 630 | dicos) 631 | basic_machine=i686-pc 632 | os=-dicos 633 | ;; 634 | djgpp) 635 | basic_machine=i586-pc 636 | os=-msdosdjgpp 637 | ;; 638 | dpx20 | dpx20-*) 639 | basic_machine=rs6000-bull 640 | os=-bosx 641 | ;; 642 | dpx2* | dpx2*-bull) 643 | basic_machine=m68k-bull 644 | os=-sysv3 645 | ;; 646 | ebmon29k) 647 | basic_machine=a29k-amd 648 | os=-ebmon 649 | ;; 650 | elxsi) 651 | basic_machine=elxsi-elxsi 652 | os=-bsd 653 | ;; 654 | encore | umax | mmax) 655 | basic_machine=ns32k-encore 656 | ;; 657 | es1800 | OSE68k | ose68k | ose | OSE) 658 | basic_machine=m68k-ericsson 659 | os=-ose 660 | ;; 661 | fx2800) 662 | basic_machine=i860-alliant 663 | ;; 664 | genix) 665 | basic_machine=ns32k-ns 666 | ;; 667 | gmicro) 668 | basic_machine=tron-gmicro 669 | os=-sysv 670 | ;; 671 | go32) 672 | basic_machine=i386-pc 673 | os=-go32 674 | ;; 675 | h3050r* | hiux*) 676 | basic_machine=hppa1.1-hitachi 677 | os=-hiuxwe2 678 | ;; 679 | h8300hms) 680 | basic_machine=h8300-hitachi 681 | os=-hms 682 | ;; 683 | h8300xray) 684 | basic_machine=h8300-hitachi 685 | os=-xray 686 | ;; 687 | h8500hms) 688 | basic_machine=h8500-hitachi 689 | os=-hms 690 | ;; 691 | harris) 692 | basic_machine=m88k-harris 693 | os=-sysv3 694 | ;; 695 | hp300-*) 696 | basic_machine=m68k-hp 697 | ;; 698 | hp300bsd) 699 | basic_machine=m68k-hp 700 | os=-bsd 701 | ;; 702 | hp300hpux) 703 | basic_machine=m68k-hp 704 | os=-hpux 705 | ;; 706 | hp3k9[0-9][0-9] | hp9[0-9][0-9]) 707 | basic_machine=hppa1.0-hp 708 | ;; 709 | hp9k2[0-9][0-9] | hp9k31[0-9]) 710 | basic_machine=m68000-hp 711 | ;; 712 | hp9k3[2-9][0-9]) 713 | basic_machine=m68k-hp 714 | ;; 715 | hp9k6[0-9][0-9] | hp6[0-9][0-9]) 716 | basic_machine=hppa1.0-hp 717 | ;; 718 | hp9k7[0-79][0-9] | hp7[0-79][0-9]) 719 | basic_machine=hppa1.1-hp 720 | ;; 721 | hp9k78[0-9] | hp78[0-9]) 722 | # FIXME: really hppa2.0-hp 723 | basic_machine=hppa1.1-hp 724 | ;; 725 | hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) 726 | # FIXME: really hppa2.0-hp 727 | basic_machine=hppa1.1-hp 728 | ;; 729 | hp9k8[0-9][13679] | hp8[0-9][13679]) 730 | basic_machine=hppa1.1-hp 731 | ;; 732 | hp9k8[0-9][0-9] | hp8[0-9][0-9]) 733 | basic_machine=hppa1.0-hp 734 | ;; 735 | hppa-next) 736 | os=-nextstep3 737 | ;; 738 | hppaosf) 739 | basic_machine=hppa1.1-hp 740 | os=-osf 741 | ;; 742 | hppro) 743 | basic_machine=hppa1.1-hp 744 | os=-proelf 745 | ;; 746 | i370-ibm* | ibm*) 747 | basic_machine=i370-ibm 748 | ;; 749 | i*86v32) 750 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 751 | os=-sysv32 752 | ;; 753 | i*86v4*) 754 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 755 | os=-sysv4 756 | ;; 757 | i*86v) 758 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 759 | os=-sysv 760 | ;; 761 | i*86sol2) 762 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 763 | os=-solaris2 764 | ;; 765 | i386mach) 766 | basic_machine=i386-mach 767 | os=-mach 768 | ;; 769 | i386-vsta | vsta) 770 | basic_machine=i386-unknown 771 | os=-vsta 772 | ;; 773 | iris | iris4d) 774 | basic_machine=mips-sgi 775 | case $os in 776 | -irix*) 777 | ;; 778 | *) 779 | os=-irix4 780 | ;; 781 | esac 782 | ;; 783 | isi68 | isi) 784 | basic_machine=m68k-isi 785 | os=-sysv 786 | ;; 787 | leon-*|leon[3-9]-*) 788 | basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` 789 | ;; 790 | m68knommu) 791 | basic_machine=m68k-unknown 792 | os=-linux 793 | ;; 794 | m68knommu-*) 795 | basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` 796 | os=-linux 797 | ;; 798 | m88k-omron*) 799 | basic_machine=m88k-omron 800 | ;; 801 | magnum | m3230) 802 | basic_machine=mips-mips 803 | os=-sysv 804 | ;; 805 | merlin) 806 | basic_machine=ns32k-utek 807 | os=-sysv 808 | ;; 809 | microblaze*) 810 | basic_machine=microblaze-xilinx 811 | ;; 812 | mingw64) 813 | basic_machine=x86_64-pc 814 | os=-mingw64 815 | ;; 816 | mingw32) 817 | basic_machine=i686-pc 818 | os=-mingw32 819 | ;; 820 | mingw32ce) 821 | basic_machine=arm-unknown 822 | os=-mingw32ce 823 | ;; 824 | miniframe) 825 | basic_machine=m68000-convergent 826 | ;; 827 | *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) 828 | basic_machine=m68k-atari 829 | os=-mint 830 | ;; 831 | mips3*-*) 832 | basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` 833 | ;; 834 | mips3*) 835 | basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown 836 | ;; 837 | monitor) 838 | basic_machine=m68k-rom68k 839 | os=-coff 840 | ;; 841 | morphos) 842 | basic_machine=powerpc-unknown 843 | os=-morphos 844 | ;; 845 | moxiebox) 846 | basic_machine=moxie-unknown 847 | os=-moxiebox 848 | ;; 849 | msdos) 850 | basic_machine=i386-pc 851 | os=-msdos 852 | ;; 853 | ms1-*) 854 | basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` 855 | ;; 856 | msys) 857 | basic_machine=i686-pc 858 | os=-msys 859 | ;; 860 | mvs) 861 | basic_machine=i370-ibm 862 | os=-mvs 863 | ;; 864 | nacl) 865 | basic_machine=le32-unknown 866 | os=-nacl 867 | ;; 868 | ncr3000) 869 | basic_machine=i486-ncr 870 | os=-sysv4 871 | ;; 872 | netbsd386) 873 | basic_machine=i386-unknown 874 | os=-netbsd 875 | ;; 876 | netwinder) 877 | basic_machine=armv4l-rebel 878 | os=-linux 879 | ;; 880 | news | news700 | news800 | news900) 881 | basic_machine=m68k-sony 882 | os=-newsos 883 | ;; 884 | news1000) 885 | basic_machine=m68030-sony 886 | os=-newsos 887 | ;; 888 | news-3600 | risc-news) 889 | basic_machine=mips-sony 890 | os=-newsos 891 | ;; 892 | necv70) 893 | basic_machine=v70-nec 894 | os=-sysv 895 | ;; 896 | next | m*-next ) 897 | basic_machine=m68k-next 898 | case $os in 899 | -nextstep* ) 900 | ;; 901 | -ns2*) 902 | os=-nextstep2 903 | ;; 904 | *) 905 | os=-nextstep3 906 | ;; 907 | esac 908 | ;; 909 | nh3000) 910 | basic_machine=m68k-harris 911 | os=-cxux 912 | ;; 913 | nh[45]000) 914 | basic_machine=m88k-harris 915 | os=-cxux 916 | ;; 917 | nindy960) 918 | basic_machine=i960-intel 919 | os=-nindy 920 | ;; 921 | mon960) 922 | basic_machine=i960-intel 923 | os=-mon960 924 | ;; 925 | nonstopux) 926 | basic_machine=mips-compaq 927 | os=-nonstopux 928 | ;; 929 | np1) 930 | basic_machine=np1-gould 931 | ;; 932 | neo-tandem) 933 | basic_machine=neo-tandem 934 | ;; 935 | nse-tandem) 936 | basic_machine=nse-tandem 937 | ;; 938 | nsr-tandem) 939 | basic_machine=nsr-tandem 940 | ;; 941 | op50n-* | op60c-*) 942 | basic_machine=hppa1.1-oki 943 | os=-proelf 944 | ;; 945 | openrisc | openrisc-*) 946 | basic_machine=or32-unknown 947 | ;; 948 | os400) 949 | basic_machine=powerpc-ibm 950 | os=-os400 951 | ;; 952 | OSE68000 | ose68000) 953 | basic_machine=m68000-ericsson 954 | os=-ose 955 | ;; 956 | os68k) 957 | basic_machine=m68k-none 958 | os=-os68k 959 | ;; 960 | pa-hitachi) 961 | basic_machine=hppa1.1-hitachi 962 | os=-hiuxwe2 963 | ;; 964 | paragon) 965 | basic_machine=i860-intel 966 | os=-osf 967 | ;; 968 | parisc) 969 | basic_machine=hppa-unknown 970 | os=-linux 971 | ;; 972 | parisc-*) 973 | basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` 974 | os=-linux 975 | ;; 976 | pbd) 977 | basic_machine=sparc-tti 978 | ;; 979 | pbb) 980 | basic_machine=m68k-tti 981 | ;; 982 | pc532 | pc532-*) 983 | basic_machine=ns32k-pc532 984 | ;; 985 | pc98) 986 | basic_machine=i386-pc 987 | ;; 988 | pc98-*) 989 | basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` 990 | ;; 991 | pentium | p5 | k5 | k6 | nexgen | viac3) 992 | basic_machine=i586-pc 993 | ;; 994 | pentiumpro | p6 | 6x86 | athlon | athlon_*) 995 | basic_machine=i686-pc 996 | ;; 997 | pentiumii | pentium2 | pentiumiii | pentium3) 998 | basic_machine=i686-pc 999 | ;; 1000 | pentium4) 1001 | basic_machine=i786-pc 1002 | ;; 1003 | pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) 1004 | basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` 1005 | ;; 1006 | pentiumpro-* | p6-* | 6x86-* | athlon-*) 1007 | basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` 1008 | ;; 1009 | pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) 1010 | basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` 1011 | ;; 1012 | pentium4-*) 1013 | basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` 1014 | ;; 1015 | pn) 1016 | basic_machine=pn-gould 1017 | ;; 1018 | power) basic_machine=power-ibm 1019 | ;; 1020 | ppc | ppcbe) basic_machine=powerpc-unknown 1021 | ;; 1022 | ppc-* | ppcbe-*) 1023 | basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` 1024 | ;; 1025 | ppcle | powerpclittle | ppc-le | powerpc-little) 1026 | basic_machine=powerpcle-unknown 1027 | ;; 1028 | ppcle-* | powerpclittle-*) 1029 | basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` 1030 | ;; 1031 | ppc64) basic_machine=powerpc64-unknown 1032 | ;; 1033 | ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` 1034 | ;; 1035 | ppc64le | powerpc64little | ppc64-le | powerpc64-little) 1036 | basic_machine=powerpc64le-unknown 1037 | ;; 1038 | ppc64le-* | powerpc64little-*) 1039 | basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` 1040 | ;; 1041 | ps2) 1042 | basic_machine=i386-ibm 1043 | ;; 1044 | pw32) 1045 | basic_machine=i586-unknown 1046 | os=-pw32 1047 | ;; 1048 | rdos | rdos64) 1049 | basic_machine=x86_64-pc 1050 | os=-rdos 1051 | ;; 1052 | rdos32) 1053 | basic_machine=i386-pc 1054 | os=-rdos 1055 | ;; 1056 | rom68k) 1057 | basic_machine=m68k-rom68k 1058 | os=-coff 1059 | ;; 1060 | rm[46]00) 1061 | basic_machine=mips-siemens 1062 | ;; 1063 | rtpc | rtpc-*) 1064 | basic_machine=romp-ibm 1065 | ;; 1066 | s390 | s390-*) 1067 | basic_machine=s390-ibm 1068 | ;; 1069 | s390x | s390x-*) 1070 | basic_machine=s390x-ibm 1071 | ;; 1072 | sa29200) 1073 | basic_machine=a29k-amd 1074 | os=-udi 1075 | ;; 1076 | sb1) 1077 | basic_machine=mipsisa64sb1-unknown 1078 | ;; 1079 | sb1el) 1080 | basic_machine=mipsisa64sb1el-unknown 1081 | ;; 1082 | sde) 1083 | basic_machine=mipsisa32-sde 1084 | os=-elf 1085 | ;; 1086 | sei) 1087 | basic_machine=mips-sei 1088 | os=-seiux 1089 | ;; 1090 | sequent) 1091 | basic_machine=i386-sequent 1092 | ;; 1093 | sh) 1094 | basic_machine=sh-hitachi 1095 | os=-hms 1096 | ;; 1097 | sh5el) 1098 | basic_machine=sh5le-unknown 1099 | ;; 1100 | sh64) 1101 | basic_machine=sh64-unknown 1102 | ;; 1103 | sparclite-wrs | simso-wrs) 1104 | basic_machine=sparclite-wrs 1105 | os=-vxworks 1106 | ;; 1107 | sps7) 1108 | basic_machine=m68k-bull 1109 | os=-sysv2 1110 | ;; 1111 | spur) 1112 | basic_machine=spur-unknown 1113 | ;; 1114 | st2000) 1115 | basic_machine=m68k-tandem 1116 | ;; 1117 | stratus) 1118 | basic_machine=i860-stratus 1119 | os=-sysv4 1120 | ;; 1121 | strongarm-* | thumb-*) 1122 | basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` 1123 | ;; 1124 | sun2) 1125 | basic_machine=m68000-sun 1126 | ;; 1127 | sun2os3) 1128 | basic_machine=m68000-sun 1129 | os=-sunos3 1130 | ;; 1131 | sun2os4) 1132 | basic_machine=m68000-sun 1133 | os=-sunos4 1134 | ;; 1135 | sun3os3) 1136 | basic_machine=m68k-sun 1137 | os=-sunos3 1138 | ;; 1139 | sun3os4) 1140 | basic_machine=m68k-sun 1141 | os=-sunos4 1142 | ;; 1143 | sun4os3) 1144 | basic_machine=sparc-sun 1145 | os=-sunos3 1146 | ;; 1147 | sun4os4) 1148 | basic_machine=sparc-sun 1149 | os=-sunos4 1150 | ;; 1151 | sun4sol2) 1152 | basic_machine=sparc-sun 1153 | os=-solaris2 1154 | ;; 1155 | sun3 | sun3-*) 1156 | basic_machine=m68k-sun 1157 | ;; 1158 | sun4) 1159 | basic_machine=sparc-sun 1160 | ;; 1161 | sun386 | sun386i | roadrunner) 1162 | basic_machine=i386-sun 1163 | ;; 1164 | sv1) 1165 | basic_machine=sv1-cray 1166 | os=-unicos 1167 | ;; 1168 | symmetry) 1169 | basic_machine=i386-sequent 1170 | os=-dynix 1171 | ;; 1172 | t3e) 1173 | basic_machine=alphaev5-cray 1174 | os=-unicos 1175 | ;; 1176 | t90) 1177 | basic_machine=t90-cray 1178 | os=-unicos 1179 | ;; 1180 | tile*) 1181 | basic_machine=$basic_machine-unknown 1182 | os=-linux-gnu 1183 | ;; 1184 | tx39) 1185 | basic_machine=mipstx39-unknown 1186 | ;; 1187 | tx39el) 1188 | basic_machine=mipstx39el-unknown 1189 | ;; 1190 | toad1) 1191 | basic_machine=pdp10-xkl 1192 | os=-tops20 1193 | ;; 1194 | tower | tower-32) 1195 | basic_machine=m68k-ncr 1196 | ;; 1197 | tpf) 1198 | basic_machine=s390x-ibm 1199 | os=-tpf 1200 | ;; 1201 | udi29k) 1202 | basic_machine=a29k-amd 1203 | os=-udi 1204 | ;; 1205 | ultra3) 1206 | basic_machine=a29k-nyu 1207 | os=-sym1 1208 | ;; 1209 | v810 | necv810) 1210 | basic_machine=v810-nec 1211 | os=-none 1212 | ;; 1213 | vaxv) 1214 | basic_machine=vax-dec 1215 | os=-sysv 1216 | ;; 1217 | vms) 1218 | basic_machine=vax-dec 1219 | os=-vms 1220 | ;; 1221 | vpp*|vx|vx-*) 1222 | basic_machine=f301-fujitsu 1223 | ;; 1224 | vxworks960) 1225 | basic_machine=i960-wrs 1226 | os=-vxworks 1227 | ;; 1228 | vxworks68) 1229 | basic_machine=m68k-wrs 1230 | os=-vxworks 1231 | ;; 1232 | vxworks29k) 1233 | basic_machine=a29k-wrs 1234 | os=-vxworks 1235 | ;; 1236 | w65*) 1237 | basic_machine=w65-wdc 1238 | os=-none 1239 | ;; 1240 | w89k-*) 1241 | basic_machine=hppa1.1-winbond 1242 | os=-proelf 1243 | ;; 1244 | xbox) 1245 | basic_machine=i686-pc 1246 | os=-mingw32 1247 | ;; 1248 | xps | xps100) 1249 | basic_machine=xps100-honeywell 1250 | ;; 1251 | xscale-* | xscalee[bl]-*) 1252 | basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` 1253 | ;; 1254 | ymp) 1255 | basic_machine=ymp-cray 1256 | os=-unicos 1257 | ;; 1258 | z8k-*-coff) 1259 | basic_machine=z8k-unknown 1260 | os=-sim 1261 | ;; 1262 | z80-*-coff) 1263 | basic_machine=z80-unknown 1264 | os=-sim 1265 | ;; 1266 | none) 1267 | basic_machine=none-none 1268 | os=-none 1269 | ;; 1270 | 1271 | # Here we handle the default manufacturer of certain CPU types. It is in 1272 | # some cases the only manufacturer, in others, it is the most popular. 1273 | w89k) 1274 | basic_machine=hppa1.1-winbond 1275 | ;; 1276 | op50n) 1277 | basic_machine=hppa1.1-oki 1278 | ;; 1279 | op60c) 1280 | basic_machine=hppa1.1-oki 1281 | ;; 1282 | romp) 1283 | basic_machine=romp-ibm 1284 | ;; 1285 | mmix) 1286 | basic_machine=mmix-knuth 1287 | ;; 1288 | rs6000) 1289 | basic_machine=rs6000-ibm 1290 | ;; 1291 | vax) 1292 | basic_machine=vax-dec 1293 | ;; 1294 | pdp10) 1295 | # there are many clones, so DEC is not a safe bet 1296 | basic_machine=pdp10-unknown 1297 | ;; 1298 | pdp11) 1299 | basic_machine=pdp11-dec 1300 | ;; 1301 | we32k) 1302 | basic_machine=we32k-att 1303 | ;; 1304 | sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) 1305 | basic_machine=sh-unknown 1306 | ;; 1307 | sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) 1308 | basic_machine=sparc-sun 1309 | ;; 1310 | cydra) 1311 | basic_machine=cydra-cydrome 1312 | ;; 1313 | orion) 1314 | basic_machine=orion-highlevel 1315 | ;; 1316 | orion105) 1317 | basic_machine=clipper-highlevel 1318 | ;; 1319 | mac | mpw | mac-mpw) 1320 | basic_machine=m68k-apple 1321 | ;; 1322 | pmac | pmac-mpw) 1323 | basic_machine=powerpc-apple 1324 | ;; 1325 | *-unknown) 1326 | # Make sure to match an already-canonicalized machine name. 1327 | ;; 1328 | *) 1329 | echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 1330 | exit 1 1331 | ;; 1332 | esac 1333 | 1334 | # Here we canonicalize certain aliases for manufacturers. 1335 | case $basic_machine in 1336 | *-digital*) 1337 | basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` 1338 | ;; 1339 | *-commodore*) 1340 | basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` 1341 | ;; 1342 | *) 1343 | ;; 1344 | esac 1345 | 1346 | # Decode manufacturer-specific aliases for certain operating systems. 1347 | 1348 | if [ x"$os" != x"" ] 1349 | then 1350 | case $os in 1351 | # First match some system type aliases 1352 | # that might get confused with valid system types. 1353 | # -solaris* is a basic system type, with this one exception. 1354 | -auroraux) 1355 | os=-auroraux 1356 | ;; 1357 | -solaris1 | -solaris1.*) 1358 | os=`echo $os | sed -e 's|solaris1|sunos4|'` 1359 | ;; 1360 | -solaris) 1361 | os=-solaris2 1362 | ;; 1363 | -svr4*) 1364 | os=-sysv4 1365 | ;; 1366 | -unixware*) 1367 | os=-sysv4.2uw 1368 | ;; 1369 | -gnu/linux*) 1370 | os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` 1371 | ;; 1372 | # First accept the basic system types. 1373 | # The portable systems comes first. 1374 | # Each alternative MUST END IN A *, to match a version number. 1375 | # -sysv* is not here because it comes later, after sysvr4. 1376 | -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ 1377 | | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ 1378 | | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ 1379 | | -sym* | -kopensolaris* | -plan9* \ 1380 | | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ 1381 | | -aos* | -aros* | -cloudabi* | -sortix* \ 1382 | | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ 1383 | | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ 1384 | | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ 1385 | | -bitrig* | -openbsd* | -solidbsd* \ 1386 | | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ 1387 | | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ 1388 | | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ 1389 | | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ 1390 | | -chorusos* | -chorusrdb* | -cegcc* \ 1391 | | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ 1392 | | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ 1393 | | -linux-newlib* | -linux-musl* | -linux-uclibc* \ 1394 | | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ 1395 | | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ 1396 | | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ 1397 | | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ 1398 | | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ 1399 | | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ 1400 | | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ 1401 | | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ 1402 | | -onefs* | -tirtos*) 1403 | # Remember, each alternative MUST END IN *, to match a version number. 1404 | ;; 1405 | -qnx*) 1406 | case $basic_machine in 1407 | x86-* | i*86-*) 1408 | ;; 1409 | *) 1410 | os=-nto$os 1411 | ;; 1412 | esac 1413 | ;; 1414 | -nto-qnx*) 1415 | ;; 1416 | -nto*) 1417 | os=`echo $os | sed -e 's|nto|nto-qnx|'` 1418 | ;; 1419 | -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ 1420 | | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ 1421 | | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) 1422 | ;; 1423 | -mac*) 1424 | os=`echo $os | sed -e 's|mac|macos|'` 1425 | ;; 1426 | -linux-dietlibc) 1427 | os=-linux-dietlibc 1428 | ;; 1429 | -linux*) 1430 | os=`echo $os | sed -e 's|linux|linux-gnu|'` 1431 | ;; 1432 | -sunos5*) 1433 | os=`echo $os | sed -e 's|sunos5|solaris2|'` 1434 | ;; 1435 | -sunos6*) 1436 | os=`echo $os | sed -e 's|sunos6|solaris3|'` 1437 | ;; 1438 | -opened*) 1439 | os=-openedition 1440 | ;; 1441 | -os400*) 1442 | os=-os400 1443 | ;; 1444 | -wince*) 1445 | os=-wince 1446 | ;; 1447 | -osfrose*) 1448 | os=-osfrose 1449 | ;; 1450 | -osf*) 1451 | os=-osf 1452 | ;; 1453 | -utek*) 1454 | os=-bsd 1455 | ;; 1456 | -dynix*) 1457 | os=-bsd 1458 | ;; 1459 | -acis*) 1460 | os=-aos 1461 | ;; 1462 | -atheos*) 1463 | os=-atheos 1464 | ;; 1465 | -syllable*) 1466 | os=-syllable 1467 | ;; 1468 | -386bsd) 1469 | os=-bsd 1470 | ;; 1471 | -ctix* | -uts*) 1472 | os=-sysv 1473 | ;; 1474 | -nova*) 1475 | os=-rtmk-nova 1476 | ;; 1477 | -ns2 ) 1478 | os=-nextstep2 1479 | ;; 1480 | -nsk*) 1481 | os=-nsk 1482 | ;; 1483 | # Preserve the version number of sinix5. 1484 | -sinix5.*) 1485 | os=`echo $os | sed -e 's|sinix|sysv|'` 1486 | ;; 1487 | -sinix*) 1488 | os=-sysv4 1489 | ;; 1490 | -tpf*) 1491 | os=-tpf 1492 | ;; 1493 | -triton*) 1494 | os=-sysv3 1495 | ;; 1496 | -oss*) 1497 | os=-sysv3 1498 | ;; 1499 | -svr4) 1500 | os=-sysv4 1501 | ;; 1502 | -svr3) 1503 | os=-sysv3 1504 | ;; 1505 | -sysvr4) 1506 | os=-sysv4 1507 | ;; 1508 | # This must come after -sysvr4. 1509 | -sysv*) 1510 | ;; 1511 | -ose*) 1512 | os=-ose 1513 | ;; 1514 | -es1800*) 1515 | os=-ose 1516 | ;; 1517 | -xenix) 1518 | os=-xenix 1519 | ;; 1520 | -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 1521 | os=-mint 1522 | ;; 1523 | -aros*) 1524 | os=-aros 1525 | ;; 1526 | -zvmoe) 1527 | os=-zvmoe 1528 | ;; 1529 | -dicos*) 1530 | os=-dicos 1531 | ;; 1532 | -nacl*) 1533 | ;; 1534 | -none) 1535 | ;; 1536 | *) 1537 | # Get rid of the `-' at the beginning of $os. 1538 | os=`echo $os | sed 's/[^-]*-//'` 1539 | echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 1540 | exit 1 1541 | ;; 1542 | esac 1543 | else 1544 | 1545 | # Here we handle the default operating systems that come with various machines. 1546 | # The value should be what the vendor currently ships out the door with their 1547 | # machine or put another way, the most popular os provided with the machine. 1548 | 1549 | # Note that if you're going to try to match "-MANUFACTURER" here (say, 1550 | # "-sun"), then you have to tell the case statement up towards the top 1551 | # that MANUFACTURER isn't an operating system. Otherwise, code above 1552 | # will signal an error saying that MANUFACTURER isn't an operating 1553 | # system, and we'll never get to this point. 1554 | 1555 | case $basic_machine in 1556 | score-*) 1557 | os=-elf 1558 | ;; 1559 | spu-*) 1560 | os=-elf 1561 | ;; 1562 | *-acorn) 1563 | os=-riscix1.2 1564 | ;; 1565 | arm*-rebel) 1566 | os=-linux 1567 | ;; 1568 | arm*-semi) 1569 | os=-aout 1570 | ;; 1571 | c4x-* | tic4x-*) 1572 | os=-coff 1573 | ;; 1574 | c8051-*) 1575 | os=-elf 1576 | ;; 1577 | hexagon-*) 1578 | os=-elf 1579 | ;; 1580 | tic54x-*) 1581 | os=-coff 1582 | ;; 1583 | tic55x-*) 1584 | os=-coff 1585 | ;; 1586 | tic6x-*) 1587 | os=-coff 1588 | ;; 1589 | # This must come before the *-dec entry. 1590 | pdp10-*) 1591 | os=-tops20 1592 | ;; 1593 | pdp11-*) 1594 | os=-none 1595 | ;; 1596 | *-dec | vax-*) 1597 | os=-ultrix4.2 1598 | ;; 1599 | m68*-apollo) 1600 | os=-domain 1601 | ;; 1602 | i386-sun) 1603 | os=-sunos4.0.2 1604 | ;; 1605 | m68000-sun) 1606 | os=-sunos3 1607 | ;; 1608 | m68*-cisco) 1609 | os=-aout 1610 | ;; 1611 | mep-*) 1612 | os=-elf 1613 | ;; 1614 | mips*-cisco) 1615 | os=-elf 1616 | ;; 1617 | mips*-*) 1618 | os=-elf 1619 | ;; 1620 | or32-*) 1621 | os=-coff 1622 | ;; 1623 | *-tti) # must be before sparc entry or we get the wrong os. 1624 | os=-sysv3 1625 | ;; 1626 | sparc-* | *-sun) 1627 | os=-sunos4.1.1 1628 | ;; 1629 | *-be) 1630 | os=-beos 1631 | ;; 1632 | *-haiku) 1633 | os=-haiku 1634 | ;; 1635 | *-ibm) 1636 | os=-aix 1637 | ;; 1638 | *-knuth) 1639 | os=-mmixware 1640 | ;; 1641 | *-wec) 1642 | os=-proelf 1643 | ;; 1644 | *-winbond) 1645 | os=-proelf 1646 | ;; 1647 | *-oki) 1648 | os=-proelf 1649 | ;; 1650 | *-hp) 1651 | os=-hpux 1652 | ;; 1653 | *-hitachi) 1654 | os=-hiux 1655 | ;; 1656 | i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) 1657 | os=-sysv 1658 | ;; 1659 | *-cbm) 1660 | os=-amigaos 1661 | ;; 1662 | *-dg) 1663 | os=-dgux 1664 | ;; 1665 | *-dolphin) 1666 | os=-sysv3 1667 | ;; 1668 | m68k-ccur) 1669 | os=-rtu 1670 | ;; 1671 | m88k-omron*) 1672 | os=-luna 1673 | ;; 1674 | *-next ) 1675 | os=-nextstep 1676 | ;; 1677 | *-sequent) 1678 | os=-ptx 1679 | ;; 1680 | *-crds) 1681 | os=-unos 1682 | ;; 1683 | *-ns) 1684 | os=-genix 1685 | ;; 1686 | i370-*) 1687 | os=-mvs 1688 | ;; 1689 | *-next) 1690 | os=-nextstep3 1691 | ;; 1692 | *-gould) 1693 | os=-sysv 1694 | ;; 1695 | *-highlevel) 1696 | os=-bsd 1697 | ;; 1698 | *-encore) 1699 | os=-bsd 1700 | ;; 1701 | *-sgi) 1702 | os=-irix 1703 | ;; 1704 | *-siemens) 1705 | os=-sysv4 1706 | ;; 1707 | *-masscomp) 1708 | os=-rtu 1709 | ;; 1710 | f30[01]-fujitsu | f700-fujitsu) 1711 | os=-uxpv 1712 | ;; 1713 | *-rom68k) 1714 | os=-coff 1715 | ;; 1716 | *-*bug) 1717 | os=-coff 1718 | ;; 1719 | *-apple) 1720 | os=-macos 1721 | ;; 1722 | *-atari*) 1723 | os=-mint 1724 | ;; 1725 | *) 1726 | os=-none 1727 | ;; 1728 | esac 1729 | fi 1730 | 1731 | # Here we handle the case where we know the os, and the CPU type, but not the 1732 | # manufacturer. We pick the logical manufacturer. 1733 | vendor=unknown 1734 | case $basic_machine in 1735 | *-unknown) 1736 | case $os in 1737 | -riscix*) 1738 | vendor=acorn 1739 | ;; 1740 | -sunos*) 1741 | vendor=sun 1742 | ;; 1743 | -cnk*|-aix*) 1744 | vendor=ibm 1745 | ;; 1746 | -beos*) 1747 | vendor=be 1748 | ;; 1749 | -hpux*) 1750 | vendor=hp 1751 | ;; 1752 | -mpeix*) 1753 | vendor=hp 1754 | ;; 1755 | -hiux*) 1756 | vendor=hitachi 1757 | ;; 1758 | -unos*) 1759 | vendor=crds 1760 | ;; 1761 | -dgux*) 1762 | vendor=dg 1763 | ;; 1764 | -luna*) 1765 | vendor=omron 1766 | ;; 1767 | -genix*) 1768 | vendor=ns 1769 | ;; 1770 | -mvs* | -opened*) 1771 | vendor=ibm 1772 | ;; 1773 | -os400*) 1774 | vendor=ibm 1775 | ;; 1776 | -ptx*) 1777 | vendor=sequent 1778 | ;; 1779 | -tpf*) 1780 | vendor=ibm 1781 | ;; 1782 | -vxsim* | -vxworks* | -windiss*) 1783 | vendor=wrs 1784 | ;; 1785 | -aux*) 1786 | vendor=apple 1787 | ;; 1788 | -hms*) 1789 | vendor=hitachi 1790 | ;; 1791 | -mpw* | -macos*) 1792 | vendor=apple 1793 | ;; 1794 | -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 1795 | vendor=atari 1796 | ;; 1797 | -vos*) 1798 | vendor=stratus 1799 | ;; 1800 | esac 1801 | basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` 1802 | ;; 1803 | esac 1804 | 1805 | echo $basic_machine$os 1806 | exit 1807 | 1808 | # Local variables: 1809 | # eval: (add-hook 'write-file-hooks 'time-stamp) 1810 | # time-stamp-start: "timestamp='" 1811 | # time-stamp-format: "%:y-%02m-%02d" 1812 | # time-stamp-end: "'" 1813 | # End: 1814 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl Process this file with autoconf to produce a configure script. 2 | AC_INIT(elf2flt.c) 3 | 4 | AC_ARG_WITH(zlib-prefix, 5 | AS_HELP_STRING([--with-zlib-prefix=], [path to installed zlib]), 6 | [ ac_zlib_prefix=$withval ], 7 | [ ac_zlib_prefix=NONE ] 8 | ) 9 | 10 | AC_ARG_WITH(libbfd, 11 | AS_HELP_STRING([--with-libbfd=], [path to libbfd.a library to use]), 12 | [ ac_libbfd=$withval ], 13 | [ ac_libbfd=NONE ] 14 | ) 15 | 16 | AC_ARG_WITH(libiberty, 17 | AS_HELP_STRING([--with-libiberty=], [path to libiberty.a library to use]), 18 | [ ac_libiberty=$withval ], 19 | [ ac_libiberty=NONE ] 20 | ) 21 | 22 | AC_ARG_WITH(bfd-include-dir, 23 | AS_HELP_STRING([--with-bfd-include-dir=], [include path for correct bfd.h]), 24 | [ ac_bfd_include_dir=$withval ], 25 | [ ac_bfd_include_dir=NONE ] 26 | ) 27 | 28 | AC_ARG_WITH(binutils-include-dir, 29 | AS_HELP_STRING([--with-binutils-include-dir=], [include path for binutils headers]), 30 | [ ac_binutils_include_dir=$withval ], 31 | [ ac_binutils_include_dir=NONE ] 32 | ) 33 | 34 | AC_ARG_WITH(binutils-ldscript-dir, 35 | AS_HELP_STRING([--with-binutils-ldscript-dir=], [path to install elf2flt.ld]), 36 | [ ac_binutils_ldscript_dir=$withval ], 37 | [ ac_binutils_ldscript_dir=NONE ] 38 | ) 39 | 40 | AC_ARG_WITH(binutils-build-dir, 41 | AS_HELP_STRING([--with-binutils-build-dir=], [path to compiled binutils tree]), 42 | [ ac_binutils_build_dir=$withval ], 43 | [ ac_binutils_build_dir=NONE ] 44 | ) 45 | 46 | AC_ARG_ENABLE(ld-elf2flt-binary, 47 | AS_HELP_STRING([--disable-ld-elf2flt-binary], [use ld-elf2flt shell script]), 48 | [ use_ld_elf2flt_binary=$enableval ], 49 | [ use_ld_elf2flt_binary=yes ] 50 | ) 51 | if test "$use_ld_elf2flt_binary" != "yes"; then 52 | AC_MSG_WARN([--disable-ld-elf2flt-binary is deprecated. 53 | If you still need this, please let us know before we delete it.]) 54 | fi 55 | 56 | dnl convert a yes/no variable to 1/0 for C code 57 | var_yn_to_10() { 58 | if eval test \"\$$1\" = yes ; then 59 | eval $1=1 60 | else 61 | eval $1=0 62 | fi 63 | } 64 | 65 | AC_ARG_ENABLE(werror, 66 | AS_HELP_STRING([--disable-werror], [do not build with -Werror]), 67 | [ werror=$enableval ], 68 | [ werror=yes ] 69 | ) 70 | var_yn_to_10 werror 71 | 72 | AC_ARG_ENABLE(got-check, 73 | AS_HELP_STRING([--disable-got-check], [disable check for GOT (needed on H8)]), 74 | [ got_check=$enableval ], 75 | [ got_check=yes ] 76 | ) 77 | var_yn_to_10 got_check 78 | 79 | AC_ARG_ENABLE(emit-relocs, 80 | AS_HELP_STRING([--disable-emit-relocs], [don't use the --emit-relocs (-q) linker option]), 81 | [ emit_relocs=$enableval ], 82 | [ emit_relocs=yes ] 83 | ) 84 | var_yn_to_10 emit_relocs 85 | 86 | AC_ARG_ENABLE(emit-ctor-dtor, 87 | AS_HELP_STRING([--enable-emit-ctor-dtor], [manually create ctor/dtor list]), 88 | [ emit_ctor_dtor=$enableval ], 89 | [ emit_ctor_dtor=no ] 90 | ) 91 | var_yn_to_10 emit_ctor_dtor 92 | 93 | AC_ARG_ENABLE(always-reloc-text, 94 | AS_HELP_STRING([--enable-always-reloc-text], [always process text relocs ignoring pic/got (needed on Blackfin)]), 95 | [ always_reloc_text=$enableval ], 96 | [ 97 | case $target in 98 | bfin*) always_reloc_text=yes;; 99 | *) always_reloc_text=no;; 100 | esac 101 | ] 102 | ) 103 | var_yn_to_10 always_reloc_text 104 | 105 | AC_CANONICAL_HOST 106 | AC_CANONICAL_TARGET 107 | 108 | dnl Checks for programs. 109 | AC_PROG_CC 110 | AC_USE_SYSTEM_EXTENSIONS 111 | AC_PROG_INSTALL 112 | 113 | if test "$ac_binutils_build_dir" != "NONE"; then 114 | test "$ac_libbfd" = "NONE" && ac_libbfd="$ac_binutils_build_dir/bfd/libbfd.a" 115 | test "$ac_libiberty" = "NONE" && ac_libiberty="$ac_binutils_build_dir/libiberty/libiberty.a" 116 | test "$ac_bfd_include_dir" = "NONE" && ac_bfd_include_dir="$ac_binutils_build_dir/bfd" 117 | test "$ac_binutils_include_dir" = "NONE" && ac_binutils_include_dir="$ac_binutils_build_dir/include" 118 | fi 119 | 120 | dnl Checks for libraries. Look for zlib before binutils libs in case they 121 | dnl need zlib themselves. 122 | if test "$ac_zlib_prefix" = "NONE"; then 123 | AC_CHECK_LIB(z, deflate) 124 | else 125 | LIBS="-L$ac_zlib_prefix/lib -lz $LIBS" 126 | fi 127 | AC_CHECK_LIB(zstd, ZSTD_decompress) 128 | if test "$ac_libiberty" = "NONE"; then 129 | AC_CHECK_LIB(iberty, objalloc_create) 130 | ac_libiberty=auto 131 | else 132 | LIBS="$ac_libiberty $LIBS" 133 | fi 134 | if test "$ac_libbfd" = "NONE"; then 135 | AC_CHECK_LIB(bfd, bfd_openr) 136 | ac_libbfd=auto 137 | else 138 | LIBS="$ac_libbfd $LIBS" 139 | fi 140 | 141 | bfd_include_dir= 142 | if test "$ac_bfd_include_dir" != "NONE"; then 143 | bfd_include_dir=$(cd "$ac_bfd_include_dir" && pwd) 144 | fi 145 | 146 | binutils_include_dir= 147 | if test "$ac_binutils_include_dir" != "NONE"; then 148 | binutils_include_dir=$(cd "$ac_binutils_include_dir" && pwd) 149 | fi 150 | 151 | zlib_include_dir= 152 | if test "$ac_zlib_prefix" != "NONE"; then 153 | zlib_include_dir="-I$ac_zlib_prefix/include" 154 | fi 155 | 156 | binutils_ldscript_dir= 157 | if test "$ac_binutils_ldscript_dir" = "NONE"; then 158 | ac_binutils_ldscript_dir="\${TOOLDIR}/../${target_alias}/lib" 159 | fi 160 | binutils_ldscript_dir="$ac_binutils_ldscript_dir" 161 | 162 | if test "$ac_libbfd" = "NONE" -o "$ac_libiberty" = "NONE" ; then 163 | AC_MSG_ERROR([ 164 | 165 | You need to specify the location of the libfd.a and libiberty.a 166 | host libraries from the binutils package. 167 | 168 | Run configure again specifying these options: 169 | 170 | ./configure --target= --with-bfd-include-dir= --with-libbfd= --with-libiberty= 171 | ]) 172 | fi 173 | 174 | if test "$ac_bfd_include_dir" = "NONE" ; then 175 | AC_MSG_ERROR([ 176 | 177 | You need to specify the location of the bfd.h header from a 178 | configured/compiled version of the binutils package for your target. 179 | Without this your elf2flt may crash as it will try to use the 180 | systems bfd.h which may be from a different binutils package. 181 | 182 | Run configure again specifying these options: 183 | 184 | ./configure --target= --with-bfd-include-dir= --with-libbfd= --with-libiberty= 185 | ]) 186 | fi 187 | 188 | SYMBOL_PREFIX= 189 | case $target in 190 | bfin*) 191 | SYMBOL_PREFIX=_ 192 | ;; 193 | esac 194 | 195 | dnl Make sure we resolve system symbols before libiberty/libbfd ones. 196 | dnl Otherwise, things like getopt get screwed up because the system headers 197 | dnl redirect some functions to the system symbols, but other local symbols 198 | dnl come from libiberty/libbfd. 199 | dnl int getopt(int, char * const [], const char *) __asm("_" "getopt" "$UNIX2003"); 200 | AC_CHECK_LIB(c, malloc, LIBS="-lc $LIBS") 201 | AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl") 202 | 203 | dnl Checks for header files. 204 | AC_HEADER_STDC 205 | AC_CHECK_HEADERS(fcntl.h unistd.h bfd.h) 206 | 207 | dnl Checks for typedefs, structures, and compiler characteristics. 208 | AC_C_CONST 209 | 210 | HAVE_BFD_XTENSA_PDIFF_RELOCS=0 211 | case $target in 212 | xtensa*) 213 | AS_VAR_COPY([OLD_CPPFLAGS], [CPPFLAGS]) 214 | AS_VAR_SET([CPPFLAGS], ["-I$bfd_include_dir -I$binutils_include_dir $CPPFLAGS"]) 215 | AC_CHECK_DECL([R_XTENSA_PDIFF8], 216 | [HAVE_BFD_XTENSA_PDIFF_RELOCS=1],, 217 | [#include "bfd.h" 218 | #include "elf/xtensa.h"]) 219 | AS_VAR_COPY([CPPFLAGS], [OLD_CPPFLAGS]) 220 | ;; 221 | esac 222 | 223 | dnl Checks for library functions. 224 | AC_FUNC_VPRINTF 225 | 226 | AC_CHECK_FUNCS([ \ 227 | dcgettext \ 228 | getline \ 229 | libintl_dgettext \ 230 | strsignal \ 231 | ]) 232 | 233 | dnl Various bfd section macros and functions like bfd_section_size() have been 234 | dnl modified starting with binutils >= 2.34. 235 | dnl Check if the prototypes take a bfd argument. 236 | if test "$binutils_include_dir" != "NONE"; then 237 | CFLAGS="-I$binutils_include_dir -I$bfd_include_dir $CFLAGS" 238 | fi 239 | 240 | AC_TRY_COMPILE([#include ], 241 | [const asection *sec; bfd_section_size(sec);], 242 | bfd_section_api_takes_bfd=no, 243 | bfd_section_api_takes_bfd=yes) 244 | if test "$bfd_section_api_takes_bfd" = "yes" ; then 245 | AC_DEFINE(HAVE_BFD_SECTION_API_TAKES_BFD, 1, 246 | [define to 1 for binutils < 2.34]) 247 | fi 248 | 249 | if test "$GCC" = yes ; then 250 | CFLAGS="-Wall $CFLAGS" 251 | if test "$werror" = 1 ; then 252 | CFLAGS="-Werror -Wno-error=unused-label $CFLAGS" 253 | fi 254 | fi 255 | 256 | dnl Subsitute values 257 | AC_SUBST(target) 258 | AC_SUBST(target_alias) 259 | AC_SUBST(target_cpu) 260 | AC_SUBST(target_os) 261 | AC_SUBST(target_vendor) 262 | AC_SUBST(bfd_include_dir) 263 | AC_SUBST(binutils_include_dir) 264 | AC_SUBST(zlib_include_dir) 265 | AC_SUBST(binutils_ldscript_dir) 266 | AC_SUBST(use_ld_elf2flt_binary) 267 | AC_SUBST(got_check) 268 | AC_SUBST(emit_relocs) 269 | AC_SUBST(emit_ctor_dtor) 270 | AC_SUBST(always_reloc_text) 271 | AC_SUBST(SYMBOL_PREFIX) 272 | AC_SUBST(HAVE_BFD_XTENSA_PDIFF_RELOCS) 273 | 274 | AC_OUTPUT(ld-elf2flt.sh:ld-elf2flt.in Makefile elf2flt.ld) 275 | 276 | -------------------------------------------------------------------------------- /e1-elf2flt.ld: -------------------------------------------------------------------------------- 1 | 2 | ENTRY (__start) 3 | 4 | MEMORY { 5 | flatmem : ORIGIN = 0x0, LENGTH = 0xfffffff 6 | } 7 | 8 | SECTIONS { 9 | .G6 (DEFINED(G6Base) ? G6Base : 0x0) : { 10 | *(.G6) 11 | } 12 | .G7 (DEFINED(G7Base) ? G7Base : 0x0) : { 13 | *(.G7) 14 | } 15 | .G8 (DEFINED(G8Base) ? G8Base : 0x0) : { 16 | *(.G8) 17 | } 18 | .G9 (DEFINED(G9Base) ? G9Base : 0) : { 19 | *(.G9) 20 | } 21 | .G10 (DEFINED(G10Base) ? G10Base : 0) : { 22 | *(.G10) 23 | } 24 | .G11 (DEFINED(G11Base) ? G11Base : 0) : { 25 | *(.G11) 26 | } 27 | .G12 (DEFINED(G12Base) ? G12Base : 0) : { 28 | *(.G12) 29 | } 30 | .G13 (DEFINED(G13Base) ? G13Base : 0) : { 31 | *(.G13) 32 | } 33 | .text 0x0 : { 34 | . = . + 4; 35 | . = ALIGN(0x4) ; 36 | _stext = . ; 37 | *(.text) 38 | *(.text.*) 39 | *(.gnu.warning) 40 | *(.stub) 41 | *(.gnu.linkonce.t*) 42 | *(.glue_7t) 43 | *(.glue_7) 44 | *(.jcr) 45 | *(.init) 46 | *(.fini) 47 | 48 | W_RODAT: *(.rodata) 49 | W_RODAT: *(.rodata1) 50 | W_RODAT: *(.rodata.*) 51 | 52 | /* This is special code area at the end of the normal 53 | text section. It contains a small lookup table at 54 | the start followed by the code pointed to by entries 55 | in the lookup table. */ 56 | . = ALIGN (4) ; 57 | PROVIDE(__ctbp = .); 58 | *(.call_table_data) 59 | *(.call_table_text) 60 | 61 | . = ALIGN(0x20) ; 62 | _etext = . ; 63 | } > flatmem 64 | .data : { 65 | . = ALIGN(0x4) ; 66 | _sdata = . ; 67 | __data_start = . ; 68 | data_start = . ; 69 | *(.got.plt) 70 | *(.got) 71 | FILL(0) ; 72 | . = ALIGN(0x20) ; 73 | LONG(-1) 74 | . = ALIGN(0x20) ; 75 | R_RODAT: *(.rodata) 76 | R_RODAT: *(.rodata1) 77 | R_RODAT: *(.rodata.*) 78 | *(.gnu.linkonce.r*) 79 | *(.data) 80 | *(.data1) 81 | *(.data.*) 82 | *(.gnu.linkonce.d*) 83 | *(.data1) 84 | *(.eh_frame) 85 | *(.gcc_except_table) 86 | 87 | /* Microblaze has .sdata and .sbss (small bss). They must 88 | be contiguous, so please don't move any of this. JW */ 89 | _ssrw = . ; 90 | *(.sdata) 91 | *(.sdata.*) 92 | *(.sbss) /* Don't move this! */ 93 | _essrw = . ; 94 | 95 | _ssrw_size = _essrw - _ssrw; 96 | PROVIDE(_SDA_BASE_ = _ssrw + (_ssrw_size / 2)); 97 | 98 | *(.gnu.linkonce.s.*) 99 | *(__libc_atexit) 100 | *(__libc_subinit) 101 | *(__libc_subfreeres) 102 | *(.note.ABI-tag) 103 | 104 | /* microblaze-specific read-only small data area 105 | and associated locating symbols */ 106 | _ssro = . ; 107 | *(.sdata2) 108 | _essro = . ; 109 | _ssro_size = _essro - _ssro; 110 | PROVIDE(_SDA2_BASE_ = _ssro + (_ssro_size / 2)); 111 | 112 | . = ALIGN(4) ; 113 | __CTOR_LIST__ = .; 114 | LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 115 | *(.ctors) 116 | LONG(0) 117 | __CTOR_END__ = .; 118 | __DTOR_LIST__ = .; 119 | LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 120 | *(.dtors) 121 | LONG(0) 122 | __DTOR_END__ = .; 123 | 124 | . = ALIGN(0x10) ; 125 | _edata = . ; 126 | } > flatmem 127 | .bss : { 128 | . = ALIGN(0x4) ; 129 | _sbss = ALIGN(0x4) ; 130 | __bss_start = . ; 131 | *(.dynsbss) 132 | *(.sbss) 133 | *(.sbss.*) 134 | *(.scommon) 135 | *(.dynbss) 136 | *(.bss) 137 | *(.bss.*) 138 | *(.bss*) 139 | *(.gnu.linkonce.b*) 140 | *(COMMON) 141 | . = ALIGN(0x10) ; 142 | _ebss = . ; 143 | _end = . ; 144 | end = . ; 145 | } > flatmem 146 | 147 | .junk 0 : { *(.rel*) *(.rela*) } 148 | /* Stabs debugging sections. */ 149 | .stab 0 : { *(.stab) } 150 | .stabstr 0 : { *(.stabstr) } 151 | .stab.excl 0 : { *(.stab.excl) } 152 | .stab.exclstr 0 : { *(.stab.exclstr) } 153 | .stab.index 0 : { *(.stab.index) } 154 | .stab.indexstr 0 : { *(.stab.indexstr) } 155 | .comment 0 : { *(.comment) } 156 | .debug_abbrev 0 : { *(.debug_abbrev) } 157 | .debug_info 0 : { *(.debug_info) } 158 | .debug_line 0 : { *(.debug_line) } 159 | .debug_pubnames 0 : { *(.debug_pubnames) } 160 | .debug_aranges 0 : { *(.debug_aranges) } 161 | } 162 | -------------------------------------------------------------------------------- /elf2flt.ld.in: -------------------------------------------------------------------------------- 1 | /* This linker script is used to produce a tighter ELF program in preparation 2 | for conversion to the flat format. It takes inputs (e.g. ELF objects) and 3 | arranges their sections in the order the runtime expects. See the GNU linker 4 | script documentation for more details on the file format. 5 | https://sourceware.org/binutils/docs/ld/Scripts.html 6 | 7 | It is dynamically processed by ld-elf2flt before being passed to GNU ld which 8 | links the final ELF image (which is then passed to elf2flt to create the flat 9 | program). 10 | 11 | The "elf2flt.ld.in" file has @FOO@ symbols replaced when the elf2flt project 12 | itself is built. These should ideally be kept to a minimum to make it easier 13 | to read & understand this script. 14 | 15 | The lines below that start with "FOO:" tags are custom ld-elf2flt logic and 16 | *not* part of the linker script language. When ld-elf2flt runs, based on its 17 | flags, it will either delete the entire line or the tag itself. 18 | 19 | The tags currently defined are as follows (in no particular order). 20 | 21 | R_RODAT: 22 | W_RODAT: 23 | By default, the read-only data (.rodata) input sections are placed into the 24 | writable output data segment (via the output .data section) and before any 25 | other input data sections. The -move-rodata option moves the .rodata input 26 | to the read-only output text segment (via the output .text section). 27 | 28 | Thus, R_RODAT lines are kept by default, while W_RODAT lines are removed. 29 | 30 | TOR: 31 | The --enable-emit-ctor-dtor configure setting. 32 | 33 | By default, all TOR lines are removed. 34 | 35 | SINGLE_LINK: 36 | The --disable-emit-relocs configure setting. 37 | 38 | By default, all SINGLE_LINK are kept. 39 | */ 40 | 41 | ENTRY (@SYMBOL_PREFIX@_start) 42 | 43 | MEMORY { 44 | flatmem : ORIGIN = 0x0, LENGTH = 0xfffffff 45 | } 46 | 47 | PHDRS { 48 | text PT_LOAD ; 49 | data PT_LOAD ; 50 | } 51 | 52 | SECTIONS { 53 | 54 | .text 0x0 : { 55 | . = . + 4; 56 | . = ALIGN(0x4) ; 57 | @SYMBOL_PREFIX@_stext = . ; 58 | *(.literal .text) 59 | *(.literal.* .text.*) 60 | *(.gnu.warning) 61 | *(.stub) 62 | *(.gnu.linkonce.literal.*) 63 | *(.gnu.linkonce.t*) 64 | *(.glue_7t) 65 | *(.glue_7) 66 | *(.jcr) 67 | *(.init.literal) 68 | KEEP (*(.init)) 69 | *(.fini.literal) 70 | KEEP (*(.fini)) 71 | 72 | W_RODAT: *(.rodata) 73 | W_RODAT: *(.rodata1) 74 | W_RODAT: *(.rodata.*) 75 | W_RODAT: *(.gnu.linkonce.r*) 76 | 77 | /* .ARM.extab name sections containing exception unwinding information */ 78 | *(.ARM.extab* .gnu.linkonce.armextab.*) 79 | 80 | /* .ARM.exidx name sections containing index entries for section unwinding */ 81 | @SYMBOL_PREFIX@__exidx_start = .; 82 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) 83 | @SYMBOL_PREFIX@__exidx_end = .; 84 | 85 | /* This is special code area at the end of the normal 86 | text section. It contains a small lookup table at 87 | the start followed by the code pointed to by entries 88 | in the lookup table. */ 89 | . = ALIGN (4) ; 90 | PROVIDE(@SYMBOL_PREFIX@__ctbp = .); 91 | *(.call_table_data) 92 | *(.call_table_text) 93 | 94 | @SYMBOL_PREFIX@_etext = . ; 95 | } > flatmem :text 96 | 97 | .data ALIGN(0x20): { 98 | @SYMBOL_PREFIX@_sdata = . ; 99 | @SYMBOL_PREFIX@__data_start = . ; 100 | @SYMBOL_PREFIX@data_start = . ; 101 | *(.got.plt) 102 | *(.got) 103 | FILL(0) ; 104 | . = ALIGN(0x20) ; 105 | LONG(-1) 106 | . = ALIGN(0x20) ; 107 | RISCV_GP: __global_pointer$ = . + 0x800 ; 108 | R_RODAT: *(.rodata) 109 | R_RODAT: *(.rodata1) 110 | R_RODAT: *(.rodata.*) 111 | R_RODAT: *(.gnu.linkonce.r*) 112 | *(.data) 113 | *(.data1) 114 | *(.data.*) 115 | *(.gnu.linkonce.d*) 116 | 117 | /* Microblaze has .sdata and .sbss (small bss). They must 118 | be contiguous, so please don't move any of this. JW */ 119 | @SYMBOL_PREFIX@_ssrw = . ; 120 | *(.sdata) 121 | *(.sdata.*) 122 | *(.sbss) /* Don't move this! */ 123 | *(.gnu.linkonce.sb*) 124 | @SYMBOL_PREFIX@_essrw = . ; 125 | 126 | @SYMBOL_PREFIX@_ssrw_size = @SYMBOL_PREFIX@_essrw - @SYMBOL_PREFIX@_ssrw; 127 | PROVIDE(@SYMBOL_PREFIX@_SDA_BASE_ = @SYMBOL_PREFIX@_ssrw + (@SYMBOL_PREFIX@_ssrw_size / 2)); 128 | 129 | *(.gnu.linkonce.s.*) 130 | *(__libc_atexit) 131 | *(__libc_subinit) 132 | *(__libc_subfreeres) 133 | 134 | /* microblaze-specific read-only small data area 135 | and associated locating symbols */ 136 | @SYMBOL_PREFIX@_ssro = . ; 137 | *(.sdata2) 138 | @SYMBOL_PREFIX@_essro = . ; 139 | @SYMBOL_PREFIX@_ssro_size = @SYMBOL_PREFIX@_essro - @SYMBOL_PREFIX@_ssro; 140 | PROVIDE(@SYMBOL_PREFIX@_SDA2_BASE_ = @SYMBOL_PREFIX@_ssro + (@SYMBOL_PREFIX@_ssro_size / 2)); 141 | 142 | . = ALIGN(8) ; 143 | TOR: @SYMBOL_PREFIX@__CTOR_LIST__ = .; 144 | TOR: LONG((@SYMBOL_PREFIX@__CTOR_END__ - @SYMBOL_PREFIX@__CTOR_LIST__) / 4 - 2) 145 | SINGLE_LINK: /* gcc uses crtbegin.o to find the start of 146 | SINGLE_LINK: the constructors, so we make sure it is 147 | SINGLE_LINK: first. Because this is a wildcard, it 148 | SINGLE_LINK: doesn't matter if the user does not 149 | SINGLE_LINK: actually link against crtbegin.o; the 150 | SINGLE_LINK: linker won't look for a file to match a 151 | SINGLE_LINK: wildcard. The wildcard also means that it 152 | SINGLE_LINK: doesn't matter which directory crtbegin.o 153 | SINGLE_LINK: is in. */ 154 | SINGLE_LINK: KEEP (*crtbegin*.o(.ctors)) 155 | SINGLE_LINK: /* We don't want to include the .ctor section from 156 | SINGLE_LINK: from the crtend.o file until after the sorted ctors. 157 | SINGLE_LINK: The .ctor section from the crtend file contains the 158 | SINGLE_LINK: end of ctors marker and it must be last */ 159 | SINGLE_LINK: KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors)) 160 | SINGLE_LINK: KEEP (*(SORT(.ctors.*))) 161 | KEEP (*(.ctors)) 162 | TOR: LONG(0) 163 | TOR: @SYMBOL_PREFIX@__CTOR_END__ = .; 164 | TOR: @SYMBOL_PREFIX@__DTOR_LIST__ = .; 165 | TOR: LONG((@SYMBOL_PREFIX@__DTOR_END__ - @SYMBOL_PREFIX@__DTOR_LIST__) / 4 - 2) 166 | SINGLE_LINK: KEEP (*crtbegin*.o(.dtors)) 167 | SINGLE_LINK: KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors)) 168 | SINGLE_LINK: KEEP (*(SORT(.dtors.*))) 169 | KEEP (*(.dtors)) 170 | TOR: LONG(0) 171 | TOR: @SYMBOL_PREFIX@__DTOR_END__ = .; 172 | 173 | PROVIDE (@SYMBOL_PREFIX@__preinit_array_start = .); 174 | KEEP (*(.preinit_array)) 175 | PROVIDE (@SYMBOL_PREFIX@__preinit_array_end = .); 176 | 177 | PROVIDE (@SYMBOL_PREFIX@__init_array_start = .); 178 | KEEP (*(SORT(.init_array.*))) 179 | KEEP (*(.init_array)) 180 | PROVIDE (@SYMBOL_PREFIX@__init_array_end = .); 181 | 182 | PROVIDE (@SYMBOL_PREFIX@__fini_array_start = .); 183 | KEEP (*(.fini_array)) 184 | KEEP (*(SORT(.fini_array.*))) 185 | PROVIDE (@SYMBOL_PREFIX@__fini_array_end = .); 186 | } > flatmem :data 187 | 188 | .note.ABI-tag : { *(.note.ABI-tag) } > flatmem 189 | .eh_frame_hdr : { *(.eh_frame_hdr) } > flatmem 190 | .eh_frame : { KEEP(*(.eh_frame)) } > flatmem 191 | .gcc_except_table : { 192 | KEEP(*(.gcc_except_table)) 193 | KEEP(*(.gcc_except_table.*)) 194 | } >flatmem 195 | 196 | . = ALIGN(0x10) ; 197 | @SYMBOL_PREFIX@_edata = . ; 198 | 199 | .bss : { 200 | . = ALIGN(0x4) ; 201 | @SYMBOL_PREFIX@_sbss = ALIGN(0x4) ; 202 | @SYMBOL_PREFIX@__bss_start = . ; 203 | *(.dynsbss) 204 | *(.sbss) 205 | *(.sbss.*) 206 | *(.scommon) 207 | *(.dynbss) 208 | *(.bss) 209 | *(.bss.*) 210 | *(.bss*) 211 | *(.gnu.linkonce.b*) 212 | *(COMMON) 213 | . = ALIGN(0x10) ; 214 | @SYMBOL_PREFIX@_ebss = . ; 215 | @SYMBOL_PREFIX@_end = . ; 216 | @SYMBOL_PREFIX@end = . ; 217 | } > flatmem 218 | 219 | .stack : { 220 | . = ALIGN(0x4); 221 | @SYMBOL_PREFIX@_stack_start = .; 222 | } > flatmem 223 | 224 | .junk 0 : { *(.rel*) *(.rela*) } 225 | /DISCARD/ : { *(.note.GNU-stack) } 226 | /* Stabs debugging sections. */ 227 | .stab 0 : { *(.stab) } 228 | .stabstr 0 : { *(.stabstr) } 229 | .stab.excl 0 : { *(.stab.excl) } 230 | .stab.exclstr 0 : { *(.stab.exclstr) } 231 | .stab.index 0 : { *(.stab.index) } 232 | .stab.indexstr 0 : { *(.stab.indexstr) } 233 | .comment 0 : { *(.comment) } 234 | /* DWARF debug sections. 235 | Symbols in the DWARF debugging sections are relative to the beginning 236 | of the section so we begin them at 0. */ 237 | /* DWARF 1 */ 238 | .debug 0 : { *(.debug) } 239 | .line 0 : { *(.line) } 240 | /* GNU DWARF 1 extensions */ 241 | .debug_srcinfo 0 : { *(.debug_srcinfo) } 242 | .debug_sfnames 0 : { *(.debug_sfnames) } 243 | /* DWARF 1.1 and DWARF 2 */ 244 | .debug_aranges 0 : { *(.debug_aranges) } 245 | .debug_pubnames 0 : { *(.debug_pubnames) } 246 | /* DWARF 2 */ 247 | .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } 248 | .debug_abbrev 0 : { *(.debug_abbrev) } 249 | .debug_line 0 : { *(.debug_line) } 250 | .debug_frame 0 : { *(.debug_frame) } 251 | .debug_str 0 : { *(.debug_str) } 252 | .debug_loc 0 : { *(.debug_loc) } 253 | .debug_macinfo 0 : { *(.debug_macinfo) } 254 | /* SGI/MIPS DWARF 2 extensions */ 255 | .debug_weaknames 0 : { *(.debug_weaknames) } 256 | .debug_funcnames 0 : { *(.debug_funcnames) } 257 | .debug_typenames 0 : { *(.debug_typenames) } 258 | .debug_varnames 0 : { *(.debug_varnames) } 259 | } 260 | -------------------------------------------------------------------------------- /flat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2005 David McCullough 3 | * Copyright (C) 1998 Kenneth Albanowski 4 | * The Silver Hammer Group, Ltd. 5 | * 6 | * This file provides the definitions and structures needed to 7 | * support uClinux flat-format executables. 8 | * 9 | * This is Free Software, under the GNU Public Licence v2 or greater. 10 | * 11 | */ 12 | 13 | #ifndef _LINUX_FLAT_H 14 | #define _LINUX_FLAT_H 15 | 16 | #ifdef __KERNEL__ 17 | #include 18 | #include 19 | #endif 20 | #include 21 | 22 | #define FLAT_VERSION 0x00000004L 23 | 24 | #ifdef CONFIG_BINFMT_SHARED_FLAT 25 | #define MAX_SHARED_LIBS (4) 26 | #else 27 | #define MAX_SHARED_LIBS (1) 28 | #endif 29 | 30 | /* 31 | * To make everything easier to port and manage cross platform 32 | * development, all fields are in network byte order. 33 | */ 34 | 35 | struct flat_hdr { 36 | char magic[4]; 37 | uint32_t rev; /* version (as above) */ 38 | uint32_t entry; /* Offset of first executable instruction 39 | with text segment from beginning of file */ 40 | uint32_t data_start; /* Offset of data segment from beginning of 41 | file */ 42 | uint32_t data_end; /* Offset of end of data segment from beginning 43 | of file */ 44 | uint32_t bss_end; /* Offset of end of bss segment from beginning 45 | of file */ 46 | 47 | /* (It is assumed that data_end through bss_end forms the bss segment.) */ 48 | 49 | uint32_t stack_size; /* Size of stack, in bytes */ 50 | uint32_t reloc_start; /* Offset of relocation records from beginning 51 | of file */ 52 | uint32_t reloc_count; /* Number of relocation records */ 53 | uint32_t flags; 54 | uint32_t build_date; /* When the program/library was built */ 55 | uint32_t filler[5]; /* Reservered, set to zero */ 56 | }; 57 | 58 | #define FLAT_FLAG_RAM 0x0001 /* load program entirely into RAM */ 59 | #define FLAT_FLAG_GOTPIC 0x0002 /* program is PIC with GOT */ 60 | #define FLAT_FLAG_GZIP 0x0004 /* all but the header is compressed */ 61 | #define FLAT_FLAG_GZDATA 0x0008 /* only data/relocs are compressed (for XIP) */ 62 | #define FLAT_FLAG_KTRACE 0x0010 /* output useful kernel trace for debugging */ 63 | #define FLAT_FLAG_L1STK 0x0020 /* use a 4k stack in L1 scratch memory. */ 64 | 65 | #ifdef __KERNEL__ /* so systems without linux headers can compile the apps */ 66 | /* 67 | * While it would be nice to keep this header clean, users of older 68 | * tools still need this support in the kernel. So this section is 69 | * purely for compatibility with old tool chains. 70 | * 71 | * DO NOT make changes or enhancements to the old format please, just work 72 | * with the format above, except to fix bugs with old format support. 73 | */ 74 | 75 | #include 76 | 77 | #define OLD_FLAT_VERSION 0x00000002L 78 | #define OLD_FLAT_RELOC_TYPE_TEXT 0 79 | #define OLD_FLAT_RELOC_TYPE_DATA 1 80 | #define OLD_FLAT_RELOC_TYPE_BSS 2 81 | 82 | typedef union { 83 | uint32_t value; 84 | struct { 85 | # if defined(mc68000) && !defined(CONFIG_COLDFIRE) 86 | int32_t offset : 30; 87 | uint32_t type : 2; 88 | # define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */ 89 | # elif defined(__BIG_ENDIAN_BITFIELD) 90 | uint32_t type : 2; 91 | int32_t offset : 30; 92 | # define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */ 93 | # elif defined(__LITTLE_ENDIAN_BITFIELD) 94 | int32_t offset : 30; 95 | uint32_t type : 2; 96 | # define OLD_FLAT_FLAG_RAM 0x1 /* load program entirely into RAM */ 97 | # else 98 | # error "Unknown bitfield order for flat files." 99 | # endif 100 | } reloc; 101 | } flat_v2_reloc_t; 102 | 103 | #endif /* __KERNEL__ */ 104 | 105 | #endif /* _LINUX_FLAT_H */ 106 | 107 | /* this __MUST__ be at the VERY end of the file - do NOT move!! 108 | * Local Variables: 109 | * c-basic-offset: 4 110 | * tab-width: 8 111 | * end: 112 | * vi: tabstop=8 shiftwidth=4 textwidth=79 noexpandtab 113 | */ 114 | -------------------------------------------------------------------------------- /flthdr.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* 3 | * A simple program to manipulate flat files 4 | * 5 | * Copyright (C) 2001-2003 SnapGear Inc, davidm@snapgear.com 6 | * Copyright (C) 2001 Lineo, davidm@lineo.com 7 | * 8 | * This is Free Software, under the GNU Public Licence v2 or greater. 9 | * 10 | */ 11 | /****************************************************************************/ 12 | 13 | #include /* Userland pieces of the ANSI C standard I/O package */ 14 | #include /* Userland prototypes of the Unix std system calls */ 15 | #include 16 | #include /* exit() */ 17 | #include /* strcat(), strcpy() */ 18 | #include 19 | #include 20 | 21 | #include "compress.h" 22 | #include 23 | 24 | #include "stubs.h" 25 | const char *elf2flt_progname; 26 | 27 | /* from uClinux-x.x.x/include/linux */ 28 | #include "flat.h" /* Binary flat header description */ 29 | 30 | #if defined(__MINGW32__) 31 | #include 32 | #endif 33 | 34 | #if defined TARGET_bfin 35 | # define flat_get_relocate_addr(addr) (addr & 0x03ffffff) 36 | #else 37 | # define flat_get_relocate_addr(addr) (addr) 38 | #endif 39 | 40 | /****************************************************************************/ 41 | 42 | static int print = 0, print_relocs = 0, docompress = 0, ramload = 0, 43 | stacksize = 0, ktrace = 0, l1stack = 0; 44 | 45 | /****************************************************************************/ 46 | 47 | void 48 | process_file(const char *ifile, const char *ofile) 49 | { 50 | int old_flags, old_stack, new_flags, new_stack; 51 | stream ifp, ofp; 52 | struct flat_hdr old_hdr, new_hdr; 53 | char *tfile, tmpbuf[256]; 54 | int input_error, output_error; 55 | 56 | *tmpbuf = '\0'; 57 | 58 | if (fopen_stream_u(&ifp, ifile, "r" BINARY_FILE_OPTS)) { 59 | fprintf(stderr, "Cannot open %s\n", ifile); 60 | return; 61 | } 62 | 63 | if (fread_stream(&old_hdr, sizeof(old_hdr), 1, &ifp) != 1) { 64 | fprintf(stderr, "Cannot read header of %s\n", ifile); 65 | fclose_stream(&ifp); 66 | return; 67 | } 68 | 69 | if (strncmp(old_hdr.magic, "bFLT", 4) != 0) { 70 | fprintf(stderr, "Cannot read header of %s\n", ifile); 71 | fclose_stream(&ifp); 72 | return; 73 | } 74 | 75 | new_flags = old_flags = ntohl(old_hdr.flags); 76 | new_stack = old_stack = ntohl(old_hdr.stack_size); 77 | new_hdr = old_hdr; 78 | 79 | if (docompress == 1) { 80 | new_flags |= FLAT_FLAG_GZIP; 81 | new_flags &= ~FLAT_FLAG_GZDATA; 82 | } else if (docompress == 2) { 83 | new_flags |= FLAT_FLAG_GZDATA; 84 | new_flags &= ~FLAT_FLAG_GZIP; 85 | } else if (docompress < 0) 86 | new_flags &= ~(FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA); 87 | 88 | if (ramload > 0) 89 | new_flags |= FLAT_FLAG_RAM; 90 | else if (ramload < 0) 91 | new_flags &= ~FLAT_FLAG_RAM; 92 | 93 | if (ktrace > 0) 94 | new_flags |= FLAT_FLAG_KTRACE; 95 | else if (ktrace < 0) 96 | new_flags &= ~FLAT_FLAG_KTRACE; 97 | 98 | if (l1stack > 0) 99 | new_flags |= FLAT_FLAG_L1STK; 100 | else if (l1stack < 0) 101 | new_flags &= ~FLAT_FLAG_L1STK; 102 | 103 | if (stacksize) 104 | new_stack = stacksize; 105 | 106 | if (print == 1) { 107 | time_t t; 108 | uint32_t reloc_count, reloc_start; 109 | 110 | printf("%s\n", ifile); 111 | printf(" Magic: %4.4s\n", old_hdr.magic); 112 | printf(" Rev: %d\n", ntohl(old_hdr.rev)); 113 | t = (time_t) htonl(old_hdr.build_date); 114 | printf(" Build Date: %s", t?ctime(&t):"not specified\n"); 115 | printf(" Entry: 0x%x\n", ntohl(old_hdr.entry)); 116 | printf(" Data Start: 0x%x\n", ntohl(old_hdr.data_start)); 117 | printf(" Data End: 0x%x\n", ntohl(old_hdr.data_end)); 118 | printf(" BSS End: 0x%x\n", ntohl(old_hdr.bss_end)); 119 | printf(" Stack Size: 0x%x\n", ntohl(old_hdr.stack_size)); 120 | reloc_start = ntohl(old_hdr.reloc_start); 121 | printf(" Reloc Start: 0x%x\n", reloc_start); 122 | reloc_count = ntohl(old_hdr.reloc_count); 123 | printf(" Reloc Count: 0x%x\n", reloc_count); 124 | printf(" Flags: 0x%x ( ", ntohl(old_hdr.flags)); 125 | if (old_flags) { 126 | if (old_flags & FLAT_FLAG_RAM) 127 | printf("Load-to-Ram "); 128 | if (old_flags & FLAT_FLAG_GOTPIC) 129 | printf("Has-PIC-GOT "); 130 | if (old_flags & FLAT_FLAG_GZIP) 131 | printf("Gzip-Compressed "); 132 | if (old_flags & FLAT_FLAG_GZDATA) 133 | printf("Gzip-Data-Compressed "); 134 | if (old_flags & FLAT_FLAG_KTRACE) 135 | printf("Kernel-Traced-Load "); 136 | if (old_flags & FLAT_FLAG_L1STK) 137 | printf("L1-Scratch-Stack "); 138 | } 139 | printf(")\n"); 140 | 141 | if (print_relocs) { 142 | uint32_t *relocs = xcalloc(reloc_count, sizeof(uint32_t)); 143 | uint32_t i; 144 | unsigned long r; 145 | 146 | printf(" Relocs:\n"); 147 | printf(" #\treloc ( address )\tdata\n"); 148 | 149 | if (old_flags & FLAT_FLAG_GZIP) 150 | reopen_stream_compressed(&ifp); 151 | if (fseek_stream(&ifp, reloc_start, SEEK_SET)) { 152 | fprintf(stderr, "Cannot seek to relocs of %s\n", ifile); 153 | fclose_stream(&ifp); 154 | return; 155 | } 156 | if (fread_stream(relocs, sizeof(uint32_t), reloc_count, &ifp) == -1) { 157 | fprintf(stderr, "Cannot read relocs of %s\n", ifile); 158 | fclose_stream(&ifp); 159 | return; 160 | } 161 | 162 | for (i = 0; i < reloc_count; ++i) { 163 | uint32_t raddr, addr; 164 | r = ntohl(relocs[i]); 165 | raddr = flat_get_relocate_addr(r); 166 | printf(" %u\t0x%08lx (0x%08"PRIx32")\t", i, r, raddr); 167 | fseek_stream(&ifp, sizeof(old_hdr) + raddr, SEEK_SET); 168 | fread_stream(&addr, sizeof(addr), 1, &ifp); 169 | printf("%"PRIx32"\n", addr); 170 | } 171 | 172 | /* reset file position for below */ 173 | fseek_stream(&ifp, sizeof(old_hdr), SEEK_SET); 174 | } 175 | } else if (print > 1) { 176 | static int first = 1; 177 | unsigned int text, data, bss, stk, rel, tot; 178 | 179 | if (first) { 180 | printf("Flag Rev Text Data BSS Stack Relocs RAM Filename\n"); 181 | printf("-----------------------------------------------------------\n"); 182 | first = 0; 183 | } 184 | *tmpbuf = '\0'; 185 | strcat(tmpbuf, (old_flags & FLAT_FLAG_KTRACE) ? "k" : ""); 186 | strcat(tmpbuf, (old_flags & FLAT_FLAG_RAM) ? "r" : ""); 187 | strcat(tmpbuf, (old_flags & FLAT_FLAG_GOTPIC) ? "p" : ""); 188 | strcat(tmpbuf, (old_flags & FLAT_FLAG_GZIP) ? "z" : 189 | ((old_flags & FLAT_FLAG_GZDATA) ? "d" : "")); 190 | printf("-%-3.3s ", tmpbuf); 191 | printf("%3d ", ntohl(old_hdr.rev)); 192 | printf("%6d ", text=ntohl(old_hdr.data_start)-sizeof(struct flat_hdr)); 193 | printf("%6d ", data=ntohl(old_hdr.data_end)-ntohl(old_hdr.data_start)); 194 | printf("%6d ", bss=ntohl(old_hdr.bss_end)-ntohl(old_hdr.data_end)); 195 | printf("%6d ", stk=ntohl(old_hdr.stack_size)); 196 | printf("%6d ", rel=ntohl(old_hdr.reloc_count) * 4); 197 | /* 198 | * work out how much RAM is needed per invocation, this 199 | * calculation is dependent on the binfmt_flat implementation 200 | */ 201 | tot = data; /* always need data */ 202 | 203 | if (old_flags & (FLAT_FLAG_RAM|FLAT_FLAG_GZIP)) 204 | tot += text + sizeof(struct flat_hdr); 205 | 206 | if (bss + stk > rel) /* which is bigger ? */ 207 | tot += bss + stk; 208 | else 209 | tot += rel; 210 | 211 | printf("%6d ", tot); 212 | /* 213 | * the total depends on whether the relocs are smaller/bigger than 214 | * the BSS 215 | */ 216 | printf("%s\n", ifile); 217 | } 218 | 219 | /* if there is nothing else to do, leave */ 220 | if (new_flags == old_flags && new_stack == old_stack) { 221 | fclose_stream(&ifp); 222 | return; 223 | } 224 | 225 | new_hdr.flags = htonl(new_flags); 226 | new_hdr.stack_size = htonl(new_stack); 227 | 228 | tfile = make_temp_file("flthdr"); 229 | 230 | if (fopen_stream_u(&ofp, tfile, "w" BINARY_FILE_OPTS)) { 231 | unlink(tfile); 232 | fatal("Failed to open %s for writing\n", tfile); 233 | } 234 | 235 | /* Copy header (always uncompressed). */ 236 | if (fwrite_stream(&new_hdr, sizeof(new_hdr), 1, &ofp) != 1) { 237 | unlink(tfile); 238 | fatal("Failed to write to %s\n", tfile); 239 | } 240 | 241 | /* Whole input file (including text) is compressed: start decompressing 242 | now. */ 243 | if (old_flags & FLAT_FLAG_GZIP) 244 | reopen_stream_compressed(&ifp); 245 | 246 | /* Likewise, output file is compressed. Start compressing now. */ 247 | if (new_flags & FLAT_FLAG_GZIP) { 248 | printf("zflat %s --> %s\n", ifile, ofile); 249 | reopen_stream_compressed(&ofp); 250 | } 251 | 252 | transfer(&ifp, &ofp, 253 | ntohl(old_hdr.data_start) - sizeof(struct flat_hdr)); 254 | 255 | /* Only data and relocs were compressed in input. Start decompressing 256 | from here. */ 257 | if (old_flags & FLAT_FLAG_GZDATA) 258 | reopen_stream_compressed(&ifp); 259 | 260 | /* Only data/relocs to be compressed in output. Start compressing 261 | from here. */ 262 | if (new_flags & FLAT_FLAG_GZDATA) { 263 | printf("zflat-data %s --> %s\n", ifile, ofile); 264 | reopen_stream_compressed(&ofp); 265 | } 266 | 267 | transfer(&ifp, &ofp, -1); 268 | 269 | input_error = ferror_stream(&ifp); 270 | output_error = ferror_stream(&ofp); 271 | 272 | if (input_error || output_error) { 273 | unlink(tfile); 274 | fatal("Error on file pointer%s%s\n", 275 | input_error ? " input" : "", 276 | output_error ? " output" : ""); 277 | } 278 | 279 | fclose_stream(&ifp); 280 | fclose_stream(&ofp); 281 | 282 | /* Copy temporary file to output location. */ 283 | fopen_stream_u(&ifp, tfile, "r" BINARY_FILE_OPTS); 284 | fopen_stream_u(&ofp, ofile, "w" BINARY_FILE_OPTS); 285 | 286 | transfer(&ifp, &ofp, -1); 287 | 288 | fclose_stream(&ifp); 289 | fclose_stream(&ofp); 290 | 291 | unlink(tfile); 292 | free(tfile); 293 | } 294 | 295 | /****************************************************************************/ 296 | 297 | void 298 | usage(const char *s) 299 | { 300 | FILE *out = s ? stderr : stdout; 301 | if (s) 302 | fprintf(out, "%s\n", s); 303 | fprintf(out, 304 | "Usage: %s [options] flat-file\n" 305 | " Allows you to change an existing flat file\n\n" 306 | " -p : print current settings\n" 307 | " -P : print relocations\n" 308 | " -z : compressed flat file\n" 309 | " -d : compressed data-only flat file\n" 310 | " -Z : un-compressed flat file\n" 311 | " -r : ram load\n" 312 | " -R : do not RAM load\n" 313 | " -k : kernel traced load (for debug)\n" 314 | " -K : normal non-kernel traced load\n" 315 | " -u : place stack in L1 scratchpad memory\n" 316 | " -U : place stack in normal SDRAM memory\n" 317 | " -s size : stack size\n" 318 | " -o file : output-file\n" 319 | " (default is to modify input file)\n", 320 | elf2flt_progname); 321 | exit(s ? 1 : 0); 322 | } 323 | 324 | /****************************************************************************/ 325 | 326 | int 327 | main(int argc, char *argv[]) 328 | { 329 | int c, noargs; 330 | const char *ofile = NULL, *ifile; 331 | 332 | elf2flt_progname = argv[0]; 333 | 334 | noargs = 1; 335 | while ((c = getopt(argc, argv, "hpPdzZrRuUkKs:o:")) != EOF) { 336 | switch (c) { 337 | case 'p': print = 1; break; 338 | case 'P': print = print_relocs = 1; break; 339 | case 'z': docompress = 1; break; 340 | case 'd': docompress = 2; break; 341 | case 'Z': docompress = -1; break; 342 | case 'r': ramload = 1; break; 343 | case 'R': ramload = -1; break; 344 | case 'k': ktrace = 1; break; 345 | case 'K': ktrace = -1; break; 346 | case 'u': l1stack = 1; break; 347 | case 'U': l1stack = -1; break; 348 | case 'o': ofile = optarg; break; 349 | case 's': 350 | if (sscanf(optarg, "%i", &stacksize) != 1) 351 | usage("invalid stack size"); 352 | break; 353 | case 'h': 354 | usage(NULL); 355 | break; 356 | default: 357 | usage("invalid option"); 358 | break; 359 | } 360 | noargs = 0; 361 | } 362 | 363 | if (optind >= argc) 364 | usage("No input files provided"); 365 | 366 | if (ofile && argc - optind > 1) 367 | usage("-o can only be used with a single file"); 368 | 369 | if (!print && noargs) /* no args == print */ 370 | print = argc - optind; /* greater than 1 is short format */ 371 | 372 | for (c = optind; c < argc; c++) { 373 | ifile = argv[c]; 374 | if (!ofile) 375 | ofile = ifile; 376 | process_file(ifile, ofile); 377 | ofile = NULL; 378 | } 379 | 380 | exit(0); 381 | } 382 | 383 | /****************************************************************************/ 384 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2013-12-25.23; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # 'make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | tab=' ' 45 | nl=' 46 | ' 47 | IFS=" $tab$nl" 48 | 49 | # Set DOITPROG to "echo" to test this script. 50 | 51 | doit=${DOITPROG-} 52 | doit_exec=${doit:-exec} 53 | 54 | # Put in absolute file names if you don't have them in your path; 55 | # or use environment vars. 56 | 57 | chgrpprog=${CHGRPPROG-chgrp} 58 | chmodprog=${CHMODPROG-chmod} 59 | chownprog=${CHOWNPROG-chown} 60 | cmpprog=${CMPPROG-cmp} 61 | cpprog=${CPPROG-cp} 62 | mkdirprog=${MKDIRPROG-mkdir} 63 | mvprog=${MVPROG-mv} 64 | rmprog=${RMPROG-rm} 65 | stripprog=${STRIPPROG-strip} 66 | 67 | posix_mkdir= 68 | 69 | # Desired mode of installed file. 70 | mode=0755 71 | 72 | chgrpcmd= 73 | chmodcmd=$chmodprog 74 | chowncmd= 75 | mvcmd=$mvprog 76 | rmcmd="$rmprog -f" 77 | stripcmd= 78 | 79 | src= 80 | dst= 81 | dir_arg= 82 | dst_arg= 83 | 84 | copy_on_change=false 85 | is_target_a_directory=possibly 86 | 87 | usage="\ 88 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 89 | or: $0 [OPTION]... SRCFILES... DIRECTORY 90 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 91 | or: $0 [OPTION]... -d DIRECTORIES... 92 | 93 | In the 1st form, copy SRCFILE to DSTFILE. 94 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 95 | In the 4th, create DIRECTORIES. 96 | 97 | Options: 98 | --help display this help and exit. 99 | --version display version info and exit. 100 | 101 | -c (ignored) 102 | -C install only if different (preserve the last data modification time) 103 | -d create directories instead of installing files. 104 | -g GROUP $chgrpprog installed files to GROUP. 105 | -m MODE $chmodprog installed files to MODE. 106 | -o USER $chownprog installed files to USER. 107 | -s $stripprog installed files. 108 | -t DIRECTORY install into DIRECTORY. 109 | -T report an error if DSTFILE is a directory. 110 | 111 | Environment variables override the default commands: 112 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 113 | RMPROG STRIPPROG 114 | " 115 | 116 | while test $# -ne 0; do 117 | case $1 in 118 | -c) ;; 119 | 120 | -C) copy_on_change=true;; 121 | 122 | -d) dir_arg=true;; 123 | 124 | -g) chgrpcmd="$chgrpprog $2" 125 | shift;; 126 | 127 | --help) echo "$usage"; exit $?;; 128 | 129 | -m) mode=$2 130 | case $mode in 131 | *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) 132 | echo "$0: invalid mode: $mode" >&2 133 | exit 1;; 134 | esac 135 | shift;; 136 | 137 | -o) chowncmd="$chownprog $2" 138 | shift;; 139 | 140 | -s) stripcmd=$stripprog;; 141 | 142 | -t) 143 | is_target_a_directory=always 144 | dst_arg=$2 145 | # Protect names problematic for 'test' and other utilities. 146 | case $dst_arg in 147 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 148 | esac 149 | shift;; 150 | 151 | -T) is_target_a_directory=never;; 152 | 153 | --version) echo "$0 $scriptversion"; exit $?;; 154 | 155 | --) shift 156 | break;; 157 | 158 | -*) echo "$0: invalid option: $1" >&2 159 | exit 1;; 160 | 161 | *) break;; 162 | esac 163 | shift 164 | done 165 | 166 | # We allow the use of options -d and -T together, by making -d 167 | # take the precedence; this is for compatibility with GNU install. 168 | 169 | if test -n "$dir_arg"; then 170 | if test -n "$dst_arg"; then 171 | echo "$0: target directory not allowed when installing a directory." >&2 172 | exit 1 173 | fi 174 | fi 175 | 176 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 177 | # When -d is used, all remaining arguments are directories to create. 178 | # When -t is used, the destination is already specified. 179 | # Otherwise, the last argument is the destination. Remove it from $@. 180 | for arg 181 | do 182 | if test -n "$dst_arg"; then 183 | # $@ is not empty: it contains at least $arg. 184 | set fnord "$@" "$dst_arg" 185 | shift # fnord 186 | fi 187 | shift # arg 188 | dst_arg=$arg 189 | # Protect names problematic for 'test' and other utilities. 190 | case $dst_arg in 191 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 192 | esac 193 | done 194 | fi 195 | 196 | if test $# -eq 0; then 197 | if test -z "$dir_arg"; then 198 | echo "$0: no input file specified." >&2 199 | exit 1 200 | fi 201 | # It's OK to call 'install-sh -d' without argument. 202 | # This can happen when creating conditional directories. 203 | exit 0 204 | fi 205 | 206 | if test -z "$dir_arg"; then 207 | if test $# -gt 1 || test "$is_target_a_directory" = always; then 208 | if test ! -d "$dst_arg"; then 209 | echo "$0: $dst_arg: Is not a directory." >&2 210 | exit 1 211 | fi 212 | fi 213 | fi 214 | 215 | if test -z "$dir_arg"; then 216 | do_exit='(exit $ret); exit $ret' 217 | trap "ret=129; $do_exit" 1 218 | trap "ret=130; $do_exit" 2 219 | trap "ret=141; $do_exit" 13 220 | trap "ret=143; $do_exit" 15 221 | 222 | # Set umask so as not to create temps with too-generous modes. 223 | # However, 'strip' requires both read and write access to temps. 224 | case $mode in 225 | # Optimize common cases. 226 | *644) cp_umask=133;; 227 | *755) cp_umask=22;; 228 | 229 | *[0-7]) 230 | if test -z "$stripcmd"; then 231 | u_plus_rw= 232 | else 233 | u_plus_rw='% 200' 234 | fi 235 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 236 | *) 237 | if test -z "$stripcmd"; then 238 | u_plus_rw= 239 | else 240 | u_plus_rw=,u+rw 241 | fi 242 | cp_umask=$mode$u_plus_rw;; 243 | esac 244 | fi 245 | 246 | for src 247 | do 248 | # Protect names problematic for 'test' and other utilities. 249 | case $src in 250 | -* | [=\(\)!]) src=./$src;; 251 | esac 252 | 253 | if test -n "$dir_arg"; then 254 | dst=$src 255 | dstdir=$dst 256 | test -d "$dstdir" 257 | dstdir_status=$? 258 | else 259 | 260 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 261 | # might cause directories to be created, which would be especially bad 262 | # if $src (and thus $dsttmp) contains '*'. 263 | if test ! -f "$src" && test ! -d "$src"; then 264 | echo "$0: $src does not exist." >&2 265 | exit 1 266 | fi 267 | 268 | if test -z "$dst_arg"; then 269 | echo "$0: no destination specified." >&2 270 | exit 1 271 | fi 272 | dst=$dst_arg 273 | 274 | # If destination is a directory, append the input filename; won't work 275 | # if double slashes aren't ignored. 276 | if test -d "$dst"; then 277 | if test "$is_target_a_directory" = never; then 278 | echo "$0: $dst_arg: Is a directory" >&2 279 | exit 1 280 | fi 281 | dstdir=$dst 282 | dst=$dstdir/`basename "$src"` 283 | dstdir_status=0 284 | else 285 | dstdir=`dirname "$dst"` 286 | test -d "$dstdir" 287 | dstdir_status=$? 288 | fi 289 | fi 290 | 291 | obsolete_mkdir_used=false 292 | 293 | if test $dstdir_status != 0; then 294 | case $posix_mkdir in 295 | '') 296 | # Create intermediate dirs using mode 755 as modified by the umask. 297 | # This is like FreeBSD 'install' as of 1997-10-28. 298 | umask=`umask` 299 | case $stripcmd.$umask in 300 | # Optimize common cases. 301 | *[2367][2367]) mkdir_umask=$umask;; 302 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 303 | 304 | *[0-7]) 305 | mkdir_umask=`expr $umask + 22 \ 306 | - $umask % 100 % 40 + $umask % 20 \ 307 | - $umask % 10 % 4 + $umask % 2 308 | `;; 309 | *) mkdir_umask=$umask,go-w;; 310 | esac 311 | 312 | # With -d, create the new directory with the user-specified mode. 313 | # Otherwise, rely on $mkdir_umask. 314 | if test -n "$dir_arg"; then 315 | mkdir_mode=-m$mode 316 | else 317 | mkdir_mode= 318 | fi 319 | 320 | posix_mkdir=false 321 | case $umask in 322 | *[123567][0-7][0-7]) 323 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 324 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 325 | ;; 326 | *) 327 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 328 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 329 | 330 | if (umask $mkdir_umask && 331 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 332 | then 333 | if test -z "$dir_arg" || { 334 | # Check for POSIX incompatibilities with -m. 335 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 336 | # other-writable bit of parent directory when it shouldn't. 337 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 338 | ls_ld_tmpdir=`ls -ld "$tmpdir"` 339 | case $ls_ld_tmpdir in 340 | d????-?r-*) different_mode=700;; 341 | d????-?--*) different_mode=755;; 342 | *) false;; 343 | esac && 344 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { 345 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 346 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 347 | } 348 | } 349 | then posix_mkdir=: 350 | fi 351 | rmdir "$tmpdir/d" "$tmpdir" 352 | else 353 | # Remove any dirs left behind by ancient mkdir implementations. 354 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 355 | fi 356 | trap '' 0;; 357 | esac;; 358 | esac 359 | 360 | if 361 | $posix_mkdir && ( 362 | umask $mkdir_umask && 363 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 364 | ) 365 | then : 366 | else 367 | 368 | # The umask is ridiculous, or mkdir does not conform to POSIX, 369 | # or it failed possibly due to a race condition. Create the 370 | # directory the slow way, step by step, checking for races as we go. 371 | 372 | case $dstdir in 373 | /*) prefix='/';; 374 | [-=\(\)!]*) prefix='./';; 375 | *) prefix='';; 376 | esac 377 | 378 | oIFS=$IFS 379 | IFS=/ 380 | set -f 381 | set fnord $dstdir 382 | shift 383 | set +f 384 | IFS=$oIFS 385 | 386 | prefixes= 387 | 388 | for d 389 | do 390 | test X"$d" = X && continue 391 | 392 | prefix=$prefix$d 393 | if test -d "$prefix"; then 394 | prefixes= 395 | else 396 | if $posix_mkdir; then 397 | (umask=$mkdir_umask && 398 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 399 | # Don't fail if two instances are running concurrently. 400 | test -d "$prefix" || exit 1 401 | else 402 | case $prefix in 403 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 404 | *) qprefix=$prefix;; 405 | esac 406 | prefixes="$prefixes '$qprefix'" 407 | fi 408 | fi 409 | prefix=$prefix/ 410 | done 411 | 412 | if test -n "$prefixes"; then 413 | # Don't fail if two instances are running concurrently. 414 | (umask $mkdir_umask && 415 | eval "\$doit_exec \$mkdirprog $prefixes") || 416 | test -d "$dstdir" || exit 1 417 | obsolete_mkdir_used=true 418 | fi 419 | fi 420 | fi 421 | 422 | if test -n "$dir_arg"; then 423 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 424 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 425 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 426 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 427 | else 428 | 429 | # Make a couple of temp file names in the proper directory. 430 | dsttmp=$dstdir/_inst.$$_ 431 | rmtmp=$dstdir/_rm.$$_ 432 | 433 | # Trap to clean up those temp files at exit. 434 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 435 | 436 | # Copy the file name to the temp name. 437 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 438 | 439 | # and set any options; do chmod last to preserve setuid bits. 440 | # 441 | # If any of these fail, we abort the whole thing. If we want to 442 | # ignore errors from any of these, just make sure not to ignore 443 | # errors from the above "$doit $cpprog $src $dsttmp" command. 444 | # 445 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 446 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 447 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 448 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 449 | 450 | # If -C, don't bother to copy if it wouldn't change the file. 451 | if $copy_on_change && 452 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 453 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 454 | set -f && 455 | set X $old && old=:$2:$4:$5:$6 && 456 | set X $new && new=:$2:$4:$5:$6 && 457 | set +f && 458 | test "$old" = "$new" && 459 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 460 | then 461 | rm -f "$dsttmp" 462 | else 463 | # Rename the file to the real destination. 464 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 465 | 466 | # The rename failed, perhaps because mv can't rename something else 467 | # to itself, or perhaps because mv is so ancient that it does not 468 | # support -f. 469 | { 470 | # Now remove or move aside any old file at destination location. 471 | # We try this two ways since rm can't unlink itself on some 472 | # systems and the destination file might be busy for other 473 | # reasons. In this case, the final cleanup might fail but the new 474 | # file should still install successfully. 475 | { 476 | test ! -f "$dst" || 477 | $doit $rmcmd -f "$dst" 2>/dev/null || 478 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 479 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 480 | } || 481 | { echo "$0: cannot unlink or rename $dst" >&2 482 | (exit 1); exit 1 483 | } 484 | } && 485 | 486 | # Now rename the file to the real destination. 487 | $doit $mvcmd "$dsttmp" "$dst" 488 | } 489 | fi || exit 1 490 | 491 | trap '' 0 492 | fi 493 | done 494 | 495 | # Local variables: 496 | # eval: (add-hook 'write-file-hooks 'time-stamp) 497 | # time-stamp-start: "scriptversion=" 498 | # time-stamp-format: "%:y-%02m-%02d.%02H" 499 | # time-stamp-time-zone: "UTC" 500 | # time-stamp-end: "; # UTC" 501 | # End: 502 | -------------------------------------------------------------------------------- /ld-elf2flt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Wrapper for the real linker and the elf2flt converter. This was 3 | * originally a simple shell script, but that doesn't work on a 4 | * Windows host without cygwin. 5 | * The proper long term solution is to add FLT as a BFD output format. 6 | * 7 | * Converted from ld-elf2flt.in by Nathan Sidwell, nathan@codesourcery.com. 8 | * Updated to latest elf2flt code by Mike Frysinger, vapier@gentoo.org. 9 | * 10 | * This is Free Software, under the GNU General Public License V2 or greater. 11 | * 12 | * Copyright (C) 2006, CodeSourcery Inc. 13 | * Copyright (C) 2009, Analog Devices, Inc. 14 | * Copyright (C) 2002-2003 David McCullough 15 | * Copyright (C) 2000, Lineo. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "stubs.h" 30 | const char *elf2flt_progname; 31 | 32 | static int flag_verbose = 0, flag_final = 1, have_elf2flt_options = 0, 33 | flag_move_data = 0, want_shared = 0; 34 | static const char *shared_lib_id = NULL; 35 | static const char *output_file = "a.out"; 36 | static const char *linker_script = NULL; 37 | static const char *emulation = NULL; 38 | static const char *tmp_file = NULL; 39 | static const char *output_gdb = NULL; 40 | static const char *output_elf = NULL; 41 | static const char *output_flt = NULL; 42 | static options_t search_dirs, all_options, other_options, flt_options; 43 | 44 | static const char *linker = NULL; 45 | static const char *elf2flt = NULL; 46 | static const char *nm = NULL; 47 | static const char *objdump = NULL; 48 | static const char *objcopy = NULL; 49 | static const char *ldscriptpath = BINUTILS_LDSCRIPTDIR; 50 | 51 | /* A list of sed commands */ 52 | typedef struct { 53 | options_t *pattern; /* '^' for start of line match, everything else verbatim */ 54 | options_t *replacement; /* Delete line, if NULL */ 55 | } sed_commands_t; 56 | 57 | /* Initialize a sed structure */ 58 | #define init_sed(DST) ( \ 59 | (DST)->pattern = xmalloc(sizeof(*(DST)->pattern)), \ 60 | (DST)->replacement = xmalloc(sizeof(*(DST)->replacement)), \ 61 | init_options((DST)->pattern), \ 62 | init_options((DST)->replacement) \ 63 | ) 64 | #define free_sed(DST) (free((DST)->pattern), free((DST)->replacement)) 65 | 66 | /* Append a slot for a new sed command. */ 67 | static void append_sed(sed_commands_t *dst, const char *pattern, 68 | const char *replacement) 69 | { 70 | debug1("adding pattern '%s' with replacement '%s'\n", 71 | pattern, replacement); 72 | append_option(dst->pattern, pattern); 73 | append_option(dst->replacement, replacement); 74 | } 75 | 76 | /* Execute an external program COMMAND. Write its stdout to OUTPUT, 77 | unless that is NULL. Pass the trailing NULL terminated list of 78 | options, followed by all those in OPTIONS, if that is non-NULL. 79 | Order of options is important here as we may run on systems that 80 | do not allow options after non-options (i.e. many BSDs). So the 81 | final command line will look like: 82 | [options] [... va args ...] 83 | This is because [options] will (should?) never contain non-options, 84 | while non-options will always be passed via the [va args]. 85 | */ 86 | static int 87 | execute(const char *command, const char *output, const options_t *options, ...) 88 | { 89 | struct pex_obj *pex; 90 | const char *errmsg; 91 | int err; 92 | int status; 93 | va_list args; 94 | const char *opt; 95 | options_t opts; 96 | 97 | debug("command=%s\n", command); 98 | 99 | init_options(&opts); 100 | append_option(&opts, command); 101 | if (options) 102 | append_options(&opts, options); 103 | va_start(args, options); 104 | while ((opt = va_arg(args, const char *))) 105 | append_option(&opts, opt); 106 | va_end(args); 107 | append_option(&opts, NULL); 108 | 109 | fflush(stdout); 110 | fflush(stderr); 111 | 112 | pex = pex_init(0, elf2flt_progname, NULL); 113 | if (pex == NULL) 114 | fatal_perror("pex_init failed"); 115 | 116 | if (flag_verbose) { 117 | unsigned ix; 118 | 119 | fprintf(stderr, "Invoking:"); 120 | for (ix = 0; ix != opts.num - 1; ix++) 121 | fprintf(stderr, " '%s'", opts.options[ix]); 122 | if (output) 123 | fprintf(stderr, " > '%s'", output); 124 | fprintf(stderr, "\n"); 125 | } 126 | 127 | errmsg = pex_run(pex, PEX_LAST | PEX_SEARCH, command, 128 | (char *const *)opts.options, output, NULL, &err); 129 | if (errmsg != NULL) { 130 | if (err != 0) { 131 | errno = err; 132 | fatal_perror(errmsg); 133 | } else 134 | fatal(errmsg); 135 | } 136 | 137 | if (!pex_get_status(pex, 1, &status)) 138 | fatal_perror("can't get program status"); 139 | pex_free(pex); 140 | 141 | if (status) { 142 | if (WIFSIGNALED(status)) { 143 | int sig = WTERMSIG(status); 144 | 145 | fatal("%s terminated with signal %d [%s]%s", 146 | command, sig, strsignal(sig), 147 | WCOREDUMP(status) ? ", core dumped" : ""); 148 | } 149 | 150 | if (WIFEXITED(status)) 151 | return WEXITSTATUS(status); 152 | } 153 | return 0; 154 | } 155 | /* Auto NULL terminate */ 156 | #define execute(...) execute(__VA_ARGS__, NULL) 157 | 158 | /* Apply the sed commands in SED to file NAME_IN producing file NAME_OUT */ 159 | static void 160 | do_sed(const sed_commands_t *sed, const char *name_in, const char *name_out) 161 | { 162 | FILE *in, *out; 163 | size_t alloc = 0; 164 | char *line = NULL; 165 | ssize_t len; 166 | const char *pattern, *replacement; 167 | int ix; 168 | 169 | if (flag_verbose) { 170 | fprintf(stderr, "emulating: sed \\\n"); 171 | for (ix = 0; ix != sed->pattern->num; ix++) { 172 | pattern = sed->pattern->options[ix]; 173 | replacement = sed->replacement->options[ix]; 174 | if (replacement) 175 | fprintf(stderr, "\t-e 's/%s/%s/' \\\n", pattern, replacement); 176 | else 177 | fprintf(stderr, "\t-e '/%s/d' \\\n", pattern); 178 | } 179 | fprintf(stderr, "\t%s > %s\n", name_in, name_out); 180 | } 181 | 182 | in = xfopen(name_in, "r"); 183 | out = xfopen(name_out, "w"); 184 | 185 | while ((len = getline(&line, &alloc, in)) > 0) { 186 | debug2("len=%2zi line=%s", len, line); 187 | 188 | for (ix = 0; ix != sed->pattern->num; ix++) { 189 | const char *ptr; 190 | int bol; 191 | size_t pat_len; 192 | 193 | pattern = sed->pattern->options[ix]; 194 | replacement = sed->replacement->options[ix]; 195 | ptr = line; 196 | bol = pattern[0] == '^'; 197 | 198 | pattern += bol; 199 | pat_len = strlen(pattern); 200 | 201 | if (!bol) { 202 | do { 203 | ptr = strchr(ptr, pattern[0]); 204 | if (!ptr) ; 205 | else if (!strncmp(ptr, pattern, pat_len)) 206 | goto found; 207 | else 208 | ptr++; 209 | } 210 | while (ptr); 211 | } else if (!strncmp(ptr, pattern, pat_len)) { 212 | found: 213 | if (replacement) { 214 | debug2(" [modified]\n"); 215 | fwrite(line, 1, ptr - line, out); 216 | fwrite(replacement, 1, strlen(replacement), out); 217 | fwrite(ptr + pat_len, 1, 218 | len - pat_len - (ptr - line), 219 | out); 220 | } else 221 | debug2(" {dropped}\n"); 222 | goto next_line; 223 | } 224 | } 225 | 226 | debug2("(untouched)\n"); 227 | fwrite(line, 1, len, out); 228 | next_line: 229 | ; 230 | } 231 | fclose(in); 232 | if (fclose(out)) 233 | fatal_perror("error writing temporary script '%s'", name_out); 234 | free(line); 235 | } 236 | 237 | /* Generate the flt binary along with any other necessary pieces. */ 238 | #define exec_or_ret(...) \ 239 | do { \ 240 | int status = execute(__VA_ARGS__); \ 241 | if (status) return status; \ 242 | } while (0) 243 | static int do_final_link(void) 244 | { 245 | sed_commands_t sed; 246 | struct stat buf; 247 | const char *script; 248 | const char *rel_output; 249 | int have_got = 0; 250 | FILE *in; 251 | char *line = NULL; 252 | size_t alloc = 0; 253 | ssize_t len; 254 | 255 | init_sed(&sed); 256 | 257 | if (flag_move_data) { 258 | FILE *in; 259 | 260 | /* See if the .rodata section contains any relocations. */ 261 | if (!output_flt) 262 | output_flt = make_temp_file(NULL); 263 | exec_or_ret(linker, NULL, &other_options, "-r", "-d", "-o", output_flt); 264 | exec_or_ret(objdump, tmp_file, NULL, "-h", output_flt); 265 | 266 | in = xfopen(tmp_file, "r"); 267 | while ((len = getline(&line, &alloc, in)) > 0) { 268 | const char *ptr = line; 269 | 270 | while (1) { 271 | ptr = strchr(ptr, '.'); 272 | if (!ptr) 273 | break; 274 | if (streqn(ptr, ".rodata")) { 275 | if (getline(&line, &alloc, in) == -1) 276 | break; 277 | ptr = line; 278 | while (1) { 279 | ptr = strchr(ptr, 'R'); 280 | if (!ptr) 281 | break; 282 | if (streqn(ptr, "RELOC")) { 283 | flag_move_data = 0; 284 | fprintf(stderr, "warning: .rodata section contains relocations"); 285 | break; 286 | } else 287 | ptr++; 288 | } 289 | break; 290 | } else 291 | ptr++; 292 | } 293 | } 294 | fclose(in); 295 | } 296 | append_sed(&sed, "^R_RODAT:", flag_move_data ? NULL : ""); 297 | append_sed(&sed, "^W_RODAT:", flag_move_data ? "" : NULL); 298 | append_sed(&sed, "^SINGLE_LINK:", USE_EMIT_RELOCS ? "" : NULL); 299 | append_sed(&sed, "^TOR:", EMIT_CTOR_DTOR ? "" : NULL); 300 | 301 | if (shared_lib_id) { 302 | const char *got_offset; 303 | int adj, id = strtol(shared_lib_id, NULL, 0); 304 | char buf[30]; 305 | 306 | /* Replace addresses using the shared object id. */ 307 | sprintf(buf, "%.2X", id); 308 | append_sed(&sed, "ORIGIN = 0x0,", concat("ORIGIN = 0x", buf, "000000,", NULL)); 309 | append_sed(&sed, ".text 0x0 :", concat(".text 0x0", buf, "000000 :", NULL)); 310 | if (id) 311 | append_sed(&sed, "ENTRY (" SYMBOL_PREFIX "_start)", "ENTRY (lib_main)"); 312 | 313 | /* Provide the symbol specifying the library's data segment 314 | pointer offset. */ 315 | adj = 4; 316 | if (streq(TARGET_CPU, "h8300")) 317 | got_offset = "__current_shared_library_er5_offset_"; 318 | else if (streq(TARGET_CPU, "bfin")) 319 | got_offset = "_current_shared_library_p5_offset_", adj = 1; 320 | else 321 | got_offset = "_current_shared_library_a5_offset_"; 322 | append_option(&other_options, "-defsym"); 323 | sprintf(buf, "%d", id * -adj - adj); 324 | append_option(&other_options, concat(got_offset, "=", buf, NULL)); 325 | } 326 | 327 | /* riscv adds a global pointer symbol to the linker file with the 328 | "RISCV_GP:" prefix. Remove the prefix for riscv64 architecture and 329 | the entire line for other architectures. */ 330 | if (streq(TARGET_CPU, "riscv64") || streq(TARGET_CPU, "riscv32")) 331 | append_sed(&sed, "^RISCV_GP:", ""); 332 | else 333 | append_sed(&sed, "^RISCV_GP:", NULL); 334 | 335 | /* Locate the default linker script, if we don't have one provided. */ 336 | if (!linker_script) 337 | linker_script = concat(ldscriptpath, "/elf2flt.ld", NULL); 338 | 339 | /* Try and locate the linker script. */ 340 | script = linker_script; 341 | if (stat(script, &buf) || !S_ISREG(buf.st_mode)) { 342 | script = concat(ldscriptpath, "/", linker_script, NULL); 343 | if (stat(script, &buf) || !S_ISREG(buf.st_mode)) { 344 | script = concat(ldscriptpath, "/ldscripts/", linker_script, NULL); 345 | if (stat(script, &buf) || !S_ISREG(buf.st_mode)) 346 | script = NULL; 347 | } 348 | } 349 | /* And process it if we can -- if we can't find it, the user must 350 | know what they are doing. */ 351 | if (script) { 352 | do_sed(&sed, linker_script, tmp_file); 353 | linker_script = tmp_file; 354 | } 355 | free_sed(&sed); 356 | 357 | if (USE_EMIT_RELOCS) { 358 | 359 | exec_or_ret(linker, NULL, &other_options, 360 | "-T", linker_script, "-q", "-o", output_gdb, emulation); 361 | 362 | append_option(&flt_options, "-a"); 363 | rel_output = output_gdb; 364 | 365 | } else if (NO_GOT_CHECK) { 366 | 367 | output_elf = make_temp_file(NULL); 368 | 369 | exec_or_ret(linker, NULL, &other_options, 370 | "-T", linker_script, "-Ur", "-d", "-o", output_elf, emulation); 371 | exec_or_ret(linker, NULL, &other_options, 372 | "-T", linker_script, "-o", output_gdb, emulation); 373 | 374 | rel_output = output_elf; 375 | 376 | } else { 377 | 378 | output_flt = make_temp_file(NULL); 379 | exec_or_ret(linker, NULL, &other_options, 380 | "-r", "-d", "-o", output_flt, emulation); 381 | 382 | output_elf = make_temp_file(NULL); 383 | exec_or_ret(linker, NULL, &search_dirs, 384 | "-T", linker_script, "-Ur", "-o", output_elf, output_flt, emulation); 385 | 386 | exec_or_ret(linker, NULL, &search_dirs, 387 | "-T", linker_script, "-o", output_gdb, output_flt, emulation); 388 | 389 | rel_output = output_elf; 390 | 391 | } 392 | 393 | if (shared_lib_id && strtol(shared_lib_id, NULL, 0) != 0) 394 | exec_or_ret(objcopy, NULL, NULL, "--localize-hidden", "--weaken", output_gdb); 395 | 396 | exec_or_ret(nm, tmp_file, NULL, "-p", output_gdb); 397 | in = xfopen(tmp_file, "r"); 398 | while ((len = getline(&line, &alloc, in)) > 0) { 399 | const char *ptr = strchr(line, '_'); 400 | if (ptr && streqn(ptr, "_GLOBAL_OFFSET_TABLE")) { 401 | have_got = 1; 402 | break; 403 | } 404 | } 405 | fclose(in); 406 | if (have_got) 407 | exec_or_ret(elf2flt, NULL, &flt_options, 408 | "-o", output_file, "-p", output_gdb, rel_output); 409 | else 410 | exec_or_ret(elf2flt, NULL, &flt_options, 411 | "-o", output_file, "-r", rel_output); 412 | 413 | return 0; 414 | } 415 | 416 | /* parse all the arguments provided to us */ 417 | static void parse_args(int argc, char **argv) 418 | { 419 | char *fltflags; 420 | int argno; 421 | 422 | for (argno = 1; argno < argc; argno++) { 423 | char const *arg = argv[argno]; 424 | int to_all = argno; 425 | 426 | if (streq(arg, "-elf2flt")) { 427 | have_elf2flt_options = 1; 428 | to_all++; 429 | } else if (streqn(arg, "-elf2flt=")) { 430 | have_elf2flt_options = 1; 431 | append_option_str(&flt_options, &arg[9], "\t "); 432 | to_all++; 433 | } else if (streq(arg, "-move-rodata")) { 434 | flag_move_data = 1; 435 | } else if (streq(arg, "-shared-lib-id")) { 436 | shared_lib_id = argv[++argno]; 437 | } else if (streq(arg, "-shared") || streq(arg, "-G")) { 438 | want_shared = 1; 439 | } else if (streqn(arg, "-o")) { 440 | output_file = arg[2] ? &arg[2] : argv[++argno]; 441 | } else if (streqn(arg, "-T")) { 442 | linker_script = arg[2] ? &arg[2] : argv[++argno]; 443 | } else if (streq(arg, "-c")) { 444 | linker_script = argv[++argno]; 445 | } else if (streqn(arg, "-L")) { 446 | const char *merged = 447 | (arg[2] ? arg : concat("-L", argv[++argno], NULL)); 448 | append_option(&other_options, merged); 449 | append_option(&search_dirs, merged); 450 | } else if (streq(arg, "-EB")) { 451 | append_option(&other_options, arg); 452 | append_option(&search_dirs, arg); 453 | } else if (streq(arg, "-relax")) { 454 | ; 455 | } else if (streq(arg, "-s") || streq(arg, "--strip-all") || 456 | streq(arg, "-S") || streq(arg, "--strip-debug")) { 457 | /* Ignore these strip options for links involving elf2flt. 458 | The final flat output will be stripped by definition, and we 459 | don't want to strip the .gdb helper file. The strip options 460 | are also incompatible with -r and --emit-relocs. */ 461 | ; 462 | } else if (streq(arg, "-r") || streq(arg, "-Ur")) { 463 | flag_final = 0; 464 | append_option(&other_options, arg); 465 | } else if (streq(arg, "--verbose")) { 466 | flag_verbose = 1; 467 | append_option(&other_options, arg); 468 | } else if (streqn(arg, "-m")) { 469 | emulation = arg[2] ? arg : concat("-m", argv[++argno], NULL); 470 | } else 471 | append_option(&other_options, arg); 472 | 473 | while (to_all <= argno) 474 | append_option(&all_options, argv[to_all++]); 475 | } 476 | 477 | fltflags = getenv("FLTFLAGS"); 478 | if (fltflags) 479 | append_option_str(&flt_options, fltflags, "\t "); 480 | } 481 | 482 | int main(int argc, char *argv[]) 483 | { 484 | const char *argv0 = argv[0]; 485 | const char *argv0_dir = make_relative_prefix(argv0, "/", "/"); 486 | const char *tooldir = argv0_dir; 487 | const char *bindir = argv0_dir; 488 | char *tmp; 489 | struct stat buf; 490 | const char *have_exe = NULL; 491 | int status; 492 | 493 | #ifdef __WIN32 494 | /* Remove the .exe extension, if it's there. */ 495 | size_t len = strlen(argv0); 496 | if (len > 4 && streq(&argv0[len - 4], ".exe")) { 497 | have_exe = ".exe"; 498 | len -= 4; 499 | argv0 = tmp = xstrdup(argv0); 500 | tmp[len] = 0; 501 | argv[0][len] = '\0'; 502 | } 503 | #endif 504 | elf2flt_progname = lbasename(argv0); 505 | 506 | /* The standard binutils tool layout has: 507 | 508 | bin/-foo 509 | lib/ 510 | /bin/foo 511 | /lib 512 | 513 | It's / that we want here: files in lib/ are for 514 | the host while those in /lib are for the target. 515 | Make bindir point to the bin dir for bin/-foo. 516 | Make tooldir point to the bin dir for /bin/foo. */ 517 | if (streqn(elf2flt_progname, "ld")) { 518 | tmp = concat(argv0_dir, "../../bin", NULL); 519 | if (stat(tmp, &buf) == 0 && S_ISDIR(buf.st_mode)) { 520 | bindir = concat(tmp, "/", NULL); 521 | } 522 | } else { 523 | tmp = concat(argv0_dir, "../" TARGET_ALIAS "/bin", NULL); 524 | if (stat(tmp, &buf) == 0 && S_ISDIR(buf.st_mode)) { 525 | tooldir = concat(tmp, "/", NULL); 526 | } 527 | } 528 | 529 | /* Typically ld-elf2flt is invoked as `ld` which means error 530 | * messages from it will look like "ld: " which is completely 531 | * confusing. So append an identifier to keep things clear. 532 | */ 533 | elf2flt_progname = concat(elf2flt_progname, " (ld-elf2flt)", NULL); 534 | 535 | xmalloc_set_program_name(elf2flt_progname); 536 | 537 | linker = concat(tooldir, "ld.real", have_exe, NULL); 538 | elf2flt = concat(tooldir, "elf2flt", have_exe, NULL); 539 | nm = concat(tooldir, "nm", have_exe, NULL); 540 | objdump = concat(bindir, TARGET_ALIAS "-objdump", have_exe, NULL); 541 | objcopy = concat(bindir, TARGET_ALIAS "-objcopy", have_exe, NULL); 542 | 543 | if (stat(ldscriptpath, &buf) || !S_ISDIR(buf.st_mode)) 544 | ldscriptpath = concat(tooldir, "../lib", NULL); 545 | 546 | parse_args(argc, argv); 547 | 548 | if (flag_verbose) { 549 | fprintf(stderr, "argv[0] = '%s'\n", argv[0]); 550 | fprintf(stderr, "bindir = '%s'\n", bindir); 551 | fprintf(stderr, "tooldir = '%s'\n", tooldir); 552 | fprintf(stderr, "linker = '%s'\n", linker); 553 | fprintf(stderr, "elf2flt = '%s'\n", elf2flt); 554 | fprintf(stderr, "nm = '%s'\n", nm); 555 | fprintf(stderr, "objdump = '%s'\n", objdump); 556 | fprintf(stderr, "objcopy = '%s'\n", objcopy); 557 | fprintf(stderr, "ldscriptpath = '%s'\n", ldscriptpath); 558 | } 559 | 560 | /* Pass off to regular linker, if there's nothing elf2flt-like */ 561 | if (!have_elf2flt_options) 562 | return execute(linker, NULL, &all_options); 563 | 564 | /* Pass off to regular linker, minus the elf2flt options, if it's 565 | not the final link. */ 566 | if (!flag_final) 567 | return execute(linker, NULL, &other_options, "-o", output_file); 568 | 569 | if (want_shared && !shared_lib_id) 570 | fatal("-shared used without passing a shared library ID"); 571 | 572 | /* Otherwise link & convert to flt. */ 573 | output_gdb = concat(output_file, ".gdb", NULL); 574 | tmp_file = make_temp_file(NULL); 575 | status = do_final_link(); 576 | if (!flag_verbose) { 577 | unlink(tmp_file); 578 | unlink(output_flt); 579 | if (output_elf) { 580 | unlink(output_elf); 581 | } 582 | } else { 583 | fprintf(stderr, 584 | "leaving elf2flt temp files behind:\n" 585 | "tmp_file = %s\n" 586 | "output_flt = %s\n" 587 | "output_elf = %s\n", 588 | tmp_file, output_flt, strNULL(output_elf)); 589 | } 590 | return status; 591 | } 592 | -------------------------------------------------------------------------------- /ld-elf2flt.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # allow us to do flat processing if the flag -Wl,-elf2flt or -elf2flt to 4 | # the 'C' compiler or linker respectively 5 | # 6 | # uses the env. var FLTFLAGS as extra parameters to pass to elf2flt 7 | # arguments given like -Wl,-elf2flt="-b 10000 -v" are given before FLTFLAGS 8 | # 9 | # Copyright (C) 2002,2003 David McCullough 10 | # Copyright (C) 2000, Lineo. davidm@lineo.com 11 | # 12 | # This is Free Software, under the GNU Public Licence v2 or greater. 13 | # 14 | 15 | LINKER="$0.real" # the original renamed-linker 16 | ELF2FLT="`expr $0 : '\(.*\)ld'`elf2flt" 17 | NM="`expr $0 : '\(.*\)ld'`nm" 18 | TOOLDIR="`dirname $0`" # let gcc find the tools for us 19 | OBJCOPY="`expr $0 : '\(.*\)ld'`objcopy" 20 | [ -f "$OBJCOPY" ] || OBJCOPY="$TOOLDIR/../../bin/@target_alias@-objcopy" 21 | OBJDUMP="`expr $OBJCOPY : '\(.*\)objcopy'`objdump" 22 | LDSCRIPTPATH="@binutils_ldscript_dir@" # and the scripts 23 | SHARED_ID="" 24 | NEWLDSCRIPT="" 25 | WANT_SHARED="" 26 | 27 | # check TOOLDIR from prefix/bin/ or prefix/target-alias/bin/ 28 | [ -d "${LDSCRIPTPATH}" ] || LDSCRIPTPATH="${TOOLDIR}/../lib" 29 | 30 | # 31 | # if we have the elf2flt options, run it 32 | # 33 | 34 | if expr "$*" : ".*-elf2flt.*" > /dev/null 35 | then 36 | ARG1= 37 | ARG2= 38 | OFILE="a.out" 39 | PIC= 40 | SDIRS= 41 | LDSCRIPT= 42 | FINAL="yes" 43 | FINAL_ONLY= 44 | MOVDAT= 45 | VERBOSE= 46 | 47 | while [ $# -ne 0 ] 48 | do 49 | case "$1" in 50 | 51 | -elf2flt) ;; # we already know this 52 | -elf2flt*)FLTFLAGS="`expr \"$1\" : '-elf2flt=\(.*\)'` $FLTFLAGS";; 53 | 54 | -move-rodata) 55 | MOVDAT="y";; # Put rodata in ROM if possible 56 | -s|-S|--strip-all|--strip-debug) 57 | ;; # Ignore strip flags 58 | 59 | -shared-lib-id) 60 | shift; SHARED_ID="$1";; # Shared library ID 61 | -shared|-G) 62 | WANT_SHARED="y";; # Shared library 63 | 64 | -o) shift; OFILE="$1";; # the final outfile 65 | -o*) OFILE="`expr \"$1\" : '-o\(.*\)'`";; 66 | 67 | -T) shift; LDSCRIPT="$1";; # they have a linker script 68 | -c) shift; LDSCRIPT="$1";; 69 | 70 | -L) ARG1="$ARG1 $1" # remember search dirs 71 | shift; 72 | ARG1="$ARG1 $1" 73 | SDIRS="$SDIRS -L$1" 74 | ;; 75 | -L*) ARG1="$ARG1 $1"; SDIRS="$SDIRS $1";; 76 | 77 | -EB) ARG1="$ARG1 $1"; SDIRS="$SDIRS $1";; # arm big endian 78 | 79 | -relax) ;; # eat this for microblaze 80 | 81 | -r|-Ur) FINAL="" # this is not a final link 82 | ARG1="$ARG1 $1" 83 | ;; 84 | 85 | -v|--verbose) 86 | ARG1="$ARG1 $1" 87 | VERBOSE="y" 88 | ;; 89 | 90 | -m) shift; EMUL="-m $1";; # ld emulations for h8300 91 | -m*) EMUL=$1;; 92 | 93 | *) ARG1="$ARG1 $1" 94 | ;; 95 | esac 96 | shift 97 | done 98 | 99 | if [ "$WANT_SHARED" = "y" ] 100 | then 101 | if [ -z "$SHARED_ID" ] 102 | then 103 | echo "-shared used without passing a shared library ID" 104 | exit 1 105 | fi 106 | fi 107 | if [ "$FINAL" = "yes" ] 108 | then 109 | [ "$VERBOSE" = "y" ] && set -x 110 | ARG1="$ARG1 $FINAL_ONLY" 111 | NEWLDSCRIPT=`mktemp /tmp/flt-XXXXXX` 112 | trap 'rm -f "$NEWLDSCRIPT"' EXIT 113 | SEDOP=" -e s/^R_RODAT:// -e /^W_RODAT:/d" 114 | OBJCOPYOP="" 115 | if [ "$MOVDAT" ] 116 | then 117 | $LINKER -r -d -o "$OFILE.elf2flt" $ARG1 || exit $? 118 | if [ "`$OBJDUMP -h "$OFILE.elf2flt" | \ 119 | egrep -A1 '[.]rodata' | grep RELOC`" ] 120 | then 121 | echo "warning: .rodata section contains relocations" 122 | else 123 | SEDOP="-e /^R_RODAT:/d -e s/^W_RODAT://" 124 | fi 125 | fi 126 | if [ "$SHARED_ID" ] 127 | then 128 | # Massage the linker script into something useful. These 129 | # regexps are ugly due to some bizzare shell quoting rules. 130 | # SEDOP="$SEDOP -e \"s/ORIGIN = 0x0,/ORIGIN = 0x${SHARED_ID}000000,/\"" 131 | # SEDOP="$SEDOP -e \"s/.text 0x0 :/.text 0x${SHARED_ID}000000 :/\"" 132 | SEDOP="$SEDOP -e s/\\(ORIGIN.=.0\\)x0,/\\1x${SHARED_ID}000000,/" 133 | SEDOP="$SEDOP -e s/\\([.]text.0\\)x0[^0-9]:/\\1x${SHARED_ID}000000:/" 134 | 135 | if [ "$SHARED_ID" -gt 0 ] 136 | then 137 | # Non application modules enter via main not _start 138 | # SEDOP="$SEDOP -e 's/ENTRY (_start)/ENTRY (main)/'" 139 | SEDOP="$SEDOP -e s/\\(ENTRY.\\)(@SYMBOL_PREFIX@_start)/\1(lib_main)/" 140 | OBJCOPYOP="--localize-hidden --weaken" 141 | fi 142 | 143 | # Provide the magic parameter that defines the library data segment pointer offset 144 | GOT_ADJ=4 145 | case "@target_cpu@" in 146 | bfin) GOT_OFFSET="_current_shared_library_p5_offset_" GOT_ADJ=1;; 147 | h8300) GOT_OFFSET="__current_shared_library_er5_offset_";; 148 | *) GOT_OFFSET="_current_shared_library_a5_offset_";; 149 | esac 150 | ARG1="$ARG1 -defsym $GOT_OFFSET=`expr ${SHARED_ID} '*' -${GOT_ADJ} - ${GOT_ADJ}`" 151 | fi 152 | if [ "@emit_relocs@" = "1" ] 153 | then 154 | SEDOP="$SEDOP -e s/^SINGLE_LINK://" 155 | else 156 | SEDOP="$SEDOP -e /^SINGLE_LINK:/d" 157 | fi 158 | if [ "@emit_ctor_dtor@" = "1" ] 159 | then 160 | SEDOP="$SEDOP -e s/^TOR://" 161 | else 162 | SEDOP="$SEDOP -e /^TOR:/d" 163 | fi 164 | 165 | # provide a default linker script, we usually need one 166 | [ -z "$LDSCRIPT" ] && LDSCRIPT="${LDSCRIPTPATH}/elf2flt.ld" 167 | 168 | # if we can find the linker script we preprocess it, otherwise 169 | # we assume the user knows what they are doing 170 | if [ -f "$LDSCRIPT" ]; then 171 | sed $SEDOP < "$LDSCRIPT" > "$NEWLDSCRIPT" 172 | LDSCRIPT="$NEWLDSCRIPT" 173 | elif [ -f "${LDSCRIPTPATH}/$LDSCRIPT" ]; then 174 | sed $SEDOP < "${LDSCRIPTPATH}/$LDSCRIPT" > "$NEWLDSCRIPT" 175 | LDSCRIPT="$NEWLDSCRIPT" 176 | elif [ -f "${LDSCRIPTPATH}/ldscripts/$LDSCRIPT" ]; then 177 | sed $SEDOP < "${LDSCRIPTPATH}/ldscripts/$LDSCRIPT" > "$NEWLDSCRIPT" 178 | LDSCRIPT="$NEWLDSCRIPT" 179 | fi 180 | 181 | if [ "@emit_relocs@" = "1" ] 182 | then 183 | $LINKER $EMUL $SDIRS -T $LDSCRIPT -q -o "$OFILE.gdb" $ARG1 ||exit $? 184 | RFILE="$OFILE.gdb" 185 | FLTFLAGS="$FLTFLAGS -a" 186 | else 187 | if [ "@got_check@" = "0" ] 188 | then 189 | $LINKER $EMUL $SDIRS -T $LDSCRIPT -Ur -d -o "$OFILE.elf" $ARG1 ||exit $? 190 | $LINKER $EMUL $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" $ARG1 ||exit $? 191 | else 192 | $LINKER $EMUL -r -d -o "$OFILE.elf2flt" $ARG1 ||exit $? 193 | $LINKER $EMUL $SDIRS -T $LDSCRIPT -Ur -o "$OFILE.elf" "$OFILE.elf2flt" ||exit $? 194 | $LINKER $EMUL $SDIRS -T $LDSCRIPT -o "$OFILE.gdb" "$OFILE.elf2flt" ||exit $? 195 | rm -f "$OFILE.elf2flt" 196 | fi 197 | RFILE="$OFILE.elf" 198 | fi 199 | if $NM "$OFILE.gdb" | grep _GLOBAL_OFFSET_TABLE_ > /dev/null 200 | then 201 | $ELF2FLT $FLTFLAGS -o "$OFILE" -p "$OFILE.gdb" "$RFILE" || exit $? 202 | else 203 | $ELF2FLT $FLTFLAGS -o "$OFILE" -r "$RFILE" || exit $? 204 | fi 205 | if [ "$OBJCOPYOP" ] 206 | then 207 | if $OBJCOPY $OBJCOPYOP --help > /dev/null 2>&1 208 | then 209 | $OBJCOPY $OBJCOPYOP "$OFILE.gdb" ||exit $? 210 | else 211 | case " $OBJCOPYOP " in 212 | *" --localize-hidden "*) 213 | SYMS=`mktemp /tmp/flt-XXXXXX` 214 | $OBJDUMP --syms "$OFILE.gdb" > "$SYMS" ||exit $? 215 | sed -n 's/.*\(\.hidden\|\.internal\) \(.*\)/-L \2/p' < "$SYMS" > "$SYMS.hidden" ||exit $? 216 | if [ -s "$SYMS.hidden" ] 217 | then 218 | xargs ${VERBOSE:+-t} $OBJCOPY "$OFILE.gdb" < "$SYMS.hidden" ||exit $? 219 | fi 220 | rm -f "$SYMS" "$SYMS.hidden" 221 | ;; 222 | esac 223 | case " $OBJCOPYOP " in 224 | *" --weaken "*) 225 | $OBJCOPY --weaken "$OFILE.gdb" ||exit $? 226 | ;; 227 | esac 228 | fi 229 | fi 230 | [ "$RFILE" = "$OFILE.gdb" ] || rm -f "$RFILE" # not needed for any reason 231 | exit 0 232 | fi 233 | 234 | exec $LINKER -o "$OFILE" $ARG1 235 | fi 236 | 237 | # 238 | # otherwise pretend we aren't here 239 | # 240 | 241 | exec $LINKER "$@" 242 | -------------------------------------------------------------------------------- /stubs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "libiberty.h" 8 | 9 | #include "stubs.h" 10 | 11 | #ifndef HAVE_DCGETTEXT 12 | const char *dcgettext(const char *domain, const char *msg, int category) 13 | { 14 | return msg; 15 | } 16 | #endif /* !HAVE_DCGETTEXT */ 17 | 18 | #ifndef HAVE_LIBINTL_DGETTEXT 19 | const char *libintl_dgettext(const char *domain, const char *msg) 20 | { 21 | return msg; 22 | } 23 | #endif /* !HAVE_LIBINTL_DGETTEXT */ 24 | 25 | #ifndef HAVE_GETLINE 26 | /* Read a line from IN. LINE points to a malloc'd buffer that is extended as 27 | necessary. ALLOC points to the allocated length of LINE. Returns 28 | the length of the string read (including any trailing \n) */ 29 | 30 | ssize_t getline(char **line, size_t *alloc, FILE *in) 31 | { 32 | size_t len = 0; 33 | 34 | if (!*alloc) { 35 | *alloc = 200; 36 | *line = xmalloc(*alloc); 37 | } 38 | 39 | while (1) { 40 | if (!fgets(*line + len, *alloc - len, in)) 41 | return 0; 42 | len += strlen(*line + len); 43 | if (len && (*line)[len - 1] == '\n') 44 | return len; 45 | 46 | *alloc *= 2; 47 | *line = xrealloc(*line, *alloc); 48 | } 49 | } 50 | #endif 51 | 52 | /* fatal error & exit */ 53 | void fatal(const char *format, ...) 54 | { 55 | va_list args; 56 | 57 | va_start(args, format); 58 | fprintf(stderr, "%s: ", elf2flt_progname); 59 | vfprintf(stderr, format, args); 60 | fprintf(stderr, "\n"); 61 | va_end(args); 62 | exit(1); 63 | } 64 | 65 | /* fatal error, perror & exit */ 66 | void fatal_perror(const char *format, ...) 67 | { 68 | int e = errno; 69 | va_list args; 70 | 71 | va_start(args, format); 72 | fprintf(stderr, "%s: ", elf2flt_progname); 73 | vfprintf(stderr, format, args); 74 | fprintf(stderr, ": %s\n", strerror(e)); 75 | va_end(args); 76 | exit(1); 77 | } 78 | 79 | /* open a file or fail */ 80 | FILE *xfopen(const char *path, const char *mode) 81 | { 82 | FILE *ret = fopen(path, mode); 83 | if (!ret) 84 | fatal_perror("Unable to open '%s'", path); 85 | return ret; 86 | } 87 | 88 | /* Append a string SRC to an options array DST */ 89 | void append_option(options_t *dst, const char *src) 90 | { 91 | if (dst->alloc == dst->num) { 92 | size_t a = (dst->num + 2) * 2; 93 | void *o = xmalloc(sizeof(*dst->options) * a); 94 | 95 | memcpy(o, dst->options, sizeof(*dst->options) * dst->num); 96 | free(dst->options); 97 | dst->options = o; 98 | dst->alloc = a; 99 | } 100 | 101 | dst->options[dst->num] = src; 102 | dst->num++; 103 | } 104 | 105 | /* Split and append a string SRC to an options array DST */ 106 | void append_option_str(options_t *dst, const char *src, const char *delim) 107 | { 108 | char *tok_src = xstrdup(src); 109 | char *tok = strtok(tok_src, delim); 110 | while (tok) { 111 | append_option(dst, tok); 112 | tok = strtok(NULL, delim); 113 | } 114 | /* don't free tok_src since options_t now points to it */ 115 | } 116 | 117 | /* Append an options array SRC to another options array DST */ 118 | void append_options(options_t *dst, const options_t *src) 119 | { 120 | if (dst->alloc < dst->num + src->num) { 121 | size_t a = (dst->num + src->num + 2) * 2; 122 | void *o = xmalloc(sizeof(*dst->options) * a); 123 | 124 | memcpy(o, dst->options, sizeof(*dst->options) * dst->num); 125 | free(dst->options); 126 | dst->options = o; 127 | dst->alloc = a; 128 | } 129 | 130 | memcpy(&dst->options[dst->num], &src->options[0], 131 | sizeof(*dst->options) * src->num); 132 | dst->num += src->num; 133 | } 134 | -------------------------------------------------------------------------------- /stubs.h: -------------------------------------------------------------------------------- 1 | /* macros for conversion between host and (internet) network byte order */ 2 | #ifndef WIN32 3 | # include /* Consts and structs defined by the internet system */ 4 | # define BINARY_FILE_OPTS 5 | #else 6 | # include 7 | # define BINARY_FILE_OPTS "b" 8 | #endif 9 | 10 | #ifndef __WIN32 11 | # include 12 | #endif 13 | #ifndef WIFSIGNALED 14 | # define WIFSIGNALED(S) (((S) & 0xff) != 0 && ((S) & 0xff) != 0x7f) 15 | #endif 16 | #ifndef WTERMSIG 17 | # define WTERMSIG(S) ((S) & 0x7f) 18 | #endif 19 | #ifndef WIFEXITED 20 | # define WIFEXITED(S) (((S) & 0xff) == 0) 21 | #endif 22 | #ifndef WEXITSTATUS 23 | # define WEXITSTATUS(S) (((S) & 0xff00) >> 8) 24 | #endif 25 | #ifndef WCOREDUMP 26 | # define WCOREDUMP(S) ((S) & WCOREFLG) 27 | #endif 28 | #ifndef WCOREFLG 29 | # define WCOREFLG 0200 30 | #endif 31 | #ifndef HAVE_STRSIGNAL 32 | # define strsignal(sig) "SIG???" 33 | #endif 34 | 35 | #define streq(str1, str2) (strcmp(str1, str2) == 0) 36 | #define streqn(str1, str2) (strncmp(str1, str2, strlen(str2)) == 0) 37 | 38 | /* Since printf(%s) is not guaranteed to print "(null)", handle it ourselves. 39 | NB: The "strNULL" name is terrible, so feel free to suggest alternatives. */ 40 | #define strNULL(s) ((s) ? (s) : "(null)") 41 | 42 | #ifndef DEBUG 43 | # define DEBUG -1 44 | #endif 45 | #define _debug(lvl, fmt, args...) \ 46 | do { \ 47 | if (lvl <= DEBUG) { \ 48 | fprintf(stderr, "%s:%i: " fmt, __func__, __LINE__ , ## args); \ 49 | fflush(stderr); \ 50 | } \ 51 | } while (0) 52 | #define debug2(...) _debug(2, __VA_ARGS__) 53 | #define debug1(...) _debug(1, __VA_ARGS__) 54 | #define debug0(...) _debug(0, __VA_ARGS__) 55 | #define debug(...) debug0(__VA_ARGS__) 56 | 57 | #ifndef HAVE_GETLINE 58 | ssize_t getline(char **line, size_t *alloc, FILE *in); 59 | #endif 60 | 61 | extern const char *elf2flt_progname; 62 | 63 | void fatal(const char *, ...); 64 | void fatal_perror(const char *, ...); 65 | 66 | FILE *xfopen(const char *path, const char *mode); 67 | 68 | /* Structure to hold a list of options */ 69 | typedef struct 70 | { 71 | const char **options; 72 | size_t num; 73 | size_t alloc; 74 | } options_t; 75 | /* Initialize an options structure */ 76 | #define init_options(DST) ((DST)->options = NULL, (DST)->num = (DST)->alloc = 0) 77 | void append_options(options_t *dst, const options_t *src); 78 | void append_option(options_t *dst, const char *src); 79 | void append_option_str(options_t *dst, const char *src, const char *delim); 80 | -------------------------------------------------------------------------------- /tests/flthdr/.gitignore: -------------------------------------------------------------------------------- 1 | /generate 2 | -------------------------------------------------------------------------------- /tests/flthdr/basic.good: -------------------------------------------------------------------------------- 1 | basic.bin 2 | Magic: bFLT 3 | Rev: 4 4 | Build Date: not specified 5 | Entry: 0x1234 6 | Data Start: 0x5678 7 | Data End: 0xabcd 8 | BSS End: 0xdef14565 9 | Stack Size: 0x10aa 10 | Reloc Start: 0x3456 11 | Reloc Count: 0x0 12 | Flags: 0xff ( Load-to-Ram Has-PIC-GOT Gzip-Compressed Gzip-Data-Compressed Kernel-Traced-Load L1-Scratch-Stack ) 13 | -------------------------------------------------------------------------------- /tests/flthdr/generate.c: -------------------------------------------------------------------------------- 1 | /* Helper tool for generating simple flat files that flthdr can read. 2 | * Written by Mike Frysinger 3 | * Distributed under the terms of the GNU General Public License v2 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "flat.h" 18 | 19 | void usage(int status) 20 | { 21 | fprintf(status ? stderr : stdout, 22 | "Usage: generate [options]\n" 23 | "\n" 24 | "Helper tool for generating flat files for testing.\n" 25 | "Flat file is written to stdout by default.\n" 26 | "\n" 27 | "Options:\n" 28 | " -m Set the magic (must be 4 bytes)\n" 29 | " -v Set the version (rev)\n" 30 | " -e Set the entry point\n" 31 | " -d Set the data start addr\n" 32 | " -D Set the data end addr\n" 33 | " -B Set the bss end addr\n" 34 | " -s Set the stack size\n" 35 | " -r Set the reloc start addr\n" 36 | " -R Set the reloc count\n" 37 | " -f Set the flags\n" 38 | " -b Set the build date\n" 39 | " -F Set the filler field (each -F sets 1 field)\n" 40 | " -o Write output to a file\n" 41 | " -h This help output\n" 42 | ); 43 | exit(status); 44 | } 45 | 46 | void set32(uint32_t *field, const char *val) 47 | { 48 | char *end; 49 | long lval; 50 | 51 | errno = 0; 52 | lval = strtol(val, &end, 0); 53 | if (*end) 54 | err(1, "invalid number: %s", val); 55 | *field = htonl(lval); 56 | } 57 | 58 | int main(int argc, char *argv[]) 59 | { 60 | FILE *output = stdout; 61 | struct flat_hdr hdr; 62 | int c, fillerpos; 63 | 64 | fillerpos = 0; 65 | memset(&hdr, 0, sizeof(hdr)); 66 | memcpy(hdr.magic, "bFLT", 4); 67 | hdr.rev = htonl(FLAT_VERSION); 68 | 69 | while ((c = getopt(argc, argv, "ho:m:v:e:d:D:B:s:r:R:f:b:F:")) != -1) { 70 | switch (c) { 71 | case 'm': /* magic */ 72 | if (strlen(optarg) != 4) 73 | errx(1, "magic must be 4 bytes"); 74 | memcpy(hdr.magic, optarg, 4); 75 | break; 76 | case 'v': /* revision */ 77 | set32(&hdr.rev, optarg); 78 | break; 79 | case 'e': /* entry */ 80 | set32(&hdr.entry, optarg); 81 | break; 82 | case 'd': /* data_start */ 83 | set32(&hdr.data_start, optarg); 84 | break; 85 | case 'D': /* data_end */ 86 | set32(&hdr.data_end, optarg); 87 | break; 88 | case 'B': /* bss_end */ 89 | set32(&hdr.bss_end, optarg); 90 | break; 91 | case 's': /* stack_size */ 92 | set32(&hdr.stack_size, optarg); 93 | break; 94 | case 'r': /* reloc_start */ 95 | set32(&hdr.reloc_start, optarg); 96 | break; 97 | case 'R': /* reloc_count */ 98 | set32(&hdr.reloc_count, optarg); 99 | break; 100 | case 'f': /* flags */ 101 | set32(&hdr.flags, optarg); 102 | break; 103 | case 'b': /* build_date */ 104 | set32(&hdr.build_date, optarg); 105 | break; 106 | case 'F': /* filler */ 107 | if (fillerpos == 5) 108 | errx(1, "can only use -F 5 times"); 109 | set32(&hdr.filler[fillerpos++], optarg); 110 | break; 111 | case 'o': /* output */ 112 | output = fopen(optarg, "wbe"); 113 | if (!output) 114 | err(1, "could not open %s", optarg); 115 | break; 116 | case 'h': 117 | usage(0); 118 | default: 119 | usage(1); 120 | } 121 | } 122 | 123 | fwrite(&hdr, sizeof(hdr), 1, output); 124 | fclose(output); 125 | 126 | return 0; 127 | } 128 | -------------------------------------------------------------------------------- /tests/flthdr/multi.good: -------------------------------------------------------------------------------- 1 | Flag Rev Text Data BSS Stack Relocs RAM Filename 2 | ----------------------------------------------------------- 3 | - 4 -64 0 0 0 0 0 multi.bin 4 | - 4 -64 0 0 0 0 0 multi.bin 5 | - 4 -64 0 0 0 0 0 multi.bin 6 | -------------------------------------------------------------------------------- /tests/flthdr/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Test behavior of flthdr. 3 | # Written by Mike Frysinger 4 | # Distributed under the terms of the GNU General Public License v2 5 | 6 | . "${0%/*}"/../lib.sh "flthdr" 7 | 8 | start 'cli no flags' 9 | if flthdr >stdout 2>stderr; then 10 | fail 'exit' 11 | elif [[ -s stdout || ! -s stderr ]]; then 12 | fail 'output' 13 | else 14 | rm stdout stderr 15 | pass 16 | fi 17 | 18 | start 'cli help' 19 | if ! flthdr -h >stdout 2>stderr; then 20 | fail 'exit' 21 | elif [[ -s stderr || ! -s stdout ]]; then 22 | fail 'output' 23 | else 24 | rm stdout stderr 25 | pass 26 | fi 27 | 28 | start 'basic flags' 29 | generate -o basic.bin \ 30 | -e 0x1234 \ 31 | -d 0x5678 \ 32 | -D 0xabcd \ 33 | -r 0x3456 \ 34 | -B 0xdef14565 \ 35 | -s 0x10aa \ 36 | -f 0xff 37 | if ! flthdr basic.bin > basic.out; then 38 | fail 'run' 39 | elif ! diff -u basic.out "${srcdir}"/basic.good; then 40 | fail 'diff' 41 | else 42 | rm basic.bin basic.out 43 | pass 44 | fi 45 | 46 | start 'multi output' 47 | generate -o multi.bin 48 | if ! flthdr multi.bin multi.bin multi.bin > multi.out; then 49 | fail 'run' 50 | elif ! diff -u multi.out "${srcdir}"/multi.good; then 51 | fail 'diff' 52 | else 53 | rm multi.bin multi.out 54 | pass 55 | fi 56 | -------------------------------------------------------------------------------- /tests/lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Common test code. 3 | # Written by Mike Frysinger 4 | # Distributed under the terms of the GNU General Public License v2 5 | 6 | set -e 7 | 8 | SUBDIR=$1 9 | 10 | if [ -z "${abs_top_srcdir}" ]; then 11 | abs_top_srcdir=$(realpath "$(dirname "$(realpath "$0")")/../..") 12 | abs_top_builddir=${abs_top_srcdir} 13 | fi 14 | srcdir="${abs_top_srcdir}/tests/${SUBDIR}" 15 | builddir="${abs_top_builddir}/tests/${SUBDIR}" 16 | cd "${builddir}" 17 | 18 | PATH="${builddir}:${abs_top_builddir}:${PATH}" 19 | 20 | FAIL_COUNT=0 21 | 22 | start() { 23 | printf '%s: testing %s ... ' "${SUBDIR}" "$1" 24 | } 25 | 26 | pass() { 27 | echo 'OK' 28 | } 29 | 30 | fail() { 31 | echo "FAIL ($*)" 32 | : $(( FAIL_COUNT += 1 )) 33 | } 34 | 35 | test_runner_exit() { 36 | if [ ${FAIL_COUNT} -ne 0 ]; then 37 | echo "${SUBDIR}: some tests (${FAIL_COUNT}) failed!" 38 | exit 1 39 | else 40 | echo "${SUBDIR}: all tests passed!" 41 | fi 42 | } 43 | trap test_runner_exit EXIT 44 | -------------------------------------------------------------------------------- /travis/arches.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # List of all supported arches. 3 | # Written by Mike Frysinger 4 | # Distributed under the terms of the GNU General Public License v2 5 | 6 | # The e1/nios targets are dead and no longer configure. 7 | ARCHES=( 8 | arm 9 | bfin 10 | # e1 11 | h8300 12 | m68k 13 | microblaze 14 | # nios 15 | nios2 16 | sh 17 | sparc 18 | v850 19 | xtensa 20 | ) 21 | -------------------------------------------------------------------------------- /travis/lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Common funcs for working w/Travis. 3 | # Written by Mike Frysinger 4 | # Distributed under the terms of the GNU General Public License v2 5 | 6 | travis_fold() { 7 | if [[ -n ${TRAVIS_OS_NAME} ]] ; then 8 | printf 'travis_fold:%s:%s\r\n' "$@" | sed 's: :_:g' 9 | fi 10 | } 11 | 12 | if [[ -n ${TRAVIS_OS_NAME} ]] ; then 13 | whitebg=$(tput setab 7) 14 | blackfg=$(tput setaf 0) 15 | normal=$(tput sgr0) 16 | else 17 | whitebg= 18 | blackbg= 19 | normal= 20 | fi 21 | v() { 22 | local fold="" 23 | case $1 in 24 | --fold=*) fold=${1:7}; shift;; 25 | esac 26 | if [[ -n ${fold} ]] ; then 27 | travis_fold start "${fold}" 28 | echo "\$ $*" 29 | "$@" 30 | travis_fold end "${fold}" 31 | else 32 | echo "${whitebg}${blackfg}\$ $*${normal}" 33 | "$@" 34 | fi 35 | } 36 | 37 | ncpus=$(getconf _NPROCESSORS_ONLN) 38 | m() { 39 | v make -j${ncpus} "$@" 40 | } 41 | -------------------------------------------------------------------------------- /travis/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Main Travis test script. 3 | # Written by Mike Frysinger 4 | # Distributed under the terms of the GNU General Public License v2 5 | 6 | . "${0%/*}"/lib.sh 7 | . "${0%/*}"/arches.sh 8 | 9 | BINUTILS_VERS=( 10 | 2.25.1 11 | 2.26.1 12 | 2.27 13 | 2.28.1 14 | 2.29.1 15 | 2.30 16 | 2.31.1 17 | ) 18 | 19 | build_one() { 20 | local arch=$1 21 | local bver=$2 22 | local S=${PWD} 23 | local build="build/${arch}-${bver}" 24 | 25 | travis_fold start ${arch} "binutils-${bver}" 26 | v mkdir -p "${build}" 27 | pushd "${build}" >/dev/null 28 | if ! v "${S}"/configure \ 29 | --enable-werror \ 30 | --with-binutils-build-dir="${S}"/../prebuilts-binutils-libs/output/${bver} \ 31 | --target=${arch}-elf ; then 32 | cat config.log 33 | exit 1 34 | fi 35 | m 36 | m check 37 | popd >/dev/null 38 | travis_fold end ${arch} 39 | } 40 | 41 | main() { 42 | if [[ ! -d ../prebuilts-binutils-libs ]] ; then 43 | v --fold="git_clone_binutils" \ 44 | git clone --depth=1 https://github.com/uclinux-dev/prebuilts-binutils-libs ../prebuilts-binutils-libs 45 | fi 46 | 47 | # Newer compilers default to PIE which the prebuilts aren't using. 48 | export CFLAGS='-O2 -pipe -no-pie' 49 | 50 | local a b 51 | for a in "${ARCHES[@]}" ; do 52 | for b in "${BINUTILS_VERS[@]}" ; do 53 | build_one "${a}" "${b}" 54 | done 55 | done 56 | } 57 | main "$@" 58 | --------------------------------------------------------------------------------