[Bug,libdw/30967] Discriminator in Dwarf_Line_s may exceed 24 bits

Message ID bug-30967-10460-HnG687BNcC@http.sourceware.org/bugzilla/
State Committed
Headers
Series [Bug,libdw/30967] Discriminator in Dwarf_Line_s may exceed 24 bits |

Commit Message

mark at klomp dot org Oct. 26, 2023, 2:55 p.m. UTC
  https://sourceware.org/bugzilla/show_bug.cgi?id=30967

--- Comment #6 from Mark Wielaard <mark at klomp dot org> ---
So my preferred workaround:

   SET (file);
@@ -140,7 +146,7 @@ add_new_line (struct line_state *state, struct linelist
*new_line)
   SET (prologue_end);
   SET (epilogue_begin);
   SET (isa);
-  SET (discriminator);
+  SETX (discriminator);
   SET (context);
   SET (function_name);


https://code.wildebeest.org/git/user/mjw/elfutils/commit/?h=really-large-disc
  

Patch

diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c
index df003c5f..69e10c7b 100644
--- a/libdw/dwarf_getsrclines.c
+++ b/libdw/dwarf_getsrclines.c
@@ -129,6 +129,12 @@  add_new_line (struct line_state *state, struct linelist
*new_line)
        return true;                                                  \
    } while (0)

+  /* Same as above, but don't flag as "invalid" just use truncated
+     value.  Used for discriminator for which llvm might use a value
+     that won't fit 24 bits.  */
+#define SETX(field)                                                  \
+     new_line->line.field = state->field;                            \
+
   SET (addr);
   SET (op_index);