Commit Graph

3953 Commits

Author SHA1 Message Date
Nick Clifton
c4375dd764 Fix an infinite loop in the DWARF decoder when parsing a corrupt string table.
PR 27861
	* dwarf.c (display_debug_str_offsets): Warn if the length field is
	larger than the amount of data remaining in the section.
2021-05-13 14:31:09 +01:00
Alan Modra
b96a1bcb81 PR27861, Infinite loop in dwarf.c:7507-7526
PR 27861
	* dwarf.c (display_debug_str_offsets): Sanity check dwarf5
	header length.
2021-05-13 22:49:17 +09:30
Alan Modra
d21f875d67 PR27860, Segmentation fault on readelf -w
Well it didn't take long for the SAFE_BYTE_GET assert to trigger.

	PR 27860
	* dwarf.c (display_debug_frames): Sanity check cie_off before
	attempting to read cie.
2021-05-13 22:49:17 +09:30
Alan Modra
a7077ce760 Ensure data pointer kept within bounds
* dwarf.c (process_extended_line_op): Don't bump data pointer past
	end when strnlen doesn't find string terminator.
	(decode_location_expression): Remove dead code.
	(skip_attr_bytes): Remove const from end param.  Ensure data
	pointer doesn't pass end.
	(get_type_signedness): Remove const from end param.
	(read_and_display_attr_value): Ensure data pointer doesn't pass end.
	(display_debug_lines_raw, display_debug_lines_decoded): Likewise.
	(display_debug_pubnames_worker): Likewise.
	(display_debug_pubnames_worker): Use SAFE_BYTE_GET_AND INC rather
	than blindly incrementing data pointer.
	(display_debug_addr, display_debug_str_offsets): Likewise.  Don't
	compare pointers, compare lengths.
2021-05-12 21:29:25 +09:30
Alan Modra
6d1ad6f783 SAFE_BYTE_GET
This rearranges SAFE_BYTE_GET* macros, eliminating some duplication,
and making sure that the _INC variants never increment their PTR arg
past END.  I've added an assertion that should show us places where we
use them improperly with user derived PTR args, which I'm sure the
fuzzers will find for us.

	* dwarf.c (SAFE_BYTE_GET_INTERNAL): Define.
	(SAFE_BYTE_GET, SAFE_BYTE_GET_AND_INC): Define using the above.
	(SAFE_SIGNED_BYTE_GET, SAFE_SIGNED_BYTE_GET_AND_INC): Likewise.
	(display_discr_list): Use SAFE_BYTE_GET_AND_INC rather than
	SAFE_BYTE_GET followed by increment.
	(process_debug_info): Likewise, and test bytes remaining before
	incrementing section_begin rather than using pointer comparison.
	(display_debug_names): Pass lvalue as SAFE_BYTE_GET PTR.
	(process_cu_tu_index): Likewise for SAFE_BYTE_GET_AND_INC.
2021-05-12 21:17:35 +09:30
Alan Modra
af2ddf69ab SAFE_BYTE_GET64
Functions dealing with lack of a 64-bit integer type can disappear now
that we require C99.  Printing using dwarf_vmatoa is better too.

binutils/
	* dwarf.c (dwarf_vmatoa64, SAFE_BYTE_GET64, add64): Delete.
	(skip_attr_bytes): Replace use of SAFE_BYTE_GET64 with
	SAFE_BYTE_GET_AND_INC.
	(read_and_display_attr_value): Likewise.  Print using dwarf_vmatoa.
	(process_debug_info, process_cu_tu_index): Likewise.
	* elfcomm.c (byte_put, byte_put_little_endian, byte_put_big_endian),
	(byte_get, byte_get_little_endian, byte_get_big_endian),
	(byte_get_signed): Make size param unsigned.  Remove code dealing
	with 4-byte elf_vma.
	(byte_get_64): Delete.
	* elfcomm.h  (byte_put, byte_put_little_endian, byte_put_big_endian),
	(byte_get, byte_get_little_endian, byte_get_big_endian),
	(byte_get_signed): Update prototypes.
	(byte_get_64): Delete.
gas/
	* testsuite/gas/elf/dwarf-5-file0.d: Update.
	* testsuite/gas/i386/dwarf5-line-1.d: Update.
2021-05-12 21:10:33 +09:30
Alan Modra
0d872fca02 PR27836, readelf -w pointer comparison UB
PR 27836
	* dwarf.c (display_debug_frames): Don't compare pointers derived
	from user input.  Test offset against bounds instead.
2021-05-12 21:10:33 +09:30
Alan Modra
55b26492bb PR27853, Infinite loop in dwarf.c
Not quite infinite but much longer than it need be.  The problem is
triggered by read_and_display_attr_value incrementing "data" past
"end".  read_and_display_attr_value shouldn't do that, but be
defensive.

	PR 27853
	* dwarf.c (display_formatted_table): Test for data >= end rather
	than data == end.
	(process_extended_line_op): Likewise.
	(display_debug_lines_raw): Likewise.
	(display_debug_lines_decoded): Likewise.
2021-05-12 15:41:10 +09:30
Alan Modra
5ab3907543 PR27849, heap-buffer-overflow on readelf -w
PR 27849
	* dwarf.c (fetch_indexed_string): Correct length sanity checks.
	Sanity check section size for version and padding too.  Correct
	index sanity check.  Handle multiple tables in .debug_str_offsets.
