]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
5 months agoUpdate year range in copyright notice of binutils files
Alan Modra [Thu, 4 Jan 2024 11:52:08 +0000 (22:22 +1030)] 
Update year range in copyright notice of binutils files

Adds two new external authors to etc/update-copyright.py to cover
bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then
updates copyright messages as follows:

1) Update cgen/utils.scm emitted copyrights.
2) Run "etc/update-copyright.py --this-year" with an extra external
   author I haven't committed, 'Kalray SA.', to cover gas testsuite
   files (which should have their copyright message removed).
3) Build with --enable-maintainer-mode --enable-cgen-maint=yes.
4) Check out */po/*.pot which we don't update frequently.

5 months agoSynchronize config.sub and config.guess with their upstream master versions.
Nick Clifton [Thu, 4 Jan 2024 12:00:34 +0000 (12:00 +0000)] 
Synchronize config.sub and config.guess with their upstream master versions.

Brings in:
commit 28ea239c53a2d5d8800c472bc2452eaa16e37af2    config.sub: Remove windows-gnu
commit a6976af01b0c6206561782183a0db42124b19f7b    config.sub: recognise ARM64EC machine type
commit 4e60c54be77f743ff8018ab58fb36fd8bc055e2a    config.sub: allow aarch64c-unknown-freebsd
commit e4786449e1c26716e3f9ea182caf472e4dbc96e0    config.guess: invoke "uname -p" from PATH for non-arm FreeBSD
commit 021155df7fad97a5ae1baa354e15a03ea14500b4    config.guess: Detect Android (as opposed to GNU/Linux)
commit 6c78704d542cebfb56d17474fe9f8395e9defb94    config.sub: add javascript-*-ghcjs
commit 2a7c4b64d4aec5c3a8a975625f0f8c369d365667    testsuite: add coverage for vendor-clobbering
commit 39c49ea712cba8ae6613ef85ab22fe7c552b48b0    config.sub: Systematize parsing of machine code formats
commit d4e37b5868ef910e3e52744c34408084bb13051c    config.sub: Handle arbitrary MIPS CPU names
commit af8d803a82436779d35ea389888788c78677804e    config.guess (aarch64:Linux:*:*): Detect 32-bit ABI
commit 602766470c886df7ae07bcfd7dcf532f0783d3e0    Add KVX MPPA detection
commit be68d790b6bc7dd84982fa6760f1448e92849e63    config.sub: Add Apple tvOS and watchOS
commit 998ba1414387b4ce1a519be234e1609bc7912e0c    config.sub: Accept $cpu-$vendor-none-{coff,elf}

5 months agoLoongArch: Fix linker generate PLT entry for data symbol
mengqinggang [Thu, 1 Dec 2022 09:23:14 +0000 (17:23 +0800)] 
LoongArch: Fix linker generate PLT entry for data symbol

With old "medium" code model, we call a function with a pair of PCALAU12I
and JIRL instructions. The assembler produces something like:

   8: 1a00000c  pcalau12i    $t0, 0
8: R_LARCH_PCALA_HI20 g
   c: 4c000181  jirl         $ra, $t0, 0
c: R_LARCH_PCALA_LO12 g

The linker generates a "PLT entry" for data without any diagnostic.
If "g" is a data symbol and ld with -shared option, it may load two
instructions in the PLT.

Without -shared option, loongarch_elf_adjust_dynamic_symbol can delete PLT
entry.

For R_LARCH_PCALA_HI20 relocation, linker only generate PLT entry for STT_FUNC
and STT_GNU_IFUNC symbols.

5 months agogdb: improve error reporting from expression parser
Andrew Burgess [Fri, 22 Dec 2023 11:29:13 +0000 (11:29 +0000)] 
gdb: improve error reporting from expression parser

This commits changes how errors are reported from the expression
parser.  Previously, parser errors were reported like this:

  (gdb) p a1 +}= 432
  A syntax error in expression, near `}= 432'.
  (gdb) p a1 +
  A syntax error in expression, near `'.

The first case is fine, a user can figure out what's going wrong, but
the second case is a little confusing; as the error occurred at the
end of the expression GDB just reports the empty string to the user.

After this commit the first case is unchanged, but the second case now
reports like this:

  (gdb) p a1 +
  A syntax error in expression, near the end of `a1 +'.

Which I think is clearer.  There is a possible issue if the expression
being parsed is very long, GDB will repeat the whole expression.  But
this issue already exists in the standard case; if the error occurs
early in a long expression GDB will repeat everything after the syntax
error.  So I've not worried about this case in my new code either,
which keeps things simpler.

I did consider trying to have multi-line errors here, in the style
that gcc produces, with some kind of '~~~~~^' marker on the second
line to indicate where the error occurred; but I rejected this due to
the places in GDB where we catch an error and repackage the message
within some longer string, I don't think multi-line error messages
would work well in that case.  At a minimum it would require some
significant work in order to make all our error handling multi-line
aware.

I've added a couple of extra tests in gdb.base/exprs.exp.

Approved-By: John Baldwin <jhb@FreeBSD.org>
5 months agogdb: merge error handling from different expression parsers
Andrew Burgess [Tue, 2 Jan 2024 14:02:44 +0000 (14:02 +0000)] 
gdb: merge error handling from different expression parsers

Many (all?) of the expression parsers implement yyerror to handle
parser errors, and all of these functions are basically identical.

This commit adds a new parser_state::parse_error() function, which
implements the common error handling code, this function can then be
called from all the different yyerror functions.

The benefit of this is that (in a future commit) I can improve the
error output, and all the expression parsers will benefit.

This commit is pure refactoring though, and so, there should be no
user visible changes after this commit.

Approved-By: John Baldwin <jhb@FreeBSD.org>
5 months agogdb: don't try to style content in error calls
Andrew Burgess [Fri, 22 Dec 2023 11:48:54 +0000 (11:48 +0000)] 
gdb: don't try to style content in error calls

While working on a later commit in this series I realised that the
error() function doesn't support output styling.  Due to the way that
output from error() calls is passed around within the exception
object and often combined with other output, it's not immediately
obvious to me if we should be trying to support styling in this
context or not.

On inspection, I found one place in GDB where we apparently try to
apply styling within the error() output (in procfs.c).  I suspect this
error() call might not be tested.

Rather than try to implement styling in the error() output, right now
I'm proposing to just remove the attempt to style error() output.

This doesn't mean that someone shouldn't add error() styling in the
future, but right now, I'm not planning to do that, I just wanted to
fix this in passing.

Approved-By: John Baldwin <jhb@FreeBSD.org>
5 months agoLoongArch: Fix loongarch*-elf target ld testsuite failure
Lulu Cai [Wed, 27 Dec 2023 09:10:41 +0000 (17:10 +0800)] 
LoongArch: Fix loongarch*-elf target ld testsuite failure

The loongarch*-elf target does not support SHARED and PIE, so this
target is skipped for some tests that require these options.

5 months agoLoongArch: Fix some macro that cannot be expanded properly
Lulu Cai [Wed, 27 Dec 2023 11:42:01 +0000 (19:42 +0800)] 
LoongArch: Fix some macro that cannot be expanded properly

Suppose we want to use la.got to generate 32 pcrel and
32 abs instruction sequences respectively. According to
the existing conditions, to generate 32 pcrel sequences
use -mabi=ilp32*, and to generate 32 abs use -mabi=ilp32*
and -mla-global-with-abs.

Due to the fact that the conditions for generating 32 abs
also satisfy 32 pcrel, using -mabi=ilp32* and -mla-global-with-abs
will result in only generating instruction sequences of 32 pcrel.

By modifying the conditions for macro expansion and adjusting
the matching order of macro instructions, it is ensured that
the correct sequence of instructions can be generated.

5 months agoAutomatic date update in version.in
GDB Administrator [Thu, 4 Jan 2024 00:01:45 +0000 (00:01 +0000)] 
Automatic date update in version.in

5 months agosim: ppc: unify igen filter modules
Mike Frysinger [Wed, 3 Jan 2024 08:12:42 +0000 (03:12 -0500)] 
sim: ppc: unify igen filter modules

The common igen code was forked from the ppc long ago.  The filter
module is still pretty similar in API, so we can unfork them with
a little bit of effort.

The filter.c module is still here because of the unique it_is API.
The common igen code doesn't seem to have an equiv API as this only
operates on two strings and not an actual filter object, and it's
easy enough to leave behind to unfork the rest.

5 months agosim: ppc: unify igen line number output modules
Mike Frysinger [Wed, 3 Jan 2024 07:54:37 +0000 (02:54 -0500)] 
sim: ppc: unify igen line number output modules

The common igen code was forked from the ppc long ago.  The lf module
is still pretty similar in API, so we can unfork them with a little
bit of effort.

Some of the generated ppc code is now slightly different, but that's
because of fixes the common igen code has gained, but not the ppc igen
code (e.g. fixing of #line numbers).

The ppc code retains lf_print__c_code because the common igen code
rewrote the logic to a new table.c API.  Let's delay that in the ppc
code to at least unfork all this code.

5 months agosim: igen: clean up headers a bit
Mike Frysinger [Wed, 3 Jan 2024 08:07:25 +0000 (03:07 -0500)] 
sim: igen: clean up headers a bit

Add standard multiple inclusion protection, and add a few missing
local includes when one header uses another.  This isn't complete,
but fixes some short comings seen when merging the ppc igen.

5 months agosim: ppc: switch to common endian code
Mike Frysinger [Wed, 3 Jan 2024 07:17:16 +0000 (02:17 -0500)] 
sim: ppc: switch to common endian code

The common sim-endian is a forked & updated version of the ppc code.
Fortunately, they didn't diverge from the basic APIs, so they are
still compatible, which means we can just delete the ppc version now
that the build env is merged at the top-level.

5 months agosim: common: include sim-types.h in the endian header directly
Mike Frysinger [Wed, 3 Jan 2024 07:15:54 +0000 (02:15 -0500)] 
sim: common: include sim-types.h in the endian header directly

This is a bit redundant for most ports as they go through sim-basics.h
which always includes sim-types.h before including sim-endian.h, but in
order to unify ppc's sim-endian code, we need this include here.  Plus,
it's the directly we generally want to go to get away from one header
that defines all APIs and causes hard to untangle dependencies.

5 months agosim: ppc: rename local ALU SIGNED64 macros
Mike Frysinger [Wed, 3 Jan 2024 07:13:55 +0000 (02:13 -0500)] 
sim: ppc: rename local ALU SIGNED64 macros

The common/ code has macros with the same name but different behavior:
it's for declaring integer constants as 64-bit, not for casting them.
Rename ppc's local variant since it's only used in this file in order
to avoid conflicts.

5 months agosim: ppc: sync WITH_TARGET_{ADDRESS,CELL}_BITSIZE with common/
Mike Frysinger [Wed, 3 Jan 2024 07:10:52 +0000 (02:10 -0500)] 
sim: ppc: sync WITH_TARGET_{ADDRESS,CELL}_BITSIZE with common/

This will make it easier to share common/ code that rely on these
additional defines.

5 months agosim: cr16: cleanup unused variable compiler warnings
Mike Frysinger [Wed, 3 Jan 2024 06:54:57 +0000 (01:54 -0500)] 
sim: cr16: cleanup unused variable compiler warnings

5 months agosim: configure: switch to m4_map
Mike Frysinger [Wed, 3 Jan 2024 01:26:53 +0000 (20:26 -0500)] 
sim: configure: switch to m4_map

Minor reduction in boilerplate here.  No real functional changes.

5 months agosim: drop support for recursive makes entirely
Mike Frysinger [Tue, 2 Jan 2024 15:23:09 +0000 (10:23 -0500)] 
sim: drop support for recursive makes entirely

Now that all ports have been merged to the top-level, we no longer need
this framework to pass settings down to sub-makefiles.  Delete it all.

5 months agosim: ppc: hoist compilation up to top-level
Mike Frysinger [Tue, 2 Jan 2024 14:58:07 +0000 (09:58 -0500)] 
sim: ppc: hoist compilation up to top-level

This removes all recursive makes from the ppc port.

5 months agosim: drop support for automatic subdir recursion
Mike Frysinger [Tue, 2 Jan 2024 15:02:39 +0000 (10:02 -0500)] 
sim: drop support for automatic subdir recursion

No port relies on this anymore, so we can scrub it all.

5 months agosim: ppc: move libsim.a creation to top-level
Mike Frysinger [Tue, 2 Jan 2024 14:50:43 +0000 (09:50 -0500)] 
sim: ppc: move libsim.a creation to top-level

The objects are still compiled in the subdir, but the creation of the
archive itself is in the top-level.  This is a required step before we
can move compilation itself up, and makes it easier to review.

The downside is that each object compile is a recursive make instead of
a single one.  It adds some overhead, so it's not great, but it shouldn't
be a big deal.  This will go away once compilation is hoisted up.

5 months agosim: ppc: move main.o compilation to top-level
Mike Frysinger [Tue, 2 Jan 2024 13:28:34 +0000 (08:28 -0500)] 
sim: ppc: move main.o compilation to top-level

5 months agoLoongArch: delete bfd/.elfnn-loongarch.c.swp
mengqinggang [Wed, 3 Jan 2024 03:27:35 +0000 (11:27 +0800)] 
LoongArch: delete bfd/.elfnn-loongarch.c.swp

5 months agoAutomatic date update in version.in
GDB Administrator [Wed, 3 Jan 2024 00:02:14 +0000 (00:02 +0000)] 
Automatic date update in version.in

5 months agoFix GDB reverse-step and reverse-next command behavior
Carl Love [Tue, 2 Jan 2024 22:46:12 +0000 (17:46 -0500)] 
Fix GDB reverse-step and reverse-next command behavior

Currently GDB when executing in reverse over multiple statements in a single
line of source code, GDB stops in the middle of the line.  Thus requiring
multiple commands to reach the previous line.  GDB should stop at the first
instruction of the line, not in the middle of the line.

The following description of the incorrect behavior was taken from an
earlier message by Pedro Alves <pedro@palves.net>:

https://sourceware.org/pipermail/gdb-patches/2023-January/196110.html

---------------------------------

The source line looks like:

   func1 ();  func2 ();

in the test case:

(gdb) list 1
1       void func1 ()
2       {
3       }
4
5       void func2 ()
6       {
7       }
8
9       int main ()
10      {
11        func1 (); func2 ();
12      }

compiled with:

 $ gcc reverse.c -o reverse -g3 -O0
 $ gcc -v
 ...
 gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)

Now let's debug it with target record, using current gdb git master
(f3d8ae90b236),

 $ gdb ~/reverse
 GNU gdb (GDB) 14.0.50.20230124-git
 ...
 Reading symbols from /home/pedro/reverse...
 (gdb) start
 Temporary breakpoint 1 at 0x1147: file reverse.c, line 11.
 Starting program: /home/pedro/reverse
 [Thread debugging using libthread_db enabled]
 Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

 Temporary breakpoint 1, main () at reverse.c:11
 11        func1 (); func2 ();
 (gdb) record

 (gdb) disassemble /s
 Dump of assembler code for function main:
 reverse.c:
 10      {
    0x000055555555513f <+0>:     endbr64
    0x0000555555555143 <+4>:     push   %rbp
    0x0000555555555144 <+5>:     mov    %rsp,%rbp

 11        func1 (); func2 ();
 => 0x0000555555555147 <+8>:     mov    $0x0,%eax
    0x000055555555514c <+13>:    call   0x555555555129 <func1>
    0x0000555555555151 <+18>:    mov    $0x0,%eax
    0x0000555555555156 <+23>:    call   0x555555555134 <func2>
    0x000055555555515b <+28>:    mov    $0x0,%eax

 12      }
    0x0000555555555160 <+33>:    pop    %rbp
    0x0000555555555161 <+34>:    ret
 End of assembler dump.

 (gdb) n
 12      }

So far so good, a "next" stepped over the whole of line 11 and stopped at
line 12.

Let's confirm where we are now:

 (gdb) disassemble /s
 Dump of assembler code for function main:
 reverse.c:
 10      {
    0x000055555555513f <+0>:     endbr64
    0x0000555555555143 <+4>:     push   %rbp
    0x0000555555555144 <+5>:     mov    %rsp,%rbp

 11        func1 (); func2 ();
    0x0000555555555147 <+8>:     mov    $0x0,%eax
    0x000055555555514c <+13>:    call   0x555555555129 <func1>
    0x0000555555555151 <+18>:    mov    $0x0,%eax
    0x0000555555555156 <+23>:    call   0x555555555134 <func2>
    0x000055555555515b <+28>:    mov    $0x0,%eax

 12      }
 => 0x0000555555555160 <+33>:    pop    %rbp
    0x0000555555555161 <+34>:    ret
 End of assembler dump.

Good, we're at the first instruction of line 12.

Now let's undo the "next", with "reverse-next":

 (gdb) reverse-next
 11        func1 (); func2 ();

Seemingly stopped at line 11.  Let's see exactly where:

 (gdb) disassemble /s
 Dump of assembler code for function main:
 reverse.c:
 10      {
    0x000055555555513f <+0>:     endbr64
    0x0000555555555143 <+4>:     push   %rbp
    0x0000555555555144 <+5>:     mov    %rsp,%rbp

 11        func1 (); func2 ();
    0x0000555555555147 <+8>:     mov    $0x0,%eax
    0x000055555555514c <+13>:    call   0x555555555129 <func1>
 => 0x0000555555555151 <+18>:    mov    $0x0,%eax
    0x0000555555555156 <+23>:    call   0x555555555134 <func2>
    0x000055555555515b <+28>:    mov    $0x0,%eax

 12      }
    0x0000555555555160 <+33>:    pop    %rbp
    0x0000555555555161 <+34>:    ret
 End of assembler dump.
 (gdb)

And lo, we stopped in the middle of line 11!  That is a bug, we should have
stepped back all the way to the beginning of the line.  The "reverse-next"
should have fully undone the prior "next" command.

--------------------

This patch fixes the incorrect GDB behavior by ensuring that GDB  stops at
the first instruction in the line.

The test case gdb.reverse/func-map-to-same-line.exp is added to testsuite
to verify this fix when the line table information is and is not available.

5 months agoPowerPC and aarch64: Fix reverse stepping failure
Carl Love [Tue, 2 Jan 2024 22:46:02 +0000 (17:46 -0500)] 
PowerPC and aarch64: Fix reverse stepping failure

When running GDB's testsuite on aarch64-linux/Ubuntu 20.04 (also spotted on
the ppc backend), there are failures in gdb.reverse/solib-precsave.exp and
gdb.reverse/solib-reverse.exp.

The failure happens around the following code:

38  b[1] = shr2(17);          /* middle part two */
40  b[0] = 6;   b[1] = 9;     /* generic statement, end part two */
42  shr1 ("message 1\n");     /* shr1 one */

