On Tue, Dec 01, 2020 at 01:48:31PM +0100, Jakub Jelinek via Gcc-patches wrote:
> I guess it depends on whether for 32-bit target and -gdwarf64, when
> calling dw2_assemble_integer with non-CONST_INT argument we only
> need positive values or might need negative ones too.
> Because positive ones can be easily emulated through that
> .long expression, 0
> or
> .long 0, expression
> depending on endianity, but I'm afraid there is no way to emit
> 0 or -1 depending on the sign of expression, when it needs relocations.
> Looking through dw2_asm_output_delta calls, at least the vast majority
> of the calls seem to guarantee being positive, not 100% sure about
> one case in .debug_line views, but I'd hope it is ok too.
> In most cases, the deltas are between two labels where the first one
> in the arguments is later in the same section than the other one,
> or where the second argument is the start of a section or another section
> base.

I went through dwarf2out.c dw2_asm_output_delta calls and I'm fairly
confident all of them are ok, represent sizes of .debug* sections or their
portions, or differences between symbols in the same section where the x
in x - y is later than y in the section (what I was worried about, something
like:
.text
.L1:
        ...
.L2:
...
        .quad .L1 - .L2
doesn't appear to happen.
Additionally, seems the x32 ABI I've been worried about uses ELF32 rather
than ELF64, so it must suffer from the same limitation, if address size is
32-bit, one can't apply 64-bit relocations.

Patch has been bootstrapped/regtested on x86_64-linux and i686-linux.
Ok for trunk together with the -gdwarf{32,64} patch?

> 2020-12-01  Jakub Jelinek  <ja...@redhat.com>
> 
>       * dwarf2asm.c (dw2_assemble_integer): Handle size twice as large
>       as DWARF2_ADDR_SIZE if x is not a scalar int by emitting it as
>       two halves, one with x and the other with const0_rtx, ordered
>       depending on endianity.

        Jakub

Reply via email to