Commit Graph

4146 Commits

Author SHA1 Message Date
Nick Alcock
caf606c90d libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case
My previous nm patch handled all cases but one -- if the user set NM in
the environment to a path which contained an option, libtool's nm
detection tries to run nm against a copy of nm with the options in it:
e.g. if NM was set to "nm --blargle", and nm was found in /usr/bin, the
test would try to run "/usr/bin/nm --blargle /usr/bin/nm --blargle".
This is unlikely to be desirable: in this case we should run
"/usr/bin/nm --blargle /usr/bin/nm".

Furthermore, as part of this nm has to detect when the passed-in $NM
contains a path, and in that case avoid doing a path search itself.
This too was thrown off if an option contained something that looked
like a path, e.g. NM="nm -B../prev-gcc"; libtool then tries to run
"nm -B../prev-gcc nm" which rarely works well (and indeed it looks
to see whether that nm exists, finds it doesn't, and wrongly concludes
that nm -p or whatever does not work).

Fix all of these by clipping all options (defined as everything
including and after the first " -") before deciding whether nm
contains a path (but not using the clipped value for anything else),
and then removing all options from the path-modified nm before
looking to see whether that nm existed.

NM=my-nm now does a path search and runs e.g.
  /usr/bin/my-nm -B /usr/bin/my-nm

NM=/usr/bin/my-nm now avoids a path search and runs e.g.
  /usr/bin/my-nm -B /usr/bin/my-nm

NM="my-nm -p../wombat" now does a path search and runs e.g.
  /usr/bin/my-nm -p../wombat -B /usr/bin/my-nm

NM="../prev-binutils/new-nm -B../prev-gcc" now avoids a path search:
  ../prev-binutils/my-nm -B../prev-gcc -B ../prev-binutils/my-nm

This seems to be all combinations, including those used by GCC bootstrap
(which, before this commit, fails to bootstrap when configured
--with-build-config=bootstrap-lto, because the lto plugin is now using
--export-symbols-regex, which requires libtool to find a working nm,
while also using -B../prev-gcc to point at the lto plugin associated
with the GCC just built.)

Regenerate all affected configure scripts.

	* libtool.m4 (LT_PATH_NM): Handle user-specified NM with
	options, including options containing paths.
2022-03-25 12:02:35 +00:00
Jan Beulich
ed084cdcc8 MAINTAINERS: add myself
I much appreciate Nick offering this role to me. Nevertheless there's
still a lot for me to learn here.

At this occasion also update my email address in the pre-existing, much
more narrow entry.
2022-03-24 09:35:56 +01:00
Fangrui Song
260ecdcec4 objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols
PR binutils/28926
    * objcopy.c (filter_symbols): Apply weaken to STB_GNU_UNIQUE symbols
    * NEWS: Mention feature.
    * testsuite/binutils-all/objcopy.exp (objcopy_test_symbol_manipulation): New test.
    * testsuite/binutils-all/weaken-gnu-unique.s: New.
2022-03-16 09:40:13 -07:00
Martin Storsj?
d65c0ddddd dlltool: Use the output name as basis for deterministic temp prefixes
PR 28885
	* dlltool.c (main): use imp_name rather than dll_name when
	generating a temporary file name.
2022-03-16 15:22:05 +00:00
Simon Marchi
0c857ef4df binutils/readelf: handle AMDGPU relocation types
Make readelf recognize AMDGPU relocation types, as documented here:

  https://llvm.org/docs/AMDGPUUsage.html#amdgpu-relocation-records

