1 1.1 christos README for BINUTILS 2 1.1 christos 3 1.1 christos These are the GNU binutils. These are utilities of use when dealing 4 1.1 christos with binary files, either object files or executables. These tools 5 1.9 christos consist of the linkers (ld and gold), the assembler (gas), and the 6 1.9 christos profiler (gprof and gprofng) each of which have their own 7 1.9 christos sub-directory named after them. There is also a collection of other 8 1.9 christos binary tools, including the disassembler (objdump) in this directory. 9 1.9 christos These tools make use of a pair of libraries (bfd and opcodes) and a 10 1.9 christos common set of header files (include). 11 1.1 christos 12 1.1 christos There are README and NEWS files in most of the program sub-directories 13 1.1 christos which give more information about those specific programs. 14 1.1 christos 15 1.1 christos 16 1.3 christos Copyright Notices 17 1.3 christos ================= 18 1.3 christos 19 1.3 christos Copyright years on binutils source files may be listed using range 20 1.8 christos notation, e.g., 1991-2021, indicating that every year in the range, 21 1.3 christos inclusive, is a copyrightable year that could otherwise be listed 22 1.3 christos individually. 23 1.3 christos 24 1.3 christos 25 1.1 christos Unpacking and Installation -- quick overview 26 1.1 christos ============================================ 27 1.1 christos 28 1.1 christos When you unpack the binutils archive file, you will get a directory 29 1.1 christos called something like `binutils-XXX', where XXX is the number of the 30 1.8 christos release. (Probably 2.36 or higher). This directory contains 31 1.1 christos various files and sub-directories. Most of the files in the top 32 1.1 christos directory are for information and for configuration. The actual 33 1.1 christos source code is in sub-directories. 34 1.1 christos 35 1.8 christos To build binutils you will need a C99 compliant compiler and library. 36 1.8 christos You can just do: 37 1.1 christos 38 1.1 christos cd binutils-XXX 39 1.1 christos ./configure [options] 40 1.1 christos make 41 1.1 christos make install # copies the programs files into /usr/local/bin 42 1.1 christos # by default. 43 1.1 christos 44 1.1 christos This will configure and build all the libraries as well as the 45 1.1 christos assembler, the binutils, and the linker. 46 1.1 christos 47 1.9 christos Note - if you have obtained the sources by checking out a copy from 48 1.9 christos the git repository then you will have both the binutils and GDB 49 1.9 christos sources in one place. In this case you may wish to add an option to 50 1.9 christos the configure command line to stop it from configuring GDB. This will 51 1.9 christos also stop the configure script from checking the libraries that are 52 1.9 christos needed by GDB, but not by the binutils. 53 1.9 christos 54 1.9 christos ./configure --disable-gdb 55 1.9 christos 56 1.9 christos Since the configure script can be quite verbose, you may also 57 1.9 christos want to add the --quiet option to reduce the amount of output. ie: 58 1.9 christos 59 1.9 christos ./configure --quiet 60 1.9 christos 61 1.1 christos If you have GNU make, we recommend building in a different directory: 62 1.1 christos 63 1.1 christos mkdir objdir 64 1.1 christos cd objdir 65 1.1 christos ../binutils-XXX/configure [options] 66 1.1 christos make 67 1.1 christos make install 68 1.1 christos 69 1.1 christos This relies on the VPATH feature of GNU make. 70 1.1 christos 71 1.1 christos By default, the binutils will be configured to support the system on 72 1.1 christos which they are built. When doing cross development, use the --target 73 1.1 christos configure option to specify a different target, eg: 74 1.1 christos 75 1.8 christos ./configure --target=powerpc64le-linux 76 1.1 christos 77 1.1 christos The --enable-targets option adds support for more binary file formats 78 1.1 christos besides the default. List them as the argument to --enable-targets, 79 1.1 christos separated by commas. For example: 80 1.1 christos 81 1.8 christos ./configure --enable-targets=powerpc-linux,rs6000-aix 82 1.1 christos 83 1.1 christos The name 'all' compiles in support for all valid BFD targets: 84 1.1 christos 85 1.1 christos ./configure --enable-targets=all 86 1.1 christos 87 1.1 christos On 32-bit hosts though, this support will be restricted to 32-bit 88 1.1 christos target unless the --enable-64-bit-bfd option is also used: 89 1.1 christos 90 1.1 christos ./configure --enable-64-bit-bfd --enable-targets=all 91 1.1 christos 92 1.1 christos You can also specify the --enable-shared option when you run 93 1.1 christos configure. This will build the BFD and opcodes libraries as shared 94 1.1 christos libraries. You can use arguments with the --enable-shared option to 95 1.1 christos indicate that only certain libraries should be built shared; for 96 1.1 christos example, --enable-shared=bfd. The only potential shared libraries in 97 1.1 christos a binutils release are bfd and opcodes. 98 1.1 christos 99 1.1 christos The binutils will be linked against the shared libraries. The build 100 1.1 christos step will attempt to place the correct library in the run-time search 101 1.1 christos path for the binaries. However, in some cases, after you install the 102 1.1 christos binaries, you may have to set an environment variable, normally 103 1.1 christos LD_LIBRARY_PATH, so that the system can find the installed libbfd 104 1.1 christos shared library. 105 1.1 christos 106 1.1 christos On hosts that support shared system libraries the binutils will be 107 1.1 christos linked against them. If you have static versions of the system 108 1.1 christos libraries installed as well and you wish to create static binaries 109 1.1 christos instead then use the LDFLAGS environment variable, like this: 110 1.1 christos 111 1.1 christos ../binutils-XXX/configure LDFLAGS="--static" [more options] 112 1.1 christos 113 1.1 christos Note: the two dashes are important. The binutils make use of the 114 1.1 christos libtool script which has a special interpretation of "-static" when it 115 1.1 christos is in the LDFLAGS environment variable. 116 1.1 christos 117 1.1 christos To build under openVMS/AXP, see the file makefile.vms in the top level 118 1.1 christos directory. 119 1.1 christos 120 1.1 christos 121 1.1 christos Native Language Support 122 1.1 christos ======================= 123 1.1 christos 124 1.1 christos By default Native Language Support will be enabled for binutils. On 125 1.1 christos some systems however this support is not present and can lead to error 126 1.1 christos messages such as "undefined reference to `libintl_gettext'" when 127 1.9 christos building these tools. If that happens the NLS support can be disabled 128 1.1 christos by adding the --disable-nls switch to the configure line like this: 129 1.1 christos 130 1.1 christos ../binutils-XXX/configure --disable-nls 131 1.1 christos 132 1.1 christos 133 1.1 christos If you don't have ar 134 1.1 christos ==================== 135 1.1 christos 136 1.1 christos If your system does not already have an 'ar' program, the normal 137 1.1 christos binutils build process will not work. In this case, run configure as 138 1.1 christos usual. Before running make, run this script: 139 1.1 christos 140 1.1 christos #!/bin/sh 141 1.1 christos MAKE_PROG="${MAKE-make}" 142 1.1 christos MAKE="${MAKE_PROG} AR=true LINK=true" 143 1.1 christos export MAKE 144 1.1 christos ${MAKE} $* all-libiberty 145 1.1 christos ${MAKE} $* all-intl 146 1.1 christos ${MAKE} $* all-bfd 147 1.1 christos cd binutils 148 1.1 christos MAKE="${MAKE_PROG}" 149 1.1 christos export MAKE 150 1.1 christos ${MAKE} $* ar_DEPENDENCIES= ar_LDADD='../bfd/*.o ../libiberty/*.o `if test -f ../intl/gettext.o; then echo '../intl/*.o'; fi`' ar 151 1.1 christos 152 1.1 christos This script will build an ar program in binutils/ar. Move binutils/ar 153 1.1 christos into a directory on your PATH. After doing this, you can run make as 154 1.1 christos usual to build the complete binutils distribution. You do not need 155 1.1 christos the ranlib program in order to build the distribution. 156 1.1 christos 157 1.1 christos Porting 158 1.1 christos ======= 159 1.1 christos 160 1.8 christos Binutils-2.36 supports many different architectures, but there 161 1.1 christos are many more not supported, including some that were supported 162 1.1 christos by earlier versions. We are hoping for volunteers to improve this 163 1.1 christos situation. 164 1.1 christos 165 1.1 christos The major effort in porting binutils to a new host and/or target 166 1.1 christos architecture involves the BFD library. There is some documentation 167 1.1 christos in ../bfd/doc. The file ../gdb/doc/gdbint.texinfo (distributed 168 1.1 christos with gdb-5.x) may also be of help. 169 1.1 christos 170 1.1 christos Reporting bugs 171 1.1 christos ============== 172 1.1 christos 173 1.8 christos Please report bugs via 174 1.1 christos 175 1.8 christos https://sourceware.org/bugzilla/enter_bug.cgi?product=binutils 176 1.1 christos 177 1.1 christos Please include the following in bug reports: 178 1.1 christos 179 1.1 christos - A description of exactly what went wrong, and exactly what should have 180 1.1 christos happened instead. 181 1.1 christos 182 1.1 christos - The configuration name(s) given to the "configure" script. The 183 1.1 christos "config.status" file should have this information. This is assuming 184 1.1 christos you built binutils yourself. If you didn't build binutils youself, 185 1.1 christos then we need information regarding your machine and operating system, 186 1.1 christos and it may be more appropriate to report bugs to wherever you obtained 187 1.1 christos binutils. 188 1.1 christos 189 1.1 christos - The options given to the tool (gas, objcopy, ld etc.) at run time. 190 1.1 christos 191 1.1 christos - The actual input file that caused the problem. 192 1.1 christos 193 1.1 christos Always mention the version number you are running; this is printed by 194 1.1 christos running any of the binutils with the --version option. We appreciate 195 1.1 christos reports about bugs, but we do not promise to fix them, particularly so 196 1.1 christos when the bug report is against an old version. If you are able, please 197 1.3 christos consider building the latest tools from git to check that your bug has 198 1.1 christos not already been fixed. 199 1.1 christos 200 1.1 christos When reporting problems about gas and ld, it's useful to provide a 201 1.1 christos testcase that triggers the problem. In the case of a gas problem, we 202 1.1 christos want input files to gas and command line switches used. The inputs to 203 1.1 christos gas are _NOT_ .c or .i files, but rather .s files. If your original 204 1.1 christos source was a C program, you can generate the .s file and see the command 205 1.1 christos line options by passing -v -save-temps to gcc in addition to all the 206 1.1 christos usual options you use. The reason we don't want C files is that we 207 1.1 christos might not have a C compiler around for the target you use. While it 208 1.1 christos might be possible to build a compiler, that takes considerable time and 209 1.1 christos disk space, and we might not end up with exactly the same compiler you 210 1.1 christos use. 211 1.1 christos 212 1.1 christos In the case of a ld problem, the input files are .o, .a and .so files, 213 1.1 christos and possibly a linker script specified with -T. Again, when using gcc 214 1.1 christos to link, you can see these files by adding options to the gcc command 215 1.1 christos line. Use -v -save-temps -Wl,-t, except that on targets that use gcc's 216 1.1 christos collect2, you would add -v -save-temps -Wl,-t,-debug. The -t option 217 1.1 christos tells ld to print all files and libraries used, so that, for example, 218 1.1 christos you can associate -lc on the ld command line with the actual libc used. 219 1.1 christos Note that your simple two line C program to trigger a problem typically 220 1.1 christos expands into several megabytes of objects by the time you include 221 1.1 christos libraries. 222 1.1 christos 223 1.8 christos There is a limit to the size of attachments accepted by bugzilla. If 224 1.8 christos compressing your testcase does not result in an acceptable size tar or 225 1.8 christos zip file, please put large testcases somewhere on an ftp or web site. 226 1.8 christos Better still, try to reduce the testcase, for example, try to develop 227 1.8 christos a ld testcase that doesn't use system libraries. However, please be 228 1.8 christos sure it is a complete testcase and that it really does demonstrate the 229 1.8 christos problem. Also, don't bother paring it down if that will cause large 230 1.8 christos delays in filing the bug report. 231 1.1 christos 232 1.1 christos If you expect to be contributing a large number of test cases, it would 233 1.1 christos be helpful if you would look at the test suite included in the release 234 1.1 christos (based on the Deja Gnu testing framework, available from the usual ftp 235 1.1 christos sites) and write test cases to fit into that framework. This is 236 1.1 christos certainly not required. 237 1.1 christos 238 1.1 christos VMS 239 1.1 christos === 240 1.1 christos 241 1.1 christos This section was written by Klaus K"ampf <kkaempf (a] rmi.de>. It 242 1.1 christos describes how to build and install the binutils on openVMS (Alpha and 243 1.1 christos Vax). (The BFD library only supports reading Vax object files.) 244 1.1 christos 245 1.1 christos Compiling the release: 246 1.1 christos 247 1.1 christos To compile the gnu binary utilities and the gnu assembler, you'll 248 1.1 christos need DEC C or GNU C for openVMS/Alpha. You'll need *both* compilers 249 1.1 christos on openVMS/Vax. 250 1.1 christos 251 1.1 christos Compiling with either DEC C or GNU C works on openVMS/Alpha only. Some 252 1.1 christos of the opcodes and binutils files trap a bug in the DEC C optimizer, 253 1.1 christos so these files must be compiled with /noopt. 254 1.1 christos 255 1.1 christos Compiling on openVMS/Vax is a bit complicated, as the bfd library traps 256 1.1 christos a bug in GNU C and the gnu assembler a bug in (my version of) DEC C. 257 1.1 christos 258 1.1 christos I never tried compiling with VAX C. 259 1.1 christos 260 1.1 christos 261 1.1 christos You further need GNU Make Version 3.76 or later. This is available 262 1.1 christos at ftp.progis.de or any GNU archive site. The makefiles assume that 263 1.1 christos gmake starts gnu make as a foreign command. 264 1.1 christos 265 1.1 christos If you're compiling with DEC C or VAX C, you must run 266 1.1 christos 267 1.1 christos $ @setup 268 1.1 christos 269 1.1 christos before starting gnu-make. This isn't needed with GNU C. 270 1.1 christos 271 1.1 christos On the Alpha you can choose the compiler by editing the toplevel 272 1.1 christos makefile.vms. Either select CC=cc (for DEC C) or CC=gcc (for GNU C) 273 1.1 christos 274 1.1 christos 275 1.1 christos Installing the release 276 1.1 christos 277 1.1 christos Provided that your directory setup conforms to the GNU on openVMS 278 1.1 christos standard, you already have a concealed device named 'GNU_ROOT'. 279 1.1 christos In this case, a simple 280 1.1 christos 281 1.1 christos $ gmake install 282 1.1 christos 283 1.1 christos suffices to copy all programs and libraries to the proper directories. 284 1.1 christos 285 1.1 christos Define the programs as foreign commands by adding these lines to your 286 1.1 christos login.com: 287 1.1 christos 288 1.1 christos $ gas :== $GNU_ROOT:[bin]as.exe 289 1.1 christos $ size :== $GNU_ROOT:[bin]size.exe 290 1.1 christos $ nm :== $GNU_ROOT:[bin]nm.exe 291 1.1 christos $ objdump :== $GNU_ROOT:[bin]objdump.exe 292 1.1 christos $ strings :== $GNU_ROOT:[bin]strings.exe 293 1.1 christos 294 1.1 christos If you have a different directory setup, copy the binary utilities 295 1.1 christos ([.binutils]size.exe, [.binutils]nm.exe, [.binutils]objdump.exe, 296 1.1 christos and [.binutils]strings.exe) and the gnu assembler and preprocessor 297 1.1 christos ([.gas]as.exe and [.gas]gasp.exe]) to a directory of your choice 298 1.1 christos and define all programs as foreign commands. 299 1.1 christos 300 1.1 christos 301 1.1 christos If you're satisfied with the compilation, you may want to remove 302 1.1 christos unneeded objects and libraries: 303 1.1 christos 304 1.1 christos $ gmake clean 305 1.1 christos 306 1.1 christos 307 1.1 christos If you have any problems or questions about the binutils on VMS, feel 308 1.1 christos free to mail me at kkaempf (a] rmi.de. 309 1.3 christos 311 1.3 christos Copyright (C) 2012-2025 Free Software Foundation, Inc. 312 1.3 christos 313 1.3 christos Copying and distribution of this file, with or without modification, 314 1.3 christos are permitted in any medium without royalty provided the copyright 315 notice and this notice are preserved. 316