DWARF: Check version >= 3 for DW_FORM_ref_addr
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 19 Mar 2021 01:34:38 +0000 (18:34 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 19 Mar 2021 01:34:48 +0000 (18:34 -0700)
Check version >= 3, instead of version == 3 || version == 4, for
DW_FORM_ref_addr.

bfd/

PR ld/27587
* dwarf2.c (read_attribute_value): Check version >= 3 for
DW_FORM_ref_addr.

ld/

PR ld/27587
* testsuite/ld-x86-64/pr27587.err: New file.
* testsuite/ld-x86-64/pr27587a.obj.bz2: Likewise.
* testsuite/ld-x86-64/pr27587b.obj.bz2: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/27587 test.

bfd/ChangeLog
bfd/dwarf2.c
ld/ChangeLog
ld/testsuite/ld-x86-64/pr27587.err [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27587a.obj.bz2 [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27587b.obj.bz2 [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index 2bea06278b83033ca18a5654b6a78fbfeb036c38..94155de66eb4c20bb147b7cc381c8916213a8a1a 100644 (file)
@@ -1,3 +1,9 @@
+2021-03-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/27587
+       * dwarf2.c (read_attribute_value): Check version >= 3 for
+       DW_FORM_ref_addr.
+
 2021-03-16  Nick Clifton  <nickc@redhat.com>
 
        * peXXigen.c (_bfd_XXi_swap_aux_out): Avoid potential buffer
index b42e641aa3b9247cb5aa323ee90f4efd18f60022..1d5ddef332933d1da54ee81801479d4bb7d314c1 100644 (file)
@@ -1213,7 +1213,7 @@ read_attribute_value (struct attribute *  attr,
     case DW_FORM_ref_addr:
       /* DW_FORM_ref_addr is an address in DWARF2, and an offset in
         DWARF3.  */
-      if (unit->version == 3 || unit->version == 4)
+      if (unit->version >= 3)
        {
          if (unit->offset_size == 4)
            attr->u.val = read_4_bytes (unit->abfd, info_ptr, info_ptr_end);
index 265f0fb6e7947d410f12353d82491c0d841924ae..d9b049f003ca9147c85619005c84967737c860c8 100644 (file)
@@ -1,3 +1,11 @@
+2021-03-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/27587
+       * testsuite/ld-x86-64/pr27587.err: New file.
+       * testsuite/ld-x86-64/pr27587a.obj.bz2: Likewise.
+       * testsuite/ld-x86-64/pr27587b.obj.bz2: Likewise.
+       * testsuite/ld-x86-64/x86-64.exp: Run PR ld/27587 test.
+
 2021-03-18  Nick Alcock  <nick.alcock@oracle.com>
 
        * testsuite/ld-ctf/slice.c: Check slices of enums too.
diff --git a/ld/testsuite/ld-x86-64/pr27587.err b/ld/testsuite/ld-x86-64/pr27587.err
new file mode 100644 (file)
index 0000000..fa87079
--- /dev/null
@@ -0,0 +1,3 @@
+#...
+.*pr27587.i:4: undefined reference to `stack_size'
+#...
diff --git a/ld/testsuite/ld-x86-64/pr27587a.obj.bz2 b/ld/testsuite/ld-x86-64/pr27587a.obj.bz2
new file mode 100644 (file)
index 0000000..eebcf54
Binary files /dev/null and b/ld/testsuite/ld-x86-64/pr27587a.obj.bz2 differ
diff --git a/ld/testsuite/ld-x86-64/pr27587b.obj.bz2 b/ld/testsuite/ld-x86-64/pr27587b.obj.bz2
new file mode 100644 (file)
index 0000000..8506e4e
Binary files /dev/null and b/ld/testsuite/ld-x86-64/pr27587b.obj.bz2 differ
index 232c9dfa3a2dbc56bbdd6a55a23a69ccd651ffd0..db3bd140193921873b00ce5f6fcf15559734033b 100644 (file)
@@ -221,6 +221,11 @@ set x86_64tests {
      "-melf_x86_64 -pie -z notext tmpdir/pr20550a.o tmpdir/pr20550b.so"
      ""
      "--64" { dummy.s } {} "pr20550"}
+    {"Build pr27587"
+     "-melf_x86_64 -e main"
+     "" ""
+     { pr27587a.obj.bz2 pr27587b.obj.bz2 }
+     {{ld "pr27587.err"}} "pr27587"}
 }
 
 run_ld_link_tests $x86_64tests