The user-visible change looks like:

    -000000000004  000400000001 unrecognized: 1       0000000000000000 SCRATCH_RSRC_DWORD0
    -00000000000c  000500000001 unrecognized: 1       0000000000000000 SCRATCH_RSRC_DWORD1
    -000000000014  000600000007 unrecognized: 7       0000000000000000 global_var0
    -00000000001c  000700000008 unrecognized: 8       0000000000000000 global_var1
    -000000000024  000800000009 unrecognized: 9       0000000000000000 global_var2
    -00000000002c  00090000000a unrecognized: a       0000000000000000 global_var3
    -000000000034  000a0000000b unrecognized: b       0000000000000000 global_var4
    +000000000004  000400000001 R_AMDGPU_ABS32_LO 0000000000000000 SCRATCH_RSRC_DWORD0
    +00000000000c  000500000001 R_AMDGPU_ABS32_LO 0000000000000000 SCRATCH_RSRC_DWORD1
    +000000000014  000600000007 R_AMDGPU_GOTPCREL 0000000000000000 global_var0
    +00000000001c  000700000008 R_AMDGPU_GOTPCREL 0000000000000000 global_var1
    +000000000024  000800000009 R_AMDGPU_GOTPCREL 0000000000000000 global_var2
    +00000000002c  00090000000a R_AMDGPU_REL32_LO 0000000000000000 global_var3
    +000000000034  000a0000000b R_AMDGPU_REL32_HI 0000000000000000 global_var4

binutils/ChangeLog:

	* readelf.c (dump_relocations): Handle EM_AMDGPU.

include/ChangeLog:

	* elf/amdgpu.h: Add relocation values.

Change-Id: I2ed4589f4cd37ea11ad2e0cb38d4b682271e1334
2022-03-16 09:01:54 -04:00
Simon Marchi
2952f10cd7 binutils/readelf: build against msgpack, dump NT_AMDGPU_METADATA note contents
The AMDGPU HSA OS ABI (code object v3 and above) defines the
NT_AMDGPU_METADATA ELF note [1].  The content is a msgpack object
describing, among other things, the kernels present in the code object
and how to call them.

I think it would be useful for readelf to be able to display the content
of those notes.  msgpack is a structured format, a bit like JSON, except
not text-based.  It is therefore possible to dump the contents in
human-readable form without knowledge of the specific layout of the
note.

Add configury to binutils to optionally check for the msgpack C library
[2].  Add There is a new --with{,out}-msgpack configure flag, and the actual
library lookup is done using pkg-config.

