Przeglądaj źródła

Add back one GetBase heuristic, apparently kernel ASLR related. (#428)

After importing pprof with #425 included to the Google's code base
a test in the symbolizer started to fail. The name of the test appears
to be related to handling the perf data from systems with kernel ASLR
related and this case turns out to depend on one of the heuristics I've
removed in #425 (I assumed that had only be used for user-mode
binaries). Add that heuristic back and add a test case with the input
equivalent to the internally failing test.

I have to say I do not quite understand the test case here as I thought
we already have a kernel ASLR test case here, and there the mmap offset
field looks more like a kernel page offset value (i.e. in the upper half
of the address space), but here it's a small number. For now just want
to make sure the existing test cases work as they were.
Alexey Alexandrov 6 lat temu
rodzic
commit
baeddb81b1
No account linked to committer's email address
2 zmienionych plików z 10 dodań i 0 usunięć
  1. 3
    0
      internal/elfexec/elfexec.go
  2. 7
    0
      internal/elfexec/elfexec_test.go

+ 3
- 0
internal/elfexec/elfexec.go Wyświetl plik

@@ -203,6 +203,9 @@ func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint6
203 203
 			return start - offset + loadSegment.Off - loadSegment.Vaddr, nil
204 204
 		}
205 205
 		// Various kernel heuristics and cases follow.
206
+		if loadSegment.Vaddr == start-offset {
207
+			return offset, nil
208
+		}
206 209
 		if start == 0 && limit != 0 {
207 210
 			// ChromeOS remaps its kernel to 0. Nothing else should come
208 211
 			// down this path. Empirical values:

+ 7
- 0
internal/elfexec/elfexec_test.go Wyświetl plik

@@ -37,6 +37,10 @@ func TestGetBase(t *testing.T) {
37 37
 	kernelHeader := &elf.ProgHeader{
38 38
 		Vaddr: 0xffffffff81000000,
39 39
 	}
40
+	kernelAslrHeader := &elf.ProgHeader{
41
+		Vaddr: 0xffffffff80200000,
42
+		Off:   0x1000,
43
+	}
40 44
 	ppc64KernelHeader := &elf.ProgHeader{
41 45
 		Vaddr: 0xc000000000000000,
42 46
 	}
@@ -57,6 +61,9 @@ func TestGetBase(t *testing.T) {
57 61
 		{"exec kernel", fhExec, kernelHeader, uint64p(0xffffffff81000198), 0xffffffff82000198, 0xffffffff83000198, 0, 0x1000000, false},
58 62
 		{"exec kernel", fhExec, kernelHeader, uint64p(0xffffffff810002b8), 0xffffffff81000000, 0xffffffffa0000000, 0x0, 0x0, false},
59 63
 		{"exec kernel ASLR", fhExec, kernelHeader, uint64p(0xffffffff810002b8), 0xffffffff81000000, 0xffffffffa0000000, 0xffffffff81000000, 0x0, false},
64
+		// TODO(aalexand): Figure out where this test case exactly comes from and
65
+		// whether it's still relevant.
66
+		{"exec kernel ASLR 2", fhExec, kernelAslrHeader, nil, 0xffffffff83e00000, 0xfffffffffc3fffff, 0x3c00000, 0x3c00000, false},
60 67
 		{"exec PPC64 kernel", fhExec, ppc64KernelHeader, uint64p(0xc000000000000000), 0xc000000000000000, 0xd00000001a730000, 0x0, 0x0, false},
61 68
 		{"exec chromeos kernel", fhExec, kernelHeader, uint64p(0xffffffff81000198), 0, 0x10197, 0, 0x7efffe68, false},
62 69
 		{"exec chromeos kernel 2", fhExec, kernelHeader, uint64p(0xffffffff81000198), 0, 0x10198, 0, 0x7efffe68, false},