Discussion:
eh_addr_size (global variable)
John Darrington
2018-10-03 11:55:45 UTC
Permalink
The variable eh_addr_size seems to be a global defined in dwarf.c
but set in readelf.c and objdump.c and the algorithm which sets it
seems to be inconsistent.

This came to my attention because, for s12z object files produced by
an existing third party compiler, objdump -Wf falls over badly,
whereas readelf --debug-dump=frames worked correctly.

Closer examination showed that this dwarf_info had the 24 bit addresses
(s12z has a 24 bit address space) encoded into 32 bits.

[ Arguably this is a violation of the dwarf standard, which says this
value should be "address-unit sized" ]

The following patch fixes my immediate problem, but it seems me that
there should be a more consistent way of setting this variable (should it
even be global?)

J'
John Darrington
2018-10-03 11:55:46 UTC
Permalink
---
binutils/objdump.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/binutils/objdump.c b/binutils/objdump.c
index f468fcdb59..d3ab2e4cd1 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -2711,6 +2711,11 @@ dump_dwarf (bfd *abfd)

eh_addr_size = bfd_arch_bits_per_address (abfd) / 8;

+ /* S12Z has a 24 bit address space. But the only known
+ producer of dwarf_info encodes addresses into 32 bits. */
+ if (bfd_get_arch (abfd) == bfd_arch_s12z)
+ eh_addr_size = 4;
+
if (bfd_big_endian (abfd))
byte_get = byte_get_big_endian;
else if (bfd_little_endian (abfd))
--
2.11.0
Alan Modra
2018-10-10 03:04:29 UTC
Permalink
Post by John Darrington
diff --git a/binutils/objdump.c b/binutils/objdump.c
index f468fcdb59..d3ab2e4cd1 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -2711,6 +2711,11 @@ dump_dwarf (bfd *abfd)
eh_addr_size = bfd_arch_bits_per_address (abfd) / 8;
+ /* S12Z has a 24 bit address space. But the only known
+ producer of dwarf_info encodes addresses into 32 bits. */
+ if (bfd_get_arch (abfd) == bfd_arch_s12z)
+ eh_addr_size = 4;
+
if (bfd_big_endian (abfd))
byte_get = byte_get_big_endian;
else if (bfd_little_endian (abfd))
I'm committing this variant of your patch.

From 8ab159a96565be6e60f8d88ba3a4638116f7e9d3 Mon Sep 17 00:00:00 2001
From: Alan Modra <***@gmail.com>
Date: Wed, 10 Oct 2018 12:17:54 +1030
Subject: [PATCH 1/4] S12Z: Set eh_addr_size to 4

* objdump.c (dump_dwarf): Set s12z eh_addr_size to 4.

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 6737c6794c..09436ccedc 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,7 @@
+2018-10-10 Alan Modra <***@gmail.com>
+
+ * objdump.c (dump_dwarf): Set s12z eh_addr_size to 4.
+
2018-10-08 Andreas Schwab <***@suse.de>

* readelf.c (is_32bit_pcrel_reloc): Handle R_RISCV_32_PCREL.
diff --git a/binutils/objdump.c b/binutils/objdump.c
index f468fcdb59..4368fc0666 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -2759,6 +2759,12 @@ dump_dwarf (bfd *abfd)
init_dwarf_regnames_riscv ();
break;

+ case bfd_arch_s12z:
+ /* S12Z has a 24 bit address space. But the only known
+ producer of dwarf_info encodes addresses into 32 bits. */
+ eh_addr_size = 4;
+ break;
+
default:
break;
}
--
Alan Modra
Australia Development Lab, IBM
Loading...