Commit Graph

466 Commits

Author SHA1 Message Date
Nick Clifton
057a2b4c4b Revert: 35fd2ddeb1
PR 20814
2024-06-26 13:17:25 +01:00
Tom Tromey
573b697e9d Fix typo in binutils manual
I happened to notice that the binutils manual has a typo in the name
of a command-line option.
2024-05-08 08:38:05 -06:00
Nick Alcock
6364617120 binutils, objdump: Add --ctf-parent-section
This lets you examine CTF where the parent and child dicts are in entirely
different sections, rather than in a CTF archive with members with different
names.  The linker doesn't emit ELF objects structured like this, but some
third-party linkers may; it's also useful for objcopy-constructed files
in some cases.

(This is what the objdump --ctf-parent option used to do before commit
80b56fad5c in 2021.  The new semantics of that option are much more
useful, but that doesn't mean the old ones are never useful at all, so let's
bring them back.)

(I was specifically driven to add this by DTrace's obscure "ctypes" and
"dtypes" options, which dump its internal, dynamically-generated dicts out
to files for debugging purposes: there are two, one the parent of the other.
Since they're in two separate files rather than a CTF archive and we have no
tools that paste files together into archives, objdump wouldn't show them --
and even pasting them together into an ELF executable with objcopy didn't
help, since objdump had no options that could be used to look in specific
sections for the parent dict.  With --ctf-parent-section, this sort of
obscure use case becomes possible again.  You'll never need it for the
output of the normal linker.)

binutils/

	* doc/ctf.options.texi: Add --ctf-parent-section=.
	* objdump.c (dump_ctf): Implement it.
	(dump_bfd): Likewise.
	(main): Likewise.
2024-04-19 16:14:45 +01:00
Nick Clifton
8e8d0b63ff Add -j/--display-section option to readelf. 2024-04-11 15:57:26 +01:00
Nick Clifton
121a3f4b4f Update objcopy's --section-alignment option so that it sets the alignment flag on PE sections. Add a check for aligned sections not matching their VMAs. 2024-04-02 15:09:16 +01:00
Peter Bergner
4199cf1e15 PowerPC: Add support for Power11 options
binutils/
	* doc/binutils.texi (PowerPC -M option): Mention power11 and pwr11.

gas/
	* config/tc-ppc.c: (md_show_usage): Mention -mpower11 and -mpwr11.
	* doc/c-ppc.texi: Likewise.

opcodes/
	* ppc-dis.c (ppc_opts): Add "power11" and "pwr11" entries.
	(powerpc_init_dialect): Default to "power11".
2024-02-09 10:52:23 -06:00
Alan Modra
fd67aa1129 Update year range in copyright notice of binutils files
Adds two new external authors to etc/update-copyright.py to cover
bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then
updates copyright messages as follows:

1) Update cgen/utils.scm emitted copyrights.
2) Run "etc/update-copyright.py --this-year" with an extra external
   author I haven't committed, 'Kalray SA.', to cover gas testsuite
   files (which should have their copyright message removed).