If msgpack support is enabled, dumping a NT_AMDGPU_METADATA note looks
like:

    $ readelf --notes amdgpu-code-object
    Displaying notes found in: .note
      Owner                Data size        Description
      AMDGPU               0x0000040d       NT_AMDGPU_METADATA (code object metadata)
        {
          "amdhsa.kernels": [
            {
              ".args": [
                {
                  ".address_space": "global",
                  ".name": "out.coerce",
                  ".offset": 0,
                  ".size": 8,
                  ".value_kind": "global_buffer",
                },
      <snip>

If msgpack support is disabled, dump the contents as hex, as is done
with notes that are not handled in a special way.  This allows one to
decode the contents manually (maybe using a command-line msgpack
decoder) if really needed.

[1] https://llvm.org/docs/AMDGPUUsage.html#code-object-metadata
[2] https://github.com/msgpack/msgpack-c/tree/c_master

binutils/ChangeLog:

	* Makefile.am (readelf_CFLAGS): New.
	(readelf_LDADD): Add MSGPACK_LIBS.
	* Makefile.in: Re-generate.
	* config.in: Re-generate.
	* configure: Re-generate.
	* configure.ac: Add --with-msgpack flag and check for msgpack
	using pkg-config.
	* readelf.c: Include msgpack.h if HAVE_MSGPACK.
	(print_note_contents_hex): New.
	(print_indents): New.
	(dump_msgpack_obj): New.
	(dump_msgpack): New.
	(print_amdgpu_note): New.
	(process_note): Handle NT_AMDGPU_METADATA note contents.
	Use print_note_contents_hex.

Change-Id: Ia60a654e620bc32dfdb1bccd845594e2af328b84
2022-03-16 09:01:43 -04:00
Simon Marchi
28cdbb183b binutils/readelf: handle NT_AMDGPU_METADATA note name
Handle the NT_AMDGPU_METADATA note, which is described here:

  https://llvm.org/docs/AMDGPUUsage.html#code-object-v3-note-records

As of this patch, just print out the name, not the contents, which is in
the msgpack format.

binutils/ChangeLog:

	* readelf.c (get_amdgpu_elf_note_type): New.
	(process_note): Handle "AMDGPU" notes.

include/ChangeLog:

	* elf/amdgcn.h (NT_AMDGPU_METADATA): New.

Change-Id: Id2dba2e2aeaa55ef7464fb35aee9c7d5f96ddb23
2022-03-16 09:01:26 -04:00
Simon Marchi
c077c5802c binutils/readelf: decode AMDGPU-specific e_flags
Decode and print the AMDGPU-specific fields of e_flags, as documented
here:

  https://llvm.org/docs/AMDGPUUsage.html#header

That is:

 - The specific GPU model
 - Whether the xnack and sramecc features are enabled

The result looks like:

-  Flags:                             0x52f
+  Flags:                             0x52f, gfx906, xnack any, sramecc any

The flags for the "HSA" OS ABI are properly versioned and documented on
that page.  But the NONE, PAL and MESA3D OS ABIs are not well documented
nor versioned.  Taking a peek at the LLVM source code, we see that they
encode their flags the same way as HSA v3.  For example, for PAL:

  c8b614cd74/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (L601)

So for those other OS ABIs, we read them the same as HSA v3.

binutils/ChangeLog:

	* readelf.c: Include elf/amdgcn.h.
	(decode_AMDGPU_machine_flags): New.
	(get_machine_flags): Handle flags for EM_AMDGPU machine type.

include/ChangeLog:

	* elf/amdgcn.h: Add EF_AMDGPU_MACH_AMDGCN_* and
	EF_AMDGPU_FEATURE_* defines.

Change-Id: Ib5b94df7cae0719a22cf4e4fd0629330e9485c12
2022-03-16 09:01:15 -04:00
Simon Marchi
37870be874 binutils/readelf: handle AMDGPU OS ABIs
When the machine is EM_AMDGPU, handle the various OS ABIs described
here:

  https://llvm.org/docs/AMDGPUUsage.html#header

For a binary with the HSA OS ABI, the change looks like:

-  OS/ABI:                            <unknown: 40>
+  OS/ABI:                            AMD HSA

binutils/ChangeLog:

	* readelf.c (get_osabi_name): Handle EM_AMDGPU OS ABIs.

include/ChangeLog:

	* elf/common.h (ELFOSABI_AMDGPU_PAL, ELFOSABI_AMDGPU_MESA3D):
	New.

Change-Id: I383590c390f7dc2fe0f902f50038735626d71863
2022-03-16 09:01:04 -04:00
Nick Clifton
f4f95df31b Updated Serbian (for binutils/) and Russian (for gprof/) translations 2022-03-16 12:47:50 +00:00
Tom Tromey
cda8dc94df Fix bug in dwarf-mode.el
I noticed that, occasionally, dwarf-mode would think that the objdump
subprocess was still running after it had clearly exited.  I managed
to reliably reproduce this today and learned that a process sentinel
is not guaranteed to be run with the current buffer set to the process
buffer.  This patch fixes the problem.

I've bumped the version number of dwarf-mode.el to make it easier to
install for users who already have an earlier one installed.

I'm checking this in.

2022-03-15  Tom Tromey  <tromey@adacore.com>

	* dwarf-mode.el: Now 1.7.
	(dwarf--sentinel): Switch to the process buffer.
2022-03-15 12:59:00 -06:00
Vladimir Mezentsev
bb368aad29 gprofng: a new GNU profiler
top-level
	* Makefile.def: Add gprofng module.
	* configure.ac: Add --enable-gprofng option.
	* src-release.sh: Add gprofng.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* gprofng: New directory.

binutils
	* MAINTAINERS: Add gprofng maintainer.
	* README-how-to-make-a-release: Add gprofng.

include.
	* collectorAPI.h: New file.
	* libcollector.h: New file.
	* libfcollector.h: New file.
2022-03-11 08:58:31 +00: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
Maciej W. Rozycki
d17e797f5c MIPS/opcodes: Fix alias annotation for branch instructions
Correct issues with INSN2_ALIAS annotation for branch instructions:

- regular MIPS BEQZ/L and BNEZ/L assembly instructions are idioms for
  BEQ/L and BNE/L respectively with the `rs' operand equal to $0,

- microMIPS 32-bit BEQZ and BNEZ assembly instructions are idioms for
  BEQ and BNE respectively with the `rt' operand equal to $0,

- regular MIPS BAL assembly instruction is an idiom for architecture
  levels of up to the MIPSr5 ISA and a machine instruction on its own
  from the MIPSr6 ISA up.

Add missing annotation to BEQZ/L and BNEZ/L accordingly then and add a
new entry for BAL for the MIPSr6 ISA, correcting a disassembly bug:

$ mips-linux-gnu-objdump -m mips:isa64r6 -M no-aliases -d bal.o

bal.o:     file format elf32-tradlittlemips

Disassembly of section .text:

00000000 <foo>:
   0:	04110000 	0x4110000
	...
$

Add test cases accordingly.

Parts for regular MIPS BEQZ/L and BNEZ/L instructions from Sagar Patel.

2022-03-06  Maciej W. Rozycki  <macro@orcam.me.uk>

	binutils/
	* testsuite/binutils-all/mips/mips1-branch-alias.d: New test.
	* testsuite/binutils-all/mips/mips1-branch-noalias.d: New test.
	* testsuite/binutils-all/mips/mips2-branch-alias.d: New test.
	* testsuite/binutils-all/mips/mips2-branch-noalias.d: New test.
	* testsuite/binutils-all/mips/mips32r6-branch-alias.d: New test.
	* testsuite/binutils-all/mips/mips32r6-branch-noalias.d: New
	test.
	* testsuite/binutils-all/mips/micromips-branch-alias.d: New
	test.
	* testsuite/binutils-all/mips/micromips-branch-noalias.d: New
	test.
	* testsuite/binutils-all/mips/mips-branch-alias.s: New test
	source.
	* testsuite/binutils-all/mips/micromips-branch-alias.s: New test
	source.
	* testsuite/binutils-all/mips/mips.exp: Run the new tests.

2022-03-06  Sagar Patel  <sagarmp@cs.unc.edu>
	    Maciej W. Rozycki  <macro@orcam.me.uk>

	opcodes/
	* mips-opc.c (mips_builtin_opcodes): Fix INSN2_ALIAS annotation
	for "bal", "beqz", "beqzl", "bnez" and "bnezl" instructions.
	* micromips-opc.c (micromips_opcodes): Likewise for "beqz" and
	"bnez" instructions.
2022-03-06 18:30:58 +00:00
Simon Marchi
84a9f19530 binutils/readelf: fix indentation in process_dynamic_section
Clangd shows a warning about misleading indentation in this file, fix
it.

binutils/ChangeLog:

	* readelf.c (process_dynamic_section): Fix indentation.

Change-Id: I43a7f4f4c75dd080af614222b980526f5debf297
2022-03-04 10:57:14 -05:00
Nick Clifton
0f38fd87ea Update the obsolete list and how-to-make-a-release documentation now that the 2.38 release is out. 2022-02-09 13:44:14 +00:00
Alan Modra
2969c3b37b PR28763, SIGSEGV during processing of program headers via readelf
PR 28763
	* readelf.c (process_file_header): Discard any cached program
	headers if there is an extension field for e_phnum in first
	section header.
2022-02-09 22:28:14 +10:30
Peilin Ye
5049d00eb7 Test --only-keep-debug on ELF relocatables
Add a test for commit 7c4643efe7, which fixed --only-keep-debug for ELF
relocatables.

	* testsuite/binutils-all/objcopy.exp
	(keep_debug_symbols_for_elf_relocatable): New test.
2022-02-09 14:48:54 +10:30
Alan Modra
481153777e PR28862, heap-buffer-overflow in parse_stab_string
I have no info on the format of a "SUNPRO C++ Namespace" stab, so am
relying on the previous code being correct in parsing these stabs.
Just don't allow NULs anywhere in the stab.

	PR 28862
	* stabs.c (parse_stab_string): Don't overrun buffer when parsing
	'Y' stab.
2022-02-08 20:28:52 +10:30
Alan Modra
cd8adbf301 Enable "size" as a dumpprog in ld
binutils/
	* testsuite/lib/binutils-common.exp (run_dump_test): Reference
	global SIZE and SIZEFLAGS.
ld/
	* testsuite/config/default.exp: Define SIZE and SIZEFLAGS.
2022-02-05 17:37:19 +10:30
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
H.J. Lu
e1dbfc17c5 Load debug section only when dumping debug sections
Don't load debug sections if we aren't dumping any debug sections.

	PR binutils/28843
	* objdump.c (dump_any_debugging): New.
	(load_debug_section): Return false if dump_any_debugging isn't
	set.
	(main): Set dump_any_debugging when dumping any debug sections.
	* readelf (dump_any_debugging): New.
	(parse_args): Set dump_any_debugging when dumping any debug
	sections.
	(load_debug_section): Return false if dump_any_debugging isn't
	set.
2022-01-31 10:16:49 -08:00
Alan Modra
7c4643efe7 objcopy --only-keep-debug
From: Peilin Ye <peilin.ye@bytedance.com>
objcopy's --only-keep-debug option has been broken for ELF files since
commit 8c803a2dd7.

  1. binutils/objcopy.c:setup_section() marks non-debug sections as
     SHT_NOBITS, then calls bfd_copy_private_section_data();
  2. If ISEC and OSEC share the same section flags,
     bfd/elf.c:_bfd_elf_init_private_section_data() restores OSEC's
     section type back to ISEC's section type, effectively undoing
     "make_nobits".

	* objcopy.c (setup_section): Act on make_nobits after calling
	bfd_copy_private_section_data.
2022-01-29 11:29:17 +10:30
Alan Modra
085b299b71 PR28753, buffer overflow in read_section_stabs_debugging_info
PR 28753
	* rddbg.c (read_section_stabs_debugging_info): Don't read past
	end of section when concatentating stab strings.
2022-01-28 11:54:54 +10:30
Nick Clifton
5fa0c2231c Updated Swedish translation for the binutils subdirectory 2022-01-27 11:21:36 +00:00
Nick Clifton
5fe73d4624 Update Bulgarian, French, Romaniam and Ukranian translation for some of the sub-directories 2022-01-24 14:22:49 +00:00
H.J. Lu
ad69b6b861 Regenerate Makefile.in files with automake 1.15.1
Regenerate Makefile.in files with the unmodified automake 1.15.1 to
remove

runstatedir = @runstatedir@

bfd/

	* Makefile.in: Regenerate.

binutils/

	* Makefile.in: Regenerate.

gas/

	* Makefile.in: Regenerate.

gold/

	* Makefile.in: Regenerate.
	* testsuite/Makefile.in: Likewise.

gprof/

	* Makefile.in: Regenerate.

ld/

	* Makefile.in: Regenerate.

opcodes/

	* Makefile.in: Regenerate.
2022-01-23 06:59:20 -08:00
H.J. Lu
31b0378d53 Regenerate configure files with autoconf 2.69
Regenerate configure files with the unmodified autoconf 2.69 to remove

  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]

bfd/

	* configure: Regenerate.

binutils/

	* configure: Regenerate.

gas/

	* configure: Regenerate.

gold/

	* configure: Regenerate.

gprof/

	* configure: Regenerate.

ld/

	* configure: Regenerate.

opcodes/

	* configure: Regenerate.
2022-01-23 05:27:01 -08:00
Martin Storsj?
58de646be2 Allow inferring tmp_prefix from the dll name from a def file. 2022-01-22 14:31:22 +00:00
Nick Clifton
5f7a57f131 Update release makeing script with new release numbers 2022-01-22 13:26:54 +00:00
Nick Clifton
f908e960c5 Change version number to 2.38.50 and regenerate files 2022-01-22 12:39:28 +00:00
Nick Clifton
a74e1cb344 Add markers for 2.38 branch 2022-01-22 12:08:55 +00:00
Mike Frysinger
ec7194506d drop old unused stamp-h.in file
This was needed by ancient versions of automake, but that hasn't been
the case since at least automake-1.5, so punt this from the tree.
2022-01-21 03:11:47 -05:00
Alan Modra
e2c0149e8b PR28029, debuginfod tests
binutils/NEWS says of the change in --process-links semantics:
  If other debug section display options are also enabled (eg
  --debug-dump=info) then the contents of matching sections in both the main
  file and the separate debuginfo file *will* be displayed.  This is because in
  most cases the debug section will only be present in one of the files.

Implying that debug info is dumped without --process-links.  Indeed
that appears to be the case for readelf.  This does the same for
objdump.

	PR 28029
	* objdump.c (dump_bfd): Do not exit early when !is_mainfile
	&& !processlinks, instead just exclude non-debug output.
	(dump_dwarf): Add is_mainfile parameter and pass to
	dump_dwarf_section.
	(dump_dwarf_section): Only display debug sections when
	!is_mainfile and !process_links.
2022-01-18 11:19:14 +10:30
Alan Modra
1657026ccd PowerPC64 DT_RELR
PowerPC64 takes a more traditional approach to DT_RELR than x86.  Count
relative relocs in check_relocs, allocate space for them and output in
the usual places but not doing so when enable_dt_relr.  DT_RELR is
sized in the existing ppc stub relaxation machinery, run via the
linker's ldemul_after_allocation hook.  DT_RELR is output in the same
function that writes ppc stubs, run via ldemul_finish.

This support should be considered experimental.

bfd/
	* elf64-ppc.c (struct ppc_local_dyn_relocs): Renamed from
	ppc_dyn_relocs.  Add rel_count field.  Update uses.
	(struct ppc_dyn_relocs): New.  Replace all uses of elf_dyn_relocs.
	(struct ppc_link_hash_table): Add relr_alloc, relr_count and
	relr_addr.
	(ppc64_elf_copy_indirect_symbol): Merge rel_count.
	(ppc64_elf_check_relocs): Init rel_count for global and local syms.
	(dec_dynrel_count): Change r_info param to reloc pointer.  Update
	all callers.  Handle decrementing rel_count.
	(allocate_got): Don't allocate space for relative relocs when
	enable_dt_relr.
	(allocate_dynrelocs): Likewise.
	(ppc64_elf_size_dynamic_sections): Likewise.  Handle srelrdyn.
	(ppc_build_one_stub): Don't emit relative relocs on .branch_lt.
	(compare_relr_address, append_relr_off): New functions.
	(got_and_plt_relr_for_local_syms, got_and_plt_relr): Likewise.
	(ppc64_elf_size_stubs): Size .relr.syn.
	(ppc64_elf_build_stubs): Emit .relr.dyn.
	(build_global_entry_stubs_and_plt): Don't output relative relocs
	when enable_dt_relr.
	(write_plt_relocs_for_local_syms): Likewise.
	(ppc64_elf_relocate_section): Likewise.
binutils/
	* testsuite/lib/binutils-common.exp (supports_dt_relr): Add
	powerpc64.
ld/
	* emulparams/elf64ppc.sh: Source dt-relr.sh.
	* testsuite/ld-elf/dt-relr-2b.d: Adjust for powerpc.
	* testsuite/ld-elf/dt-relr-2c.d: Likewise.
	* testsuite/ld-elf/dt-relr-2d.d: Likewise.
	* testsuite/ld-elf/dt-relr-2e.d: Likewise.
2022-01-18 11:18:45 +10:30
Nick Clifton
6c037fdbf0 Update the config.guess and config.sub files from the master repository and regenerate files. 2022-01-17 16:21:22 +00:00
Alan Modra
fb6ac163ad testsuite supports_dt_relr
Tidy, and fix "FAIL: Build dt-relr-glibc-1b.so" on all non-x86
linux targets.

binutils/
	* binutils-common.exp (supports_dt_relr): New proc.
ld/
	* testsuite/config/default.exp (DT_RELR_LDFLAGS, NO_DT_RELR_LDFLAGS),
	(DT_RELR_CC_LDFLAGS, NO_DT_RELR_CC_LDFLAGS): Use supports_dt_relr.
	* testsuite/ld-elf/dt-relr.exp: Don't run unless supports_dt_relr.
	* testsuite/ld-elf/dt-relr-1a.d: Likewise.
	* testsuite/ld-elf/dt-relr-1b.d: Likewise.
	* testsuite/ld-elf/dt-relr-1c.d: Likewise.
	* testsuite/ld-elf/dt-relr-2a.d: Likewise.
	* testsuite/ld-elf/dt-relr-2b.d: Likewise.
	* testsuite/ld-elf/dt-relr-2c.d: Likewise.
	* testsuite/ld-elf/dt-relr-2d.d: Likewise.
	* testsuite/ld-elf/dt-relr-2e.d: Likewise.
	* testsuite/ld-elf/dt-relr-2f.d: Likewise.
	* testsuite/ld-elf/dt-relr-2g.d: Likewise.
	* testsuite/ld-elf/dt-relr-2h.d: Likewise.
	* testsuite/ld-elf/dt-relr-3a.d: Likewise.
	* testsuite/ld-elf/dt-relr-3b.d: Likewise.
2022-01-13 14:12:43 +10:30
H.J. Lu
f2e37a5c7f elf: Support DT_RELR in linker tests
Allow eabling and disabling DT_RELR in linker tests.  Disable DT_RELR in
linker tests which don't expect DT_RELR in linker outputs.

binutils/

	* testsuite/lib/binutils-common.exp (run_dump_test): Make
	DT_RELR_LDFLAGS and NO_DT_RELR_LDFLAGS global.

ld/

	* testsuite/config/default.exp (DT_RELR_LDFLAGS): New.
	(DT_RELR_CC_LDFLAGS): Likewise.
	(NO_DT_RELR_LDFLAGS): Likewise.
	(NO_DT_RELR_CC_LDFLAGS): Likewise.
	* testsuite/ld-elf/shared.exp: Pass $NO_DT_RELR_LDFLAGS to
	linker for some tests.
	* testsuite/ld-i386/export-class.exp: Likewise.
	* testsuite/ld-i386/i386.exp: Likewise.
	* testsuite/ld-i386/ibt-plt-2a.d: Pass $NO_DT_RELR_LDFLAGS to
	linker.
	* testsuite/ld-i386/ibt-plt-3a.d: Likewise.
	* testsuite/ld-i386/ibt-plt-3c.d: Likewise.
	* testsuite/ld-i386/pr26869.d: Likewise.
	* testsuite/ld-i386/report-reloc-1.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
	* testsuite/ld-x86-64/bnd-branch-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise.
	* testsuite/ld-x86-64/bnd-plt-1.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-2a.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise.
	* testsuite/ld-x86-64/ibt-plt-3a.d: Likewise.
	* testsuite/ld-x86-64/ilp32-4.d: Likewise.
	* testsuite/ld-x86-64/load1c.d: Likewise.
	* testsuite/ld-x86-64/load1d.d: Likewise.
	* testsuite/ld-x86-64/pr13082-2b.d: Likewise.
	* testsuite/ld-x86-64/pr14207.d: Likewise.
	* testsuite/ld-x86-64/pr18176.d: Likewise.
	* testsuite/ld-x86-64/pr19162.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2d.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1d.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1f.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1j.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1l.d: Likewise.
	* testsuite/ld-x86-64/report-reloc-1-x32.d: Likewise.
	* testsuite/ld-x86-64/report-reloc-1.d: Likewise.
	* testsuite/ld-x86-64/export-class.exp (x86_64_export_class_test):
	Pass $NO_DT_RELR_LDFLAGS to linker.
	* testsuite/ld-x86-64/x86-64.exp: Pass $NO_DT_RELR_LDFLAGS to
	linker for some tests.
2022-01-12 06:04:51 -08:00
Hans-Peter Nilsson
c4f5871457 objdump, readelf: Emit "CU:" format only when wide output is requested
As pre-approved by Alan in
https://sourceware.org/pipermail/binutils/2021-September/118019.html
and I believe people have run into getting testsuite failures for
test-environments with "long" directory names, at least once more
since that time.  Enough.  I grepped the gas, binutils and ld
testsuites for "CU:" to catch target-specific occurrences, but I
noticed none.  I chose to remove "CU:" on the objdump tests instead of
changing options to get the wide format, so as to keep the name of the
test consistent with actual options; but added it to the readelf
options for the gas test as I believe the "CU:" format is preferable.

Tested for cris-elf and native x86_64-pc-linux-gnu.

binutils:
	* dwarf.c (display_debug_lines_decoded): Don't check the
	string length of the directory, instead emit the "CU: dir/name"
	format only if wide output is requested.
	* testsuite/binutils-all/dw5.W, testsuite/binutils-all/objdump.WL:
	Adjust accordingly.

gas:
	* testsuite/gas/elf/dwarf-5-loc0.d: Add -W to readelf options.
2022-01-12 05:51:25 +01: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
Martin Storsj
c4a8df19ba Fix multiple problems with DLL generation.
ld	* pe-dll.c (make_head): Prefix the symbol name with the dll name.
	(make_tail, make_one, make_singleton_name_thunk): Likewise.
	(make_import_fixup_entry, make_runtime_pseudo_reloc): Likewise.
	(pe_create_runtime_relocator_reference): Likewise.
	(pe_dll_generate_implib): Set dll_symname_len.
	(pe_process_import_defs): Likewise.

binutils
	* dlltool.c (main): If a prefix has not been provided, attempt to
	use a deterministic one based upon the dll name.
2022-01-11 15:43:59 +00:00
Pavel Mayorov
0e9f1c04b9 Revert previous delta to debug.c. Replace with patch to reject indirect types that point to indirect types.
PR 28718
	* dwarf.c: Revert previous delta.
	(debug_get_real_type): Reject indirect types that point to
	indirect types.
	(debug_get_type_name, debug_get_type_size, debug_write_type):
	Likewise.
2022-01-07 12:34:37 +00:00
Nick Clifton
af4004d1da Fix a stack exhaustion bug parsing malicious STABS format debug information.
PR 28718
	* debug.c (debug_write_type): Allow for malicious recursion via
	indirect debug types.
2022-01-06 16:37:26 +00: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
Nick Clifton
40c01d1b3d Add ATTRIBUTE_UNUSED to load_build_id_debug_file()'s main_filename parameter. 2022-01-04 10:34:01 +00:00
Nick Clifton
e2c0cef94d Remove a spurious debugging message.
PR 28716
	* dwarf.c (load_build_id_debug_file): Remove spurious printf.
2022-01-04 10:26:15 +00: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
Alan Modra
682351b932 readelf: avoid a possible divide by zero
* readelf.c (process_section_headers): Check SHT_RELR entsize.
2021-12-19 12:24:16 +10:30
Alan Modra
dbc6a0e2e4 try_build_id_prefix gcc-10 -Wformat-security errors
dwarf.c:11300:3: error: format not a string literal and no format arguments [-Werror=format-security]
11300 |   f += sprintf (f, prefix);

	PR 28697
	* dwarf.c (try_build_id_prefix): Avoid -Wformat-security error.
2021-12-17 11:42:18 +10:30