Skip to content

Commit f8973fc

Browse files
committed
cmd/link: revert CL 89535: "fix up location lists for dsymutil"
This reverts commit 230b0ba. Reason for revert: breaking the build. Fixes #24165 Change-Id: I9d8dda59f97a47e5c436f1c061b34ced82bde8ec Reviewed-on: https://go-review.googlesource.com/97575 Run-TryBot: Heschi Kreinick <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Joe Tsai <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 21343e0 commit f8973fc

File tree

1 file changed

+0
-71
lines changed

1 file changed

+0
-71
lines changed

src/cmd/link/internal/ld/dwarf.go

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,10 +1759,6 @@ func collectlocs(ctxt *Link, syms []*sym.Symbol, units []*compilationUnit) []*sy
17591759
reloc.Sym.Attr |= sym.AttrReachable | sym.AttrNotInSymbolTable
17601760
syms = append(syms, reloc.Sym)
17611761
empty = false
1762-
// LLVM doesn't support base address entries. Strip them out so LLDB and dsymutil don't get confused.
1763-
if ctxt.HeadType == objabi.Hdarwin {
1764-
removeLocationListBaseAddress(ctxt, fn, reloc.Sym)
1765-
}
17661762
// One location list entry per function, but many relocations to it. Don't duplicate.
17671763
break
17681764
}
@@ -1779,73 +1775,6 @@ func collectlocs(ctxt *Link, syms []*sym.Symbol, units []*compilationUnit) []*sy
17791775
return syms
17801776
}
17811777

1782-
func removeLocationListBaseAddress(ctxt *Link, info, list *sym.Symbol) {
1783-
// The list symbol contains multiple lists, but they're all for the
1784-
// same function, and it's not empty.
1785-
fn := list.R[0].Sym
1786-
1787-
// Discard the relocations for the base address entries.
1788-
list.R = list.R[:0]
1789-
1790-
// Add relocations for each location entry's start and end addresses,
1791-
// so that the base address entries aren't necessary.
1792-
// We could remove them entirely, but that's more work for a relatively
1793-
// small size win. If dsymutil runs it'll throw them away anyway.
1794-
1795-
// relocate adds a CU-relative relocation to fn+addr at offset.
1796-
relocate := func(addr uint64, offset int) {
1797-
list.R = append(list.R, sym.Reloc{
1798-
Off: int32(offset),
1799-
Siz: uint8(ctxt.Arch.PtrSize),
1800-
Type: objabi.R_ADDRCUOFF,
1801-
Add: int64(addr),
1802-
Sym: fn,
1803-
})
1804-
}
1805-
1806-
for i := 0; i < len(list.P); {
1807-
first := readPtr(ctxt, list.P[i:])
1808-
second := readPtr(ctxt, list.P[i+ctxt.Arch.PtrSize:])
1809-
1810-
if first == 0 ||
1811-
first == ^uint64(0) ||
1812-
(ctxt.Arch.PtrSize == 4 && first == uint64(^uint32(0))) {
1813-
// Base address selection entry or end of list. Ignore.
1814-
i += ctxt.Arch.PtrSize * 2
1815-
continue
1816-
}
1817-
1818-
relocate(first, i)
1819-
relocate(second, i+ctxt.Arch.PtrSize)
1820-
1821-
// Skip past the actual location.
1822-
i += ctxt.Arch.PtrSize * 2
1823-
i += 2 + int(ctxt.Arch.ByteOrder.Uint16(list.P[i:]))
1824-
}
1825-
1826-
// Rewrite the DIE's relocations to point to the first location entry,
1827-
// not the now-useless base address selection entry.
1828-
for i := range info.R {
1829-
r := &info.R[i]
1830-
if r.Sym != list {
1831-
continue
1832-
}
1833-
r.Add += int64(2 * ctxt.Arch.PtrSize)
1834-
}
1835-
}
1836-
1837-
// Read a pointer-sized uint from the beginning of buf.
1838-
func readPtr(ctxt *Link, buf []byte) uint64 {
1839-
switch ctxt.Arch.PtrSize {
1840-
case 4:
1841-
return uint64(ctxt.Arch.ByteOrder.Uint32(buf))
1842-
case 8:
1843-
return ctxt.Arch.ByteOrder.Uint64(buf)
1844-
default:
1845-
panic("unexpected pointer size")
1846-
}
1847-
}
1848-
18491778
/*
18501779
* Elf.
18511780
*/

0 commit comments

Comments
 (0)