From e01a226fadcac721e26c12921ca54388c7244d03 Mon Sep 17 00:00:00 2001 From: Victor Michel Date: Sun, 30 Aug 2020 20:43:39 +0000 Subject: [PATCH] debug/elf: support relocations relative to sections with non-zero addresses commit 72ec930fa70c20ce69b21bf32a7916c04c2e9c2f added basic support for relocations, but assumed that the symbol value would be 0, likely because .debug_info always has address == 0 in the ELF section headers. CL 195679 added further support for relocations, but explicitly encoded the original assumption that section addresses would be 0. This change removes that assumption: all relocations will now be properly computed based on the target symbol value even when that symbol is a section with a non-zero address. Typically, sections that are part of a LOAD program segment have non-zero addresses. For example, .debug_ranges relocations could be relative to .text, which usually has an address > 0. Fixes #40879 Change-Id: Ib0a616bb8b05d6c96d179b03ca33a10946fc5d59 GitHub-Last-Rev: 4200de732641995f3a4958a13a5c78f65b7eae50 GitHub-Pull-Request: golang/go#41038 Reviewed-on: https://go-review.googlesource.com/c/go/+/250559 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/debug/elf/file.go | 77 +++++++---------- src/debug/elf/file_test.go | 81 +++++++++++++++++- ...location-test-gcc930-ranges-no-rela-x86-64 | Bin 0 -> 5696 bytes ...cation-test-gcc930-ranges-with-rela-x86-64 | Bin 0 -> 7680 bytes .../elf/testdata/multiple-code-sections.c | 28 ++++++ 5 files changed, 135 insertions(+), 51 deletions(-) create mode 100644 src/debug/elf/testdata/go-relocation-test-gcc930-ranges-no-rela-x86-64 create mode 100644 src/debug/elf/testdata/go-relocation-test-gcc930-ranges-with-rela-x86-64 create mode 100644 src/debug/elf/testdata/multiple-code-sections.c diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go index 1e863ef78e..cd5bf8fab0 100644 --- a/src/debug/elf/file.go +++ b/src/debug/elf/file.go @@ -628,23 +628,14 @@ func (f *File) applyRelocations(dst []byte, rels []byte) error { } } -// relocSymbolTargetOK decides whether we should try to apply a +// canApplyRelocation reports whether we should try to apply a // relocation to a DWARF data section, given a pointer to the symbol -// targeted by the relocation. Most relocations in DWARF data tend to -// be section-relative, but some target non-section symbols (for -// example, low_PC attrs on subprogram or compilation unit DIEs that -// target function symbols), and we need to include these as well. -// Return value is a pair (X,Y) where X is a boolean indicating -// whether the relocation is needed, and Y is the symbol value in the -// case of a non-section relocation that needs to be applied. -func relocSymbolTargetOK(sym *Symbol) (bool, uint64) { - if ST_TYPE(sym.Info) == STT_SECTION { - return true, 0 - } - if sym.Section != SHN_UNDEF && sym.Section < SHN_LORESERVE { - return true, sym.Value - } - return false, 0 +// targeted by the relocation. +// Most relocations in DWARF data tend to be section-relative, but +// some target non-section symbols (for example, low_PC attrs on +// subprogram or compilation unit DIEs that target function symbols). +func canApplyRelocation(sym *Symbol) bool { + return sym.Section != SHN_UNDEF && sym.Section < SHN_LORESERVE } func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) error { @@ -670,8 +661,7 @@ func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) error { continue } sym := &symbols[symNo-1] - needed, val := relocSymbolTargetOK(sym) - if !needed { + if !canApplyRelocation(sym) { continue } @@ -684,13 +674,13 @@ func (f *File) applyRelocationsAMD64(dst []byte, rels []byte) error { if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val64 := val + uint64(rela.Addend) + val64 := sym.Value + uint64(rela.Addend) f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], val64) case R_X86_64_32: if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val32 := uint32(val) + uint32(rela.Addend) + val32 := uint32(sym.Value) + uint32(rela.Addend) f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], val32) } } @@ -796,8 +786,7 @@ func (f *File) applyRelocationsARM64(dst []byte, rels []byte) error { continue } sym := &symbols[symNo-1] - needed, val := relocSymbolTargetOK(sym) - if !needed { + if !canApplyRelocation(sym) { continue } @@ -810,13 +799,13 @@ func (f *File) applyRelocationsARM64(dst []byte, rels []byte) error { if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val64 := uint64(val) + uint64(rela.Addend) + val64 := sym.Value + uint64(rela.Addend) f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], val64) case R_AARCH64_ABS32: if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val32 := uint32(val) + uint32(rela.Addend) + val32 := uint32(sym.Value) + uint32(rela.Addend) f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], val32) } } @@ -847,8 +836,7 @@ func (f *File) applyRelocationsPPC(dst []byte, rels []byte) error { continue } sym := &symbols[symNo-1] - needed, val := relocSymbolTargetOK(sym) - if !needed { + if !canApplyRelocation(sym) { continue } @@ -857,7 +845,7 @@ func (f *File) applyRelocationsPPC(dst []byte, rels []byte) error { if rela.Off+4 >= uint32(len(dst)) || rela.Addend < 0 { continue } - val32 := uint32(val) + uint32(rela.Addend) + val32 := uint32(sym.Value) + uint32(rela.Addend) f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], val32) } } @@ -888,8 +876,7 @@ func (f *File) applyRelocationsPPC64(dst []byte, rels []byte) error { continue } sym := &symbols[symNo-1] - needed, val := relocSymbolTargetOK(sym) - if !needed { + if !canApplyRelocation(sym) { continue } @@ -898,13 +885,13 @@ func (f *File) applyRelocationsPPC64(dst []byte, rels []byte) error { if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val64 := val + uint64(rela.Addend) + val64 := sym.Value + uint64(rela.Addend) f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], val64) case R_PPC64_ADDR32: if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val32 := uint32(val) + uint32(rela.Addend) + val32 := uint32(sym.Value) + uint32(rela.Addend) f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], val32) } } @@ -980,8 +967,7 @@ func (f *File) applyRelocationsMIPS64(dst []byte, rels []byte) error { continue } sym := &symbols[symNo-1] - needed, val := relocSymbolTargetOK(sym) - if !needed { + if !canApplyRelocation(sym) { continue } @@ -990,13 +976,13 @@ func (f *File) applyRelocationsMIPS64(dst []byte, rels []byte) error { if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val64 := val + uint64(rela.Addend) + val64 := sym.Value + uint64(rela.Addend) f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], val64) case R_MIPS_32: if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val32 := uint32(val) + uint32(rela.Addend) + val32 := uint32(sym.Value) + uint32(rela.Addend) f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], val32) } } @@ -1027,8 +1013,7 @@ func (f *File) applyRelocationsRISCV64(dst []byte, rels []byte) error { continue } sym := &symbols[symNo-1] - needed, val := relocSymbolTargetOK(sym) - if !needed { + if !canApplyRelocation(sym) { continue } @@ -1037,13 +1022,13 @@ func (f *File) applyRelocationsRISCV64(dst []byte, rels []byte) error { if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val64 := val + uint64(rela.Addend) + val64 := sym.Value + uint64(rela.Addend) f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], val64) case R_RISCV_32: if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val32 := uint32(val) + uint32(rela.Addend) + val32 := uint32(sym.Value) + uint32(rela.Addend) f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], val32) } } @@ -1074,8 +1059,7 @@ func (f *File) applyRelocationss390x(dst []byte, rels []byte) error { continue } sym := &symbols[symNo-1] - needed, val := relocSymbolTargetOK(sym) - if !needed { + if !canApplyRelocation(sym) { continue } @@ -1084,13 +1068,13 @@ func (f *File) applyRelocationss390x(dst []byte, rels []byte) error { if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val64 := val + uint64(rela.Addend) + val64 := sym.Value + uint64(rela.Addend) f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], val64) case R_390_32: if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val32 := uint32(val) + uint32(rela.Addend) + val32 := uint32(sym.Value) + uint32(rela.Addend) f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], val32) } } @@ -1121,8 +1105,7 @@ func (f *File) applyRelocationsSPARC64(dst []byte, rels []byte) error { continue } sym := &symbols[symNo-1] - needed, val := relocSymbolTargetOK(sym) - if !needed { + if !canApplyRelocation(sym) { continue } @@ -1131,13 +1114,13 @@ func (f *File) applyRelocationsSPARC64(dst []byte, rels []byte) error { if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val64 := val + uint64(rela.Addend) + val64 := sym.Value + uint64(rela.Addend) f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], val64) case R_SPARC_32, R_SPARC_UA32: if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 { continue } - val32 := uint32(val) + uint32(rela.Addend) + val32 := uint32(sym.Value) + uint32(rela.Addend) f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], val32) } } diff --git a/src/debug/elf/file_test.go b/src/debug/elf/file_test.go index 4da580da5a..24948e696a 100644 --- a/src/debug/elf/file_test.go +++ b/src/debug/elf/file_test.go @@ -293,6 +293,7 @@ func decompress(gz string) (io.ReaderAt, error) { type relocationTestEntry struct { entryNumber int entry *dwarf.Entry + pcRanges [][2]uint64 } type relocationTest struct { @@ -319,6 +320,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x6}}, }, }, }, @@ -340,6 +342,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x5}}, }, }, }, @@ -361,6 +364,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x6}}, }, }, }, @@ -382,6 +386,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x24}}, }, }, }, @@ -403,6 +408,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x28}}, }, }, }, @@ -421,9 +427,10 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0x0), Class: dwarf.ClassLinePtr}, {Attr: dwarf.AttrCompDir, Val: "/tmp", Class: dwarf.ClassString}, {Attr: dwarf.AttrLowpc, Val: uint64(0x0), Class: dwarf.ClassAddress}, - {Attr: dwarf.AttrHighpc, Val: int64(48), Class: dwarf.ClassConstant}, + {Attr: dwarf.AttrHighpc, Val: int64(0x30), Class: dwarf.ClassConstant}, }, }, + pcRanges: [][2]uint64{{0x0, 0x30}}, }, }, }, @@ -445,6 +452,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x44}}, }, }, }, @@ -466,6 +474,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x24}}, }, }, }, @@ -483,10 +492,11 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrName, Val: "hello.c", Class: dwarf.ClassString}, {Attr: dwarf.AttrCompDir, Val: "/tmp", Class: dwarf.ClassString}, {Attr: dwarf.AttrLowpc, Val: uint64(0x0), Class: dwarf.ClassAddress}, - {Attr: dwarf.AttrHighpc, Val: int64(100), Class: dwarf.ClassConstant}, + {Attr: dwarf.AttrHighpc, Val: int64(0x64), Class: dwarf.ClassConstant}, {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x64}}, }, }, }, @@ -504,10 +514,11 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrName, Val: "hello.c", Class: dwarf.ClassString}, {Attr: dwarf.AttrCompDir, Val: "/tmp", Class: dwarf.ClassString}, {Attr: dwarf.AttrLowpc, Val: uint64(0x0), Class: dwarf.ClassAddress}, - {Attr: dwarf.AttrHighpc, Val: int64(58), Class: dwarf.ClassConstant}, + {Attr: dwarf.AttrHighpc, Val: int64(0x3a), Class: dwarf.ClassConstant}, {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x3a}}, }, }, }, @@ -529,6 +540,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x2c}}, }, }, }, @@ -550,6 +562,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x58}}, }, }, }, @@ -571,6 +584,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x5c}}, }, }, }, @@ -588,10 +602,11 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrName, Val: "hello.c", Class: dwarf.ClassString}, {Attr: dwarf.AttrCompDir, Val: "/tmp", Class: dwarf.ClassString}, {Attr: dwarf.AttrLowpc, Val: uint64(0x0), Class: dwarf.ClassAddress}, - {Attr: dwarf.AttrHighpc, Val: int64(100), Class: dwarf.ClassConstant}, + {Attr: dwarf.AttrHighpc, Val: int64(0x64), Class: dwarf.ClassConstant}, {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x64}}, }, }, }, @@ -613,6 +628,7 @@ var relocationTests = []relocationTest{ {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, }, }, + pcRanges: [][2]uint64{{0x0, 0x2c}}, }, }, }, @@ -670,6 +686,56 @@ var relocationTests = []relocationTest{ }, }, }, + { + "testdata/go-relocation-test-gcc930-ranges-no-rela-x86-64", + []relocationTestEntry{ + { + entry: &dwarf.Entry{ + Offset: 0xb, + Tag: dwarf.TagCompileUnit, + Children: true, + Field: []dwarf.Field{ + {Attr: dwarf.AttrProducer, Val: "GNU C17 9.3.0 -mtune=generic -march=x86-64 -g -fno-asynchronous-unwind-tables", Class: dwarf.ClassString}, + {Attr: dwarf.AttrLanguage, Val: int64(12), Class: dwarf.ClassConstant}, + {Attr: dwarf.AttrName, Val: "multiple-code-sections.c", Class: dwarf.ClassString}, + {Attr: dwarf.AttrCompDir, Val: "/tmp", Class: dwarf.ClassString}, + {Attr: dwarf.AttrRanges, Val: int64(0), Class: dwarf.ClassRangeListPtr}, + {Attr: dwarf.AttrLowpc, Val: uint64(0), Class: dwarf.ClassAddress}, + {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, + }, + }, + pcRanges: [][2]uint64{ + {0x765, 0x777}, + {0x7e1, 0x7ec}, + }, + }, + }, + }, + { + "testdata/go-relocation-test-gcc930-ranges-with-rela-x86-64", + []relocationTestEntry{ + { + entry: &dwarf.Entry{ + Offset: 0xb, + Tag: dwarf.TagCompileUnit, + Children: true, + Field: []dwarf.Field{ + {Attr: dwarf.AttrProducer, Val: "GNU C17 9.3.0 -mtune=generic -march=x86-64 -g -fno-asynchronous-unwind-tables", Class: dwarf.ClassString}, + {Attr: dwarf.AttrLanguage, Val: int64(12), Class: dwarf.ClassConstant}, + {Attr: dwarf.AttrName, Val: "multiple-code-sections.c", Class: dwarf.ClassString}, + {Attr: dwarf.AttrCompDir, Val: "/tmp", Class: dwarf.ClassString}, + {Attr: dwarf.AttrRanges, Val: int64(0), Class: dwarf.ClassRangeListPtr}, + {Attr: dwarf.AttrLowpc, Val: uint64(0), Class: dwarf.ClassAddress}, + {Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr}, + }, + }, + pcRanges: [][2]uint64{ + {0x765, 0x777}, + {0x7e1, 0x7ec}, + }, + }, + }, + }, } func TestDWARFRelocations(t *testing.T) { @@ -705,6 +771,13 @@ func TestDWARFRelocations(t *testing.T) { if !reflect.DeepEqual(testEntry.entry, entry) { t.Errorf("entry %d mismatch: got:%#v want:%#v", testEntry.entryNumber, entry, testEntry.entry) } + pcRanges, err := dwarf.Ranges(entry) + if err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(testEntry.pcRanges, pcRanges) { + t.Errorf("entry %d: PC range mismatch: got:%#v want:%#v", testEntry.entryNumber, pcRanges, testEntry.pcRanges) + } } }) } diff --git a/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-no-rela-x86-64 b/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-no-rela-x86-64 new file mode 100644 index 0000000000000000000000000000000000000000..c013f3e081c7ecf1056be3457332be97ffa0f31c GIT binary patch literal 5696 zcmbtXOK%%h6u#q$lN2Xzl0uvEl7S+MkcUzzEssLl(4>KshX^krbUU%fj=>&>@wiPu zKsP{zSdxc`~{Y=L1IF7ZXOA^M!ZX$!t11uVl3F&Pg*gRBVN@DUO~dpg8&p{SG_B zXUL44q911}ajpC7d|;eO=f?7ml3Tv2{KT$FXM*Cp;5qm2cFT8{?kU|>x@q^qj!9=~ zWM=xkqr06Q)RCe=-NKFnh4s)LQ!3q8a%qZ++bO$1q+!7*SVlavg*WQg3-oo(t=vQB z&+<6^CPyO0ykk23cHCNR2i01)9#nflEpBzgo>wC>wKQS26)+rk(kYHTRCJyx6v#vI zdaA-Cx>q>GZJ(lwgqPFzZ%U4F)+WYAM$gIq+QVKc!6%mVNO|Io!tD6)9C5iGJT!n% z0PlqG{HS@#%s>1@W%jm%X*5-;owy$chnqndM6DVX{iwEbcde+)2*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K%n#xDy5yGvqF>=c zCh7Iy_ae8i=l`PUU(aYci@w4#Fvw@Pft&-{ujX_U(--|mT=V`$ c>}K^9IruNA233(>l==E!$5U@*B~V544_DUSr~m)} literal 0 HcmV?d00001 diff --git a/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-with-rela-x86-64 b/src/debug/elf/testdata/go-relocation-test-gcc930-ranges-with-rela-x86-64 new file mode 100644 index 0000000000000000000000000000000000000000..51e03aa7b0d6010410a31d6594540b07c0b3b6c5 GIT binary patch literal 7680 zcmbVQQEVJX8J@lM*$#FtXD3aZ7OGR45Vz&FuG_RpO45s+#CCC-RB;Oxp!NE0eZF$H zXZH3Iy9kIXrSeOq6d^&R2r8i3-6AwJV122{6Lkh|Z;-NesBDGTZ|K0yP z&&};Y#7KAl%s2n{|Ns0mJF~OjKeKo?V_6EtRwos=t_&tf2_1V-QL3bls$KLysSYbv z8=zlFx=lH6CmoQ(qQ@}vP;QGJ+NK1LW7B!2-j>*b?8loIBapDOQ&Q27_gXg5gamI? zDjAVxoNK~^1n-Vibbq26_sq*YK!UeVD#!)<(|OCng9L9vDtVD65AzNQUR&~_^Vm1? zd~XPv=~5q`gcd7KIuqPyu;BiyuO$rbCrUZ{;M2=YJqX%4P7w$$Co%h)Tj_(!X z>2aEInQg>5H#>X0FnQWvsd+)+nDdM?Rebu$<4H|@nOI3a5_MmK85e6GOMAq$F72O^ zOa?P-@gf=h8vR|APF-ZaLoI7>_6-uI6YB<}_P1k=9M?1N*5hnidmm;r^X{@57|7Ow zNM(mF6ObMLF8vQ$gI7olU7|m0JT`5{Yu!-Rm~|+(d&JH?l6!UEn3bpXopG!e_uIMS zBQJ~`8#%mxVfUCdK2)0c(ae5pHwBVa=v&yGp=CXAP>qb79I+`y*s$1*)l(dy^=WP={l{A(t$9l|+V!ZmUiXXTX2mbI{Bl%l1}&#d%H%1pc4ROd zd(6s?ekE(Yp2?7f>;dXR677eq?2ccdi-^3P-lt+IYa>58G<;2-uY+ur3T$FZPv!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V=M%Um4+8h#@uh`2 zk+*+~qP|Y_aUnLugY!{2t<45qL`X(qBG*u>YzEY+9F|e2oNCZ^F8N`L?rU8Qm-<4# z?y;iO;yu$@uSZU`83`8o8&qxi>t5(ZzAHCBJT@b?C_V9(@8IZj zeBop%j7!=UJ|w5w#)3#xQNN}w@T3s##nx}<+)CG;7AQ#-r@LdS&miu`wu?{f5{Kl>Gaeo7!zaZ#^ZRmy18l8`O z9{AWlz(bsnM-4vigWwm$nHj&pYR=%}-U$9}QG|bU{I3Zg`ybwa!PoaBHpTn6US6RF zV$0k5Xv^e$9)%k_)FN^{(-+? z@UIyDJtR&Hz%T6iR7o5Eyo~>r@Ok{azrZi@vMw0n$EOLz-`RIakBbqGdW$f9{J5us z&wH<4%=vqVI+-u&?%d}w|A-eh(1zTijZmgfCv01g26w|{|EJdy^sIA zOceaEe}+u|%Ywl_zE8maB=zeBe8^u?C)dHpiwF4d4;$b?eqiwNy#su6y@3aN?^7i$ z|G0O-KaZck`GF6d@6U`Oe(>O*y1EMZ0RKpp|He1<&Gq|d;xje{gCgPI{Ne&WBAq)CX{A}nN&>vE&|fxzb!Awm{*SfQTmzr zJJiSjhWKAI{DTj;(8vEL;(u8b*?)n4;3I$2;vaE}y1FC&uL2NB>T!Xb5x&43;md|@ z+651aCkRN(-v#;jvn+}n|6}ws<7az#mk`xh{8;>dAmjKVp?Fte1&p812U)5Ncgh8M Zarui8u+dbU<~05-iJ!j@>BVTO{{Um6#jpSX literal 0 HcmV?d00001 diff --git a/src/debug/elf/testdata/multiple-code-sections.c b/src/debug/elf/testdata/multiple-code-sections.c new file mode 100644 index 0000000000..03b9d53ab9 --- /dev/null +++ b/src/debug/elf/testdata/multiple-code-sections.c @@ -0,0 +1,28 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Build with: +// gcc -g multiple-code-sections.c -Wl,--emit-relocs -Wl,--discard-none -Wl,-zmax-page-size=1 -fno-asynchronous-unwind-tables -o go-relocation-test-gcc930-ranges-with-rela-x86-64 +// gcc -g multiple-code-sections.c -Wl,-zmax-page-size=1 -fno-asynchronous-unwind-tables -o go-relocation-test-gcc930-ranges-no-rela-x86-64 +// Strip with: +// strip --only-keep-debug \ +// --remove-section=.eh_frame \ +// --remove-section=.eh_frame_hdr \ +// --remove-section=.shstrtab \ +// --remove-section=.strtab \ +// --remove-section=.symtab \ +// --remove-section=.note.gnu.build-id \ +// --remove-section=.note.ABI-tag \ +// --remove-section=.dynamic \ +// --remove-section=.gnu.hash \ +// --remove-section=.interp \ +// --remove-section=.rodata +__attribute__((section(".separate_section"))) // To get GCC to emit a DW_AT_ranges attribute for the CU. +int func(void) { + return 0; +} + +int main(int argc, char *argv[]) { + return 0; +} -- 2.48.1