Normal execution:

- step from line 38 will land on line 40.
- step from line 40 will land on line 42.

Reverse execution:
- step from line 42 will land on line 40.
- step from line 40 will land on line 40.
- step from line 40 will land on line 38.

The problem here is that line 40 contains two contiguous but distinct
PC ranges in the line table, like so:

Line 40 - [0x7ec ~ 0x7f4]
Line 40 - [0x7f4 ~ 0x7fc]

The two distinct ranges are generated because GCC started outputting source
column information, which GDB doesn't take into account at the moment.

When stepping forward from line 40, we skip both of these ranges and land on
line 42. When stepping backward from line 42, we stop at the start PC of the
second (or first, going backwards) range of line 40.

Since we've reached ecs->event_thread->control.step_range_start, we stop
stepping backwards.

The above issues were fixed by introducing a new function that looks for
adjacent PC ranges for the same line, until we notice a line change. Then
we take that as the start PC of the range.  The new start PC for the range
is used for the control.step_range_start when setting up a step range.

The test case gdb.reverse/map-to-same-line.exp is added to test the fix
for the above reverse step issues.

Patch has been tested on PowerPC, X86 and AArch64 with no regressions.

5 months agoAdd gdb_compile options column-info and no-column-info
Carl Love [Tue, 2 Jan 2024 22:45:55 +0000 (17:45 -0500)] 
Add gdb_compile options column-info and no-column-info

