golabels: adjust offset extraction
Adapt the extraction for relative offsets from RIP.
This is the case that will be supported with this PR:
0000000005f06ca0 <runtime.stackcheck.abi0@@Base>:
5f06ca0: 48 8b 0d 01 13 1b 10 mov 0x101b1301(%rip),%rcx # 160b7fa8 <runtime.tlsg@@Base+0x160b7fa8>
5f06ca7: 64 48 8b 01 mov %fs:(%rcx),%rax
5f06cab: 48 39 60 08 cmp %rsp,0x8(%rax)
5f06caf: 77 05 ja 5f06cb6 <runtime.stackcheck.abi0@@Base+0x16>
5f06cb1: e8 ca ff ff ff call 5f06c80 <runtime.abort.abi0@@Base>
5f06cb6: 48 3b 20 cmp (%rax),%rsp
5f06cb9: 77 05 ja 5f06cc0 <runtime.stackcheck.abi0@@Base+0x20>
5f06cbb: e8 c0 ff ff ff call 5f06c80 <runtime.abort.abi0@@Base>
5f06cc0: c3 ret
Could you add a unit test for the new sequence?
So far we don't know the reason that causes this relative offset from RIP. I can name a bunch of Go executables (each multiple MB in size) that have this relative offset. But adding them to the repo as test feels wrong.
And the use of f.VirtualMemory() makes it hard to construct a mocked test. An option could be to split extractTLSGOffset() into several parts, like (a) identify gopclntab, (b) walk code and (c) introduce a function to read the memory, so that f.VirtualMemory() can be mocked for tests. Should we got this route @fabled ?
@fabled I did add a unit test with https://github.com/open-telemetry/opentelemetry-ebpf-profiler/pull/890/commits/abc27ccc414ccecf5eb7ed80f08f0cd1eb6d1b93 as described in https://github.com/open-telemetry/opentelemetry-ebpf-profiler/pull/890#issuecomment-3450486920.
Closing, as it is blocked by https://github.com/open-telemetry/opentelemetry-ebpf-profiler/pull/984. Once https://github.com/open-telemetry/opentelemetry-ebpf-profiler/pull/984 is merged, I will open a new PR. Due to changes to EasyCLA I can not apply changes to this branch anymore.