This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] msp430: Set DWARF2_ADDR_SIZE to 4

msp430: Set DWARF2_ADDR_SIZE to 4.

This change makes gas's notion of the msp430 dwarf2 address size match
that of gcc and gdb.  This is needed so that the format of addresses
generated for DW_LNE_set_address in .debug_line will match the address
size for the compilation unit.

In gcc/config/msp430/msp430.h, it's set to 4:

  #define	DWARF2_ADDR_SIZE			4

Likewise in gdb/msp430-tdep.c:

  set_gdbarch_dwarf2_addr_size (gdbarch, 4);

(As far as I can tell, however, GDB doesn't use this value when decoding
.debug_line.  Instead, GDB uses the Pointer Size from the compilation

readelf is able to seamlessly handle mismatches between these various
sizes by using the size of the DW_LNE_set_address instruction to
determine the address size.  Another way to fix this problem is to
make GDB behave in a similar manner.  In my opinion, GDB should detect
and inform the user about these mismatches; it's not clear to me if
it's correct for GDB to go ahead and read the address anyway when a
size mismatch is detected.

Without this change, addresses in .debug_line are encoded in two bytes
for some multilibs.  When GDB reads the address for
DW_LNE_set_address, it uses the pointer size provided by the CU.  When
these values don't match, GDB reads the wrong number of bytes.  In the
cases that I've looked at, GDB is reading 4 bytes from a 2 byte
container, which results in a garbage address.  GDB discards lines
which have a bogus address; the end result is that GDB records no line
number information for CUs which have a mismatch between the address
size (from the CU) and the format of the address used by

    	* config/tc-msp430.h (DWARF2_ADDR_SIZE): Set to 4.
 gas/config/tc-msp430.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gas/config/tc-msp430.h b/gas/config/tc-msp430.h
index 4a02452..86c9117 100644
--- a/gas/config/tc-msp430.h
+++ b/gas/config/tc-msp430.h
@@ -171,3 +171,5 @@ extern bfd_boolean msp430_allow_local_subtract (expressionS *, expressionS *, se
 #define TC_LINKRELAX_FIXUP(seg) ((seg->flags & SEC_CODE) || (seg->flags & SEC_DEBUGGING))
+#define DWARF2_ADDR_SIZE(bfd) 4

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]