On Wed, Aug 19, 2015 at 4:25 PM, Richard Biener <rguent...@suse.de> wrote:
>
> This is needed so that we can output references to $early-debug-symbol +
> constant offset where $early-debug-symbol is the beginning of a
> .debug_info section containing early debug info from the compile-stage.
> Constant offsets are always fine for any object formats I know, I
> tested ia64-linux apart from x86_64-linux.  I have access to darwin at
> home (x86_64), so can try there as well.
>
> The question is whether we want to assemble "+" HOST_WIDE_INT_PRINT_DEC
> directly for the non-ASM_OUTPUT_DWARF_OFFSET case as well as opposed
> to building a PLUS (we do build a SYMBOL_REF already).
>
> I've also refrained from changing all existing callers to
> dw2_asm_output_offset to pass a 0 offset argument to avoid the
> overloading - please tell me if you prefer that.  The LTO support
> adds a single call here:
>
> @@ -9064,8 +9248,12 @@ output_die (dw_die_ref die)
>                     size = DWARF2_ADDR_SIZE;
>                   else
>                     size = DWARF_OFFSET_SIZE;
> -                 dw2_asm_output_offset (size, sym, debug_info_section,
> "%s",
> -                                        name);
> +                 if (AT_ref (a)->with_offset)
> +                   dw2_asm_output_offset (size, sym, AT_ref
> (a)->die_offset,
> +                                          debug_info_section, "%s",
> name);
> +                 else
> +                   dw2_asm_output_offset (size, sym, debug_info_section,
> "%s",
> +                                          name);
>                 }
>
> (ignore that ->with_offset, it can hopefully go if die_offset is zero
> for other cases - just checking with an assert right now).
>
> Bootstrap & regtest pending on x86_64-unknown-linux-gnu.  The patch
> is an effective no-op currently (the offset != 0 condition is always
> false for now).
>
> Ok?
>
> CCing affected target maintainers - I've verified this on ia64
> by just generating assembly for a simple testcase with -g and
> changing one of the generated section-relative offsets in the
> suggested way (adding "+4"), passing through the assembler and
> inspecting the resulting relocations.

Given no further comments and my plan to go ahead with the early LTO debug
merge I am currently re-testing this nicely split out part and plan to commit it
once that succeeded.  This makes life a lot easier when testing the remains
as the tm.texi dance vanishes.

Richard.