This patch adds two new options to gdb_compile to specify if the compile
should or should not generate the line table information.  The
options are supported on clang and gcc version 7 and newer.

Patch has been tested on PowerPC with both gcc and clang.

5 months agogdb/dwarf2: Add support for DW_LNS_set_epilogue_begin in line-table
Guinevere Larsen [Wed, 1 Nov 2023 16:25:32 +0000 (17:25 +0100)] 
gdb/dwarf2: Add support for DW_LNS_set_epilogue_begin in line-table

This commit adds a mechanism for GDB to detect the linetable opcode
DW_LNS_set_epilogue_begin. This opcode is set by compilers to indicate
that a certain instruction marks the point where the frame is destroyed.

While the standard allows for multiple points marked with epilogue_begin
in the same function, for performance reasons, the function that
searches for the epilogue address will only find the last address that
sets this flag for a given block.

This commit also changes amd64_stack_frame_destroyed_p_1 to attempt to
use the epilogue begin directly, and only if an epilogue can't be found
will it attempt heuristics based on the current instruction.

Finally, this commit also changes the dwarf assembler to be able to emit
epilogue-begin instructions, to make it easier to test this patch

Approved-By: Tom Tromey <tom@tromey.com>
5 months agosim: ppc: hoist pk.h creation to top-level
Mike Frysinger [Tue, 2 Jan 2024 07:18:53 +0000 (02:18 -0500)] 
sim: ppc: hoist pk.h creation to top-level

5 months agosim: ppc: hoist hw.[ch] creation to top-level
Mike Frysinger [Tue, 2 Jan 2024 07:11:11 +0000 (02:11 -0500)] 
sim: ppc: hoist hw.[ch] creation to top-level

5 months agosim: ppc: hoist igen execution to top-level
Mike Frysinger [Tue, 2 Jan 2024 07:00:09 +0000 (02:00 -0500)] 
sim: ppc: hoist igen execution to top-level

Invoke ppc's igen from the top-level like we do for all other ports.

5 months agosim: ppc: merge configure logic into top-level
Mike Frysinger [Tue, 2 Jan 2024 06:40:06 +0000 (01:40 -0500)] 
sim: ppc: merge configure logic into top-level

Now that the ppc configure script is just namespaced options, we can
move it to ppc/acinclude.m4 and include it directly in the top-level
configure script and kill off the last subdir configure script.

5 months agosim: ppc: scope configure options to --enable-sim-ppc-xxx
Mike Frysinger [Tue, 2 Jan 2024 06:30:53 +0000 (01:30 -0500)] 
sim: ppc: scope configure options to --enable-sim-ppc-xxx

To prepare for moving these into the top-level configure, namespace
then with the port name like we do with all other ports.

5 months agosim: ppc: standardize configure option processing
Mike Frysinger [Tue, 2 Jan 2024 06:13:44 +0000 (01:13 -0500)] 
sim: ppc: standardize configure option processing

