[PATCH] [gdb/testsuite] Fix 64-bit dwarf test-cases with -m32

Tom de Vries tdevries@suse.de
Fri Nov 19 14:08:12 GMT 2021


On 11/3/21 9:30 PM, Andreas Schwab wrote:
> On Nov 03 2021, Tom de Vries wrote:
> 
>> On 11/1/21 9:54 PM, Andreas Schwab wrote:
>>> On Nov 01 2021, Tom de Vries via Gdb-patches wrote:
>>>
>>>> When running test-case gdb.dwarf2/loc-sec-offset.exp with target board -m32,
>>>> I run into:
>>>> ...
>>>> builtin_spawn -ignore SIGHUP gcc -fno-stack-protector -m32 \
>>>>   -fdiagnostics-color=never -c -o loc-sec-offset-dw641.o \
>>>>   loc-sec-offset-dw64.S^M
>>>> as: loc-sec-offset-dw641.o: unsupported relocation type: 0x1^M
>>>> loc-sec-offset-dw64.S: Assembler messages:^M
>>>> loc-sec-offset-dw64.S:29: Error: cannot represent relocation type \
>>>>   BFD_RELOC_64^M
>>>> ...
>>>>
>>>> Looking at line 29, we have:
>>>> ...
>>>>         .8byte        .Labbrev1_begin   /* Abbrevs */
>>>> ...
>>>>
>>>> It would be nice if the assembler could handle this somehow.  But I guess
>>>> it's not unreasonable that an assembler for a 32-bit architecture will object
>>>> to handling 64-bit labels.
>>>
>>> Shouldn't the 64-bit dwarf tests just be skipped on 32-bit targets?
>>
>> Because ?
> 
> Because 32-bit targets have no way to represent 8-byte relocations.
> 
> Andreas.
> 

I tried a hello world with gcc-11, -m32 and -gdwarf64:
...
$ gcc-11 ~/hello.c -g -gdwarf64 -m32 -save-temps -dA
...
and looked at a section offset:
...
        .long   .Ldebug_line0, 0        # DW_AT_stmt_list
...

This comes from dw2_assemble_integer, where we have:
...
void
dw2_assemble_integer (int size, rtx x)
{
  if (size == 2 * (int) DWARF2_ADDR_SIZE && !CONST_SCALAR_INT_P (x))
    {
      /* On 32-bit targets with -gdwarf64, DImode values with

         relocations usually result in assembler errors.  Assume

         all such values are positive and emit the relocation only

         in the least significant half.  */
...

So, it seems I chose the same solution as gcc.

I'll commit this shortly.

Thanks,
- Tom


More information about the Gdb-patches mailing list