https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61577

--- Comment #45 from dave.anglin at bell dot net ---
On 2019-07-05 3:34 p.m., elowe at elowe dot com wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61577
>
> --- Comment #44 from EML <elowe at elowe dot com> ---
> The aforementioned gprel patch I think is incorrect on HPUX, given this in
> ia64.c
>
> /* For HPUX, it is illegal to have relocations in shared segments.  */
>
> static int
> ia64_hpux_reloc_rw_mask (void)
> {
>   return 3;
> }
>
>
> Therefore, if I understand correctly, HP requires all relocations, even to
> local data, to be dynamic. And I understand the entire purpose of the earlier
> patch is in direct contradiction to this.
>
> Removing this (by adding a !TARGET_HPUX) to ia64.c results in a little
> progress.
I think this is wrong, but this is getting closer to a fix.  Would like to see
the .s output.

We have in varasm.c:

section *
default_select_rtx_section (machine_mode mode ATTRIBUTE_UNUSED,
                            rtx x,
                            unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
{
  if (compute_reloc_for_rtx (x) & targetm.asm_out.reloc_rw_mask ())
    return data_section;
  else
    return readonly_data_section;
}

As you can see, when a bit is set in the reloc_rw_mask and the rtx requires
relocation,
the rtx is output in the data section.

I think the problem is the rtx is actually output in .rodata and the HP dynamic
linker
can't do this relocation in .rodata.

The ia64 target is actually using default_elf_select_rtx_section:

section *
default_elf_select_rtx_section (machine_mode mode, rtx x,
                                unsigned HOST_WIDE_INT align)
{
  int reloc = compute_reloc_for_rtx (x);

  /* ??? Handle small data here somehow.  */

  if (reloc & targetm.asm_out.reloc_rw_mask ())
    {
      if (reloc == 1)
        return get_named_section (NULL, ".data.rel.ro.local", 1);
      else
        return get_named_section (NULL, ".data.rel.ro", 3);
    }

  return mergeable_constant_section (mode, align, 0);
}

It seems to me compute_reloc_for_rtx() must be doing the wrong thing for the
rtx
(i.e., returning 0).

You could dump the RTL by adding "-da" to the compile options.  Then, you could
upload
the "final" file.

Reply via email to