Files
binutils/pr32556.diff
Ana Guerrero 18f7e9754d Accepting request 1312402 from devel:gcc
Lets try for some build results in staging.

- Update to version 2.45:
  * New versioned release of libsframe.so.2
  * s390: tools now support SFrame format 2; recognize "z17" as CPU
    name [bsc#1247105, jsc#IBM-1485]
  * sframe sections are now of ELF section type SHT_GNU_SFRAME.
  * sframe secions generated by the assembler have
    SFRAME_F_FDE_FUNC_START_PCREL set.
  * riscv: Support more extensions: standard: Zicfiss v1.0, Zicfilp v1.0,
    Zcmp v1.0, Zcmt v1.0, Smrnmi v1.0, S[sm]dbltrp v1.0, S[sm]ctr v1.0,
    ssqosid v1.0, ssnpm v1.0, smnpm v1.0, smmpm v1.0, sspm v1.0, supm v1.0,
    sha v1.0, zce v1.0, smcdeleg v1.0, ssccfg v1.0, svvptc v1.0, zilsd v1.0,
    zclsd v1.0, smrnmi v1.0;
    vendor: CORE-V, xcvbitmanip v1.0 and xcvsimd v1.0;
    SiFive, xsfvqmaccdod v1.0, xsfvqmaccqoqv1.0 and xsfvfnrclipxfqf v1.0;
    T-Head: xtheadvdot v1.0;
    MIPS: xmipscbop v1.0, xmipscmov v1.0, xmipsexectl v1.0, xmipslsp v1.0.
  * Support RISC-V privileged version 1.13, profiles 20/22/23, and
    .bfloat16 directive.
  * x86: Add support for these ISAs: Intel Diamond Rapids AMX, MOVRS,
    AVX10.2 (including SM4), MSR_IMM; Zhaoxin PadLock PHE2, RNG2, GMI, XMODX.
    Drop support for  AVX10.2 256 bit rounding.
  * arm: Add support for most of Armv9.6, enabled by -march=armv9.6-a and
    extensions '+cmpbr', '+f8f16mm', '+f8f32mm', '+fprcvt', '+lsfe', '+lsui',
    '+occmo', '+pops', '+sme2p2', '+ssve-aes', '+sve-aes', '+sve-aes2',
    '+sve-bfscale', '+sve-f16f32mm' and '+sve2p2'.
  * Predefined symbols "GAS(version)" and, on non-release builds, "GAS(date)"
    are now being made available.
  * Add .errif and .warnif directives.
  * linker:
    - Add --image-base=<ADDR> option to the ELF linker to behave the same

OBS-URL: https://build.opensuse.org/request/show/1312402
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/binutils?expand=0&rev=182
2025-10-21 09:15:06 +00:00

102 lines
3.6 KiB
Diff

commit 7be4186c22f89a87fff048c28910f5d26a0f61ce
Author: Dmitry Klochkov <dmitry.klochkov@bell-sw.com>
Date: Tue Sep 9 12:06:25 2025 +0200
nm: fix treating an ifunc symbol as a stab if '--ifunc-chars=--' is given
If an ifunc symbol is processed in print_symbol(), a 'type' field of a
'syminfo' structure is set to any character specified by a user with an
'--ifunc-chars' option. But afterwards the 'type' field is used to
check whether a symbol is a stab in print_symbol_info_{bsd,sysv}()
functions in order to print additional stab related data. If the 'type'
field equals '-', a symbol is treated as a stab. If '--ifunc-chars=--'
is given, all ifunc symbols will be treated as stab symbols and
uninitialized stab related fields of the 'syminfo' structure will be
printed which can lead to segmentation fault.
To fix this, check if a symbol is a stab before override the 'type'
field. Also, add a test case for this fix.
PR binutils/32556
* nm.c (extended_symbol_info): Add is_stab.
(print_symbol): Check if a symbol is a stab.
(print_symbol_info_bsd): Use info->is_stab.
(print_symbol_info_sysv): Use info->is_stab.
* testsuite/binutils-all/nm.exp: Test nm --ifunc-chars=--.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32556
Fixes: e6f6aa8d184 ("Add option to nm to change the characters displayed for ifunc symbols")
Signed-off-by: Dmitry Klochkov <dmitry.klochkov@bell-sw.com>
diff --git a/binutils/nm.c b/binutils/nm.c
index dce9207f44f..c3d118a93c3 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -70,6 +70,7 @@ struct extended_symbol_info
bfd_vma ssize;
elf_symbol_type *elfinfo;
coff_symbol_type *coffinfo;
+ bool is_stab;
/* FIXME: We should add more fields for Type, Line, Section. */
};
#define SYM_VALUE(sym) (sym->sinfo->value)
@@ -1208,8 +1209,11 @@ print_symbol (bfd * abfd,
bfd_get_symbol_info (abfd, sym, &syminfo);
+ info.is_stab = false;
+ if (syminfo.type == '-')
+ info.is_stab = true;
/* PR 22967 - Distinguish between local and global ifunc symbols. */
- if (syminfo.type == 'i'
+ else if (syminfo.type == 'i'
&& sym->flags & BSF_GNU_INDIRECT_FUNCTION)
{
if (ifunc_type_chars == NULL || ifunc_type_chars[0] == 0)
@@ -1873,7 +1877,7 @@ print_symbol_info_bsd (struct extended_symbol_info *info, bfd *abfd)
printf (" %c", SYM_TYPE (info));
- if (SYM_TYPE (info) == '-')
+ if (info->is_stab)
{
/* A stab. */
printf (" ");
@@ -1902,7 +1906,7 @@ print_symbol_info_sysv (struct extended_symbol_info *info, bfd *abfd)
printf ("| %c |", SYM_TYPE (info));
- if (SYM_TYPE (info) == '-')
+ if (info->is_stab)
{
/* A stab. */
printf ("%18s| ", SYM_STAB_NAME (info)); /* (C) Type. */
diff --git a/binutils/testsuite/binutils-all/nm.exp b/binutils/testsuite/binutils-all/nm.exp
index fea68bf76bc..1feb8578fba 100644
--- a/binutils/testsuite/binutils-all/nm.exp
+++ b/binutils/testsuite/binutils-all/nm.exp
@@ -329,6 +329,23 @@ if [is_elf_format] {
fail "$testname (local ifunc)"
}
+ # PR 32556
+ # Test nm --ifunc-chars=--
+
+ set got [binutils_run $NM "$NMFLAGS --ifunc-chars=-- $tmpfile"]
+
+ if [regexp -line "^\\S+ - global_foo$" $got] then {
+ pass "$testname=-- (global ifunc)"
+ } else {
+ fail "$testname=-- (global ifunc)"
+ }
+
+ if [regexp -line "^\\S+ - local_foo$" $got] then {
+ pass "$testname=-- (local ifunc)"
+ } else {
+ fail "$testname=-- (local ifunc)"
+ }
+
if { $verbose < 1 } {
remote_file host delete "tmpdir/ifunc.o"
}