Switch from ad-hoc $silent checks & echo calls to standard
AC_MSG_CHECKING & AC_MSG_RESULT calls.  Also delete pointless
variable setting after calling AC_MSG_ERROR.

5 months agosim: ppc: switch to AS_HELP_STRING for automatic formatting
Mike Frysinger [Tue, 2 Jan 2024 05:55:33 +0000 (00:55 -0500)] 
sim: ppc: switch to AS_HELP_STRING for automatic formatting

5 months agosim: ppc: drop now unused config.in
Mike Frysinger [Tue, 2 Jan 2024 05:39:08 +0000 (00:39 -0500)] 
sim: ppc: drop now unused config.in

5 months agosim: ppc: move defines.h generation to the top-level
Mike Frysinger [Tue, 2 Jan 2024 05:24:22 +0000 (00:24 -0500)] 
sim: ppc: move defines.h generation to the top-level

Since we rely on the top-level config.h now, the defines.h generation
step should live here too.

5 months agosim: ppc: drop configure compiler checks
Mike Frysinger [Tue, 2 Jan 2024 05:12:51 +0000 (00:12 -0500)] 
sim: ppc: drop configure compiler checks

Now that the ppc script only checks configure options and sets up
variables in the Makefile from those, delete all the compile related
logic to greatly simplify the configure script.

5 months agosim: ppc: drop custom config.h header
Mike Frysinger [Tue, 2 Jan 2024 05:11:38 +0000 (00:11 -0500)] 
sim: ppc: drop custom config.h header

Now that everything has moved to the top-level, we can drop the
custom ppc config.h and reuse the common one.

5 months agosim: ppc: stop including headers from gdb/
Mike Frysinger [Tue, 2 Jan 2024 05:10:33 +0000 (00:10 -0500)] 
sim: ppc: stop including headers from gdb/

The common sim code doesn't snoop in gdb/, and the ppc code doesn't
need to either.  Any common code we pull from gnulib/ now only.

5 months agosim: ppc: move termios probes to top-level
Mike Frysinger [Tue, 2 Jan 2024 04:57:12 +0000 (23:57 -0500)] 
sim: ppc: move termios probes to top-level

This is the last compile-time logic in the ppc subdir.

5 months agosim: ppc: switch to AC_CACHE_CHECK
Mike Frysinger [Tue, 2 Jan 2024 04:42:45 +0000 (23:42 -0500)] 
sim: ppc: switch to AC_CACHE_CHECK

This macro replaces the AC_MSG_CHECKING+AC_CACHE_VAL+AC_MSG_RESULT
which reduces the boilerplate in here a little bit.

5 months agosim: ppc: switch struct member checks to AC_CHECK_MEMBER
Mike Frysinger [Tue, 2 Jan 2024 04:53:53 +0000 (23:53 -0500)] 
sim: ppc: switch struct member checks to AC_CHECK_MEMBER

This covers a lot of the AC_MSG_CHECKING+AC_TRY_COMPILE+AC_MSG_RESULT
boilerplate and matches what we do in the top-level platform checks.

5 months agosim: ppc: move termio defines to config.h
Mike Frysinger [Tue, 2 Jan 2024 04:37:11 +0000 (23:37 -0500)] 
sim: ppc: move termio defines to config.h

Move the defines from explicit -D options to config.h defines to simplify
the build and make it easier to move to the top-level configure.

5 months agosim: ppc: move struct statfs to top-level
Mike Frysinger [Tue, 2 Jan 2024 04:32:29 +0000 (23:32 -0500)] 
sim: ppc: move struct statfs to top-level

5 months agosim: ppc: move long long test to top-level
Mike Frysinger [Tue, 2 Jan 2024 04:22:17 +0000 (23:22 -0500)] 
sim: ppc: move long long test to top-level

While the sim code doesn't utilize HAVE_LONG_LONG itself, other code
(like libiberty) seem to, so check for it in the top-level for all
ports to leverage.

5 months agosim: ppc: hoist sysv tests to top-level
Mike Frysinger [Tue, 2 Jan 2024 04:15:46 +0000 (23:15 -0500)] 
sim: ppc: hoist sysv tests to top-level

Now that the sysv tests turn into config.h defines and everything
checks that, we can move the tests to the top-level and out of the
ppc subdir.

5 months agosim: ppc: always compile in the sysv sem & shm device files
Mike Frysinger [Tue, 2 Jan 2024 01:22:45 +0000 (20:22 -0500)] 
sim: ppc: always compile in the sysv sem & shm device files

Move the stub logic to the device files themselves.  This makes the
configure & build logic more static which will make it easier to move
to the top-level build, and matches what we did with the common/ hw
tree already.

This also decouples the logic from the two -- in the past, you needed
both sem & shm in order to enable the device models, but now each one
is tied to its own independent knob.  Practically speaking, this will
probably not make a difference, but it simplifies the build a bit.

5 months agosim: ppc: change SysV sem & shm tests to compile-time
Mike Frysinger [Tue, 2 Jan 2024 01:11:52 +0000 (20:11 -0500)] 
sim: ppc: change SysV sem & shm tests to compile-time

Instead of executing code to see if SysV semaphores & shared memory
are available, switch to just a compile-time test.  The system used
to compile might not match the system used to run the code wrt the
current kernel & OS settings, but the library APIs should.  So move
the failures from compile-time to runtime so the program is more
portable, and works correctly even when cross-compiling.

5 months agosim: ppc: merge System V semaphores checks
Mike Frysinger [Tue, 2 Jan 2024 01:03:26 +0000 (20:03 -0500)] 
sim: ppc: merge System V semaphores checks

Compile tests can use earlier defines, so hoist the HAVE_UNION_SEMUN
define to before the semaphore check, and use it in the test so that
we can merge the 2 versions into one.

This also defines HAVE_UNION_SEMUN even when ac_cv_sysv_sem is not
set, but that's OK as this define is only about a type existing, not
about whether the overall code is usable.

5 months agosim: ppc: fix bad AC_CACHE_CHECK call with semun
Mike Frysinger [Tue, 2 Jan 2024 00:54:10 +0000 (19:54 -0500)] 
sim: ppc: fix bad AC_CACHE_CHECK call with semun

The first arg is the cache var name, and this one was typoed relative
to what the call actually set.  We also don't need the manual call to
AC_MSG_RESULT as the AC_CACHE_CHECK takes care of it for us.

5 months agosim: ppc: delete unused build compile & link settings
Mike Frysinger [Tue, 2 Jan 2024 05:27:12 +0000 (00:27 -0500)] 
sim: ppc: delete unused build compile & link settings

These should have been removed as part of the ppc/igen merging into the
top-level, but they were missed.  Clean up now.