2021-05-12 15:41:10 +09:30
Hans-Peter Nilsson
d30182b51e dwarf.c (process_abbrev_set): Properly parenthesize, fix fallout
Building as ILP32 shows:

 gcc -m32 -DHAVE_CONFIG_H -I. -I/checkout/binutils  -I. -I/checkout/binutils -I../bfd -I/checkout/binutils/../bfd -I/checkout/binutils/../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -I/checkout/binutils/../zlib -g -O2   -MT dwarf.o -MD -MP -MF $depbase.Tpo -c -o dwarf.o /checkout/binutils/dwarf.c &&\
 mv -f $depbase.Tpo $depbase.Po
 In file included from /checkout/binutils/sysdep.h:101:0,
                  from /checkout/binutils/dwarf.c:21:
 /checkout/binutils/dwarf.c: In function 'process_abbrev_set':
 /checkout/binutils/dwarf.c:1072:15: error: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'dwarf_vma {aka long long unsigned int}' [-Werror=format=]
        warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
                ^
 /checkout/binutils/dwarf.c:1072:13: note: in expansion of macro '_'
        warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
              ^
 cc1: all warnings being treated as errors
 Makefile:1101: recipe for target 'dwarf.o' failed

The recent commit, casting one of the terms, has an obvious
typo.  To wit, the (non-cast) term abbrev_size is a
dwarf_vma and causes the whole expression to (still) be 64
bits.

binutils:
	* dwarf.c (process_abbrev_set): Properly parenthesize before
	casting to unsigned long.
2021-05-11 16:26:30 +02:00
Alan Modra
f2f9554bf0 PR27845, readelf heap-buffer-overflow
PR 27845
	* dwarf.c (process_abbrev_set): Replace start and end parameters
	with section, abbrev_base, abbrev_size, abbrev_offset.  Update
	all callers.  Sanity check parameters correctly and emit warnings
	here rather than..
	(process_debug_info): ..here.
2021-05-11 19:07:02 +09:30
Thomas Wolff
749c700282 Restore old behaviour of windres so that options containing spaces are not enclosed in double quotes.
PR 4356
	PR 26865
	PR 27594
	* windres.c (quot): Revert previous delta.  Do not use double
	quotes when spaces are detected in options.
	* doc/binutils.texi (windres): Remove suggestion that the
	--preprocessor option can take arguments.
2021-05-10 11:28:15 +01:00
Alan Modra
2d4b49864e Avoid possible pointer wrap
PTR supplied to these macros can be read from user input, END is an
end of buffer pointer.  It's safer to do arithmetic on END than on PTR.

	* dwarf.c (SAFE_BYTE_GET): Check bounds by subtracting amount from
	END rather than adding amount to PTR.
	(SAFE_SIGNED_BYTE_GET, SAFE_BYTE_GET64): Likewise.
2021-05-10 10:03:00 +09:30
Alan Modra
b05a0fc79b Use htab_eq_string in binutils
A quick check says this is the only place in all of bfd, opcodes,
binutils, gas, ld, gprof that duplicates the new libiberty
htab_eq_string.

	* objcopy.c (eq_string): Delete.
	(create_symbol_htab): Use htab_eq_string.
2021-05-09 12:28:18 +09:30
Mike Frysinger
354c317ea4 binutils: update release docs process
Now that we generate multiple html & pdf forms, update the release
process to show how they get updated.
2021-05-08 12:06:41 -04:00
Mike Frysinger
cf758b3960 support generating multi-html pages in parallel
Use the pattern from other projects where we generate the html pages
in a dir named the same as the project.  So now we have:
gas/doc/gas.html - single html page
gas/doc/gas/ - multiple html pages

This works for projects that have a doc/ subdir already, but gprof &
ld require a little tweaking since they generate their docs in their
respective toplevels.
2021-05-08 12:06:07 -04:00
Mike Frysinger
2faf902da5 generate single html manual page by default
This better matches other GNU projects like autoconf/automake where
the html manual is the single page form.  We'll support the multi-page
form in a follow up change.
2021-05-08 11:58:19 -04:00
Nick Clifton
3ecc00ec9c Srop readelf's unwind decoder from complaining about x86 binaries.
* readelf.c (no_processor_specific_unwind): New function.
	(process_unwind): Use no_processor_specific_unwind for X86
	targets.
2021-05-07 15:24:14 +01:00
Michael Forney
4896932e62 dwarf: Don't omit second operand of '?' operator
This is a GNU C extension and is not valid in ISO C.

	* dwarf.c: Don't omit second operand of '?' operator.
2021-05-07 16:54:00 +09:30
Nick Clifton
bfbfa6e7f4 Fix attempt to free non-allocated pointer when parsing .debug_sup sections.
PR 27796
	* dwarf.c (load_debug_sup_file): Allocate memory for filename in
	.debug_sup section.
2021-04-30 12:28:39 +01:00
Nick Clifton
5edb8e3f5a Correct the text describing windres's --processor option.
PR 27594
 * doc/binutils.texi (windres): Correct the description of the
 default value of the --preprocessor argument.
2021-04-29 13:11:29 +01:00
Nick Clifton
3d64c987c7 Reject debuglink sections with no associated filename.
PR 27779
	* dwarf.c (parse_gnu_debuglink): Reject empty names.
	(parse_gnu_debugaltlink): Likewise.
2021-04-27 15:19:41 +01:00
Cl?ment Chigot
b11b2969a9 Harmonize and improve auxiliary entries support for XCOFF
bfd/ChangeLog:
	* coff-rs6000.c (_bfd_xcoff_swap_aux_in): Add errors for
	unsupported storage class or auxialiry entries.
	Improve and adapt to new aux structures.
	Add C_DWARF support.
	(_bfd_xcoff_swap_aux_out): Likewise.
	* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Likewise.
	(_bfd_xcoff64_swap_aux_out): Likewise.