3) Build with --enable-maintainer-mode --enable-cgen-maint=yes.
4) Check out */po/*.pot which we don't update frequently.
2024-01-04 22:58:12 +10:30
Petr Tesarik
721e21d62f
binutils: Fix documentation typo in the --set-sect-name option
Fix a --set-sect-name typo in the description of objcopy
--rename-section.
2023-12-02 17:39:18 +01:00
Nick Clifton
fab62191f8 Improve objdump's handling of compressed sections.
PR 31062
  * objdump.c (decompressed_dumps): New local variable. (usage): Mention the -z/--decompress option. (long_options): Add --decompress. (dump_section_header): Add "COMPRESSED" to the Flags field of any compressed section. (dump_section): Warn users when dumping a compressed section. (display_any_bfd): Decompress the section if decompressed_dumps is true. (main): Handle the -z/--decompress option.
  * NEWS: Mention the new feature.
  * doc/binutils.texi: Document the new feature.
  * testsuite/binutils-all/objdump.s: Update expected output.
  * testsuite/binutils-all/objdump.exp: Add test of -Z -s.
  * testsuite/binutils-all/objdump.Zs: New file.
  * readelf.c (maybe_expand_or_relocate_section): New function. Contains common code found in dump functions.  Adds a note message if a compressed section is not being decompressed. (dump_section_as_strings): Use new function. (dump_section_as_bytes): Likewise.
2023-11-14 10:57:58 +00:00
Clément Chigot
be381d7175 objcopy: fix typo in --heap and --stack parser
The help says that <reserve> and <commit> should be separated by a ","
but the implementation is checking for ".". Having two numbers being
separated by a "." could be confusing, thus adjust the implementation to
match the help syntax.

binutils/ChangeLog:

	* objcopy.c (copy_main): Set separator to "," between <reserve>
	and <commit> for --heap and --stack.
	* doc/binutils.texi: Add <commit> for --heap and --stack.
2023-10-23 10:17:47 +02:00
Nick Clifton
6f56739807 Allow the use of SOURCE_DATE_EPOCH in the timestamps for members of static archives.
(For some reason this commit was not applied at the time that the patch was approved).
2023-09-26 14:07:23 +01:00
Nick Clifton
b6ac461ace readelf: Add option to display the names of sections referenced by symbols.
PR 30684
  * readelf.c (extra_sym_info): New variable. (section_name_valid): Also check for filedata being NULL. (section_name_print): Delete. (section_index_real): New function.  Returns true if the given section index references a real section. (print_symbol): Rename to print_sumbol_name. (printable_section_name): Use a rotating array of static buffers for the return string. (printable_section_name_from_index): Merge code from dump_relocations and get_symbol_index_type into here. (long_option_values): Add OPTION_NO_EXTRA_SYM_INFO. (options): Add "extra-sym-info" and "no-extra-sym-info". (usage): Mention new options. (parse_args): Parse new options. (get_symbol_index_type): Delete. (print_dynamic_symbol_size): Rename to print_symbol_size. (print_dynamic_symbol): Rename to print_symbol. (print_symbol_table_heading): New function. (process_symbol_table): Use new function.
  * doc/binutils.texi: Document the new option.
  * NEWS: Mention the new feature.
2023-09-05 11:08:23 +01:00
Sam James
b5c37946cc Revert "2.41 Release sources"
This reverts commit 675b9d612c.

See https://sourceware.org/pipermail/binutils/2023-August/128761.html.
2023-08-02 12:06:23 +01:00
Nick Clifton
675b9d612c 2.41 Release sources 2023-08-02 09:23:36 +01:00
Johannes Schauer Marin Rodrigues
6badd1020f objcopy embeds the current time and ignores SOURCE_DATE_EPOCH making the output unreproducible.
bfd
  * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined.
binutils
  * doc/binutils.texi (objcopy): Document change in behaviour of objcopy's --preserve-dates command line option.
ld
  * pe-dll.c (fill_edata): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined.
  * ld.texi (--insert-timestamp): Document change in behaviour.
2023-07-24 16:59:19 +01:00
Fangrui Song
5e24da908d PR30592 objcopy: allow --set-section-flags to add or remove SHF_X86_64_LARGE
For example, objcopy --set-section-flags .data=alloc,large will add
SHF_X86_64_LARGE to the .data section.  Omitting "large" will drop the
SHF_X86_64_LARGE flag.

The bfd_section flag is named generically, SEC_ELF_LARGE, in case other
processors want to follow SHF_X86_64_LARGE.  SEC_ELF_LARGE has the same
value as SEC_TIC54X_BLOCK used by coff.

bfd/
    * section.c: Define SEC_ELF_LARGE.
    * bfd-in2.h: Regenerate.
    * elf64-x86-64.c (elf_x86_64_section_flags, elf_x86_64_fake_sections,
    elf_x86_64_copy_private_section_data): New.

binutils/
    * NEWS: Mention the new feature for objcopy.
    * doc/binutils.texi: Mention "large".
    * objcopy.c (parse_flags): Parse "large".
    (check_new_section_flags): Error if "large" is used with a
    non-x86-64 ELF target.
    * testsuite/binutils-all/x86-64/large-sections.d: New.
    * testsuite/binutils-all/x86-64/large-sections.s: New.
    * testsuite/binutils-all/x86-64/large-sections-i386.d: New.
    * testsuite/binutils-all/x86-64/large-sections-2.d: New.
    * testsuite/binutils-all/x86-64/large-sections-2-x32.d: New.
2023-07-09 10:57:19 -07:00
Kaylee Blake
96cc7918c1 ELF: Strip section header in ELF objects
Section header isn't mandatory on ELF executable nor shared library.
This patch adds a new linker option, -z nosectionheader, to omit ELF
section header, a new objcopy and strip option, --strip-section-headers,
to remove ELF section headers.

bfd/

2023-06-06  H.J. Lu  <hongjiu.lu@intel.com>
	    Kaylee Blake  <klkblake@gmail.com>

	PR ld/25617
	* bfd.c (BFD_NO_SECTION_HEADER): New.
	(BFD_FLAGS_SAVED): Add BFD_NO_SECTION_HEADER.
	(BFD_FLAGS_FOR_BFD_USE_MASK): Likewise.
	* elfcode.h (elf_swap_ehdr_out): Omit section header with
	BFD_NO_SECTION_HEADER.
	(elf_write_shdrs_and_ehdr): Likewise.
	* elfxx-target.h (TARGET_BIG_SYM): Add BFD_NO_SECTION_HEADER
	to object_flags.
	(TARGET_LITTLE_SYM): Likewise.
	* bfd-in2.h: Regenerated.

binutils/

2023-06-06  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/25617
	* NEWS: Mention --strip-section-headers for objcopy and strip.
	* objcopy.c (strip_section_headers): New.
	(command_line_switch): Add OPTION_STRIP_SECTION_HEADERS.
	(strip_options): Add --strip-section-headers.
	(copy_options): Likewise.
	(copy_usage): Add --strip-section-headers.
	(strip_usage): Likewise.
	(copy_object): Handle --strip-section-headers for ELF files.
	(strip_main): Handle OPTION_STRIP_SECTION_HEADERS.
	(copy_main): Likewise.
	* doc/binutils.texi: Document --strip-section-headers for objcopy
	and strip.

ld/

2023-06-06  H.J. Lu  <hongjiu.lu@intel.com>
	    Kaylee Blake  <klkblake@gmail.com>

	PR ld/25617
	* NEWS: Mention -z nosectionheader.
	* emultempl/elf.em: Support -z sectionheader and
	-z nosectionheader.
	* ld.h (ld_config_type): Add no_section_header.
	* ld.texi: Document -z sectionheader and -z nosectionheader.
	* ldlang.c (ldlang_open_output): Handle
	config.no_section_header.
	* lexsup.c (parse_args): Enable --strip-all with
	-z nosectionheader.  Disallow -r with -z nosectionheader.
	(elf_static_list_options): Add -z sectionheader and
	-z nosectionheader.
2023-06-29 10:29:46 -07:00
Nick Clifton
45b8517aae Enhance objdump's --private option so that it can display the contents of PE format files.
* od-pe.c: New file: Dumps fields in PE format headers.
  * configure.ac (od_vectors): Add objdump_private_desc_pe for PE format targets. (od_files): Add od-pe for PE format targets.
  * configure: Regenerate.
  * Makefile.am (CFILES): Add od-pe.c (EXTRA_objdump_SOURCE): Likewise.
  * Makefile.in: Generate.
  * NEWS: Mention the new feature.
  * doc/binutils.texi: Document the new support.
  * objdump.c (wide_output): Change from local to global.
  * objdump.h (wide_output): Prototype. (objdump_private_desc_pe): Prototype.
  * testsuite/binutils-all/objdump.exp: Add a test of the new feature.
2023-05-26 15:41:20 +01:00
Alan Modra
0a3137ce4c objdump -D of bss sections and -s with -j
There is some inconsistency between the behaviour of objdump -D and
objdump -s, both supposedly operating on all sections by default.
objdump -s ignores bss sections, while objdump -D dissassembles the
zeros.  Fix this by making objdump -D ignore bss sections too.

Furthermore, "objdump -s -j .bss" doesn't dump .bss as it should,
since the user is specifically asking to look at all those zeros.

This change does find some tests that used objdump -D with expected
output in bss-style sections.  I've updated all the msp430 tests that
just wanted to find a non-empty section to look at section headers
instead, making the tests slightly more stringent.  The ppc xcoff and
spu tests are fixed by adding -j options to objdump, which makes the
tests somewhat more lenient.

binutils/
	* objdump.c (disassemble_section): Ignore sections without
	contents, unless overridden by -j.
	(dump_section): Allow -j to override the default of not
	displaying sections without contents.
	* doc/binutils.texi (objdump options): Update -D, -s and -j
	description.
gas/
	* testsuite/gas/ppc/xcoff-tls-32.d: Select wanted objdump
	sections with -j.
	* testsuite/gas/ppc/xcoff-tls-64.d: Likewise.
ld/
	* testsuite/ld-msp430-elf/main-bss-lower.d,
	* testsuite/ld-msp430-elf/main-bss-upper.d,
	* testsuite/ld-msp430-elf/main-const-lower.d,
	* testsuite/ld-msp430-elf/main-const-upper.d,
	* testsuite/ld-msp430-elf/main-text-lower.d,
	* testsuite/ld-msp430-elf/main-text-upper.d,
	* testsuite/ld-msp430-elf/main-var-lower.d,
	* testsuite/ld-msp430-elf/main-var-upper.d: Expect -wh output.
	* testsuite/ld-msp430-elf/msp430-elf.exp: Use objdump -wh
	rather than objdump -D or objdump -d with tests checking for
	non-empty given sections.
	* testsuite/ld-spu/ear.d,
	* testsuite/ld-spu/icache1.d,
	* testsuite/ld-spu/ovl.d,
	* testsuite/ld-spu/ovl2.d: Select wanted objdump sections.
2023-02-11 16:43:54 +10:30
Nick Clifton
3a8be578d6 Fix documentation of the 'n' symbol type displayed by nm.
PR 30080 * doc/binutils.texi (nm): Update description of the 'n' symbol type.
2023-02-07 11:41:28 +00:00
Alan Modra
d87bef3a7b Update year range in copyright notice of binutils files
The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2023-01-01 21:50:11 +10:30
Nick Clifton
c7ce51d8c8 Fix previous delta to allow for compilation on 32-bit systems 2022-12-16 15:44:55 +00:00
Alan Modra
b8d7a9572d PR10368, ISO 8859 mentioned as 7bit encoding in strings documentation
PR 10368
	* doc/binutils.texi (strings): Delete example of 7-bit encoding.
2022-11-28 20:16:59 +10:30
Nick Clifton
1a7e622b82 Fix ARM and AArch64 assembler tests to work in a multi-arch environment.
PR 29764
gas	* testsuite/gas/arm/cpu-cortex-a76ae.d: Add arm prefix to the -m
	option passed to objdump.
	* testsuite/gas/arm/cpu-cortex-a77.d: Likewise.
	* testsuite/gas/aarch64/cpu-cortex-a76ae.d: Add aarch64 prefix to
	the -m option passed to objdump.
	* testsuite/gas/aarch64/cpu-cortex-a77.d: Likewise.

bfd	* cpu-arm.c (scan): Accept machine names prefixed with "arm:".
	* cpu-aarch64.c (scan): Accept machine names prefixed with "aarch64:".

bin	* doc/binutils.texi (objdump): Note that the -m option supports
	the <architecture>:<machine> syntax.
2022-11-21 16:44:02 +00:00
Indu Bhagat
42b6953bba readelf/objdump: support for SFrame section
This patch adds support for SFrame in readelf and objdump. The arguments
of --sframe are optional for both readelf and objdump.

include/ChangeLog:

	* sframe-api.h (dump_sframe): New function declaration.

ChangeLog:

	* binutils/Makefile.am: Add dependency on libsframe for
	readelf and objdump.
	* binutils/Makefile.in: Regenerate.
	* binutils/doc/binutils.texi: Document --sframe=[section].
	* binutils/doc/sframe.options.texi: New file.
	* binutils/objdump.c: Add support for SFrame format.
	* binutils/readelf.c: Likewise.
	* include/sframe-api.h: Add new API for dumping .sframe
	section.
	* libsframe/Makefile.am: Add sframe-dump.c.
	* libsframe/Makefile.in: Regenerate.
	* libsframe/sframe-dump.c: New file.
2022-11-15 15:50:05 -08:00
Nick Clifton
18bf56434d objdump: Add configure time option to enable colored disassembly output by default.
PR 29457
	* configure.ac: Add --enable-colored-disassembly.
	* objdump.c: Add --disassembler-color=terminal.
	* doc/binutils.texi (objdump): Document the new option.
	* NEWS: Mention new feature.
	* config.in: Regenerate in.
	* configure: Regenerate.
2022-10-31 09:35:16 +00:00
Tsukasa OI
b64dc199b0 binutils: Remove unused substitution PROGRAM
Unlike other substitution, this substitution of @PROGRAM@ was done in
binutils/Makefile and it was intended for binutils/cxxfilt.man.  @PROGRAM@
in binutils/cxxfilt.man is removed in the commit 0285c67df1 ("Automate
generate on man pages") in 2001 and @PROGRAM@ is ineffective since then.

Because PROGRAM substitution does nothing, removing this manual
substitution should be completely safe.

binutils/ChangeLog:

	* doc/local.mk: Remove unused substitution PROGRAM.
	* Makefile.in: Regenerate.
2022-10-20 00:42:13 +00:00
Alan Modra
61a457e5da e200 LSP support
It has bothered me for a long time that we have disabled LSP (and SPE)
tests.  Also the LSP test comment indicating there is something wrong
with get_powerpc_dialect.  I don't think there is.  Decoding of a VLE
instruction depends on whether the processor is in VLE mode (some
processors support both VLE and standard PPC) which we flag per
section with SHF_PPC_VLE for decoding when disassembling.

Background: Some versions of powerpc e200 have "Lightweight Signal
Processing" support, examples being e200z215 and e200z425.  As far as
I can tell, LSP and SPE are mutually exclusive.  This seems to be
borne out by insn encoding, for example LSP "zvaddih" and SPE "evaddw"
have the same encoding.  So none of the processor descriptions in
ppc_opts ought to have both PPC_OPCODE_LSP and PPC_OPCODE_SPE/2, if we
want disassembly to work.  I also could not find anything to suggest
that the LSP insns are enabled only in VLE mode, which means the LSP
insns should not be in vle_opcodes.

Fix all this by moving the LSP insns to their own table, and add a new
e200z2 cpu entry with LSP support, removing LSP from -me200z4 and from
-mvle.  (Yes, I know, as I said above some of the e200z4 processors
have LSP.  Others have SPE.  It's hard to choose good options.  Think
of z2 as meaning earlier, z4 as later.)  Also add -mlsp to allow
adding the LSP insn set.

include/
	* opcode/ppc.h (lsp_opcodes, lsp_num_opcodes): Declare.
	(LSP_OP_TO_SEG): Define.
binutils/
	* doc/binutils.texi: Update ppc docs.
gas/
	* config/tc-ppc.c (ppc_setup_opcodes): Add lsp opcodes to ppc_hash.
	* doc/c-ppc.texi: Document e200 and lsp.
	* testsuite/gas/ppc/lsp-checks.d: Assemble with -me200z2.
	* testsuite/gas/ppc/lsp.d: Likewise, disassembly too.
	* testsuite/gas/ppc/ppc.exp: Don't xfail lsp test.
opcodes/
	* ppc-dis.c (ppc_opts): Add e200z2 and lsp.  Don't set
	PPC_OPCODE_LSP for e200z4 or vle.
	(ppc_parse_cpu): Mutually exclude LSP and SPE.
	(LSP_OPCD_SEGS): Define.
	(lsp_opcd_indices): New array.
	(disassemble_init_powerpc): Init lsp_opcd_indices.
	(lookup_lsp): New function.
	(print_insn_powerpc): Call it.
	* ppc-opc.c: Include libiberty.h for ARRAY_SIZE and use throughout.
	(vle_opcodes): Move LSP opcodes to..
	(lsp_opcodes): ..here, and sort.
	(lsp_num_opcodes): New.
2022-10-14 22:07:18 +10:30
Nick Clifton
be5f79aa39 The help document of size misses an option.
PR 29628
	* size.c (usage): Add -f.
	* doc/binutils.texi (size): Add -f.
2022-09-28 15:29:18 +01:00
Fangrui Song
2cac01e3ff binutils, gdb: support zstd compressed debug sections
PR29397 PR29563: Add new configure option --with-zstd which defaults to
auto.  If pkgconfig/libzstd.pc is found, define HAVE_ZSTD and support
zstd compressed debug sections for most tools.

* bfd: for addr2line, objdump --dwarf, gdb, etc
* gas: support --compress-debug-sections=zstd
* ld: support ELFCOMPRESS_ZSTD input and --compress-debug-sections=zstd
* objcopy: support ELFCOMPRESS_ZSTD input for
  --decompress-debug-sections and --compress-debug-sections=zstd
* gdb: support ELFCOMPRESS_ZSTD input.  The bfd change references zstd
  symbols, so gdb has to link against -lzstd in this patch.

If zstd is not supported, ELFCOMPRESS_ZSTD input triggers an error.  We
can avoid HAVE_ZSTD if binutils-gdb imports zstd/ like zlib/, but this
is too heavyweight, so don't do it for now.

```
% ld/ld-new a.o
ld/ld-new: a.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support
...

% ld/ld-new a.o --compress-debug-sections=zstd
ld/ld-new: --compress-debug-sections=zstd: ld is not built with zstd support

% binutils/objcopy --compress-debug-sections=zstd a.o b.o
binutils/objcopy: --compress-debug-sections=zstd: binutils is not built with zstd support

% binutils/objcopy b.o --decompress-debug-sections
binutils/objcopy: zstd.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support
...
```
2022-09-26 19:50:13 -07:00
Peter Bergner
29a6701e53 ppc: Document the -mfuture and -Mfuture options and make them usable
The -mfuture and -Mfuture options which are used for adding potential
new ISA instructions were not documented.  They also lacked a bitmask
so new instructions could not be enabled by those options.  Fixed.

binutils/
	* doc/binutils.texi: Document -Mfuture.

gas/
	* config/tc-ppc.c: Document -mfuture
	* doc/c-ppc.texi: Likewise.

include/
	* opcode/ppc.h (PPC_OPCODE_FUTURE): Define.

opcodes/
	* ppc-dis.c (ppc_opts) <future>: Use it.
	* ppc-opc.c (FUTURE): Define.
2022-09-12 14:56:20 -05:00
Nick Clifton
25ee24d990 Add an option to dlltool to allow the creation of deterministic libraries.
PR 29489
	* dlltool.c (deterministic): New variable.
	(gen_lib_file): If deterministic is true set the
	BFD_DETERMINISTIC_OUTPUT flag.
	(usage): Mention --deterministic-libraries and
	--non-deterministic-libraries.
	(long_options): Add new options.
	(main): Parse new options.
	* doc/binutils.texi: Document the new options.
	* NEWS: Mention the new feature.
2022-08-23 09:54:52 +01:00
Nick Clifton
a88c79b770 Default to enabling colored disassembly if output is to a terminal.
PR 29457
	* objdump.c (disassembler_color): Change type to an enum.
	(disassembler_extended_color): Remove.
	(usage): Update.
	(objdump_color_for_assembler_style): Update.
	(main): Update initialisation of disassembler_color.  If not
	initialised via a command line option, set based upon terminal
	output.
	* doc/binutils.texi: Update description of disassmbler-color
	option.
	* testsuite/binutils-all/arc/objdump.exp: Add
	--disassembler-color=off option when disassembling.
	* testsuite/binutils-all/arm/objdump.exp: Likewise.
2022-08-09 14:57:48 +01:00
Nick Clifton
2c3cc81e06 Add a --no-weak option to nm.
PR 29135
	* nm.c (non_weak): New variable.
	(filter_symbols): When non-weak is true, ignore weak symbols.
	(long_options): Add --no-weak.
	(usage): Mention --no-weak.
	(main): Handle -W/--no-weak.
	* doc/binutils.texi: Document new feature.
	* NEWS: Mention the new feature.
	* testsuite/binutils-all/nm.exp: Add test of new feature.
	* testsuite/binutils-all/no-weak.s: New test source file.
2022-05-18 13:15:22 +01:00
Nick Clifton
aa02037b08 nm: use -U as an alias for --defines-only, in line with llvm-nm 2022-05-11 13:54:30 +01:00
Andrew Burgess
60a3da00bd objdump/opcodes: add syntax highlighting to disassembler output
This commit adds the _option_ of having disassembler output syntax
highlighted in objdump.  This option is _off_ by default.  The new
command line options are:

  --disassembler-color=off		# The default.
  --disassembler-color=color
  --disassembler-color=extended-color

I have implemented two colour modes, using the same option names as we
use of --visualize-jumps, a basic 8-color mode ("color"), and an
extended 8bit color mode ("extended-color").

The syntax highlighting requires that each targets disassembler be
updated; each time the disassembler produces some output we now pass
through an additional parameter indicating what style should be
applied to the text.

As updating all target disassemblers is a large task, the old API is
maintained.  And so, a user of the disassembler (i.e. objdump, gdb)
must provide two functions, the current non-styled print function, and
a new, styled print function.

I don't currently have a plan for converting every single target
disassembler, my hope is that interested folk will update the
disassemblers they are interested in.  But it is possible some might
never get updated.

In this initial series I intend to convert the RISC-V disassembler
completely, and also do a partial conversion of the x86 disassembler.
Hopefully having the x86 disassembler at least partial converted will
allow more people to try this out easily and provide feedback.

In this commit I have focused on objdump.  The changes to GDB at this
point are the bare minimum required to get things compiling, GDB makes
no use of the styling information to provide any colors, that will
come later, if this commit is accepted.

This first commit in the series doesn't convert any target
disassemblers at all (the next two commits will update some targets),
so after this commit, the only color you will see in the disassembler
output, is that produced from objdump itself, e.g. from
objdump_print_addr_with_sym, where we print an address and a symbol
name, these are now printed with styling information, and so will have
colors applied (if the option is on).

Finally, my ability to pick "good" colors is ... well, terrible.  I'm
in no way committed to the colors I've picked here, so I encourage
people to suggest new colors, or wait for this commit to land, and
then patch the choice of colors.

I do have an idea about using possibly an environment variable to
allow the objdump colors to be customised, but I haven't done anything
like that in this commit, the color choices are just fixed in the code
for now.

binutils/ChangeLog:

	* NEWS: Mention new feature.
	* doc/binutils.texi (objdump): Describe --disassembler-color
	option.
	* objdump.c (disassembler_color): New global.
	(disassembler_extended_color): Likewise.
	(disassembler_in_comment): Likewise.
	(usage): Mention --disassembler-color option.
	(long_options): Add --disassembler-color option.
	(objdump_print_value): Use fprintf_styled_func instead of
	fprintf_func.
	(objdump_print_symname): Likewise.
	(objdump_print_addr_with_sym): Likewise.
	(objdump_color_for_disassembler_style): New function.
	(objdump_styled_sprintf): New function.
	(fprintf_styled): New function.
	(disassemble_jumps): Use disassemble_set_printf, and reset
	disassembler_in_comment.
	(null_styled_print): New function.
	(disassemble_bytes): Use disassemble_set_printf, and reset
	disassembler_in_comment.
	(disassemble_data): Update init_disassemble_info call.
	(main): Handle --disassembler-color option.

include/ChangeLog:

	* dis-asm.h (enum disassembler_style): New enum.
	(struct disassemble_info): Add fprintf_styled_func field, and
	created_styled_output field.
	(disassemble_set_printf): Declare.
	(init_disassemble_info): Add additional parameter.
	(INIT_DISASSEMBLE_INFO): Add additional parameter.

opcodes/ChangeLog:

	* dis-init.c (init_disassemble_info): Take extra parameter,
	initialize the new fprintf_styled_func and created_styled_output
	fields.
	* disassembler.c (disassemble_set_printf): New function definition.
2022-04-04 13:10:52 +01:00
Nick Clifton
bed566bbf6 Add option to objdump/readelf to disable access to debuginfod servers.
* dwarf.c (use_debuginfod): New variable.  Set to 1.
	(load_separate_debug_info): Only call
	debuginfod_fetch_separate_debug_info is use_debuginfod is true.
	(dwarf_select_sections_by_names): Add do-not-use-debuginfod and
	use-debuginfod options.
	(dwarf_select_sections_by_letters): Add D and E options.
	* dwarf.h (use_debuginfod): New extern.
	* objdump.c (usage): Mention the new options.
	* readelf.c (usage): Likewise.
	* doc/binutils.texi: Document the new options.
	* doc/debug-options.texi: Describe the new options.
	* NEWS: Mention the new feature.
	* testsuite/binutils-all/debuginfod.exp: Add tests of the new
	options.
2022-03-10 09:11:40 +00:00
Andi Kleen
fd3c53675c Support symbol+offset lookup in addr2line
The Linux kernel usually ouputs symbol+offset instead of plain code
addresses these days, to avoid leaking ASLR secrets and to handle
dynamically loaded modules.

Converting those with addr2line is somewhat involved: it requires
looking up the symbol first using nm and then manually compute the
offset, and then pass it to addr2line.

This patch implements the necessary steps directly in addr2line,
by looking up the symbol (with demangling if needed) and computing
the offset.

It's possible that a symbol is ambigious with a hex number. In this
case it uses the symbol lookup if the string contains a +. When it isn't
ambigious the + is optional.
2022-02-03 18:41:56 -08:00
Fangrui Song
d1b69c506f ar: Add --thin for creating thin archives
In many ar implementations (FreeBSD, elfutils, etc), -T has the X/Open
System Interface specified semantics. Therefore -T for thin archives is
not recommended for portability. -T is deprecated without diagnostics.

    PR binutils/28759
    * ar.c (long_options): Add --thin.
    (usage) Add --thin. Deprecate -T without diagnostics.
    * doc/binutils.texi: Add doc.
    * NEWS: Mention --thin.
    * binutils/testsuite/binutils-all/ar.exp: Add tests.
2022-01-11 08:59:40 -08:00
H.J. Lu
8acecab0b0 doc: Replace =frame-interp with =frames-interp
The actual objdump and readelf option name is =frames-interp, not
=frames-interp.

	PR binutils/28747
	* doc/debug.options.texi: Replace =frame-interp with
	=frames-interp.
2022-01-05 11:51:40 -08:00
Alan Modra
a2c5833233 Update year range in copyright notice of binutils files
The result of running etc/update-copyright.py --this-year, fixing all
the files whose mode is changed by the script, plus a build with
--enable-maintainer-mode --enable-cgen-maint=yes, then checking
out */po/*.pot which we don't update frequently.

The copy of cgen was with commit d1dd5fcc38ead reverted as that commit
breaks building of bfp opcodes files.
2022-01-02 12:04:28 +10:30
Alan Modra
5ab88688f0 Typo fixes in binutils doc
* doc/binutils.texi: Fix typos.
2021-12-21 16:58:57 +10:30
Mike Frysinger
cd06c1cab2 binutils: add missing prefix for binutils/index.html rule 2021-12-01 16:00:49 -05:00
Roland McGrath
6e2acee1b5 Fix missing build dependency for binutils man pages
binutils/
	* doc/local.mk: Give each man page target its missing dependency on
	doc/$(am__dirstamp).
2021-11-30 10:16:45 -08:00
Mike Frysinger
45c06bb712 binutils: merge doc subdir up a level
This avoids a recursive make into the doc subdir and speeds up the
build slightly.  It also allows for more parallelism.
2021-11-29 20:26:26 -05:00
Mike Frysinger
d8bbdb9dd5 binutils: enable silent build rules
Also add $(AM_V_xxx) to various manual rules in here.
2021-11-29 20:26:26 -05:00
Nick Clifton
8fee99c3c8 Update description of string's -n option.
PR 28632
	* strings.c (usage): Update desciption of -n option.
	* doc/binutils.texi: Likewise.
2021-11-29 14:52:42 +00:00
H.J. Lu
c9dcc18f8d elfedit: Add --output-abiversion option to update ABIVERSION
* NEWS: Mention --output-abiversion.
	* elfedit.c (input_elf_abiversion): New.
	(output_elf_abiversion): Likewise.
	(update_elf_header): Update EI_ABIVERSION.
	(command_line_switch): Add OPTION_INPUT_ABIVERSION and
	OPTION_OUTPUT_ABIVERSION.
	(options): Add --input-abiversion and --output-abiversion.
	(usage): Likewise.
	(main): Handle --input-abiversion and --output-abiversion.
	* doc/binutils.texi: Document --input-abiversion and
	--output-abiversion.
	* testsuite/binutils-all/elfedit.exp: Run elfedit-6.
	* testsuite/binutils-all/elfedit-6.d: New file.
2021-11-17 05:15:48 -08:00
Nick Clifton
b3aa80b45c Add --unicode option to control how unicode characters are handled by display tools.
* nm.c: Add --unicode option to control how unicode characters are
	handled.
	* objdump.c: Likewise.
	* readelf.c: Likewise.
	* strings.c: Likewise.
	* binutils.texi: Document the new feature.
	* NEWS: Document the new feature.
	* testsuite/binutils-all/unicode.exp: New file.
	* testsuite/binutils-all/nm.hex.unicode
	* testsuite/binutils-all/strings.escape.unicode
	* testsuite/binutils-all/objdump.highlight.unicode
	* testsuite/binutils-all/readelf.invalid.unicode
2021-11-09 13:25:42 +00:00
Nick Alcock
10909ea819 binutils, ld: make objdump --ctf's parameter optional
ld by default (and always, unless adjusted with a hand-rolled linker
script) emits deduplicated CTF into the .ctf section.  But viewing
it needs you to explicitly tell objdump this: it doesn't default
its argument, even though what you always end up typing is
--ctf=.ctf.

This is annoying, so make the argument optional.

binutils/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (usage): --ctf now has an optional argument.
	(main): Adjust accordingly.
	(dump_ctf): Default it.
	* doc/ctf.options.texi: Adjust.

ld/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

	* testsuite/ld-ctf/array.d: Change --ctf=.ctf to --ctf.
	* testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise.
	* testsuite/ld-ctf/conflicting-enums.d: Likewise.
	* testsuite/ld-ctf/conflicting-typedefs.d: Likewise.
	* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
	* testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d: Likewise.
	* testsuite/ld-ctf/cross-tu-into-cycle.d: Likewise.
	* testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
	* testsuite/ld-ctf/cycle-1.d: Likewise.
	* testsuite/ld-ctf/cycle-2.A.d: Likewise.
	* testsuite/ld-ctf/cycle-2.B.d: Likewise.
	* testsuite/ld-ctf/cycle-2.C.d: Likewise.
	* testsuite/ld-ctf/data-func-conflicted.d: Likewise.
	* testsuite/ld-ctf/diag-cttname-null.d: Likewise.
	* testsuite/ld-ctf/diag-cuname.d: Likewise.
	* testsuite/ld-ctf/diag-parlabel.d: Likewise.
	* testsuite/ld-ctf/enum-forward.d: Likewise.
	* testsuite/ld-ctf/enums.d: Likewise.
	* testsuite/ld-ctf/forward.d: Likewise.
	* testsuite/ld-ctf/function.d: Likewise.
	* testsuite/ld-ctf/nonrepresentable.d: Likewise.
	* testsuite/ld-ctf/slice.d: Likewise.
	* testsuite/ld-ctf/super-sub-cycles.d: Likewise.
2021-10-25 11:17:03 +01:00