5 months agoAutomatic date update in version.in
GDB Administrator [Tue, 2 Jan 2024 00:00:57 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agosim: ppc: merge misc igen APIs
Mike Frysinger [Mon, 1 Jan 2024 23:14:13 +0000 (18:14 -0500)] 
sim: ppc: merge misc igen APIs

The common igen code provides the same misc APIs as the ppc version,
so delete the ppc code and pull in the common one.  There is one
minor difference: the ppc code has a unique dumpf function.  The
common code switched to lf_printf for the same functionality, but
since that requires changes throughout the igen codebase, delay that
cleanup for now so we can merge the rest.

5 months agosim: ppc: rework igen error to match common
Mike Frysinger [Mon, 1 Jan 2024 22:34:01 +0000 (17:34 -0500)] 
sim: ppc: rework igen error to match common

Switch to an ERROR macro and tweak the error signature to match the
common igen version in preparation for merging the two implementations.

5 months agosim: igen: extend error to take arguments
Mike Frysinger [Mon, 1 Jan 2024 22:28:51 +0000 (17:28 -0500)] 
sim: igen: extend error to take arguments

The ppc igen error helper allows arbitrary printf calls, so extend
the common one to do the same.

5 months agosim: ppc: rename igen max_insn_bit_size
Mike Frysinger [Mon, 1 Jan 2024 22:17:50 +0000 (17:17 -0500)] 
sim: ppc: rename igen max_insn_bit_size

We want to avoid conflicts with the common igen enums.  This should
get migrated over to the common parsing logic, but for now, switch
the name to avoid redefinition.

5 months agosim: igen: minor constify logic
Mike Frysinger [Mon, 1 Jan 2024 22:09:02 +0000 (17:09 -0500)] 
sim: igen: minor constify logic

Copy some improvements from the ppc igen code.

5 months agosim: ppc: unify igen filter_filename implementations
Mike Frysinger [Mon, 1 Jan 2024 21:44:50 +0000 (16:44 -0500)] 
sim: ppc: unify igen filter_filename implementations

Now that both igen implementations are in the top-level, we can unify
the filter_filename implementation between them since they're the same
(literally the same code).

5 months agosim: ppc: replace filter_filename with lbasename
Mike Frysinger [Mon, 1 Jan 2024 21:32:48 +0000 (16:32 -0500)] 
sim: ppc: replace filter_filename with lbasename

The lbasename function from libiberty provides the same API as this
custom function.  The common/ code already made the switch, so make
the same change to the ppc code to avoid target duplication.

5 months agosim: ppc: hoist igen compilation into top-level
Mike Frysinger [Mon, 1 Jan 2024 20:48:15 +0000 (15:48 -0500)] 
sim: ppc: hoist igen compilation into top-level

This simplifies the build a bit (especially for deps in port subdirs),
and avoids recursive make.  This in turn speeds up the build, and lets
us reuse existing build-time vs host-time logic from Makefile.am.

5 months agosim: ppc: drop build-config.h usage
Mike Frysinger [Mon, 1 Jan 2024 20:26:21 +0000 (15:26 -0500)] 
sim: ppc: drop build-config.h usage

This header is only used by the igen tool, and none of the igen code
depends on the configure-time checks.  Delete the logic to simplify
to prepare for moving it to the local.mk code.

5 months agosim: ppc: simplify filter_host.c logic
Mike Frysinger [Mon, 1 Jan 2024 20:24:12 +0000 (15:24 -0500)] 
sim: ppc: simplify filter_host.c logic

Switch this from a build-time generation to a static include.  This
makes the build rules a bit simpler, especially as we move them to
Automake from hand-written makefiles.

5 months agosim: igen: remove libigen.a when cleaning
Mike Frysinger [Mon, 1 Jan 2024 20:38:10 +0000 (15:38 -0500)] 
sim: igen: remove libigen.a when cleaning

5 months agosim: ppc: drop unused host bitsize settings
Mike Frysinger [Mon, 1 Jan 2024 16:04:08 +0000 (11:04 -0500)] 
sim: ppc: drop unused host bitsize settings

This is never set anywhere, so it's always empty.  Scrub it.

5 months agosim: frv: fix cmpb uninitialized variable usage
Mike Frysinger [Sun, 24 Dec 2023 10:21:30 +0000 (05:21 -0500)] 
sim: frv: fix cmpb uninitialized variable usage

This code sets up the cc variable based on the comparison of other
registers, but it does so incrementally with bit operations, and it
never initializes the cc variable.  Initialize it to 0 which the
cmpba insn is already doing.

5 months agosim: arm: mark local read-only arrays as static const
Mike Frysinger [Fri, 22 Dec 2023 01:06:10 +0000 (20:06 -0500)] 
sim: arm: mark local read-only arrays as static const

Move it into read-only data sections to avoid constructing them on the
stack at runtime.

5 months agosim: warnings: enable -Wunused-variable
Mike Frysinger [Wed, 6 Dec 2023 13:39:25 +0000 (06:39 -0700)] 
sim: warnings: enable -Wunused-variable

5 months agocpu: or1k: drop unused l.swa flag
Mike Frysinger [Tue, 19 Dec 2023 01:55:58 +0000 (20:55 -0500)] 
cpu: or1k: drop unused l.swa flag

The "flag" argument isn't set/used in this insn, so drop it.
This fixes an unused variable warning in the generated sim.

5 months agosim: fix pervasive typo
Tom Tromey [Sun, 31 Dec 2023 21:55:58 +0000 (14:55 -0700)] 
sim: fix pervasive typo

I noticed a typo in a sim constant.  This patch fixes it.
permenant -> permanent

5 months agoAutomatic date update in version.in
GDB Administrator [Mon, 1 Jan 2024 00:00:49 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoRun 'black' on tui-window.py
Tom Tromey [Sun, 31 Dec 2023 23:36:44 +0000 (16:36 -0700)] 
Run 'black' on tui-window.py

Mark pointed out that a recent patch of mine caused the buildbot to
complain about the formatting of some Python test code.  This patch
re-runs 'black' to fix the problem.

5 months ago[gdb/testsuite] Fix typo in gdb.base/catch-syscall.exp
Tom de Vries [Sun, 31 Dec 2023 08:39:45 +0000 (09:39 +0100)] 
[gdb/testsuite] Fix typo in gdb.base/catch-syscall.exp

On aarch64-linux with a gdb build without libexpat, I run into:
...
(gdb) PASS: gdb.base/catch-syscall.exp: determine pipe syscall: \
  catch syscall 59
continue
Continuing.

Catchpoint 5 (call to syscall 59), 0x0000fffff7e04578 in pipe () from \
  /lib64/libc.so.6
(gdb) FAIL: gdb.base/catch-syscall.exp: determine pipe syscall: continue
...

In the test-case, this pattern handles either the syscall name or number for
the pipe syscall:
...
  -re -wrap "Catchpoint $decimal \\(call to syscall (pipe|$SYS_pipe)\\).*" {
...
but the pattern for the pipe2 syscall mistakenly uses SYS_pipe instead of
SYS_pipe2:
...
  -re -wrap "Catchpoint $decimal \\(call to syscall (pipe2|$SYS_pipe)\\).*" {
...
and consequently doesn't handle the pipe2 syscall number.

Fix the typo by using SYS_pipe2 instead.

Tested on aarch64-linux.

5 months agoAutomatic date update in version.in
GDB Administrator [Sun, 31 Dec 2023 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoAdd keywords to TuiWindow.write
Tom Tromey [Wed, 13 Dec 2023 05:49:52 +0000 (22:49 -0700)] 
Add keywords to TuiWindow.write

The gdb docs promise that methods with more than two or more arguments
will accept keywords.  However, I found that TuiWindow.write didn't
allow them.  This patch adds the missing support.

5 months ago[gdb/testsuite] Fix gdb.base/gdb-index-err.exp for root user
Tom de Vries [Sat, 30 Dec 2023 19:04:10 +0000 (20:04 +0100)] 
[gdb/testsuite] Fix gdb.base/gdb-index-err.exp for root user

When running test-case gdb.base/gdb-index-err.exp in a container as root user,
I run into:
...
FAIL: gdb.base/gdb-index-err.exp: flag=: \
  try to write index to a non-writable directory
FAIL: gdb.base/gdb-index-err.exp: flag=-dwarf-5: \
  try to write index to a non-writable directory
...

The test-case creates a directory without write permissions:
...
$ ls -ald private
dr-xr-xr-x 2 root root 4096 Dec 29 06:26 private/
...
but apparently the root user is still able to write in it.

Fix this by making the test unsupported for the root user.

Tested on x86_64-linux.

Reviewed-By: Lancelot SIX <lancelot.six@amd.com>
PR testsuite/31197
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31197

5 months agoLoongArch: Commas inside double quotes
Alan Modra [Thu, 28 Dec 2023 11:42:17 +0000 (22:12 +1030)] 
LoongArch: Commas inside double quotes

This adds an extra feature: Commas inside double quotes are not an
arg delimiter, and thus can be part of the arg.

* loongarch-coder.c (loongarch_split_args_by_comma): Commas
inside quotes are not arg delimiters.

5 months agoRegen bfd-in2.h
Alan Modra [Sat, 30 Dec 2023 02:27:42 +0000 (12:57 +1030)] 
Regen bfd-in2.h

Please DON'T edit this file.  READ THE COMMENT!

5 months agoMAINTAINERS: Update my email address
Joseph Myers [Sat, 30 Dec 2023 00:32:00 +0000 (00:32 +0000)] 
MAINTAINERS: Update my email address

There will be another update in January.

5 months agoAutomatic date update in version.in
GDB Administrator [Sat, 30 Dec 2023 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agox86: Append "#pass" to APX tests
H.J. Lu [Fri, 29 Dec 2023 23:46:59 +0000 (15:46 -0800)] 
x86: Append "#pass" to APX tests

Append "#pass" to APX tests for targets which pad text sections with NOPs.

* testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d: Append
"#pass".
* testsuite/gas/i386/x86-64-apx-ndd-optimize.d: Likewise.
* testsuite/gas/i386/x86-64-apx-ndd.d: Likewise.
* testsuite/gas/i386/x86-64-apx-pushp-popp-intel.d: Likewise.
* testsuite/gas/i386/x86-64-apx-pushp-popp.d: Likewise.

5 months agox86: Don't use .insn with '/'
H.J. Lu [Fri, 29 Dec 2023 23:43:07 +0000 (15:43 -0800)] 
x86: Don't use .insn with '/'

'/' starts a comment for some targets.  Use .byte instead of .insn with
'/'.

* testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s: Use .byte
instead of .insn with '/'.

5 months agoFix x86-64: Add R_X86_64_CODE_4_GOTPCRELX
H.J. Lu [Fri, 29 Dec 2023 20:43:11 +0000 (12:43 -0800)] 
Fix x86-64: Add R_X86_64_CODE_4_GOTPCRELX

commit 3d5a60de52556f6a53d71d7e607c6696450ae3e4
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jun 8 10:01:03 2023 -0700

    x86-64: Add R_X86_64_CODE_4_GOTPCRELX

added a new field, fx_tcbit3, to fix.  But it didn't initialize it.
Fix it by clearing it in fix_new_internal.

* wrtite.c (fix_new_internal): Clear fx_tcbit3.

5 months agodwarf, fortran: add support for DW_TAG_entry_point
Nils-Christian Kempke [Mon, 21 Mar 2022 14:43:38 +0000 (15:43 +0100)] 
dwarf, fortran: add support for DW_TAG_entry_point

Fortran provides additional entry points for subroutines and functions.
These entry points may use only a subset (or a different set) of the
parameters of the original subroutine.  The entry points may be described
via the DWARF tag DW_TAG_entry_point.

This commit adds support for parsing the DW_TAG_entry_point DWARF tag.
Currently, between ifx/ifort/gfortran, only ifort is actually emitting
this tag.  Both, ifx and gfortran use the DW_TAG_subprogram tag as
workaround/alternative.  Thus, this patch really only adds more ifort
support.  Even so, some of the attached tests still fail for ifort, due
to some wrong line info generated for the entry points in ifort.

After this patch it is possible to set a breakpoint in gdb with the
ifort compiled example at the entry points 'foo' and 'foobar', which was not
possible before.

As gcc and ifx do not emit the tag I also added a test to gdb.dwarf2
which uses some underlying c compiled code and adds some Fortran style DWARF
to it emitting the DW_TAG_entry_point.  Before this patch it was not
possible to actually define breakpoint at the entry point tags.

For gfortran there actually exists a bug on bugzilla, asking for the use
of DW_TAG_entry_point over DW_TAG_subprogram:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37134

This patch was originally posted here

https://sourceware.org/legacy-ml/gdb-patches/2017-07/msg00317.html

but its review/pinging got lost after a while.  I reworked it to fit the
current GDB.

Co-authored-by: Bernhard Heckel <bernhard.heckel@intel.com>
Co-authored-by: Tim Wiederhake <tim.wiederhake@intel.com>
Approved-by: Tom Tromey <tom@tromey.com>
5 months agogdb, dwarf: add assert to dwarf2_get_pc_bounds
Nils-Christian Kempke [Wed, 13 Jul 2022 09:23:36 +0000 (11:23 +0200)] 
gdb, dwarf: add assert to dwarf2_get_pc_bounds

In dwarf2_get_pc_bounds we were writing unchecked to *lowpc.  This
commit adds a gdb_assert to first check that lowpc != nullptr.

Approved-by: Tom Tromey <tom@tromey.com>
5 months agogdb, dwarf: move part of dwarf2_get_pc_bounds into separate function
Nils-Christian Kempke [Wed, 13 Jul 2022 08:57:27 +0000 (10:57 +0200)] 
gdb, dwarf: move part of dwarf2_get_pc_bounds into separate function

This commit is in preparation of the next commit.  There, we will add
a second variation to retrieve the pc bounds for DIEs tagged with
DW_TAG_entry_point.  Instead of dwarf_get_pc_bounds_ranges_or_highlow_pc
we will call a separate method for entry points.  As the validity checks
at the endo f dwarf2_get_pc_bounds are the same for both variants,
we introduced the new dwarf_get_pc_bounds_ranges_or_highlow_pc method,
outsourcing part of dwarf2_get_pc_bounds.

This commit should have no functional impact on GDB.

Approved-by: Tom Tromey <tom@tromey.com>
5 months agoLoongArch: ld: Add support for tls le relax.
changjiachen [Thu, 28 Dec 2023 12:01:15 +0000 (20:01 +0800)] 
LoongArch: ld: Add support for tls le relax.

Add tls le relax related testsuites in ld.

The new test cases are mainly tested in three aspects:

1. tls le relax function correctness test.
2. tls le relax boundary check test.
3. tls le relax function compatibility test.

ld/testsuite/ChangeLog:

* ld/testsuite/ld-loongarch-elf/relax.exp: Modify test.
* ld/testsuite/ld-loongarch-elf/old-tls-le.s: New test.
* ld/testsuite/ld-loongarch-elf/relax-bound-check-tls-le.s: Likewise.
* ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-new.s: Likewise.
* ld/testsuite/ld-loongarch-elf/relax-tls-le.s: Likewise.
* ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-old.s: Likewise.

5 months agoLoongArch: gas: Add support for tls le relax.
changjiachen [Thu, 28 Dec 2023 11:59:39 +0000 (19:59 +0800)] 
LoongArch: gas: Add support for tls le relax.

Add tls le relax related relocs support and testsuites in gas.

The main test is three new relocation items,
R_LARCH_TLS_LE_ADD_R, R_LARCH_TLS_LE_HI20_R,
R_LARCH_TLS_LE_LO12_R can be generated properly
and tls le insn format check.

gas/ChangeLog:

* config/tc-loongarch.c:
(loongarch_args_parser_can_match_arg_helper): Add support for relax.
* gas/testsuite/gas/loongarch/reloc.d: Likewise.
* gas/testsuite/gas/loongarch/reloc.s: Likewise.
* gas/testsuite/gas/loongarch/loongarch.exp: Likewise.
* gas/testsuite/gas/loongarch/tls_le_insn_format_check.s: New test.

5 months agoLoongArch: opcodes: Add support for tls le relax.
changjiachen [Thu, 28 Dec 2023 11:58:28 +0000 (19:58 +0800)] 
LoongArch: opcodes: Add support for tls le relax.

Add new opcode for tls le relax.

opcode/ChangeLog:

* loongarch-opc.c: Add new loongarch opcode.

5 months agoLoongArch: include: Add support for tls le relax.
changjiachen [Thu, 28 Dec 2023 11:57:30 +0000 (19:57 +0800)] 
LoongArch: include: Add support for tls le relax.

Add new relocs number for tls le relax.

include/ChangeLog:

* elf/loongarch.h:
(RELOC_NUMBER (R_LARCH_TLS_LE_HI20_R, 121)): New relocs number.
(RELOC_NUMBER (R_LARCH_TLS_LE_ADD_R, 122)): Likewise.
(RELOC_NUMBER (R_LARCH_TLS_LE_LO12_R, 123)): Likewise.

5 months agoLoongArch: bfd: Add support for tls le relax.
changjiachen [Thu, 28 Dec 2023 12:07:54 +0000 (20:07 +0800)] 
LoongArch: bfd: Add support for tls le relax.

Add tls le relax support and related relocs in bfd.

New relocation related explanation can refer to the following url:
https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc

This support does two main things:

1. Implement support for three new relocation items in bfd.

The three new relocation items are shown below:

R_LARCH_TLS_LE_ADD_R
R_LARCH_TLS_LE_HI20_R
R_LARCH_TLS_LE_LO12_R

2. ADD a new macro RELOCATE_TLS_TP32_HI20

Handle problems caused by symbol extensions in TLS LE, The processing
is similar to the macro RELOCATE_CALC_PC32_HI20 method.

3. Implement the tls le relax function.

bfd/ChangeLog:

* bfd-in2.h: Add relocs related to tls le relax.
* elfnn-loongarch.c:
(loongarch_relax_tls_le): New function.
(RELOCATE_TLS_TP32_HI20): New macro.
(loongarch_elf_check_relocs): Add new reloc support.
(perform_relocation): Likewise.
(loongarch_elf_relocate_section): Handle new relocs related to relax.
(loongarch_elf_relax_section): Likewise.
* elfxx-loongarch.c:
(LOONGARCH_HOWTO (R_LARCH_TLS_LE_ADD_R)): New reloc how to type.
(LOONGARCH_HOWTO (R_LARCH_TLS_LE_HI20_R)): Likewise.
(LOONGARCH_HOWTO (R_LARCH_TLS_LE_LO12_R)): Likewise.
* libbfd.h: Add relocs related to tls le relax.
* reloc.c: Likewise.

5 months agoRISC-V: THEAD: Add 5 assembly pseudoinstructions for XTheadVector extension
Jin Ma [Mon, 25 Dec 2023 08:49:21 +0000 (16:49 +0800)] 
RISC-V: THEAD: Add 5 assembly pseudoinstructions for XTheadVector extension

In order to make it easier to complete the compiler's support for
the XTheadVector extension and to be as compatible as possible
with the programming model of the 'V' extension ([1]), we consider
adding a few pseudo instructions ([2]).

th.vmmv.m vd,vs => th.vmand.mm vd,vs,vs
th.vneg.v vd,vs => th.vrsub.vx vd,vs,x0
th.vncvt.x.x.v vd,vs,vm => th.vnsrl.vx vd,vs,x0,vm
th.vfneg.v vd,vs => th.vfsgnjn.vv vd,vs,vs
th.vfabs.v vd,vs => th.vfsgnjx.vv vd,vs,vs

Ref:
[1] https://gcc.gnu.org/pipermail/gcc-patches/2023-December/641302.html
[2] https://github.com/T-head-Semi/thead-extension-spec/pull/40

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector.d: Add tests for new
pseudoinstructions.
* testsuite/gas/riscv/x-thead-vector.s: Likewise.

opcodes/ChangeLog:

* riscv-opc.c: Add new pseudoinstructions.

5 months agoAutomatic date update in version.in
GDB Administrator [Fri, 29 Dec 2023 00:00:37 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agold: Mention support for Intel APX relocations in NEWS
H.J. Lu [Thu, 28 Dec 2023 16:46:31 +0000 (08:46 -0800)] 
ld: Mention support for Intel APX relocations in NEWS

5 months agoGold: Handle R_X86_64_CODE_4_GOTPC32_TLSDESC/R_X86_64_CODE_4_GOTTPOFF
H.J. Lu [Sun, 2 Jul 2023 14:46:21 +0000 (07:46 -0700)] 
Gold: Handle R_X86_64_CODE_4_GOTPC32_TLSDESC/R_X86_64_CODE_4_GOTTPOFF

Handle R_X86_64_CODE_4_GOTTPOFF and R_X86_64_CODE_4_GOTPC32_TLSDESC.
Convert

add name@gottpoff(%rip), %reg
mov name@gottpoff(%rip), %reg

to

add $name@tpoff, %reg
mov $name@tpoff, %reg

and

lea name@tlsdesc(%rip), %reg

to

mov     $name@tpoff, %reg
mov name@gottpoff(%rip), %reg

if the instruction is encoded with the REX2 prefix when possible.

elfcpp/

* x86_64.h (R_X86_64_CODE_4_GOTTPOFF): New.
(R_X86_64_CODE_4_GOTPC32_TLSDESC): Likewise.

gold/

* x86_64.cc (Target_x86_64::optimize_tls_reloc): Handle
R_X86_64_CODE_4_GOTPC32_TLSDESC and R_X86_64_CODE_4_GOTTPOFF.
(Target_x86_64::Scan::get_reference_flags): Likewise.
(Target_x86_64::Scan::local): Likewise.
(Target_x86_64::Scan::global): Likewise.
(Target_x86_64::Relocate::relocate): Likewise.
(Target_x86_64::Relocate::relocate_tls): Likewise.
(Target_x86_64::Relocate::tls_desc_gd_to_ie): Handle
R_X86_64_CODE_4_GOTPC32_TLSDESC.
(Target_x86_64::Relocate::tls_desc_gd_to_le): Likewise.
(Target_x86_64::Relocate::tls_ie_to_le): Handle.
R_X86_64_CODE_4_GOTTPOFF.
* testsuite/Makefile.am: Add x86_64_ie_to_le test.
* testsuite/Makefile.in: Regenerated.
* testsuite/x86_64_gd_to_le.s: Add R_X86_64_CODE_4_GOTPC32_TLSDESC
test.
* testsuite/x86_64_gd_to_le.sh: Check GDesc to LE conversion.
* testsuite/x86_64_ie_to_le.s: New file.
* testsuite/x86_64_ie_to_le.sh: Likewise.

5 months agox86-64: Add R_X86_64_CODE_4_GOTTPOFF/R_X86_64_CODE_4_GOTPC32_TLSDESC
H.J. Lu [Fri, 9 Jun 2023 20:50:22 +0000 (13:50 -0700)] 
x86-64: Add R_X86_64_CODE_4_GOTTPOFF/R_X86_64_CODE_4_GOTPC32_TLSDESC

For

add name@gottpoff(%rip), %reg
mov name@gottpoff(%rip), %reg

add

 # define R_X86_64_CODE_4_GOTTPOFF 44

and for

lea name@tlsdesc(%rip), %reg

add

 # define R_X86_64_CODE_4_GOTPC32_TLSDESC 45

if the instruction starts at 4 bytes before the relocation offset.
They are similar to R_X86_64_GOTTPOFF and R_X86_64_GOTPC32_TLSDESC,
respectively.  Linker can covert GOTTPOFF to

add $name@tpoff, %reg
mov $name@tpoff, %reg

and GOTPC32_TLSDESC to

mov $name@tpoff, %reg
mov name@gottpoff(%rip), %reg

if the instruction is encoded with the REX2 prefix when possible.

bfd/

* elf64-x86-64.c (x86_64_elf_howto_table): Add
R_X86_64_CODE_4_GOTTPOFF and R_X86_64_CODE_4_GOTPC32_TLSDESC.
(R_X86_64_standard): Updated.
(x86_64_reloc_map): Add BFD_RELOC_X86_64_CODE_4_GOTTPOFF
and BFD_RELOC_X86_64_CODE_4_GOTPC32_TLSDESC.
(elf_x86_64_check_tls_transition): Handle R_X86_64_CODE_4_GOTTPOFF
and R_X86_64_CODE_4_GOTPC32_TLSDESC.
(elf_x86_64_tls_transition): Likewise.
(elf_x86_64_scan_relocs): Likewise.
(elf_x86_64_relocate_section): Likewise.
* reloc.c (bfd_reloc_code_real): Add
BFD_RELOC_X86_64_CODE_4_GOTTPOFF and
BFD_RELOC_X86_64_CODE_4_GOTPC32_TLSDESC.
* bfd-in2.h: Regenerated.
* libbfd.h: Likewise.

gas/

* config/tc-i386.c (tc_i386_fix_adjustable): Handle
BFD_RELOC_X86_64_CODE_4_GOTTPOFF and
BFD_RELOC_X86_64_CODE_4_GOTPC32_TLSDESC.
(md_assemble): Handle BFD_RELOC_X86_64_CODE_4_GOTTPOFF.
(output_insn): Don't add empty REX prefix with REX2 prefix.
(output_disp): Handle BFD_RELOC_X86_64_CODE_4_GOTTPOFF and
BFD_RELOC_X86_64_CODE_4_GOTPC32_TLSDESC.
(md_apply_fix): Likewise.
(i386_validate_fix): Generate BFD_RELOC_X86_64_CODE_4_GOTTPOFF or
BFD_RELOC_X86_64_CODE_4_GOTPC32_TLSDESC if ixp->fx_tcbit3 is set.
(tc_gen_reloc): Handle BFD_RELOC_X86_64_CODE_4_GOTTPOFF and
BFD_RELOC_X86_64_CODE_4_GOTPC32_TLSDESC.
* testsuite/gas/i386/x86-64-gottpoff.d: New file.
* testsuite/gas/i386/x86-64-gottpoff.s: Likewise.
* testsuite/gas/i386/x86-64-tlsdesc.d: Likewise.
* testsuite/gas/i386/x86-64-tlsdesc.s: Likewise.

include/

* elf/x86-64.h (elf_x86_64_reloc_type): Add
R_X86_64_CODE_4_GOTTPOFF and R_X86_64_CODE_4_GOTPC32_TLSDESC

ld/

* testsuite/ld-x86-64/tlsbindesc.d: Updated.
* testsuite/ld-x86-64/tlsbindesc.rd: Likewise.
* testsuite/ld-x86-64/tlsbindesc.s: Add R_X86_64_CODE_4_GOTTPOFF
and R_X86_64_CODE_4_GOTPC32_TLSDESC tests.

5 months agogold: Handle R_X86_64_CODE_4_GOTPCRELX
H.J. Lu [Thu, 8 Jun 2023 19:12:48 +0000 (12:12 -0700)] 
gold: Handle R_X86_64_CODE_4_GOTPCRELX

Handle R_X86_64_CODE_4_GOTPCRELX and convert

mov name@GOTPCREL(%rip), %r31

to

lea name@GOTPCREL(%rip), %r31

if the instruction is encoded with the REX2 prefix when possible.

elfcpp/

* x86_64.h (R_X86_64_CODE_4_GOTPCRELX): New.

gold/

* x86_64.cc (Target_x86_64::can_convert_mov_to_lea): Handle
R_X86_64_CODE_4_GOTPCRELX.
(Target_x86_64::Scan::get_reference_flags): Likewise.
(Target_x86_64::Scan::local): Likewise.
(Target_x86_64::Scan::possible_function_pointer_reloc): Likewise.
(Target_x86_64::Scan::global): Likewise.
(Target_x86_64::Relocate::relocate): Likewise.
* testsuite/x86_64_mov_to_lea1.s: Add a test for
R_X86_64_CODE_4_GOTPCRELX.
* testsuite/x86_64_mov_to_lea2.s: Likewise.
* testsuite/x86_64_mov_to_lea3.s: Likewise.
* testsuite/x86_64_mov_to_lea4.s: Likewise.
* testsuite/x86_64_mov_to_lea5.s: Likewise.
* testsuite/x86_64_mov_to_lea.sh: Updated.

5 months agox86-64: Add R_X86_64_CODE_4_GOTPCRELX
H.J. Lu [Thu, 8 Jun 2023 17:01:03 +0000 (10:01 -0700)] 
x86-64: Add R_X86_64_CODE_4_GOTPCRELX

For

mov        name@GOTPCREL(%rip), %reg
test       %reg, name@GOTPCREL(%rip)
binop      name@GOTPCREL(%rip), %reg

where binop is one of adc, add, add, cmp, or, sbb, sub, xor instructions,
add

 # define R_X86_64_CODE_4_GOTPCRELX  43

if the instruction starts at 4 bytes before the relocation offset.  It
similar to R_X86_64_GOTPCRELX.  Linker can treat R_X86_64_CODE_4_GOTPCRELX
as R_X86_64_GOTPCREL or convert the above instructions to

lea name(%rip), %reg
mov $name, %reg
test $name, %reg
binop $name, %reg

if the instruction is encoded with the REX2 prefix when possible.

bfd/

* elf64-x86-64.c (x86_64_elf_howto_table): Add
R_X86_64_CODE_4_GOTPCRELX.
(R_X86_64_standard): Updated.
(x86_64_reloc_map): Add BFD_RELOC_X86_64_CODE_4_GOTPCRELX.
(elf_x86_64_convert_load_reloc): Handle R_X86_64_CODE_4_GOTPCRELX.
(elf_x86_64_scan_relocs): Likewise.
(elf_x86_64_relocate_section): Likewise.
* reloc.c (bfd_reloc_code_real): Add
BFD_RELOC_X86_64_CODE_4_GOTPCRELX.
* bfd-in2.h: Regenerated.
* libbfd.h: Likewise.

gas/

* write.h (fix): Add fx_tcbit3.  Change fx_unused to 1 bit.
* config/tc-i386.c (tc_i386_fix_adjustable): Handle
BFD_RELOC_X86_64_CODE_4_GOTPCRELX.
(tc_gen_reloc): Likewise.
(output_disp): Set fixP->fx_tcbit3 for REX2 prefix.
(i386_validate_fix): Generate BFD_RELOC_X86_64_CODE_4_GOTPCRELX
if fixp->fx_tcbit3 is set.
* config/tc-i386.h (TC_FORCE_RELOCATION_LOCAL): Add
BFD_RELOC_X86_64_CODE_4_GOTPCRELX.
(TC_FORCE_RELOCATION_ABS): Likewise.
* testsuite/gas/i386/x86-64-gotpcrel.s: Add tests for
R_X86_64_CODE_4_GOTPCRELX.
* testsuite/gas/i386/x86-64-localpic.s: Likewise.
* testsuite/gas/i386/x86-64-gotpcrel.d: Updated.
* testsuite/gas/i386/x86-64-localpic.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-localpic.d: Likewise.

include/

* elf/x86-64.h (elf_x86_64_reloc_type): Add
R_X86_64_CODE_4_GOTPCRELX.

ld/

* testsuite/ld-x86-64/apx-load1.s: New file.
* testsuite/ld-x86-64/apx-load1a.d: Likewise.
* testsuite/ld-x86-64/apx-load1b.d: Likewise.
* testsuite/ld-x86-64/apx-load1c.d: Likewise.
* testsuite/ld-x86-64/apx-load1d.d: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run apx-load1a, apx-load1b,
apx-load1c and apx-load1d.

5 months agogas: Mention initial support for Intel APX in NEWS
H.J. Lu [Thu, 28 Dec 2023 16:19:39 +0000 (08:19 -0800)] 
gas: Mention initial support for Intel APX in NEWS