binutils/ChangeLog:
	* od-xcoff.c (dump_xcoff32_symbols): Adapt to new
	aux structures.

include/ChangeLog:
	* coff/internal.h (union internal_auxent):
	 Add x_sect structure.
	* coff/rs6000.h (union external_auxent): Rework to
	match official documentation.
	* coff/rs6k64.h (union external_auxent): Likewise.
	(_AUX_SECT): New define.
2021-04-22 12:28:50 +01:00
Nick Lott
047c3dbf55 Add ability to select numeric base when displaying symbol values in readelf.
PR 27672
	* readelf.c (sym_base): New variable.
	(enum print_mode): Add more modes.
	(print_vma): Add suport for new modes.
	(options): Add sym-base.
	(usage): Add sym-base.
	(parse_args): Add support for --sym-base.
	(print_dynamic_symbol_size): New function.
	(print_dynamic_symbol): Use new function.
	* doc/binutils.texi: Document the new feature.
	* NEWS: Mention the new feature.
2021-04-21 15:33:13 +01:00
Nick Clifton
2335639744 Adjust readelf's output so that section symbols without a name as shown with their section name.
binutils* readelf.c (print_dynamic_symbol): Print the section name for
	section symbols without a name of their own.
	* testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d:
	Adjust expected output to allow for named section symbols.
	* testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d:
	Likewise.
	* testsuite/binutils-all/readelf.s-64: Likewise.
	* testsuite/binutils-all/readelf.ss-64-unused: Likewise.
	* testsuite/binutils-all/readelf.ss-tmips: Likewise.
	* testsuite/binutils-all/readelf.ss-unused: Likewise.

ld	* testsuite/ld-aarch64/variant_pcs-now.d: Adjust expected output
	to allow for named section symbols.
	* testsuite/ld-aarch64/variant_pcs-r.d: Likewise.
	* testsuite/ld-aarch64/variant_pcs-shared.d: Likewise.
	* testsuite/ld-alpha/tlsbin.rd: Likewise.
	* testsuite/ld-alpha/tlsbinr.rd: Likewise.
	* testsuite/ld-alpha/tlspic.rd: Likewise.
	* testsuite/ld-arm/rodata-merge-map.sym: Likewise.
	* testsuite/ld-arm/script-type.sym: Likewise.
	* testsuite/ld-cris/libdso-2.d: Likewise.
	* testsuite/ld-cris/pr16044.d: Likewise.
	* testsuite/ld-elf/sec64k.exp: Likewise.
	* testsuite/ld-ia64/tlsbin.rd: Likewise.
	* testsuite/ld-ia64/tlspic.rd: Likewise.
	* testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: Likewise.
	* testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: Likewise.
	* testsuite/ld-mmix/bspec1.d: Likewise.
	* testsuite/ld-mmix/bspec2.d: Likewise.
	* testsuite/ld-mmix/local1.d: Likewise.
	* testsuite/ld-mmix/local3.d: Likewise.
	* testsuite/ld-mmix/local5.d: Likewise.
	* testsuite/ld-mmix/local7.d: Likewise.
	* testsuite/ld-mmix/undef-3.d: Likewise.
	* testsuite/ld-powerpc/tlsso.r: Likewise.
	* testsuite/ld-powerpc/tlsso32.r: Likewise.
	* testsuite/ld-powerpc/tlstocso.r: Likewise.
	* testsuite/ld-s390/tlsbin.rd: Likewise.
	* testsuite/ld-s390/tlsbin_64.rd: Likewise.
	* testsuite/ld-s390/tlspic.rd: Likewise.
	* testsuite/ld-s390/tlspic_64.rd: Likewise.
	* testsuite/ld-sparc/gotop32.rd: Likewise.
	* testsuite/ld-sparc/gotop64.rd: Likewise.
	* testsuite/ld-sparc/tlssunbin32.rd: Likewise.
	* testsuite/ld-sparc/tlssunbin64.rd: Likewise.
	* testsuite/ld-sparc/tlssunnopic32.rd: Likewise.
	* testsuite/ld-sparc/tlssunnopic64.rd: Likewise.
	* testsuite/ld-sparc/tlssunpic32.rd: Likewise.
	* testsuite/ld-sparc/tlssunpic64.rd: Likewise.
	* testsuite/ld-tic6x/common.d: Likewise.
	* testsuite/ld-tic6x/shlib-1.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1b.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1r.rd: Likewise.
	* testsuite/ld-tic6x/shlib-1rb.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1b.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1r.rd: Likewise.
	* testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise.
	* testsuite/ld-tic6x/shlib-noindex.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1b.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1r.rd: Likewise.
	* testsuite/ld-tic6x/static-app-1rb.rd: Likewise.

