diff mbox series

libgo patch committed: Fix handling of DW_FORM_strp for 64-bit DWARF

Message ID CAOyqgcUeWgC_sQZrZL-eCs8kkdJWXh5y=Em5fTZWHCg0kwUz2w@mail.gmail.com
State New
Headers show
Series libgo patch committed: Fix handling of DW_FORM_strp for 64-bit DWARF | expand

Commit Message

Ian Lance Taylor Jan. 11, 2018, 1:51 a.m. UTC
This libgo patch fixes the handling of DW_FORM_strp when using 64-bit
DWARF.  This is an early backport of https://golang.org/cl/84379,
which will be in Go 1.11.
Backporting now for AIX support in gccgo.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
diff mbox series

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 256450)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-19d94969c5202c07b3b166079b9f4ebbb52dfa6b
+1176dd2b53f2d2b826b599a126f3f9828283cec3
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/debug/dwarf/entry.go
===================================================================
--- libgo/go/debug/dwarf/entry.go	(revision 256366)
+++ libgo/go/debug/dwarf/entry.go	(working copy)
@@ -461,7 +461,18 @@  func (b *buf) entry(atab abbrevTable, ub
 		case formString:
 			val = b.string()
 		case formStrp:
-			off := b.uint32() // offset into .debug_str
+			var off uint64 // offset into .debug_str
+			is64, known := b.format.dwarf64()
+			if !known {
+				b.error("unknown size for DW_FORM_strp")
+			} else if is64 {
+				off = b.uint64()
+			} else {
+				off = uint64(b.uint32())
+			}
+			if uint64(int(off)) != off {
+				b.error("DW_FORM_strp offset out of range")
+			}
 			if b.err != nil {
 				return nil
 			}