Skip to content

interpreter/golables: use .gopclntab for symbol lookup#728

Merged
christos68k merged 5 commits intomainfrom
issue-718-2
Aug 29, 2025
Merged

interpreter/golables: use .gopclntab for symbol lookup#728
christos68k merged 5 commits intomainfrom
issue-718-2

Conversation

@florianl
Copy link
Copy Markdown
Member

@florianl florianl commented Aug 25, 2025

Use the mmap backed .gopclntab to lookup symbols for golabels.

Supersedes #719 Fixes #718

…irect case

Use the mmap backed .gopclntab to lookup symbols for golabels.

While further investigating the topic, a case with an indirect offset was also identified:

```
$ objdump -S -d go/src/github.com/open-telemetry/opentelemetry-ebpf-profiler/ebpf-profiler | grep -A 3 'runtime.stackcheck'
0000000000480700 <runtime.stackcheck.abi0>:
  480700:	64 48 8b 04 25 f8 ff 	mov    %fs:0xfffffffffffffff8,%rax
  480707:	ff ff
  480709:	48 39 60 08          	cmp    %rsp,0x8(%rax)
  48070d:	77 05                	ja     480714 <runtime.stackcheck.abi0+0x14>

$ sudo objdump -S -d elastic-agent-9.1.1-51565f/elastic-agent | grep -A 3 8945a20
0000000008945a20 <runtime.stackcheck.abi0@@base>:
     8945a20:	48 8b 0d a1 c5 d0 17 	mov    0x17d0c5a1(%rip),%rcx        # 20651fc8 <runtime.tlsg@@base+0x20651fc8>
     8945a27:	64 48 8b 01          	mov    %fs:(%rcx),%rax
     8945a2b:	48 39 60 08          	cmp    %rsp,0x8(%rax)
     8945a2f:	77 05                	ja     8945a36 <runtime.stackcheck.abi0@@base+0x16>
```

Supersedes #719
Fixes #718

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Copy link
Copy Markdown
Contributor

@fabled fabled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment for extractOffsetFromBytes on rebasing reasons.

This said, could you rebase this on top of the other PR, and include:

  • the gopclntab symbol lookup
  • the amd64 unit test cases for extracting offset
  • if time permits, add arm64 unit test cases for extracting the offset

Otherwise looks good. Thanks!

Comment thread interpreter/golabels/tls_amd64.go Outdated
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
@florianl florianl changed the title interpreter/golables: use .gopclntab for symbol lookup and handle ind… interpreter/golables: use .gopclntab for symbol lookup Aug 26, 2025
Copy link
Copy Markdown
Contributor

@fabled fabled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks good, API could be made to be same as in other similar places.

Comment thread nativeunwind/elfunwindinfo/elfgopclntab.go Outdated
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Comment thread nativeunwind/elfunwindinfo/elfgopclntab.go
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Copy link
Copy Markdown
Contributor

@fabled fabled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@christos68k christos68k merged commit 7e152e9 into main Aug 29, 2025
28 checks passed
@christos68k christos68k deleted the issue-718-2 branch August 29, 2025 08:07
gnurizen pushed a commit to parca-dev/opentelemetry-ebpf-profiler that referenced this pull request Sep 30, 2025
…y#728)

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
umanwizard pushed a commit to parca-dev/opentelemetry-ebpf-profiler that referenced this pull request Feb 17, 2026
…y#728)

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
umanwizard pushed a commit to parca-dev/opentelemetry-ebpf-profiler that referenced this pull request Feb 18, 2026
…y#728)

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

failed to read .symtab: section not present

3 participants