[Bug ld/30930] Broken BTI veneers: ld-2.41 links mame in a way which gets stuck on aarch64

2023-11-09 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=30930

--- Comment #29 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Szabolcs Nagy :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d3a8dfdef0797244d0f2f3a8ec5db8f1dcf1337b

commit d3a8dfdef0797244d0f2f3a8ec5db8f1dcf1337b
Author: Szabolcs Nagy 
Date:   Mon Oct 16 13:18:13 2023 +0100

bfd: aarch64: Fix broken BTI stub PR30930

Input sections are grouped together that can use the same stub area
(within reach) and these groups have a stable id.

Stubs have a name generated from the stub group id and target symbol.
When a relocation requires a stub with a name that already exists, the
stub is reused instead of adding a new one.

For an indirect branch stub another BTI stub may be inserted near the
target to provide a BTI landing pad.

The BTI stub can end up with the same stub group id and thus the same
name as the indirect stub. This happens if the target symbol is within
reach of the indirect branch stub. Then, due to the name collision,
only a single stub was emmitted which branched to itself causing an
infinite loop at runtime.

A possible solution is to just name the BTI stubs differently, but
since in the problematic case the indirect and BTI stub are in the
same stub area, a better solution is to emit a single stub with a
direct branch. The stub is still needed since the caller cannot reach
the target directly and we also want a BTI landing pad in the stub in
case other indirect stubs target the same symbol and thus need a BTI
stub.

In short we convert an indirect branch stub into a BTI stub when the
target is within reach and has no BTI. It is a hassle to change the
symbol of the stub so a BTI stub may end up with *_veneer instead of
*_bti_veneer after the conversion, but this should not matter much.
(Refactoring some of _bfd_aarch64_add_call_stub_entries would be
useful but too much for this bug fix patch.)

The same conversion to direct branch could be done even if the target
did not need a BTI. The stub groups are fixed in the current logic so
linking can fail if too many stubs are inserted and the section layout
is changed too much, but this only happens in extreme cases that can
be reasonably ignored. Because of this the target cannot go out of
reach during stub insertion so the optimization is valid, but not
implemented by this patch for the non-BTI case.

Fixes bug 30930.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30957] aarch64: unnecessary bti veneer

2023-11-09 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=30957

--- Comment #2 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Szabolcs Nagy :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fc48504c7abe8eb9d9723632b2d53504927f46ff

commit fc48504c7abe8eb9d9723632b2d53504927f46ff
Author: Szabolcs Nagy 
Date:   Wed Oct 18 16:12:56 2023 +0100

bfd: aarch64: Avoid BTI stub for a PLT that has BTI

We decide to emit BTI stubs based on the instruction at the target
location. But PLT code is generated later than the stubs so we always
read 0 which is not a valid BTI.

Fix the logic to special case the PLT section: this is code the linker
generates so we know when it will have BTI.

This avoids BTI stubs in large executables where the PLTs have them
already. An alternative is to never emit BTI stubs for PLTs, instead
use BTI in the PLT if a library gets too big, however that may be
more tricky given the ordering of PLT sizing and stub insertion.

Related to bug 30957.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30957] aarch64: unnecessary bti veneer

2023-11-09 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=30957

--- Comment #1 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Szabolcs Nagy :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=98b94ebb3ffe715fddde762bb3ee7fd6d972f233

commit 98b94ebb3ffe715fddde762bb3ee7fd6d972f233
Author: Szabolcs Nagy 
Date:   Fri Oct 13 17:51:15 2023 +0100

bfd: aarch64: Fix BTI stub optimization PR30957

The instruction was looked up in the wrong input file (file of branch
source instead of branch target) when optimizing away BTI stubs in

  commit 5834f36d93cabf1a8bcc7dd7654141aed3d296bc
  bfd: aarch64: Optimize BTI stubs PR30076

This can cause adding BTI stubs when they are not necessary or removing
them when they are (the latter is a correctness issue but it is very
unlikely in practice).

Fixes bug 30957.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/30930] Broken BTI veneers: ld-2.41 links mame in a way which gets stuck on aarch64

2023-11-09 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30930

Nick Clifton  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #30 from Nick Clifton  ---
Patch applied.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug gas/31043] Poor error message for wrong register numbers

2023-11-09 Thread jbeulich at suse dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=31043

--- Comment #4 from Jan Beulich  ---
(In reply to Sam James from comment #3)
> (In reply to Jan Beulich from comment #2)
> > Hmm, both in 2.41 and in master I'm seeing "operand size mismatch", not
> > "unsupported instruction". That's still not ideal, but imo quite a bit
> > better. Yet I'm at a loss to explain why I would see a different error
> > message than you do.
> 
> Andrew got the same error message as me which is curious...

Well, apologies, that was because of an embarrassing mistake of mine.

Is https://sourceware.org/pipermail/binutils/2023-November/130465.html going to
make this any better, do you think?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/31009] regression: assertion fail ../../bfd/merge.c:243

2023-11-09 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=31009

--- Comment #12 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Michael Matz :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=836654b1177ab305c36fe7319f08f0ad5d4fac1b

commit 836654b1177ab305c36fe7319f08f0ad5d4fac1b
Author: Michael Matz 
Date:   Tue Nov 7 16:54:44 2023 +0100

ld: Avoid overflows in string merging

as the bug report shows we had an overflow in the test if
hash table resizing is needed.  Reorder the expression to avoid
that.  There's still a bug somewhere in gracefully handling
failure in resizing (e.g. out of memory), but this pushes the
boundary for that occurring somewhen into the future and
immediately helps the reporter.

bfd/

PR ld/31009
* merge.c (NEEDS_RESIZE): New macro avoiding overflow.
(sec_merge_maybe_resize): Use it.
(sec_merge_hash_insert): Ditto.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/31009] regression: assertion fail ../../bfd/merge.c:243

2023-11-09 Thread matz at suse dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=31009

Michael Matz  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|UNCONFIRMED |RESOLVED

--- Comment #13 from Michael Matz  ---
So, immediate problem fixed.  That the error-paths that are supposed to recover
from out-of-memory here (and invalidly were triggered) didn't quite work in
recovery is something for another time.

-- 
You are receiving this mail because:
You are on the CC list for the bug.