From 3d8efabf21cfeb2f6244fadcf915da4c7f51ed6f Mon Sep 17 00:00:00 2001 From: Kevin Buettner Date: Wed, 27 Jan 2016 12:44:38 -0700 Subject: [PATCH] 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 unit.) 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 DW_LNE_set_address. gas/ChangeLog: * config/tc-msp430.h (DWARF2_ADDR_SIZE): Set to 4. --- gas/ChangeLog | 4 ++++ gas/config/tc-msp430.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/gas/ChangeLog b/gas/ChangeLog index 10a72d2d707..56146c7f804 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,7 @@ +2016-02-03 Kevin Buettner + + * config/tc-msp430.h (DWARF2_ADDR_SIZE): Set to 4. + 2016-02-03 H.J. Lu * NEWS: Mention new command line option -mfence-as-lock-add=yes diff --git a/gas/config/tc-msp430.h b/gas/config/tc-msp430.h index 4a02452628d..86c9117d834 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 DWARF2_USE_FIXED_ADVANCE_PC 1 #define TC_LINKRELAX_FIXUP(seg) ((seg->flags & SEC_CODE) || (seg->flags & SEC_DEBUGGING)) + +#define DWARF2_ADDR_SIZE(bfd) 4 -- 2.30.2