gas	* testsuite/gas/aarch64/dwarf.d: Adjust expected output to allow
	for named section symbols.
	* testsuite/gas/arm/thumbver.d: Likewise.
	* testsuite/gas/bfin/loop_temps.d: Likewise.
	* testsuite/gas/elf/section2.e-arc: Likewise.
	* testsuite/gas/elf/section2.e-arm: Likewise.
	* testsuite/gas/elf/section2.e-csky: Likewise.
	* testsuite/gas/elf/section2.e-m32r: Likewise.
	* testsuite/gas/elf/section2.e-mips: Likewise.
	* testsuite/gas/elf/section2.e-msp430: Likewise.
	* testsuite/gas/elf/section2.e-riscv: Likewise.
	* testsuite/gas/elf/section2.e-rl78: Likewise.
	* testsuite/gas/elf/section2.e-rx: Likewise.
	* testsuite/gas/elf/section2.e-score: Likewise.
	* testsuite/gas/elf/section2.e-tic6x: Likewise.
	* testsuite/gas/elf/section2.e-unused: Likewise.
	* testsuite/gas/elf/section2.e-v850: Likewise.
	* testsuite/gas/elf/section2.e-xtensa: Likewise.
	* testsuite/gas/ia64/alias-ilp32.d: Likewise.
	* testsuite/gas/ia64/alias.d: Likewise.
	* testsuite/gas/ia64/global.d: Likewise.
	* testsuite/gas/microblaze/relax_size.elf: Likewise.
	* testsuite/gas/microblaze/relax_size2.elf: Likewise.
	* testsuite/gas/mips/global-local-symtab-sort-n64t.d: Likewise.
	* testsuite/gas/mips/global-local-symtab-sort-o32t.d: Likewise.
	* testsuite/gas/mmix/bspec-1.d: Likewise.
	* testsuite/gas/mmix/byte-1.d: Likewise.
	* testsuite/gas/mmix/comment-1.d: Likewise.
	* testsuite/gas/mmix/loc-1.d: Likewise.
	* testsuite/gas/mmix/loc-2.d: Likewise.
	* testsuite/gas/mmix/loc-3.d: Likewise.
	* testsuite/gas/mmix/loc-4.d: Likewise.
	* testsuite/gas/mmix/loc-5.d: Likewise.
	* testsuite/gas/tic6x/scomm-directive-4.d: Likewise.
2021-04-21 10:34:32 +01:00
Andreas Krebbel
aee4e85e27 MAINTAINERS: Remove Martin Schwidefsky as s390 maintainer
https://lwn.net/ml/linux-kernel/20190521162350.GA17107@osiris/

ChangeLog:

2021-04-20  Andreas Krebbel  <krebbel@linux.ibm.com>

	* MAINTAINERS: Remove Martin Schwidefsky as s390 maintainer and
	add him to Past Maintainers.
	Update my email address.
2021-04-20 09:19:16 +02:00
Nick Clifton
229597a129 Fix a problem running the archiver program in MRI mode on archives containing LTO compiled objects.
PR 21702
	* arsup.c (ar_addmod): Enable plugin support, if available.
2021-04-19 17:38:39 +01:00
Nick Clifton
4dee4f3ea1 Fix compile time warning about unused functions.
binutils * rename.c: (get_stat_atime_ns): Add prototype.
	(get_stat_mtime_ns): Add prototype.
2021-04-19 09:41:04 +01:00
Alan Modra
ad7c46164f undefined reference to get_stat_atime
PR 27725
	* rename.c (get_stat_atime, get_stat_mtime): Make static.
	(get_stat_atime_ns, get_stat_mtime_ns): Likewise.
2021-04-16 12:12:50 +09:30
Pekka Seppänen
4c79248a46 PR27734, get_stat_atime_ns/get_stat_mtime_ns might not use parameter
PR 27725
	* rename.c (get_stat_atime_ns): Add ATTRIBUTE_UNUSED.
	(get_stat_mtime_ns): Likewise.
2021-04-16 00:09:26 +09:30
Alan Modra
985e026451 PR27725, better objcopy -p times
Nanosecond rather than second resolution.

	PR 27725
	* configure.ac: Check for sys/time.h and utimensat.  Use standard
	checks for mkstemp and mkdtemp.  Whitespace.  Check for nanosecond
	members of struct stat.
	* rename.c: Prefer sys/time.h for utimes over utime.h for utime.
	(STAT_TIMESPEC, STAT_TIMESPEC_NS): Define
	(get_stat_atime_ns, get_stat_mtime_ns): New inline functions.
	(get_stat_atime, get_stat_mtime): Likewise.
	(set_times): Choose first available of utimensat, utimes, utime.
	Use above inline functions to set timespec and timeval values.
	* configure: Regenerate.
	* config.in: Regenerate.
	* testsuite/binutils-all/objcopy.exp (objcopy_test): Add test of
	file timestamp when --preserve-dates is used.
2021-04-15 17:51:17 +09:30
Alan Modra
d0ecdcddc3 Make objcopy -p work when an output file is specified
More fallout from the PR27456 fixes.

	PR 27456
	* rename.c (smart_rename): When TO and FROM are equal, just set
	file timestamp.
	* objcopy.c (strip_main, copy_main): Always call smart_rename.
2021-04-15 14:16:55 +09:30
H.J. Lu
9917b5596a elf: Set p_memsz to p_filesz for loadable PT_NOTE segment
Since p_memsz of the loadable PT_NOTE segment should be the same as
p_filesz, set p_memsz on the loadable PT_NOTE segment when updating
p_filesz.

bfd/

	PR binutils/27708
	* elf.c (assign_file_positions_for_non_load_sections): Set
	p_memsz to p_filesz for the loadable PT_NOTE segment.

binutils/

	PR binutils/27708
	* testsuite/binutils-all/x86-64/pr27708.dump: New file.
	* testsuite/binutils-all/x86-64/pr27708.exe.bz2: Likewise.
	* testsuite/binutils-all/x86-64/x86-64.exp: Run binutils/27708
	test.
2021-04-14 05:31:15 -07:00
Mark Harmstone
6be872a439 Ignore trailing bytes at the end of a Windows Resource Version structure.
PR 27686
	* resbin.c (bin_to_res_version): Ignore any trailing bytes at the
	end of the structure.
2021-04-14 11:55:16 +01:00
Frederic Cambus
5f47741bf6 Remove unneeded tests for definitions of NT_BSDNETCORE values.
binutils* readelf.c (get_netbsd_elfcore_note_type): Remove unneeded #ifdef
	checks for NT_NETBSDCORE_AUXV and NT_NETBSDCORE_LWPSTATUS.

bfd	* elf.c (elfcore_grok_netbsd_note): Remove unneeded #ifdef
	checks for NT_NETBSDCORE_AUXV and NT_NETBSDCORE_LWPSTATUS.
2021-04-14 11:15:01 +01:00
Alan Modra
13acb58d42 PR27716, build failure for msdosdjgpp: PATH_MAX undeclared
We shouldn't be using arbitrary limits like PATH_MAX in GNU programs.
This patch also fixes some memory leaks in readelf when processing
separate debug info.

	PR 27716
binutils/
	* objdump.c (show_line): Don't limit paths to PATH_MAX.
	* readelf.c (struct filedata): Change program_interpreter from
	a char array to a char pointer.
	(process_program_headers): Sanity check PT_INTERP p_filesz.
	Malloc program_interpreter using p_filesz and read directly from
	file.
	(process_dynamic_section): Check program_interpreter is non-NULL.
	(free_filedata): New function, split out from..
	(process_object): ..here.
	(close_debug_file): Call free_filedata.
	* sysdep.h: Don't include sys/param.h.
	(PATH_MAX): Don't define.
	* configure.ac: Don't check for sys/param.h.
	* configure: Regenerate.
gprof/
	* gprof.h (PATH_MAX): Don't define.
	* corefile.c (core_create_line_syms): Don't use PATH_MAX for initial
	file name size.
	* source.c (annotate_source): Malloc file name buffer.  Always
	trim off "-ann" when dos 8.3 annotate file matches original.
	* utils.c (print_name_only): Malloc file name buffer.
2021-04-14 15:06:11 +09:30
Frederic Cambus
0fa29e2dee Remove now unneeded #ifdef check for NT_NETBSD_PAX.
NT_NETBSD_PAX was defined in commit be3b926d8d.

binutils/ChangeLog:

	* readelf.c (process_netbsd_elf_note): Remove now unneeded #ifdef
	check for NT_NETBSD_PAX.
2021-04-13 16:11:39 +09:30
Alan Modra
43e05cd4f4 ENABLE_CHECKING in bfd, opcodes, binutils, ld
gas already has this.  Here it enables checking hash table type passed
to elf_link_hash_lookup and elf_link_hash_traverse.

bfd/
	* elf-bfd.h (ENABLE_CHECKING): Define.
	(elf_link_hash_lookup): Abort if wrong type of hash table.
	(elf_link_hash_traverse): Likewise.
	* configure.ac (--enable-checking): Add support.
	* config.in: Regenerate.
	* configure: Regenerate.
binutils/
	* configure.ac (--enable-checking): Add support.
	* config.in: Regenerate.
	* configure: Regenerate.
ld/
	* configure.ac (--enable-checking): Add support.
	* config.in: Regenerate.
	* configure: Regenerate.
opcodes/
	* configure.ac (--enable-checking): Add support.
	* config.in: Regenerate.
	* configure: Regenerate.
2021-04-13 00:35:44 +09:30
Alan Modra
c3f72de4f5 PowerPC disassembly of pcrel references
This adds some annotation to Power10 pcrel instructions, displaying
the target address (ie. pc + D34 field) plus a symbol if there is one
at exactly that target address.  pld from the .got or .plt will also
look up the entry and display it, symbolically if there is a dynamic
relocation on the entry.

include/
	* dis-asm.h (struct disassemble_info): Add dynrelbuf and dynrelcount.
binutils/
	* objdump.c (struct objdump_disasm_info): Delete dynrelbuf and
	dynrelcount.
	(find_symbol_for_address): Adjust for dynrelbuf and dynrelcount move.
	(disassemble_section, disassemble_data): Likewise.
opcodes/
	* ppc-dis.c (struct dis_private): Add "special".
	(POWERPC_DIALECT): Delete.  Replace uses with..
	(private_data): ..this.  New inline function.
	(disassemble_init_powerpc): Init "special" names.
	(skip_optional_operands): Add is_pcrel arg, set when detecting R
	field of prefix instructions.
	(bsearch_reloc, print_got_plt): New functions.
	(print_insn_powerpc): For pcrel instructions, print target address
	and symbol if known, and decode plt and got loads too.
gas/
	* testsuite/gas/ppc/prefix-pcrel.d: Update expected output.
	* testsuite/gas/ppc/prefix-reloc.d: Likewise.
	* gas/testsuite/gas/ppc/vsx_32byte.d: Likewise.
ld/
	* testsuite/ld-powerpc/inlinepcrel-1.d: Update expected output.
	* testsuite/ld-powerpc/inlinepcrel-2.d: Likewise.
	* testsuite/ld-powerpc/notoc2.d: Likewise.
	* testsuite/ld-powerpc/notoc3.d: Likewise.
	* testsuite/ld-powerpc/pcrelopt.d: Likewise.
	* testsuite/ld-powerpc/startstop.d: Likewise.
	* testsuite/ld-powerpc/tlsget.d: Likewise.
	* testsuite/ld-powerpc/tlsget2.d: Likewise.
	* testsuite/ld-powerpc/tlsld.d: Likewise.
	* testsuite/ld-powerpc/weak1.d: Likewise.
	* testsuite/ld-powerpc/weak1so.d: Likewise.
2021-04-09 16:56:43 +09:30
Alan Modra
a2e6677373 Return symbol from symbol_at_address_func
include/
	* dis-asm.h (struct disassemble_info <symbol_at_address_func>):
	Return asymbol*.
binutils/
	* objdump.c (objdump_symbol_at_address): Return asymbol*.
opcodes/
	* dis-buf.c (generic_symbol_at_address): Return symbol* NULL.
	* s12z-dis.c (decode_possible_symbol): Use symbol returned from
	symbol_at_address_func.
2021-04-06 23:25:09 +09:30
Alan Modra
4db29512ce C99 NEWS and README
* NEWS: Mention C99 requirement.
	* README: Likewise.  Modernise examples and "Reporting bugs".
2021-04-06 23:25:09 +09:30
Alan Modra
87b9f2556d C99 binutils configury
* configure.ac: Assume long long is available.  Don't test for
	strings.h, stdlib.h, limits.h, locale.h, or wchar.h.  Check
	inttypes.h, stdint.h, sys/stat.h and sys/types.h. Don't check for
	strcoll, setlocale, setmode or location of time_t.  Don't check
	for fprintf, getenv, snprintf, strnlen, strstr or vsnprintf decls.
	(AC_ISC_POSIX, AXC_HEADER_STRING, AC_FUNC_ALLOCA): Don't invoke.
	* sysdep.h: Don't include alloca-conf.h, include config.h instead.
	Test HAVE_SYS_TYPES_H and reorder includes.  Include limits.h,
	locale.h, string.h and stdlib.h unconditionally.  Remove various
	fallback declarations.  Assume long long is available.
	* addr2line.c: Don't test HAVE_SETLOCALE.
	* ar.c: Likewise.
	* coffdump.c: Likewise.
	* dlltool.c: Likewise.
	* dllwrap.c: Likewise.
	* elfedit.c: Likewise.
	* nm.c: Likewise.
	* objcopy.c: Likewise.
	* objdump.c: Likewise.
	* readelf.c: Likewise.
	* size.c: Likewise.
	* srconv.c: Likewise.
	* strings.c: Likewise.
	* sysdump.c: Likewise.
	* windmc.c: Likewise.
	* windres.c: Likewise.
	* bucomm.c: Don't test HAVE_TIME_T_IN_TIME_H or HAVE_TIME_T_IN_TYPES_H.
	* dwarf.c: Include limits.h unconditionally.  Assume long long
	is available.
	* nm.c: Don't test HAVE_STRCOLL.
	* readelf.c: Don't test HAVE_WCHAR_H.
	* strings.c: Assume long long is available.
	* syslex.l: Include string.h unconditionally.
	* aclocal.m4: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.
2021-04-05 15:30:22 +09:30
Martin Liska
e9b095a538 Remove strneq macro and use startswith.
bfd/ChangeLog:

	* ecoff.c (strneq): Remove strneq and use startswith.
	(_bfd_ecoff_slurp_armap): Likewise.

binutils/ChangeLog:

	* elfcomm.h (strneq): Remove strneq and use startswith.
	* readelf.c (ia64_process_unwind): Likewise.
	(process_note): Likewise.

gas/ChangeLog:

	* config/obj-coff.c (strneq): Remove strneq and use startswith.
	(weak_is_altname): Likewise.
	(obj_coff_section): Likewise.
	* config/tc-cr16.c (process_label_constant): Likewise.
	* config/tc-crx.c (strneq): Likewise.

include/ChangeLog:

	* opcode/cr16.h (strneq): Remove strneq and use startswith.

ld/ChangeLog:

	* ldbuildid.c (strneq): Remove strneq and use startswith.
	(validate_build_id_style): Likewise.
	(compute_build_id_size): Likewise.

opcodes/ChangeLog:

	* arm-dis.c (strneq): Remove strneq and use startswith.
	* cr16-dis.c (print_insn_cr16): Likewise.
	* score-dis.c (streq): Likewise.
	(strneq): Likewise.
	* score7-dis.c (strneq): Likewise.
2021-04-01 15:00:56 +02:00
Martin Liska
3f3328b816 Use startswith more for strncmp function calls.
bfd/ChangeLog:

	* elf-bfd.h (bfd_section_is_ctf): Use startswith function.
	* elf.c (_bfd_elf_make_section_from_shdr): Likewise.
	(elf_get_reloc_section): Likewise.
	* elf32-arc.c (elf_arc_size_dynamic_sections): Likewise.
	* elf32-m32r.c (m32r_elf_section_flags): Likewise.
	* elf32-microblaze.c (microblaze_elf_size_dynamic_sections): Likewise.
	* elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise.
	(nds32_elf_relocate_section): Likewise.
	(nds32_elf_action_discarded): Likewise.
	(nds32_elf_check_relocs): Likewise.
	(nds32_elf_section_flags): Likewise.
	* elf32-or1k.c (or1k_elf_check_relocs): Likewise.
	* elf32-ppc.c (ppc_elf_section_from_shdr): Likewise.
	* elf32-rx.c (rx_table_find): Likewise.
	(rx_table_map): Likewise.
	* elf32-spu.c (spu_elf_backend_symbol_processing): Likewise.
	(spu_elf_find_overlays): Likewise.
	(needs_ovl_stub): Likewise.
	(allocate_spuear_stubs): Likewise.
	(build_spuear_stubs): Likewise.
	(mark_overlay_section): Likewise.
	(spu_elf_auto_overlay): Likewise.
	(spu_elf_output_symbol_hook): Likewise.
	* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise.
	* elf32-xtensa.c (xtensa_property_section_name): Likewise.
	* elf64-ppc.c (ppc64_elf_section_flags): Likewise.
	(ppc64_elf_relocate_section): Likewise.
	* elflink.c (resolve_section): Likewise.
	(UNARY_OP): Likewise.
	(BINARY_OP_HEAD): Likewise.
	(elf_link_input_bfd): Likewise.
	* elfnn-riscv.c (riscv_elf_size_dynamic_sections): Likewise.
	* elfxx-riscv.c (riscv_parse_subset): Likewise.
	* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise.
	* opncls.c (get_build_id): Likewise.

binutils/ChangeLog:

	* dllwrap.c: Use startswith function.
	* objcopy.c (is_dwo_section): Likewise.
	(handle_remove_section_option): Likewise.
	(copy_main): Likewise.
	* objdump.c (is_significant_symbol_name): Likewise.
2021-04-01 14:59:04 +02:00
Martin Liska
24d127aa9f Replace const_strneq with startswith.
binutils/ChangeLog:

	* dwarf.c (display_debug_lines_raw): Replace const_strneq with
	startswith.
	(display_debug_lines_decoded): Likewise.
	(display_debug_links): Likewise.
	* elfcomm.c (setup_archive): Likewise.
	* elfcomm.h (const_strneq): Likewise.
	* readelf.c (process_section_headers): Likewise.
	(slurp_ia64_unwind_table): Likewise.
	(slurp_hppa_unwind_table): Likewise.
	(decode_arm_unwind): Likewise.
	(display_debug_section): Likewise.
	(process_note): Likewise.
2021-04-01 14:58:36 +02:00
Alan Modra
015dc7e1f8 Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
	* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
	* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
	* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
	* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
	* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
	* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
	* windmc.c, * windmc.h, * windres.c, * winduni.c,
	* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
	and TRUE with true throughout.
2021-03-31 10:49:23 +10:30
Alan Modra
3dfb1b6d34 Remove bfd_stdint.h
If we require C99 for binutils then stdint.h is available.

bfd/
	* .gitignore: Delete bfd_stdint.h entry.
	* Makefile.am (bfdinclude_HEADERS): Delete bfd_stdint.h.
	(BUILD_HFILES, LOCAL_H_DEPS): Likewise.
	* bfd-in.h: Include stdint.h in place of bfd_stdint.h.
	* configure.ac: Don't invoke GCC_HEADER_STDINT.
	* configure.com: Don't create bfd_stdint.h.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* bfd-in2.h: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
	* po/BLD-POTFILES.in: Regenerate.
binutils/
	* coffdump.c: Include stdint.h in place of bfd_stdint.h.
	* dwarf.c: Likewise.
gas/
	* config/tc-aarch64.c: Include stdint.h in place of bfd_stdint.h.
	* config/tc-crx.c: Likewise.
	* config/tc-nds32.h: Likewise.
include/
	* cgen/basic-modes.h: Include stdint.h in place of bfd_stdint.h.
	* elf/nfp.h: Likewise.
	* opcode/aarch64.h: Likewise.
	* opcode/cgen.h: Likewise.
	* opcode/nfp.h: Likewise.
	* opcode/ppc.h: Likewise.
ld/
	* elf-hints-local.h: Include stdint.h in place of bfd_stdint.h.
	* emultempl/nds32elf.em: Likewise.
	* testsuite/ld-elf/mbind2b.c: Likewise.
	* testsuite/ld-elf/pr18718.c: Likewise.
	* testsuite/ld-elf/pr18720a.c: Likewise.
	* testsuite/ld-elf/pr25749-1.c: Likewise.
	* testsuite/ld-elf/pr25749-1a.c: Likewise.
	* testsuite/ld-elf/pr25749-1b.c: Likewise.
	* testsuite/ld-elf/pr25749-1c.c: Likewise.
	* testsuite/ld-elf/pr25749-1d.c: Likewise.
	* testsuite/ld-elf/pr25749-2.c: Likewise.
	* testsuite/ld-elf/pr25754-1a.c: Likewise.
	* testsuite/ld-elf/pr25754-2a.c: Likewise.
	* testsuite/ld-elf/pr25754-3a.c: Likewise.
	* testsuite/ld-elf/pr25754-4a.c: Likewise.
	* testsuite/ld-elf/pr25754-5a.c: Likewise.
	* testsuite/ld-elf/pr25754-6a.c: Likewise.
opcodes/
	* aarch64-dis.c: Include stdint.h in place of bfd_stdint.h.
	* aarch64-dis.h: Likewise.
	* aarch64-opc.c: Likewise.
	* avr-dis.c: Likewise.
	* csky-dis.c: Likewise.
	* nds32-asm.c: Likewise.
	* nds32-dis.c: Likewise.
	* nfp-dis.c: Likewise.
	* riscv-dis.c: Likewise.
	* s12z-dis.c: Likewise.
	* wasm32-dis.c: Likewise.
2021-03-31 10:49:23 +10:30
Alan Modra
57ae980e32 Include string.h in bfd.h and delete LITMEMCPY, LITSTRCPY
This fixes the issue that startswith depends on strncpy being
declared, and not all projects using bfd.h include string.h before
bfd.h.  I've also deleted some macros that don't find much use
anywhere.

bfd/
	* bfd-in.h: Include string.h.
	(LITMEMCPY, LITSTRCPY): Delete.
	* bfd-in2.h: Regenerate.
binutils/
	* prdbg.c (pr_function_type): Replace LITSTTCPY with strcpy.
