[PATCH] readelf: Handle SHT_RISCV_ATTRIBUTES like SHT_GNU_ATTRIBUTES

2022-08-10 Thread Andreas Schwab via Elfutils-devel
Signed-off-by: Andreas Schwab 
---
 src/ChangeLog | 4 
 src/readelf.c | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index fbcef29e..88db4051 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2022-08-10  Andreas Schwab  
+
+   * readelf.c (print_attributes): Also handle SHT_RISCV_ATTRIBUTES.
+
 2022-08-09  Andreas Schwab  
 
* elflint.c (check_program_header): Don't complain about p_filesz
diff --git a/src/readelf.c b/src/readelf.c
index f1f77ce8..1a10fd01 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -3672,7 +3672,9 @@ print_attributes (Ebl *ebl, const GElf_Ehdr *ehdr)
   && (shdr->sh_type != SHT_ARM_ATTRIBUTES
   || ehdr->e_machine != EM_ARM)
   && (shdr->sh_type != SHT_CSKY_ATTRIBUTES
-  || ehdr->e_machine != EM_CSKY)))
+  || ehdr->e_machine != EM_CSKY)
+  && (shdr->sh_type != SHT_RISCV_ATTRIBUTES
+  || ehdr->e_machine != EM_RISCV)))
continue;
 
   printf (_("\
-- 
2.37.1


-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


[PATCH RFC] backends: Add RISC-V object attribute printing

2022-08-10 Thread Andreas Schwab via Elfutils-devel
This does not work yet.  The RISC-V attribute tags use the same
convention as the GNU attributes: odd numbered tags take a string value,
even numbered ones an integer value, but print_attributes assumes the
ARM numbering scheme by default for non-GNU attributes.

---
 backends/ChangeLog |  6 
 backends/Makefile.am   |  3 +-
 backends/riscv_attrs.c | 80 ++
 backends/riscv_init.c  |  2 ++
 4 files changed, 90 insertions(+), 1 deletion(-)
 create mode 100644 backends/riscv_attrs.c

diff --git a/backends/ChangeLog b/backends/ChangeLog
index 5b0daffe..a642fe9e 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,9 @@
+2022-08-10  Andreas Schwab  
+
+   * Makefile.am (riscv_SRCS): Add riscv_attrs.c.
+   * riscv_init.c (riscv_init): Hook in riscv_check_object_attribute.
+   * riscv_attrs.c: New file.
+
 2022-08-09  Andreas Schwab  
 
* riscv_init.c (riscv_init): HOOK segment_type_name,
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 9566377f..1863f66a 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -91,7 +91,8 @@ m68k_corenote_no_Wpacked_not_aligned = yes
 bpf_SRCS = bpf_init.c bpf_regs.c bpf_symbol.c
 
 riscv_SRCS = riscv_init.c riscv_symbol.c riscv_cfi.c riscv_regs.c \
-riscv_initreg.c riscv_corenote.c riscv64_corenote.c riscv_retval.c
+riscv_initreg.c riscv_corenote.c riscv64_corenote.c \
+riscv_retval.c riscv_attrs.c
 
 csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.c \
csky_regs.c csky_initreg.c csky_corenote.c
diff --git a/backends/riscv_attrs.c b/backends/riscv_attrs.c
new file mode 100644
index ..6947be6e
--- /dev/null
+++ b/backends/riscv_attrs.c
@@ -0,0 +1,80 @@
+/* Object attribute tags for RISC-V.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+   Software Foundation; either version 3 of the License, or (at
+   your option) any later version
+
+   or
+
+ * the GNU General Public License as published by the Free
+   Software Foundation; either version 2 of the License, or (at
+   your option) any later version
+
+   or both in parallel, as here.
+
+   elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see .  */
+
+#ifdef HAVE_CONFIG_H
+# include 
+#endif
+
+#include 
+#include 
+
+#define BACKEND riscv_
+#include "libebl_CPU.h"
+
+#define KNOWN_VALUES(...) do   \
+  {\
+static const char *table[] = { __VA_ARGS__ };  \
+if (value < sizeof table / sizeof table[0])\
+  *value_name = table[value];  \
+  } while (0)
+
+bool
+riscv_check_object_attribute (Ebl *ebl __attribute__ ((unused)),
+ const char *vendor, int tag, uint64_t value,
+ const char **tag_name, const char **value_name)
+{
+  if (!strcmp (vendor, "riscv"))
+switch (tag)
+  {
+  case 4:
+   *tag_name = "RISCV_stack_align";
+   return true;
+
+  case 5:
+   *tag_name = "RISCV_arch";
+   return true;
+
+  case 6:
+   *tag_name = "RISCV_unaligned_access";
+   KNOWN_VALUES ("No unaligned access", "Unaligned access");
+   return true;
+
+  case 8:
+   *tag_name = "RISCV_priv_spec";
+   return true;
+
+  case 10:
+*tag_name = "RISCV_priv_spec_minor";
+return true;
+
+  case 12:
+*tag_name = "RISCV_priv_spec_revision";
+return true;
+  }
+
+  return false;
+}
diff --git a/backends/riscv_init.c b/backends/riscv_init.c
index f2d46082..e5e9e33e 100644
--- a/backends/riscv_init.c
+++ b/backends/riscv_init.c
@@ -69,6 +69,8 @@ riscv_init (Elf *elf,
   HOOK (eh, section_type_name);
   HOOK (eh, dynamic_tag_name);
   HOOK (eh, dynamic_tag_check);
+  HOOK (eh, check_object_attribute);
+  HOOK (eh, set_initial_registers_tid);
   if (eh->class == ELFCLASS64)
 eh->core_note = riscv64_core_note;
   else
-- 
2.37.1


-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


[Bug libdw/29450] run-low_high_pc.sh fails on i386 against binutils-2.39

2022-08-10 Thread mark at klomp dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29450

--- Comment #6 from Mark Wielaard  ---
Did the binutils 2.39 commit:

commit e8cf73215187b0c08679d726a5cc7c019fa3ea2e
Author: Jan Beulich 
Date:   Wed Aug 10 10:34:22 2022 +0200

gas/Dwarf: properly skip zero-size functions

Fix this?

In that case I suggest we close this bug and recommend people upgrade to
binutils 2.39.1 when that gets released

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

[Bug libdw/29450] run-low_high_pc.sh fails on i386 against binutils-2.39

2022-08-10 Thread mliska at suse dot cz via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29450

--- Comment #7 from Martin Liska  ---
(In reply to Mark Wielaard from comment #6)
> Did the binutils 2.39 commit:
> 
> commit e8cf73215187b0c08679d726a5cc7c019fa3ea2e
> Author: Jan Beulich 
> Date:   Wed Aug 10 10:34:22 2022 +0200
> 
> gas/Dwarf: properly skip zero-size functions
> 
> Fix this?

Yes.

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