> Thanks,
> Richard.
>
> 2015-08-19  Richard Biener  <rguent...@suse.de>
>
>         * dwarf2asm.h (dw2_asm_output_offset): Add overload with
>         extra offset argument.
>         * dwarf2asm.c (dw2_asm_output_offset): Implement that.
>         * doc/tm.texi.in (ASM_OUTPUT_DWARF_OFFSET): Adjust documentation
>         to reflect new offset parameter.
>         * doc/tm.texi: Regenerate.
>         * config/darwin.h (ASM_OUTPUT_DWARF_OFFSET): Adjust.
>         * config/darwin-protos.h (darwin_asm_output_dwarf_delta): Add
>         offset argument.
>         (darwin_asm_output_dwarf_offset): Likewise.
>         * config/darwin.c (darwin_asm_output_dwarf_delta): Add offset
>         argument.
>         (darwin_asm_output_dwarf_offset): Pass offset argument through.
>         * config/ia64/ia64.h (ASM_OUTPUT_DWARF_OFFSET): Adjust.
>         * config/i386/cygmin.h (ASM_OUTPUT_DWARF_OFFSET): Likewise.
>
> Index: gcc/dwarf2asm.c
> ===================================================================
> --- gcc/dwarf2asm.c     (revision 226856)
> +++ gcc/dwarf2asm.c     (working copy)
> @@ -33,6 +33,8 @@ along with GCC; see the file COPYING3.
>  #include "dwarf2asm.h"
>  #include "dwarf2.h"
>  #include "tm_p.h"
> +#include "function.h"
> +#include "emit-rtl.h"
>
>
>  /* Output an unaligned integer with the given value and size.  Prefer not
> @@ -190,12 +192,39 @@ dw2_asm_output_offset (int size, const c
>    va_start (ap, comment);
>
>  #ifdef ASM_OUTPUT_DWARF_OFFSET
> -  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label, base);
> +  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label, 0, base);
>  #else
>    dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label));
>  #endif
>
>    if (flag_debug_asm && comment)
> +    {
> +      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
> +      vfprintf (asm_out_file, comment, ap);
> +    }
> +  fputc ('\n', asm_out_file);
> +
> +  va_end (ap);
> +}
> +
> +void
> +dw2_asm_output_offset (int size, const char *label, HOST_WIDE_INT offset,
> +                      section *base ATTRIBUTE_UNUSED,
> +                      const char *comment, ...)
> +{
> +  va_list ap;
> +
> +  va_start (ap, comment);
> +
> +#ifdef ASM_OUTPUT_DWARF_OFFSET
> +  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label, offset, base);
> +#else
> +  dw2_assemble_integer (size, gen_rtx_PLUS (Pmode,
> +                                           gen_rtx_SYMBOL_REF (Pmode, label),
> +                                           gen_int_mode (offset, Pmode)));
> +#endif
> +
> +  if (flag_debug_asm && comment)
>      {
>        fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
>        vfprintf (asm_out_file, comment, ap);
> Index: gcc/dwarf2asm.h
> ===================================================================
> --- gcc/dwarf2asm.h     (revision 226856)
> +++ gcc/dwarf2asm.h     (working copy)
> @@ -40,6 +40,10 @@ extern void dw2_asm_output_offset (int,
>                                    const char *, ...)
>       ATTRIBUTE_NULL_PRINTF_4;
>
> +extern void dw2_asm_output_offset (int, const char *, HOST_WIDE_INT,
> +                                  section *, const char *, ...)
> +     ATTRIBUTE_NULL_PRINTF_5;
> +
>  extern void dw2_asm_output_addr (int, const char *, const char *, ...)
>       ATTRIBUTE_NULL_PRINTF_3;
>
> Index: gcc/doc/tm.texi.in
> ===================================================================
> --- gcc/doc/tm.texi.in  (revision 226856)
> +++ gcc/doc/tm.texi.in  (working copy)
> @@ -7020,10 +7020,11 @@ between the two given labels in system d
>  slots on IA64 VMS, using an integer of the given size.
>  @end defmac
>
> -@defmac ASM_OUTPUT_DWARF_OFFSET (@var{stream}, @var{size}, @var{label}, 
> @var{section})
> +@defmac ASM_OUTPUT_DWARF_OFFSET (@var{stream}, @var{size}, @var{label}, 
> @var{offset}, @var{section})
>  A C statement to issue assembly directives that create a
> -section-relative reference to the given @var{label}, using an integer of the
> -given @var{size}.  The label is known to be defined in the given 
> @var{section}.
> +section-relative reference to the given @var{label} plus @var{offset}, using
> +an integer of the given @var{size}.  The label is known to be defined in the
> +given @var{section}.
>  @end defmac
>
>  @defmac ASM_OUTPUT_DWARF_PCREL (@var{stream}, @var{size}, @var{label})
> Index: gcc/config/darwin-protos.h
> ===================================================================
> --- gcc/config/darwin-protos.h  (revision 226856)
> +++ gcc/config/darwin-protos.h  (working copy)
> @@ -91,9 +91,9 @@ extern void darwin_globalize_label (FILE
>  extern void darwin_assemble_visibility (tree, int);
>
>  extern void darwin_asm_output_dwarf_delta (FILE *, int, const char *,
> -                                          const char *);
> +                                          const char *, HOST_WIDE_INT);
>  extern void darwin_asm_output_dwarf_offset (FILE *, int, const char *,
> -                                           section *);
> +                                           HOST_WIDE_INT, section *);
>
>  extern void darwin_asm_declare_object_name (FILE *, const char *, tree);
>  extern void darwin_asm_declare_constant_name (FILE *, const char *,
> Index: gcc/config/darwin.c
> ===================================================================
> --- gcc/config/darwin.c (revision 226856)
> +++ gcc/config/darwin.c (working copy)
> @@ -2814,7 +2814,8 @@ static int darwin_dwarf_label_counter;
>
>  void
>  darwin_asm_output_dwarf_delta (FILE *file, int size,
> -                              const char *lab1, const char *lab2)
> +                              const char *lab1, const char *lab2,
> +                              HOST_WIDE_INT offset)
>  {
>    int islocaldiff = (lab1[0] == '*' && lab1[1] == 'L'
>                      && lab2[0] == '*' && lab2[1] == 'L');
> @@ -2828,6 +2829,8 @@ darwin_asm_output_dwarf_delta (FILE *fil
>    assemble_name_raw (file, lab1);
>    fprintf (file, "-");
>    assemble_name_raw (file, lab2);
> +  if (offset != 0)
> +    fprintf (file, "+" HOST_WIDE_INT_PRINT_DEC, offset);
>    if (islocaldiff)
>      fprintf (file, "\n\t%s L$set$%d", directive, 
> darwin_dwarf_label_counter++);
>  }
> @@ -2839,7 +2842,7 @@ darwin_asm_output_dwarf_delta (FILE *fil
>
>  void
>  darwin_asm_output_dwarf_offset (FILE *file, int size, const char * lab,
> -                               section *base)
> +                               HOST_WIDE_INT offset, section *base)
>  {
>    char sname[64];
>    int namelen;
> @@ -2850,7 +2853,7 @@ darwin_asm_output_dwarf_offset (FILE *fi
>
>    namelen = strchr (base->named.name + 8, ',') - (base->named.name + 8);
>    sprintf (sname, "*Lsection%.*s", namelen, base->named.name + 8);
> -  darwin_asm_output_dwarf_delta (file, size, lab, sname);
> +  darwin_asm_output_dwarf_delta (file, size, lab, sname, offset);
>  }
>
>  /* Called from the within the TARGET_ASM_FILE_START for each target.  */
> Index: gcc/config/darwin.h
> ===================================================================
> --- gcc/config/darwin.h (revision 226856)
> +++ gcc/config/darwin.h (working copy)
> @@ -826,10 +826,10 @@ enum machopic_addr_class {
>       ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)
>
>  #define ASM_OUTPUT_DWARF_DELTA(FILE,SIZE,LABEL1,LABEL2)  \
> -  darwin_asm_output_dwarf_delta (FILE, SIZE, LABEL1, LABEL2)
> +  darwin_asm_output_dwarf_delta (FILE, SIZE, LABEL1, LABEL2, 0)
>
> -#define ASM_OUTPUT_DWARF_OFFSET(FILE,SIZE,LABEL,BASE)  \
> -  darwin_asm_output_dwarf_offset (FILE, SIZE, LABEL, BASE)
> +#define ASM_OUTPUT_DWARF_OFFSET(FILE,SIZE,LABEL,OFFSET,BASE)  \
> +  darwin_asm_output_dwarf_offset (FILE, SIZE, LABEL, OFFSET, BASE)
>
>  #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(ASM_OUT_FILE, ENCODING, SIZE, 
> ADDR, DONE)    \
>        if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) {                 
>           \
> Index: gcc/config/ia64/ia64.h
> ===================================================================
> --- gcc/config/ia64/ia64.h      (revision 226856)
> +++ gcc/config/ia64/ia64.h      (working copy)
> @@ -1583,11 +1583,13 @@ do {                                                  
>                   \
>  /* Use section-relative relocations for debugging offsets.  Unlike other
>     targets that fake this by putting the section VMA at 0, IA-64 has
>     proper relocations for them.  */
> -#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, SECTION)    \
> +#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, OFFSET, SECTION) \
>    do {                                                         \
>      fputs (integer_asm_op (SIZE, FALSE), FILE);                        \
>      fputs ("@secrel(", FILE);                                  \
>      assemble_name (FILE, LABEL);                               \
> +    if (offset != 0)                                           \
> +      fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, OFFSET);     \
>      fputc (')', FILE);                                         \
>    } while (0)
>
> Index: gcc/config/i386/cygming.h
> ===================================================================
> --- gcc/config/i386/cygming.h   (revision 226856)
> +++ gcc/config/i386/cygming.h   (working copy)
> @@ -97,13 +97,15 @@ along with GCC; see the file COPYING3.
>  /* Use section relative relocations for debugging offsets.  Unlike
>     other targets that fake this by putting the section VMA at 0, PE
>     won't allow it.  */
> -#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, SECTION)    \
> +#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, OFFSET, SECTION) \
>    do {                                                         \
>      switch (SIZE)                                              \
>        {                                                                \
>        case 4:                                                  \
>         fputs ("\t.secrel32\t", FILE);                          \
>         assemble_name (FILE, LABEL);                            \
> +       if (offset != 0)                                        \
> +         fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, offset)   \
>         break;                                                  \
>        case 8:                                                  \
>         /* This is a hack.  There is no 64-bit section relative \
> @@ -113,6 +115,8 @@ along with GCC; see the file COPYING3.
>            Fake the 64-bit offset by zero-extending it.  */     \
>         fputs ("\t.secrel32\t", FILE);                          \
>         assemble_name (FILE, LABEL);                            \
> +       if (offset != 0)                                        \
> +         fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, offset)   \
>         fputs ("\n\t.long\t0", FILE);                           \
>         break;                                                  \
>        default:                                                 \

Reply via email to