This is the mail archive of the
mailing list for the GCC project.
Re: MIPS64 -msym32 and DWARF2_ADDR_SIZE
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Adam Nemet <anemet at caviumnetworks dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 31 Jan 2009 12:41:38 +0000
- Subject: Re: MIPS64 -msym32 and DWARF2_ADDR_SIZE
- References: <firstname.lastname@example.org>
Adam Nemet <email@example.com> writes:
> -msym32 changes DWARF's address_size from 64 bits to 32 bits. This means that
> while symbols are 64-bit (due to ELF64), target addresses in the debug info
> are 32-bit.
> There is support for this in DWARF of course in fact you can specify different
> address_size for each compilation unit which nicely maps with -msym32 being
> link-compatible with regular N64 objects.
> However, this asymmetry exposed several bugs in binutils. Also, as I just
> discovered today, dwarfdump (libdwarf) has no support for changing the
> address_size between compilation units and in fact derives address_size from
> the ELF class (ELF64/ELF32). (Obviously, that's a bug in libdwarf.)
> So my question is whether the saving in the size of the debug info with
> -msym32 is really worth the trouble here or should we just start generating
> 64-bit addresses with -msym32?
Generating 64-bit addresses would be fine with me FWIW. I'm not sure
the current behaviour is exactly deliberate; it was probably just
something I overlooked when adding -msym32.
How about the patch below? I'll apply it in the next couple of days
if there are no objections.
* config/mips/mips.h (FILE_HAS_64BIT_SYMBOLS): New macro.
(ABI_HAS_64BIT_SYMBOLS): Use it.
(DWARF2_ADDR_SIZE): Use it instead of ABI_HAS_64BIT_SYMBOLS.
--- gcc/config/mips/mips.h 2009-01-31 12:21:01.000000000 +0000
+++ gcc/config/mips/mips.h 2009-01-31 12:38:03.000000000 +0000
@@ -767,9 +767,15 @@ #define ABI_NEEDS_64BIT_REGS (TARGET_NEW
/* Likewise for 32-bit regs. */
#define ABI_NEEDS_32BIT_REGS (mips_abi == ABI_32)
-/* True if symbols are 64 bits wide. At present, n64 is the only
- ABI for which this is true. */
-#define ABI_HAS_64BIT_SYMBOLS (mips_abi == ABI_64 && !TARGET_SYM32)
+/* True if the file format uses 64-bit symbols. At present, this is
+ only true for n64, which uses 64-bit ELF. */
+#define FILE_HAS_64BIT_SYMBOLS (mips_abi == ABI_64)
+/* True if symbols are 64 bits wide. This is usually determined by
+ the ABI's file format, but it can be overridden by -msym32. Note that
+ overriding the size with -msym32 changes the ABI of relocatable objects,
+ although it doesn't change the ABI of a fully-linked object. */
+#define ABI_HAS_64BIT_SYMBOLS (FILE_HAS_64BIT_SYMBOLS && !TARGET_SYM32)
/* ISA has instructions for managing 64-bit fp and gp regs (e.g. mips3). */
#define ISA_HAS_64BIT_REGS (ISA_MIPS3 \
@@ -1218,7 +1224,14 @@ #define DWARF2_DEBUGGING_INFO 1
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
-#define DWARF2_ADDR_SIZE (ABI_HAS_64BIT_SYMBOLS ? 8 : 4)
+/* The size of DWARF addresses should be the same as the size of symbols
+ in the target file format. They shouldn't depend on things like -msym32,
+ because many DWARF consumers do not allow the mixture of address sizes
+ that one would then get from linking -msym32 code with -msym64 code.
+ Note that the default POINTER_SIZE test is not appropriate for MIPS.
+ EABI64 has 64-bit pointers but uses 32-bit ELF. */
+#define DWARF2_ADDR_SIZE (FILE_HAS_64BIT_SYMBOLS ? 8 : 4)
/* By default, turn on GDB extensions. */
#define DEFAULT_GDB_EXTENSIONS 1