Skip to content

feat: apply custom labels patch#16

Closed
elsakeirouz wants to merge 1 commit intonsavoire/update_upstreamfrom
elsa/custom-labels-for-trace-corr
Closed

feat: apply custom labels patch#16
elsakeirouz wants to merge 1 commit intonsavoire/update_upstreamfrom
elsa/custom-labels-for-trace-corr

Conversation

@elsakeirouz
Copy link
Copy Markdown

  • .github/workflows/unit-test-on-pull-request.yml
  • Makefile
  • customlabelstest/customlabels_test.go
  • host/host.go
  • interpreter/customlabels/customlabels.go
  • libpf/interpretertype.go
  • libpf/pfelf/file.go
  • libpf/trace.go
  • processmanager/ebpf/ebpf.go
  • processmanager/execinfomanager/manager.go
  • processmanager/manager.go
  • remotememory/remotememory.go
  • rust-crates/custom-labels-example/Cargo.lock
  • rust-crates/custom-labels-example/Cargo.toml
  • rust-crates/custom-labels-example/build.rs
  • rust-crates/custom-labels-example/src/main.rs
  • support/ebpf/interpreter_dispatcher.ebpf.c
  • support/ebpf/native_stack_trace.ebpf.c
  • support/ebpf/tracemgmt.h
  • support/ebpf/tracer.ebpf.amd64
  • support/ebpf/types.h
  • support/ebpf/util.h
  • tools/coredump/coredump.go
  • tracer/tracer.go

@elsakeirouz elsakeirouz force-pushed the elsa/custom-labels-for-trace-corr branch from cb16a5a to cda6ff4 Compare April 22, 2025 14:23
@elsakeirouz elsakeirouz self-assigned this Apr 22, 2025
@elsakeirouz elsakeirouz added the enhancement New feature or request label Apr 22, 2025
@elsakeirouz elsakeirouz force-pushed the elsa/custom-labels-for-trace-corr branch 3 times, most recently from 62491ea to 877b6e4 Compare April 22, 2025 15:03
* .github/workflows/unit-test-on-pull-request.yml
* Makefile
* customlabelstest/customlabels_test.go
* host/host.go
* interpreter/customlabels/customlabels.go
* libpf/interpretertype.go
* libpf/pfelf/file.go
* libpf/trace.go
* processmanager/ebpf/ebpf.go
* processmanager/execinfomanager/manager.go
* processmanager/manager.go
* processmanager/manager_test.go
* remotememory/remotememory.go
* rust-crates/custom-labels-example/Cargo.lock
* rust-crates/custom-labels-example/Cargo.toml
* rust-crates/custom-labels-example/build.rs
* rust-crates/custom-labels-example/src/main.rs
* support/ebpf/interpreter_dispatcher.ebpf.c
* support/ebpf/native_stack_trace.ebpf.c
* support/ebpf/tracemgmt.h
* support/ebpf/tracer.ebpf.amd64
* support/ebpf/types.h
* support/ebpf/util.h
* testutils/helpers.go
* tools/coredump/coredump.go
* tracer/tracer.go
@elsakeirouz elsakeirouz force-pushed the elsa/custom-labels-for-trace-corr branch from 877b6e4 to 4a3ba07 Compare April 22, 2025 15:44
@elsakeirouz elsakeirouz deleted the elsa/custom-labels-for-trace-corr branch April 23, 2025 14:33
nsavoire added a commit that referenced this pull request Aug 21, 2025
Go binaries built with -buildmode=pie have slightly different assembly code.
On arm64, the runtime.load_g symbol has 2 mov (movz and movk) instructions
instead of 1 mov:

0x00000000000c2290 <+0>:	adrp	x27, 0x2ca000 <runtime.itabTableInit+3072>
0x00000000000c2294 <+4>:	ldrsb	x0, [x27, #1766]
0x00000000000c2298 <+8>:	cbz	x0, 0xc22ac <runtime.load_g+28>
0x00000000000c229c <+12>:	mrs	x0, tpidr_el0
0x00000000000c22a0 <+16>:	movz	x27, #0x0, lsl #16
0x00000000000c22a4 <+20>:	movk	x27, #0x10
0x00000000000c22a8 <+24>:	ldr	x28, [x0, x27]
0x00000000000c22ac <+28>:	ret

And on amd64, the runtime.stackcheck symbol has also 2 mov instructions instead of 1:
0x00000000007ec320 <+0>:	mov    $0xfffffffffffffff8,%rcx
0x00000000007ec327 <+7>:	mov    %fs:(%rcx),%rax

This commit fixes the TLS offset retrieval for both architectures.
On amd64, it uses amd.Interpreter to find the mov instruction with fs segment
and then determine the offset into the segment when displacement is a register.
On arm64, it looks for mov or movk instructions (ignoring movz instruction since
it seems to always be 0).
nsavoire added a commit that referenced this pull request Sep 1, 2025
Go binaries built with -buildmode=pie have slightly different assembly code.
On arm64, the runtime.load_g symbol has 2 mov (movz and movk) instructions
instead of 1 mov:

0x00000000000c2290 <+0>:	adrp	x27, 0x2ca000 <runtime.itabTableInit+3072>
0x00000000000c2294 <+4>:	ldrsb	x0, [x27, #1766]
0x00000000000c2298 <+8>:	cbz	x0, 0xc22ac <runtime.load_g+28>
0x00000000000c229c <+12>:	mrs	x0, tpidr_el0
0x00000000000c22a0 <+16>:	movz	x27, #0x0, lsl #16
0x00000000000c22a4 <+20>:	movk	x27, #0x10
0x00000000000c22a8 <+24>:	ldr	x28, [x0, x27]
0x00000000000c22ac <+28>:	ret

And on amd64, the runtime.stackcheck symbol has also 2 mov instructions instead of 1:
0x00000000007ec320 <+0>:	mov    $0xfffffffffffffff8,%rcx
0x00000000007ec327 <+7>:	mov    %fs:(%rcx),%rax

This commit fixes the TLS offset retrieval for both architectures.
On amd64, it uses amd.Interpreter to find the mov instruction with fs segment
and then determine the offset into the segment when displacement is a register.
On arm64, it looks for mov or movk instructions (ignoring movz instruction since
it seems to always be 0).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant