Commit Graph

111231 Commits

Author SHA1 Message Date
Tsukasa OI
d0975d8002 bfd, binutils, gas: Remove/mark unused variables
Clang generates a warning on unused (technically, written but not read
thereafter) variables.  By the default configuration (with "-Werror"), it
causes a build failure (unless "--disable-werror" is specified).

This commit adds ATTRIBUTE_UNUSED attribute to some of them, which means
they are *possibly* unused (can be used but no warnings occur when
unused) and removes others.

bfd/ChangeLog:

	* elf32-lm32.c (lm32_elf_size_dynamic_sections): Mark unused
	rgot_count variable.
	* elf32-nds32.c (elf32_nds32_unify_relax_group): Remove unused
	count variable.
	* mmo.c (mmo_scan): Mark unused lineno variable.

binutils/ChangeLog:

	* windmc.c (write_rc): Remove unused i variable.

gas/ChangeLog:

	* config/tc-riscv.c (riscv_ip): Remove unused argnum variable.

ld/ChangeLog:

	* pe-dll.c (generate_reloc): Remove unused bi and page_count
	variables.
2022-09-15 10:46:02 +00:00
Vladimir Mezentsev
fe39ffdc20 gprofng: fix build issues on musl
gprofng/ChangeLog
2022-09-14  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/29477
	* configure.ac: Set __MUSL_LIBC.
	* configure: Rebuild.
	* common/config.h.in: Rebuild.
	* src/collector_module.h: Fix compiler errors because mmap64, open64,
	pwrite64 are macros and getcontext() is absent on musl.
	* libcollector/collector.c: Likewise.
	* libcollector/hwprofile.c: Likewise.
	* libcollector/iolib.c: Likewise.
	* libcollector/libcol_util.c: Likewise.
	* libcollector/linetrace.c: Likewise.
	* libcollector/memmgr.c: Likewise.
	* libcollector/profile.c: Likewise.
	* libcollector/unwind.c: Likewise.
	* libcollector/dispatcher.c: Likewise.
	* src/Experiment.cc: Likewise.
	* libcollector/collector.h: Use dlsym() because dlvsym() is not defined
	on musl.
	* libcollector/iotrace.c: Remove interposition of versioned functions.
	* libcollector/mmaptrace.c: Likewise.
	* libcollector/libcol_util.h: Fix -Wint-to-pointer-cast warnings.
	* libcollector/jprofile.c: Likewise.
	* libcollector/synctrace.c: Include "collector.h".
	* src/Print.cc: Use get_basename() because basename() is not defined
	on musl.
	* common/hwcdrv.c: Fix -Wformat= warnings.
2022-09-14 18:38:09 -07:00
GDB Administrator
8422cbe455 Automatic date update in version.in 2022-09-15 00:00:13 +00:00
Rupesh Potharla
e959744eca Binutils: Readelf testcase failing with clang
* testsuite/binutils-all/readelf.exp (readelf_wi_test): Extend
	regexps to allow for output genreated by the Clang compiler.
2022-09-14 10:27:38 +01:00
Alan Modra
8d783d5e1d looping in bfd_mach_o_fat_openr_next_archived_file
mach-o.c doesn't sanity check mach-o-fat archives, making it easy for
fuzzers to create an archive with mach_o_fat_archentry headers that
point to the same offset.  bfd_mach_o_fat_openr_next_archived_file
uses the previous element offset to find its header, and thus the next
element.  If two offsets are the same, any tool reading the archive
will get stuck.  This patch rejects such archives, and any with
overlapping elements.

	* mach-o.c (overlap_previous): New function.
	(bfd_mach_o_fat_archive_p): Sanity check that elements do not
	overlap each other or the file and archive headers.
2022-09-14 17:14:06 +09:30
Alan Modra
faf351b59d regen pofiles 2022-09-14 15:45:19 +09:30
Tsukasa OI
491cf3178f bfd: Stop using -Wstack-usage=262144 when built with Clang
Some components of GNU Binutils will pass "-Wstack-usage=262144" when
"GCC >= 5.0" is detected.  However, Clang does not support "-Wstack-usage",
despite that related configuration part in bfd/warning.m4 handles the latest
Clang (15.0.0 as of this writing) as "GCC >= 5.0".

The option "-Wstack-usage" was ignored when the first version of Clang is
released but even this "ignoring" behavior is removed before Clang 4.0.0.
So, if we give Clang "-Wstack-usage=262144", it generates a warning, making
the build failure.

This commit checks "__clang__" macro to prevent adding the option if the
compiler is identified as Clang.

bfd/ChangeLog:

	* warning.m4: Stop appending "-Wstack-usage=262144" option when
	compiled with Clang.
	* configure: Regenerate.

binutils/ChangeLog:

	* configure: Regenerate.

gas/ChangeLog:

	* configure: Regenerate.

gold/ChangeLog:

	* configure: Regenerate.

gprof/ChangeLog:

	* configure: Regenerate.

ld/ChangeLog:

	* configure: Regenerate.

opcodes/ChangeLog:

	* configure: Regenerate.
2022-09-14 05:42:17 +00:00
Alan Modra
fdbca36115 Modify ld-ctf test files to suit ARM
The "@" char starts a comment on ARM.

	* testsuite/ld-ctf/diag-ctf-version-0.s: Replace @progbits with
	%progbits.
	* testsuite/ld-ctf/diag-ctf-version-2-unsupported-feature.s: Likewise.
	* testsuite/ld-ctf/diag-ctf-version-f.s: Likewise.
	* testsuite/ld-ctf/diag-cttname-invalid.s: Likewise.
	* testsuite/ld-ctf/diag-cttname-null.s: Likewise.
	* testsuite/ld-ctf/diag-cuname.s: Likewise.
	* testsuite/ld-ctf/diag-decompression-failure.s: Likewise.
	* testsuite/ld-ctf/diag-parlabel.s: Likewise.
	* testsuite/ld-ctf/diag-parname.s: Likewise.
	* testsuite/ld-ctf/diag-strlen-invalid.s: Likewise.
	* testsuite/ld-ctf/diag-unsupported-flag.s: Likewise.
	* testsuite/ld-ctf/diag-wrong-magic-number.s: Likewise.
2022-09-14 10:19:57 +09:30
Alan Modra
acfd5524fa asan: som_set_reloc_info heap buffer overflow
Also a bugfix.  The first time the section was read, the contents
didn't supply an addend.

	* som.c (som_set_reloc_info): Sanity check offset.  Do process
	contents after reading.  Tidy section->contents after freeing.
2022-09-14 10:19:57 +09:30
Alan Modra
72e366db62 ubsan: som_is_space null dereference
On objcopy of fuzzed file.

	* som.c (som_write_fixups): Exit loop if space sections all
	processed.
2022-09-14 10:19:56 +09:30
Alan Modra
3cb5e955a3 msan: vms-alpha use-of-uninitialized-value in dst_retrieve_location
* vms-alpha.c (dst_define_location): Init any unused entries.
2022-09-14 10:19:56 +09:30
Alan Modra
f15ba945a4 ubsan: arm-dis.c index out of bounds
We are way off in the weeds with this one, and will be printing
<UNPREDICTABLE> for S > 10.

	* arm-dis.c (print_insn_cde): Wrap 'T' value.
2022-09-14 10:19:56 +09:30
Alan Modra
365bf300da PR29540, R_PPC64_NONE in .rela.dyn when linking Linux vdso
PR 29540
	* elf64-ppc.c (allocate_dynrelocs): Don't alloc space for relocs
	against discarded sections.
	(ppc64_elf_size_dynamic_sections): Use standard test for discarded
	sections.
	* elf32-ppc.c (allocate_dynrelocs): Don't alloc space for relocs
	against discarded sections.
	(ppc_elf_size_dynamic_sections): Use standard test for discarded
	sections.
2022-09-14 10:19:56 +09:30
GDB Administrator
620fe92831 Automatic date update in version.in 2022-09-14 00:00:17 +00:00
Aaron Merey
e9a241e87b objdump: '-S' should trigger search for separate debuginfo.
Add with_source_code to the command line options that trigger
might_need_separate_debug_info and dump_any_debugging.  This helps
'objdump -S' download missing files via debuginfod without the need for
specifying extra command line options like '-L'.
2022-09-13 09:29:09 -04:00
Bruno Larsen
8fa9bc6a03 gdb/testsuite: Update gdb.base/so-impl-ld.exp
gdb.base/so-impl-ld.exp was setup assuming that the compiler would add
epilogue information and that GDB would stop in the } line.  This would
make clang tests fail like so:

 step^M
 solib_main (arg=10000) at ../../../common/git-repos/binutils-gdb/gdb/testsuite/gdb.base/solib1.c:7^M
 7|__  return arg*arg;|__|___/* HERE */^M
 (gdb) PASS: gdb.base/so-impl-ld.exp: step into solib call
 next^M
 main () at ../../../common/git-repos/binutils-gdb/gdb/testsuite/gdb.base/so-impl-ld.c:22^M
 22|_  return 0;^M
 (gdb) FAIL: gdb.base/so-impl-ld.exp: step in solib call
 next^M
 0x00007ffff7cef560 in __libc_start_call_main () from /lib64/libc.so.6^M
 (gdb) FAIL: gdb.base/so-impl-ld.exp: step out of solib call

This patch changes it so solib_main has 2 lines where GDB can stop
regardless of compiler choices, and updates the exp file to
generically deal with unknown number of steps until leaving that
function.
2022-09-13 14:02:51 +02:00
Bruno Larsen
9db78678c7 gdb/testsuite: introduce gdb_step_until
Currently, GDB's testsuite uses a set amount of step commands to exit
functions. This is a problem if a compiler emits different epilogue
information from gcc, or emits no epilogue information at all. It was
most noticeable if Clang was used to test GDB.

To fix this unreliability, this commit introduces a new proc that will
step the inferior until it is stopped at a line that matches the given
regexp, or until it steps too many times - defined as an optional
argument. If the line is found, it shows up as a single PASS in the
test, and if the line is not found, a single FAIL is emitted.

This patch only introduces this proc, but does not add it to any
existing tests, these will be introduced in the following commit.
2022-09-13 14:02:20 +02:00
Bruno Larsen
3f5bbc3e20 explicitly test for stderr in gdb.base/dprintf.exp
Not all compilers add stderr debug information when compiling a
program. Clang, for instance, prefers to add nothing from standard
libraries and let an external debug package have this information.
Because of this, gdb.base/dprintf.exp was failing when GDB attempted to
use dprintf as a call to fprintf(stderrr, ...), like this:

 (gdb) PASS: gdb.base/dprintf.exp: call: fprintf: set dprintf style to call
 continue
 Continuing.
 kickoff 1234
 also to stderr 1234
 'stderr' has unknown type; cast it to its declared type
 (gdb) FAIL: gdb.base/dprintf.exp: call: fprintf: 1st dprintf (timeout)

To avoid this false positive, we explicitly test to see if
the compiler has added information about stderr at all, and abort
testing dprintf as an fprintf call if it is unavailable.
2022-09-13 13:12:11 +02:00
Mark Harmstone
6a69b0a180 Add pdb archive format
Resubmitted with changes in
https://sourceware.org/pipermail/binutils/2022-September/122791.html
made.
2022-09-13 10:31:05 +01:00
Jiangshuai Li
77c2f1aad1 gdb/csky rm csky_print_registers_info
The reason for implementing this interface is that we want to print
GPR, PC, EPC, PSR and EPSR when the "info register" command
is executed.

A prev patch has added PC, EPC, PSR and EPSR to reggroup
general_group, the purpose has been achieved, so this function is
no longer required.
2022-09-13 14:24:39 +08:00
Jiangshuai Li
c0828c5a52 gdb/csky rm csky_memory_insert/remove_breakpoint
Software breakpoints are inserted or removed by the gdb stub via
remote protocol, these two functions are no longer needed.
2022-09-13 14:21:55 +08:00
Jiangshuai Li
d354e0c8e7 gdb/csky add unwinder for long branch cases
There are two sequences of instructions for long branch:
1. jmpi [pc+4]    //insn code: 0xeac00001
   .long addr

2. lrw t1, [pc+8] //insn code: 0xea8d0002
   jmp t1         //insn code: 0x7834
   nop            //insn code: 0x6c03
   .long addr
2022-09-13 14:19:26 +08:00
Jiangshuai Li
02cd1b4e97 gdbserver/csky add csky gdbserver support
Add new files:
  gdb/arch/csky.c
  gdb/arch/csky.h
  gdb/features/cskyv2-linux.c
  gdbserver/linux-csky-low.cc

1. In gdb/arch/csky.c file, add function "csky_create_target_description()"
for csky_target::low_arch_setup(). later, it can be used for csky native gdb.

2. In gdb/features/cskyv2-linux.c file, create target_tdesc for csky, include
gprs, pc, hi, lo, float, vector and float control registers.

3. In gdbserver/linux-csky-low.cc file, using PTRACE_GET/SET_RGESET to
get/set registers. The main data structures in asm/ptrace.h are:
struct pt_regs {
    unsigned long   tls;
    unsigned long   lr;
    unsigned long   pc;
    unsigned long   sr;
    unsigned long   usp;

    /*
     * a0, a1, a2, a3:
     * r0, r1, r2, r3
     */
    unsigned long   orig_a0;
    unsigned long   a0;
    unsigned long   a1;
    unsigned long   a2;
    unsigned long   a3;

    /*
     * r4 ~ r13
     */
    unsigned long   regs[10];

    /* r16 ~ r30 */
    unsigned long   exregs[15];

    unsigned long   rhi;
    unsigned long   rlo;
    unsigned long   dcsr;
};

struct user_fp {
    unsigned long   vr[96];
    unsigned long   fcr;
    unsigned long   fesr;
    unsigned long   fid;
    unsigned long   reserved;
};
2022-09-13 11:20:54 +08:00
GDB Administrator
20e2bd5c63 Automatic date update in version.in 2022-09-13 00:00:19 +00:00
Tom Tromey
5f48d886a9 Use checked_static_cast in more places
I went through all the uses of dynamic_cast<> in gdb, looking for ones
that could be replaced with checked_static_cast.  This patch is the
result.  Regression tested on x86-64 Fedora 34.
2022-09-12 14:25:06 -06: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
Bruno Larsen
fbdc50d2c7 add xfails to gdb.base/complex-parts.exp when testing with clang
clang doesn't add encoding to the name of complex variables, only says
that the type name is complex, making the relevant tests fail.
This patch adds the xfails to the tests that expect the variable name to
include it.
2022-09-12 14:09:44 +02:00
Bruno Larsen
39801ed969 Fix gdb.base/call-ar-st to work with Clang
When running gdb.base/call-ar-st.exp against Clang, we see one FAIL,
like so:

 print_all_arrays (array_i=<main.integer_array>, array_c=<main.char_array> "ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa
 ZaZaZaZaZaZaZaZaZaZaZaZa", array_f=<main.float_array>, array_d=<main.double_array>) at ../../../src/gdb/testsuite/gdb.base/call-ar-st.c:274
 274       print_int_array(array_i);     /* -step1- */
 (gdb) FAIL: gdb.base/call-ar-st.exp: step inside print_all_arrays

With GCC we instead see:

 print_all_arrays (array_i=<integer_array>, array_c=<char_array> "ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa", array_f=<float_array>, array_d=<double_array>) at /home/pedro/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/call-ar-st.c:274
 274       print_int_array(array_i);     /* -step1- */
 (gdb) PASS: gdb.base/call-ar-st.exp: step inside print_all_arrays

The difference is that with Clang we get:

 array_i=<main.integer_array>, ...

instead of

 array_i = <integer_array>, ...

These symbols are local static variables, and "main" is the name of
the function they are defined in.  GCC instead appends a sequence
number to the linkage name:

 $ nm -A call-ar-st.gcc | grep integer_
 call-ar-st/call-ar-st:00000000000061a0 b integer_array.3968

 $ nm -A call-ar-st.clang | grep integer_
 call-ar-st:00000000004061a0 b main.integer_array

This commit changes the testcase to accept both outputs, as they are
functionally identical.

Co-Authored-By: Pedro Alves <pedro@palves.net>
Change-Id: Iaf2ccdb9d5996e0268ed12f595a6e04b368bfcb4
2022-09-12 14:09:07 +02:00
Bruno Larsen
96ca89d245 fix gdb.base/access-mem-running.exp for clang testing
Clang was optimizing global_var away because it was not being used
anywhere. this commit fixes that by adding the attribute used it.
2022-09-12 14:08:44 +02:00
Bruno Larsen
8a0eb19943 update gdb.base/info-program.exp to not fail with clang
The test specifically mentions that it doesn't care where the program
stops, however it was still testing for a specific location.  The clang
compiler emits different line information for epilogue, so GDB reports a
different stopping location, depending on the used compiler.  With this
patch the test works even with clang.
2022-09-12 14:07:32 +02:00
Bruno Larsen
e330204945 gdb/testsuite: change gdb.base/nodebug.exp to not fail with clang
Clang organizes the variables differently to gcc in the original version
of this code, leading to the following differences when testing
p (int*) &dataglobal + 1

gcc:
$16 = (int *) 0x404034 <datalocal>

clang:
$16 = (int *) 0x404034 <dataglobal8>

However, since the important part of this test doesn't seem to be which
symbol is linked, but rather if GDB is correctly increasing the
address. This test was changed to actually measure address changes,
instead of assuming the ordering and naming of symbols.

Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
2022-09-12 14:06:51 +02:00
Martin Storsjö
825a844fdc ld: pe: Apply review suggestions on the existing exports/imports arrays
Use a separate explicit max_exports/imports field, instead of
deducing it from the number of allocated elements. Use a named
constant for the incremental growth of the array.

Use bool instead of int for boolean values.

Remove an unnecessary if statement/scope in the def_file_free
function.

Add more verbose comments about parameters, and about insertion
into an array of structs.

Generally use unsigned integers for all array indices and sizes.
The num_exports/imports fields are kept as is as signed integers,
since changing them to unsigned would require a disproportionate
amount of changes ti pe-dll.c to avoid comparisons between signed
and unsigned.

Simply use xrealloc instead of a check and xmalloc/xrealloc;
xrealloc can take NULL as the first parameter (and does a similar
check internally). (This wasn't requested in review though,
but noticed while working on the code.)
2022-09-12 11:07:35 +03:00
Martin Storsjö
a33a94cf43 ld: pe: Improve performance of object file exclude symbol directives
Store the list of excluded symbols in a sorted list, speeding up
checking for duplicates when inserting new entries.

This is done in the same way as is done for exports and imports
(while the previous implementation was done with a linked list,
based on the implementation for aligncomm).

When linking object files with excluded symbols, there can potentially
be very large numbers of excluded symbols (just like builds with
exports can have a large number of exported symbols).

This improves the link performance somewhat, when linking with large
numbers of excluded symbols.

The later actual use of the excluded symbols within pe-dll.c
handles them via an unordered linked list still, though.
2022-09-12 11:07:35 +03:00
Tom de Vries
3d36a6396f [gdb] Fix abort in selftest run_on_main_thread with ^C
When running selftest run_on_main_thread and pressing ^C, we can run into:
...
Running selftest run_on_main_thread.
terminate called without an active exception

Fatal signal: Aborted
...

The selftest function looks like this:
...
static void
run_tests ()
{
  std::thread thread;

  done = false;

  {
    gdb::block_signals blocker;

    thread = std::thread (set_done);
  }

  while (!done && gdb_do_one_event () >= 0)
    ;

  /* Actually the test will just hang, but we want to test
     something.  */
  SELF_CHECK (done);

  thread.join ();
}
...

The error message we see is due to the destructor of thread being called while
thread is joinable.

This is supposed to be taken care of by thread.join (), but the ^C prevents
that one from being called, while the destructor is still called.

Fix this by ensuring thread.join () is called (if indeed required) before the
destructor using SCOPE_EXIT.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29549
2022-09-12 10:05:18 +02:00
Tom de Vries
abe47e91d8 [gdb/symtab] Support .gdb_index section with TUs in .debug_info
The .gdb_index variant of commit d878bb39e4 ("[gdb/symtab] Support
.debug_names section with TUs in .debug_info").

Tested on x86_64-linux.
2022-09-12 10:05:18 +02:00
Tom de Vries
52b920c5d2 [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp for ppc64le
In commit cd919f5533 ("[gdb/testsuite] Fix
gdb.dwarf2/dw2-dir-file-name.exp"), I made gdb.dwarf2/dw2-dir-file-name.exp
independent of prologue analyzers, using this change:
...
-       gdb_breakpoint $func
+       gdb_breakpoint *$func
...

That however caused a regression on ppc64le.  For PowerPC, as described in the
ELFv2 ABI, a function can have a global and local entry point.

Setting a breakpoint on *$func effectively creates a breakpoint for the global
entry point, so if the function is entered through the local entry point, the
breakpoint doesn't trigger.

Fix this by reverting commit cd919f5533, and setting the breakpoint on
${func}_label instead.

Tested on x86_64-linux and ppc64le-linux.
2022-09-12 10:05:18 +02:00
Tom de Vries
9e338b141b [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp with clang
When running test-case gdb.dwarf2/dw2-dir-file-name.exp with clang, we run
into:
...
(gdb) break *compdir_missing__ldir_missing__file_basename^M
Breakpoint 2 at 0x400580^M
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, 0x0000000000400580 in \
  compdir_missing.ldir_missing.file_basename ()^M
(gdb) FAIL: gdb.dwarf2/dw2-dir-file-name.exp: \
  compdir_missing__ldir_missing__file_basename: continue to breakpoint: \
  compdir_missing__ldir_missing__file_basename
...

The problem is that the test-case uses labels outside functions, which is know
to cause problem with clang, as documented in the comment for proc
function_range.

Fix this by using get_func_info instead.

Tested on x86_64-linux, with both gcc 7.5.0 and clang 13.0.0.
2022-09-12 10:05:18 +02:00
Jan Beulich
ac3fe48fd6 x86: avoid i386_dis_printf()'s staging area for a fair part of output
While PR binutils/29483 has now been addressed differently, this
originally proposed change still has its merits: Avoiding vsnprintf()
for typically far more than half of the overall output results in a 2-3%
performance gain in my testing (with debug builds of objdump, libbfd,
and libopcodes).

With that part of output no longer using staging_area[], the array also
doesn't need to be quite as large anymore (the largest presently used
size is 27, from "64-bit address is disabled").

While limiting the scope of "res" it became apparent that
- no caller cares about the function's return value,
- the comment about the return value was wrong,
- a particular positive return value would have been meaningless to the
  caller.
Therefore convert the function to return "void" at the same time.
2022-09-12 08:19:55 +02:00
Nelson Chu
ecb915b4de RISC-V: PR28509, the default visibility symbol cannot be referenced by R_RISCV_JAL.
When generating the shared object, the default visibility symbols may bind
externally, which means they will be exported to the dynamic symbol table,
and are preemptible by default.  These symbols cannot be referenced by the
non-pic R_RISCV_JAL and R_RISCV_RVC_JUMP.  However, consider that linker
may relax the R_RISCV_CALL relocations to R_RISCV_JAL or R_RISCV_RVC_JUMP,
if these relocations are relocated to the plt entries, then we won't report
error for them.  Perhaps we also need the similar checks for the
R_RISCV_BRANCH and R_RISCV_RVC_BRANCH relocations.

After applying this patch, and revert the following glibc patch,
riscv: Fix incorrect jal with HIDDEN_JUMPTARGET
https://sourceware.org/git/?p=glibc.git;a=commit;h=68389203832ab39dd0dbaabbc4059e7fff51c29b

I get the expected errors as follows,
ld: relocation R_RISCV_RVC_JUMP against `__sigsetjmp' which may bind externally can not be used when making a shared object; recompile with -fPIC
ld: relocation R_RISCV_JAL against `exit' which may bind externally can not be used when making a shared object; recompile with -fPIC

Besides, we also have similar changes for libgcc,
RISC-V: jal cannot refer to a default visibility symbol for shared object
45116f3420

bfd/
	pr 28509
	* elfnn-riscv.c (riscv_elf_relocate_section): Report errors when
	makeing a shard object, and the referenced symbols of R_RISCV_JAL
	relocations are default visibility.  Besides, we should handle most
	of the cases here, so don't need the unresolvable check later for
	R_RISCV_JAL and R_RISCV_RVC_JUMP.
ld/
	pr 28509
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
	* testsuite/ld-riscv-elf/lib-nopic-01a.s: Removed.
	* testsuite/ld-riscv-elf/lib-nopic-01b.d: Likewise.
	* testsuite/ld-riscv-elf/lib-nopic-01b.s: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-01.d: New testcase.
	* testsuite/ld-riscv-elf/shared-lib-nopic-01.s: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-02.d: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-02.s: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-03.d: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-03.s: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-04.d: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-04.s: Likewise.
2022-09-12 11:31:41 +08:00
GDB Administrator
0967e2e492 Automatic date update in version.in 2022-09-12 00:00:10 +00:00
Tom de Vries
a34a90995a [gdb/symtab] Fix handling of DW_TAG_unspecified_type
Currently, the test-case contained in this patch fails:
...
(gdb) p (int) foo ()^M
Invalid cast.^M
(gdb) FAIL: gdb.dwarf2/dw2-unspecified-type.exp: p (int) foo ()
...
because DW_TAG_unspecified_type is translated as void.

There's some code in read_unspecified_type that marks the type as stub, but
that's only active for ada:
...
  if (cu->lang () == language_ada)
    type->set_is_stub (true);
...

Fix this by:
- marking the type as a stub for all languages, and
- handling the stub return type case in call_function_by_hand_dummy.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29558
2022-09-11 09:01:03 +02:00
GDB Administrator
20a64ae9cb Automatic date update in version.in 2022-09-11 00:00:12 +00:00
Alan Modra
1180f540d5 Re: PR29466, APP/NO_APP with linefile
It looks like I copied the SIZE init across from
binutils/testsuite/config/default.exp without some necessary editing.

	* testsuite/config/default.exp (SIZE): Adjust relative path.
2022-09-10 22:03:49 +09:30
GDB Administrator
9d3b25ecc5 Automatic date update in version.in 2022-09-10 00:00:07 +00:00
Nick Clifton
efc1521e40 Support debuginfo files with empty group sections.
PR 29532
bfd	* elf.c (setup_group): Do not return false if there is no group
	information available.

bionutils* objcopy.c (setup_section): Leave group sections intact when
	creating separate debuginfo files.
2022-09-09 12:01:55 +01:00
Tsukasa OI
1daabcc746 RISC-V: Fix vector CSR requirements
Vector CSRs are also required on smaller vector subsets.

Not only that the most of vector CSRs are general purpose (and must be
accessible for every vector subsets), current minimum vector subset 'Zve32x'
requires fixed point arithmetic, making remaining non-general purpose
(fixed point arithmetic only) CSRs mandatory for such subsets.

So, those CSRs must be accessible from 'Zve32x', not just from 'V'.
This commit fixes this issue which caused CSR accessibility warnings.

gas/ChangeLog:

	* config/tc-riscv.c (riscv_csr_address): Change vector CSR
	requirement from 'V' to 'Zve32x'.
	* testsuite/gas/riscv/csr-version-1p9p1.l: Change vector CSR
	requirement from 'V' to 'Zve32x'.
	* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.l: Likewise.
2022-09-09 10:12:13 +00:00
GDB Administrator
58448ad29c Automatic date update in version.in 2022-09-09 00:00:26 +00:00
Carl Love
a47a2d45bd Fix hardware watchpoint check in test gdb.base/watchpoint-reuse-slot.exp
This test generates 48 failures on Power 9 when testing with HW watchpoints
enabled.  Note HW watchpoint support is disabled on Power 9 due to a HW bug.
The skip_hw_watchpoint_tests proc must be used to correctly determine
if the processor supports HW watchpoints.

This patch replaces the [target_info exists gdb,no_hardware_watchpoints]
with the skip_hw_watchpoint_tests check.

This patch was tested on Power 9, Power 10 and X86-64 with no regressions.
2022-09-08 15:13:03 +00:00
Nick Clifton
0ee31dffb8 Gas generated incorrect debug info (top-level DW_TAG_unspecified_type DIE)
PR 29559
	* dwarf2dbg.c (out_debug_info): Place DW_TAG_unspecified_type at
	the end of the list of children, not at the start of the CU
	information.
	* testsuite/gas/elf/dwarf-3-func.d: Update expected output.
	* testsuite/gas/elf/dwarf-5-func-global.d: Likewise.
	* testsuite/gas/elf/dwarf-5-func-local.d: Likewise.
	* testsuite/gas/elf/dwarf-5-func.d: Likewise.
2022-09-08 12:43:33 +01:00
Tsukasa OI
39eedb20b7 gdbsupport: Fix config.status dependency
Commit 171fba11ab ("Make GDBserver abort on internal error in development mode")
created a new substitution CONFIG_STATUS_DEPENDENCIES but this is used by
Makefile.in (which is not regenerated by that commit).  After regenerating
it, it is found that CONFIG_STATUS_DEPENDENCIES value is not valid, making
gdbsupport fail to build.

Since the CONFIG_STATUS_DEPENDENCIES value is used in the Makefile, macro
substitution must have a Makefile format but commit 171fba11ab used shell
format "$srcdir/../bfd/development.sh".

This commit fixes this issue by substituting "$srcdir" (shell format) to
"$(srcdir)" (Makefile format).  It preserves the dependency as Pedro
intended and fixes the build problem.

It also regenerates corresponding files with the maintainer mode.

gdbsupport/ChangeLog:

	* configure.ac: Fix config.status dependency.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
2022-09-08 11:03:12 +00:00