1*a9fa9459Szrj README for BINUTILS 2*a9fa9459Szrj 3*a9fa9459SzrjThese are the GNU binutils. These are utilities of use when dealing 4*a9fa9459Szrjwith binary files, either object files or executables. These tools 5*a9fa9459Szrjconsist of the linker (ld), the assembler (gas), and the profiler 6*a9fa9459Szrj(gprof) each of which have their own sub-directory named after them. 7*a9fa9459SzrjThere is also a collection of other binary tools, including the 8*a9fa9459Szrjdisassembler (objdump) in this directory. These tools make use of a 9*a9fa9459Szrjpair of libraries (bfd and opcodes) and a common set of header files 10*a9fa9459Szrj(include). 11*a9fa9459Szrj 12*a9fa9459SzrjThere are README and NEWS files in most of the program sub-directories 13*a9fa9459Szrjwhich give more information about those specific programs. 14*a9fa9459Szrj 15*a9fa9459Szrj 16*a9fa9459SzrjCopyright Notices 17*a9fa9459Szrj================= 18*a9fa9459Szrj 19*a9fa9459SzrjCopyright years on binutils source files may be listed using range 20*a9fa9459Szrjnotation, e.g., 1991-2012, indicating that every year in the range, 21*a9fa9459Szrjinclusive, is a copyrightable year that could otherwise be listed 22*a9fa9459Szrjindividually. 23*a9fa9459Szrj 24*a9fa9459Szrj 25*a9fa9459SzrjUnpacking and Installation -- quick overview 26*a9fa9459Szrj============================================ 27*a9fa9459Szrj 28*a9fa9459SzrjWhen you unpack the binutils archive file, you will get a directory 29*a9fa9459Szrjcalled something like `binutils-XXX', where XXX is the number of the 30*a9fa9459Szrjrelease. (Probably 2.13 or higher). This directory contains 31*a9fa9459Szrjvarious files and sub-directories. Most of the files in the top 32*a9fa9459Szrjdirectory are for information and for configuration. The actual 33*a9fa9459Szrjsource code is in sub-directories. 34*a9fa9459Szrj 35*a9fa9459SzrjTo build binutils, you can just do: 36*a9fa9459Szrj 37*a9fa9459Szrj cd binutils-XXX 38*a9fa9459Szrj ./configure [options] 39*a9fa9459Szrj make 40*a9fa9459Szrj make install # copies the programs files into /usr/local/bin 41*a9fa9459Szrj # by default. 42*a9fa9459Szrj 43*a9fa9459SzrjThis will configure and build all the libraries as well as the 44*a9fa9459Szrjassembler, the binutils, and the linker. 45*a9fa9459Szrj 46*a9fa9459SzrjIf you have GNU make, we recommend building in a different directory: 47*a9fa9459Szrj 48*a9fa9459Szrj mkdir objdir 49*a9fa9459Szrj cd objdir 50*a9fa9459Szrj ../binutils-XXX/configure [options] 51*a9fa9459Szrj make 52*a9fa9459Szrj make install 53*a9fa9459Szrj 54*a9fa9459SzrjThis relies on the VPATH feature of GNU make. 55*a9fa9459Szrj 56*a9fa9459SzrjBy default, the binutils will be configured to support the system on 57*a9fa9459Szrjwhich they are built. When doing cross development, use the --target 58*a9fa9459Szrjconfigure option to specify a different target, eg: 59*a9fa9459Szrj 60*a9fa9459Szrj ./configure --target=foo-elf 61*a9fa9459Szrj 62*a9fa9459SzrjThe --enable-targets option adds support for more binary file formats 63*a9fa9459Szrjbesides the default. List them as the argument to --enable-targets, 64*a9fa9459Szrjseparated by commas. For example: 65*a9fa9459Szrj 66*a9fa9459Szrj ./configure --enable-targets=sun3,rs6000-aix,decstation 67*a9fa9459Szrj 68*a9fa9459SzrjThe name 'all' compiles in support for all valid BFD targets: 69*a9fa9459Szrj 70*a9fa9459Szrj ./configure --enable-targets=all 71*a9fa9459Szrj 72*a9fa9459SzrjOn 32-bit hosts though, this support will be restricted to 32-bit 73*a9fa9459Szrjtarget unless the --enable-64-bit-bfd option is also used: 74*a9fa9459Szrj 75*a9fa9459Szrj ./configure --enable-64-bit-bfd --enable-targets=all 76*a9fa9459Szrj 77*a9fa9459SzrjYou can also specify the --enable-shared option when you run 78*a9fa9459Szrjconfigure. This will build the BFD and opcodes libraries as shared 79*a9fa9459Szrjlibraries. You can use arguments with the --enable-shared option to 80*a9fa9459Szrjindicate that only certain libraries should be built shared; for 81*a9fa9459Szrjexample, --enable-shared=bfd. The only potential shared libraries in 82*a9fa9459Szrja binutils release are bfd and opcodes. 83*a9fa9459Szrj 84*a9fa9459SzrjThe binutils will be linked against the shared libraries. The build 85*a9fa9459Szrjstep will attempt to place the correct library in the run-time search 86*a9fa9459Szrjpath for the binaries. However, in some cases, after you install the 87*a9fa9459Szrjbinaries, you may have to set an environment variable, normally 88*a9fa9459SzrjLD_LIBRARY_PATH, so that the system can find the installed libbfd 89*a9fa9459Szrjshared library. 90*a9fa9459Szrj 91*a9fa9459SzrjOn hosts that support shared system libraries the binutils will be 92*a9fa9459Szrjlinked against them. If you have static versions of the system 93*a9fa9459Szrjlibraries installed as well and you wish to create static binaries 94*a9fa9459Szrjinstead then use the LDFLAGS environment variable, like this: 95*a9fa9459Szrj 96*a9fa9459Szrj ../binutils-XXX/configure LDFLAGS="--static" [more options] 97*a9fa9459Szrj 98*a9fa9459SzrjNote: the two dashes are important. The binutils make use of the 99*a9fa9459Szrjlibtool script which has a special interpretation of "-static" when it 100*a9fa9459Szrjis in the LDFLAGS environment variable. 101*a9fa9459Szrj 102*a9fa9459SzrjTo build under openVMS/AXP, see the file makefile.vms in the top level 103*a9fa9459Szrjdirectory. 104*a9fa9459Szrj 105*a9fa9459Szrj 106*a9fa9459SzrjNative Language Support 107*a9fa9459Szrj======================= 108*a9fa9459Szrj 109*a9fa9459SzrjBy default Native Language Support will be enabled for binutils. On 110*a9fa9459Szrjsome systems however this support is not present and can lead to error 111*a9fa9459Szrjmessages such as "undefined reference to `libintl_gettext'" when 112*a9fa9459Szrjbuilding there tools. If that happens the NLS support can be disabled 113*a9fa9459Szrjby adding the --disable-nls switch to the configure line like this: 114*a9fa9459Szrj 115*a9fa9459Szrj ../binutils-XXX/configure --disable-nls 116*a9fa9459Szrj 117*a9fa9459Szrj 118*a9fa9459SzrjIf you don't have ar 119*a9fa9459Szrj==================== 120*a9fa9459Szrj 121*a9fa9459SzrjIf your system does not already have an 'ar' program, the normal 122*a9fa9459Szrjbinutils build process will not work. In this case, run configure as 123*a9fa9459Szrjusual. Before running make, run this script: 124*a9fa9459Szrj 125*a9fa9459Szrj#!/bin/sh 126*a9fa9459SzrjMAKE_PROG="${MAKE-make}" 127*a9fa9459SzrjMAKE="${MAKE_PROG} AR=true LINK=true" 128*a9fa9459Szrjexport MAKE 129*a9fa9459Szrj${MAKE} $* all-libiberty 130*a9fa9459Szrj${MAKE} $* all-intl 131*a9fa9459Szrj${MAKE} $* all-bfd 132*a9fa9459Szrjcd binutils 133*a9fa9459SzrjMAKE="${MAKE_PROG}" 134*a9fa9459Szrjexport MAKE 135*a9fa9459Szrj${MAKE} $* ar_DEPENDENCIES= ar_LDADD='../bfd/*.o ../libiberty/*.o `if test -f ../intl/gettext.o; then echo '../intl/*.o'; fi`' ar 136*a9fa9459Szrj 137*a9fa9459SzrjThis script will build an ar program in binutils/ar. Move binutils/ar 138*a9fa9459Szrjinto a directory on your PATH. After doing this, you can run make as 139*a9fa9459Szrjusual to build the complete binutils distribution. You do not need 140*a9fa9459Szrjthe ranlib program in order to build the distribution. 141*a9fa9459Szrj 142*a9fa9459SzrjPorting 143*a9fa9459Szrj======= 144*a9fa9459Szrj 145*a9fa9459SzrjBinutils-2.13 supports many different architectures, but there 146*a9fa9459Szrjare many more not supported, including some that were supported 147*a9fa9459Szrjby earlier versions. We are hoping for volunteers to improve this 148*a9fa9459Szrjsituation. 149*a9fa9459Szrj 150*a9fa9459SzrjThe major effort in porting binutils to a new host and/or target 151*a9fa9459Szrjarchitecture involves the BFD library. There is some documentation 152*a9fa9459Szrjin ../bfd/doc. The file ../gdb/doc/gdbint.texinfo (distributed 153*a9fa9459Szrjwith gdb-5.x) may also be of help. 154*a9fa9459Szrj 155*a9fa9459SzrjReporting bugs 156*a9fa9459Szrj============== 157*a9fa9459Szrj 158*a9fa9459SzrjSend bug reports and patches to: 159*a9fa9459Szrj 160*a9fa9459Szrj bug-binutils@gnu.org. 161*a9fa9459Szrj 162*a9fa9459SzrjPlease include the following in bug reports: 163*a9fa9459Szrj 164*a9fa9459Szrj- A description of exactly what went wrong, and exactly what should have 165*a9fa9459Szrj happened instead. 166*a9fa9459Szrj 167*a9fa9459Szrj- The configuration name(s) given to the "configure" script. The 168*a9fa9459Szrj "config.status" file should have this information. This is assuming 169*a9fa9459Szrj you built binutils yourself. If you didn't build binutils youself, 170*a9fa9459Szrj then we need information regarding your machine and operating system, 171*a9fa9459Szrj and it may be more appropriate to report bugs to wherever you obtained 172*a9fa9459Szrj binutils. 173*a9fa9459Szrj 174*a9fa9459Szrj- The options given to the tool (gas, objcopy, ld etc.) at run time. 175*a9fa9459Szrj 176*a9fa9459Szrj- The actual input file that caused the problem. 177*a9fa9459Szrj 178*a9fa9459SzrjAlways mention the version number you are running; this is printed by 179*a9fa9459Szrjrunning any of the binutils with the --version option. We appreciate 180*a9fa9459Szrjreports about bugs, but we do not promise to fix them, particularly so 181*a9fa9459Szrjwhen the bug report is against an old version. If you are able, please 182*a9fa9459Szrjconsider building the latest tools from git to check that your bug has 183*a9fa9459Szrjnot already been fixed. 184*a9fa9459Szrj 185*a9fa9459SzrjWhen reporting problems about gas and ld, it's useful to provide a 186*a9fa9459Szrjtestcase that triggers the problem. In the case of a gas problem, we 187*a9fa9459Szrjwant input files to gas and command line switches used. The inputs to 188*a9fa9459Szrjgas are _NOT_ .c or .i files, but rather .s files. If your original 189*a9fa9459Szrjsource was a C program, you can generate the .s file and see the command 190*a9fa9459Szrjline options by passing -v -save-temps to gcc in addition to all the 191*a9fa9459Szrjusual options you use. The reason we don't want C files is that we 192*a9fa9459Szrjmight not have a C compiler around for the target you use. While it 193*a9fa9459Szrjmight be possible to build a compiler, that takes considerable time and 194*a9fa9459Szrjdisk space, and we might not end up with exactly the same compiler you 195*a9fa9459Szrjuse. 196*a9fa9459Szrj 197*a9fa9459SzrjIn the case of a ld problem, the input files are .o, .a and .so files, 198*a9fa9459Szrjand possibly a linker script specified with -T. Again, when using gcc 199*a9fa9459Szrjto link, you can see these files by adding options to the gcc command 200*a9fa9459Szrjline. Use -v -save-temps -Wl,-t, except that on targets that use gcc's 201*a9fa9459Szrjcollect2, you would add -v -save-temps -Wl,-t,-debug. The -t option 202*a9fa9459Szrjtells ld to print all files and libraries used, so that, for example, 203*a9fa9459Szrjyou can associate -lc on the ld command line with the actual libc used. 204*a9fa9459SzrjNote that your simple two line C program to trigger a problem typically 205*a9fa9459Szrjexpands into several megabytes of objects by the time you include 206*a9fa9459Szrjlibraries. 207*a9fa9459Szrj 208*a9fa9459SzrjIt is antisocial to post megabyte sized attachments to mailing lists, so 209*a9fa9459Szrjplease put large testcases somewhere on an ftp or web site so that only 210*a9fa9459Szrjinterested developers need to download them, or offer to email them on 211*a9fa9459Szrjrequest. Better still, try to reduce the testcase, for example, try to 212*a9fa9459Szrjdevelop a ld testcase that doesn't use system libraries. However, 213*a9fa9459Szrjplease be sure it is a complete testcase and that it really does 214*a9fa9459Szrjdemonstrate the problem. Also, don't bother paring it down if that will 215*a9fa9459Szrjcause large delays in filing the bug report. 216*a9fa9459Szrj 217*a9fa9459SzrjIf you expect to be contributing a large number of test cases, it would 218*a9fa9459Szrjbe helpful if you would look at the test suite included in the release 219*a9fa9459Szrj(based on the Deja Gnu testing framework, available from the usual ftp 220*a9fa9459Szrjsites) and write test cases to fit into that framework. This is 221*a9fa9459Szrjcertainly not required. 222*a9fa9459Szrj 223*a9fa9459SzrjVMS 224*a9fa9459Szrj=== 225*a9fa9459Szrj 226*a9fa9459SzrjThis section was written by Klaus K"ampf <kkaempf@rmi.de>. It 227*a9fa9459Szrjdescribes how to build and install the binutils on openVMS (Alpha and 228*a9fa9459SzrjVax). (The BFD library only supports reading Vax object files.) 229*a9fa9459Szrj 230*a9fa9459SzrjCompiling the release: 231*a9fa9459Szrj 232*a9fa9459SzrjTo compile the gnu binary utilities and the gnu assembler, you'll 233*a9fa9459Szrjneed DEC C or GNU C for openVMS/Alpha. You'll need *both* compilers 234*a9fa9459Szrjon openVMS/Vax. 235*a9fa9459Szrj 236*a9fa9459SzrjCompiling with either DEC C or GNU C works on openVMS/Alpha only. Some 237*a9fa9459Szrjof the opcodes and binutils files trap a bug in the DEC C optimizer, 238*a9fa9459Szrjso these files must be compiled with /noopt. 239*a9fa9459Szrj 240*a9fa9459SzrjCompiling on openVMS/Vax is a bit complicated, as the bfd library traps 241*a9fa9459Szrja bug in GNU C and the gnu assembler a bug in (my version of) DEC C. 242*a9fa9459Szrj 243*a9fa9459SzrjI never tried compiling with VAX C. 244*a9fa9459Szrj 245*a9fa9459Szrj 246*a9fa9459SzrjYou further need GNU Make Version 3.76 or later. This is available 247*a9fa9459Szrjat ftp.progis.de or any GNU archive site. The makefiles assume that 248*a9fa9459Szrjgmake starts gnu make as a foreign command. 249*a9fa9459Szrj 250*a9fa9459SzrjIf you're compiling with DEC C or VAX C, you must run 251*a9fa9459Szrj 252*a9fa9459Szrj $ @setup 253*a9fa9459Szrj 254*a9fa9459Szrjbefore starting gnu-make. This isn't needed with GNU C. 255*a9fa9459Szrj 256*a9fa9459SzrjOn the Alpha you can choose the compiler by editing the toplevel 257*a9fa9459Szrjmakefile.vms. Either select CC=cc (for DEC C) or CC=gcc (for GNU C) 258*a9fa9459Szrj 259*a9fa9459Szrj 260*a9fa9459SzrjInstalling the release 261*a9fa9459Szrj 262*a9fa9459SzrjProvided that your directory setup conforms to the GNU on openVMS 263*a9fa9459Szrjstandard, you already have a concealed device named 'GNU_ROOT'. 264*a9fa9459SzrjIn this case, a simple 265*a9fa9459Szrj 266*a9fa9459Szrj $ gmake install 267*a9fa9459Szrj 268*a9fa9459Szrjsuffices to copy all programs and libraries to the proper directories. 269*a9fa9459Szrj 270*a9fa9459SzrjDefine the programs as foreign commands by adding these lines to your 271*a9fa9459Szrjlogin.com: 272*a9fa9459Szrj 273*a9fa9459Szrj $ gas :== $GNU_ROOT:[bin]as.exe 274*a9fa9459Szrj $ size :== $GNU_ROOT:[bin]size.exe 275*a9fa9459Szrj $ nm :== $GNU_ROOT:[bin]nm.exe 276*a9fa9459Szrj $ objdump :== $GNU_ROOT:[bin]objdump.exe 277*a9fa9459Szrj $ strings :== $GNU_ROOT:[bin]strings.exe 278*a9fa9459Szrj 279*a9fa9459SzrjIf you have a different directory setup, copy the binary utilities 280*a9fa9459Szrj([.binutils]size.exe, [.binutils]nm.exe, [.binutils]objdump.exe, 281*a9fa9459Szrjand [.binutils]strings.exe) and the gnu assembler and preprocessor 282*a9fa9459Szrj([.gas]as.exe and [.gas]gasp.exe]) to a directory of your choice 283*a9fa9459Szrjand define all programs as foreign commands. 284*a9fa9459Szrj 285*a9fa9459Szrj 286*a9fa9459SzrjIf you're satisfied with the compilation, you may want to remove 287*a9fa9459Szrjunneeded objects and libraries: 288*a9fa9459Szrj 289*a9fa9459Szrj $ gmake clean 290*a9fa9459Szrj 291*a9fa9459Szrj 292*a9fa9459SzrjIf you have any problems or questions about the binutils on VMS, feel 293*a9fa9459Szrjfree to mail me at kkaempf@rmi.de. 294*a9fa9459Szrj 295*a9fa9459SzrjCopyright (C) 2012-2016 Free Software Foundation, Inc. 296*a9fa9459Szrj 297*a9fa9459SzrjCopying and distribution of this file, with or without modification, 298*a9fa9459Szrjare permitted in any medium without royalty provided the copyright 299*a9fa9459Szrjnotice and this notice are preserved. 300