aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2023-12-13 16:55:18 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-01-17 09:28:44 +0000
commitedd756a5fa6390fb08e2b515e507253a59b22d70 (patch)
treead966024ad642a0a0a6f9891ee049ac598e7fc0f /pkg
parent3392690e404b6ba5022825d33259bc2e9e89eb53 (diff)
pkg/cover/backend: retire pcFixUpOffset
Adjusting the module pc by 0x18 is a poorly documented hack that relies on the fixed .plt size. Remove it in favor of a more flexible solution.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/cover/backend/dwarf.go22
-rw-r--r--pkg/cover/backend/elf.go21
2 files changed, 7 insertions, 36 deletions
diff --git a/pkg/cover/backend/dwarf.go b/pkg/cover/backend/dwarf.go
index 9f36cdfa6..4db2f2ad4 100644
--- a/pkg/cover/backend/dwarf.go
+++ b/pkg/cover/backend/dwarf.go
@@ -24,16 +24,12 @@ import (
)
type dwarfParams struct {
- target *targets.Target
- objDir string
- srcDir string
- buildDir string
- moduleObj []string
- hostModules []host.KernelModule
- // Kernel coverage PCs in the [pcFixUpStart,pcFixUpEnd) range are offsetted by pcFixUpOffset.
- pcFixUpStart uint64
- pcFixUpEnd uint64
- pcFixUpOffset uint64
+ target *targets.Target
+ objDir string
+ srcDir string
+ buildDir string
+ moduleObj []string
+ hostModules []host.KernelModule
readSymbols func(*Module, *symbolInfo) ([]*Symbol, error)
readTextData func(*Module) ([]byte, error)
readModuleCoverPoints func(*targets.Target, *Module, *symbolInfo) ([2][]uint64, error)
@@ -209,11 +205,7 @@ func makeDWARFUnsafe(params *dwarfParams) (*Impl, error) {
func makeRestorePC(params *dwarfParams, pcBase uint64) func(pc uint32) uint64 {
return func(pcLow uint32) uint64 {
- pc := PreviousInstructionPC(params.target, RestorePC(pcLow, uint32(pcBase>>32)))
- if pc >= params.pcFixUpStart && pc < params.pcFixUpEnd {
- pc -= params.pcFixUpOffset
- }
- return pc
+ return PreviousInstructionPC(params.target, RestorePC(pcLow, uint32(pcBase>>32)))
}
}
diff --git a/pkg/cover/backend/elf.go b/pkg/cover/backend/elf.go
index c9a02aba4..57975a9d5 100644
--- a/pkg/cover/backend/elf.go
+++ b/pkg/cover/backend/elf.go
@@ -8,7 +8,6 @@ import (
"encoding/binary"
"fmt"
"io"
- "path/filepath"
"strings"
"github.com/google/syzkaller/pkg/host"
@@ -18,23 +17,6 @@ import (
func makeELF(target *targets.Target, objDir, srcDir, buildDir string,
moduleObj []string, hostModules []host.KernelModule) (*Impl, error) {
- var pcFixUpStart, pcFixUpEnd, pcFixUpOffset uint64
- if target.Arch == targets.ARM64 {
- // On arm64 as PLT is enabled by default, .text section is loaded after .plt section,
- // so there is 0x18 bytes offset from module load address for .text section
- // we need to remove the 0x18 bytes offset in order to correct module symbol address
- // TODO: obtain these values from the binary instead of hardcoding.
- file, err := elf.Open(filepath.Join(objDir, target.KernelObject))
- if err != nil {
- return nil, err
- }
- defer file.Close()
- if file.Section(".plt") != nil {
- pcFixUpStart = 0x8000000000000000
- pcFixUpEnd = 0xffffffd010000000
- pcFixUpOffset = 0x18
- }
- }
return makeDWARF(&dwarfParams{
target: target,
objDir: objDir,
@@ -42,9 +24,6 @@ func makeELF(target *targets.Target, objDir, srcDir, buildDir string,
buildDir: buildDir,
moduleObj: moduleObj,
hostModules: hostModules,
- pcFixUpStart: pcFixUpStart,
- pcFixUpEnd: pcFixUpEnd,
- pcFixUpOffset: pcFixUpOffset,
readSymbols: elfReadSymbols,
readTextData: elfReadTextData,
readModuleCoverPoints: elfReadModuleCoverPoints,