2021-03-31 10:47:59 +10:30
Alan Modra
63b4cc53dc TRUE/FALSE simplification
There is really no need to write code like "foo != 0 ? TRUE : FALSE"
unless we had stupidly defined FALSE as something other than 0 or TRUE
as something other than 1.  The simpler "foo != 0" does just as well.
Similarly "(condition == TRUE)" or "(condition == FALSE) can be
simplified to "(condition)" and "(!condition)" respectively.

I'll note that there is reason to use "integer_expression != 0" when
assigning a bfd_boolean rather than the simpler "integer_expression",
if you expect the variable to have 0 or 1 value.  It's probably even a
good idea to not rely on implicit conversion if bfd_boolean were _Bool.

bfd/
	* aoutx.h (aout_link_write_symbols): Don't cast boolean expression
	to bfd_boolean.
	* elf32-or1k.c (or1k_set_got_and_rela_sizes): Dont compare booleans
	against FALSE.
	* elf32-arc.c (name_for_global_symbol): Don't compare boolean to TRUE.
	(is_reloc_PC_relative): Don't use "boolean_condition ? TRUE : FALSE".
	(is_reloc_SDA_relative, is_reloc_for_GOT): Likewise.
	(is_reloc_for_PLT, is_reloc_for_TLS): Likewise.
	* elf32-arm.c (stm32l4xx_need_create_replacing_stub): Likewise.
	* elf32-nds32.c (insert_nds32_elf_blank): Likewise.
	* elf32-rx.c (rx_set_section_contents): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_ignore_undef_symbol): Likewise.
	* mach-o.c (bfd_mach_o_read_command): Likewise.
	* targets.c (bfd_get_target_info): Likewise.
binutils/
	* dlltool.c (main): Don't use "boolean_condition ? TRUE : FALSE".
	* dwarf.c (read_and_display_attr_value): Likewise.
	(display_debug_str_offsets): Likewise.
	* objdump.c (dump_bfd): Likewise.
	* readelf.c (dump_section_as_strings): Likewise.
	(dump_section_as_bytes): Likewise.
gas/
	* atof-generic.c (FALSE, TRUE): Don't define.
	* config/obj-elf.h (FALSE, TRUE): Don't define.
	* config/obj-som.h (FALSE, TRUE): Don't define.
	* config/tc-hppa.h (FALSE, TRUE): Don't define.
	* config/tc-pdp11.c (FALSE, TRUE): Don't define.
	* config/tc-iq2000.h (obj_fix_adjustable): Delete.
	* config/tc-m32r.h (TC_FIX_ADJUSTABLE): Delete.
	* config/tc-mt.h (obj_fix_adjustable): Delete.
	* config/tc-nds32.h (TC_FIX_ADJUSTABLE): Delete.
	* config/tc-arc.c (parse_opcode_flags): Simplify boolean expression.
	(relaxable_flag, relaxable_operand, assemble_insn): Likewise.
	(tokenize_extregister): Likewise.
	* config/tc-csky.c (parse_opcode, get_operand_value): Likewise.
	(parse_operands_op, parse_operands, md_assemble): Likewise.
	* config/tc-d10v.c (build_insn): Likewise.
	* config/tc-score.c (s3_gen_insn_frag): Likewise.
	* config/tc-score7.c (s7_gen_insn_frag, s7_relax_frag): Likewise.
	* config/tc-tic6x.c (tic6x_update_features, md_assemble): Likewise.
	* config/tc-z80.c (emit_byte): Likewise.
include/
	* opcode/aarch64.h (alias_opcode_p): Simplify boolean expression.
	(opcode_has_alias, pseudo_opcode_p, optional_operand_p): Likewise.
	(opcode_has_special_coder): Likewise.
ld/
	* emultempl/aix.em (gld${EMULATION_NAME}_before_allocation): Simplify
	boolean expression.
	* lexsup.c (parse_args): Likewise.
	* pe-dll.c (pe_dll_id_target): Likewise.
opcodes/
	* aarch64-opc.c (vector_qualifier_p): Simplify boolean expression.
	(fp_qualifier_p, get_data_pattern): Likewise.
	(aarch64_get_operand_modifier_from_value): Likewise.
	(aarch64_extend_operator_p, aarch64_shift_operator_p): Likewise.
	(operand_variant_qualifier_p): Likewise.
	(qualifier_value_in_range_constraint_p): Likewise.
	(aarch64_get_qualifier_esize): Likewise.
	(aarch64_get_qualifier_nelem): Likewise.
	(aarch64_get_qualifier_standard_value): Likewise.
	(get_lower_bound, get_upper_bound): Likewise.
	(aarch64_find_best_match, match_operands_qualifier): Likewise.
	(aarch64_print_operand): Likewise.
	* aarch64-opc.h (operand_has_inserter, operand_has_extractor): Likewise.
	(operand_need_sign_extension, operand_need_shift_by_two): Likewise.
	(operand_need_shift_by_four, operand_maybe_stack_pointer): Likewise.
	* arm-dis.c (print_insn_mve, print_insn_thumb32): Likewise.
	* tic6x-dis.c (tic6x_check_fetch_packet_header): Likewise.
	(print_insn_tic6x): Likewise.
2021-03-29 11:22:22 +10:30
Alan Modra
1be305ffcd binutils int vs bfd_boolean fixes
* objdump.c (process_links): Use type int.
	* readelf.c (request_dump): Don't increment do_dump, set it.
	* windint.h (target_is_bigendian): Use type bfd_boolean.
	* windmc.c (target_is_bigendian): Likewise.
	* windres.c (target_is_bigendian): Likewise.
2021-03-29 11:22:21 +10:30