Skip to content

Add support for .note.stapsdt sections#1202

Merged
marxin merged 3 commits into
wild-linker:mainfrom
marxin:support-note-stapsdt
Oct 14, 2025
Merged

Add support for .note.stapsdt sections#1202
marxin merged 3 commits into
wild-linker:mainfrom
marxin:support-note-stapsdt

Conversation

@marxin

@marxin marxin commented Oct 13, 2025

Copy link
Copy Markdown
Collaborator

Sample binary output with Wild:

Note section [39] '.note.stapsdt' of 144 bytes at offset 0x3a47bc:
  Owner          Data size  Type
  stapsdt               52  Version: 3
    PC: 0x14b36, Base: 0x13916, Semaphore: 0
    Provider: testgroup, Name: testprobe, Args: '-8@%rax'
  stapsdt               52  Version: 3
    PC: 0x14b8c, Base: 0x13916, Semaphore: 0x582ce
    Provider: lazygroup, Name: lazyprobe, Args: '-8@%rax'

readelf with ld built binary:

❯ readelf -SW bin-ld | rg 'prob|base|stap'
  [17] .stapsdt.base     PROGBITS        000000000004c152 04c152 000001 00   A  0   0  1
  [30] .probes           PROGBITS        00000000000579c0 0579c0 000002 00  WA  0   0  2
  [33] .note.stapsdt     NOTE            0000000000000000 057a14 000090 00      0   0  4

the same with Wild:

  [16] .stapsdt.base     PROGBITS        0000000000013916 013916 000001 00   A  0   0  1
  [30] .probes           PROGBITS        00000000000582ce 0562ce 000002 00  WA  0   0  2
  [39] .note.stapsdt     NOTE            0000000000000000 3a47bc 000090 00      0   0  4

Fixes: #1119

Plus, the tracing output prints filename for a loaded section (helps with navigation to the source object file).

@mati865 mati865 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should also remove stapsdt ignores from linker-diff/src/lib.rs.

Comment thread libwild/src/layout.rs Outdated
@marxin marxin requested a review from mati865 October 13, 2025 17:49
@davidlattimore

Copy link
Copy Markdown
Member

Is this section something that linkers need to deal with explicitly, or is there perhaps a more general rule that we're missing? e.g. perhaps we need to, by default, keep all sections with sh_type=NOTE. GNU ld's built-in linker script (ld --verbose) doesn't seem to mention stapsdt.

@marxin

marxin commented Oct 13, 2025

Copy link
Copy Markdown
Collaborator Author

No, you are right, there's nothing special. Let me rework the PR to cover all notes except the ones we synthetize by the linker.

@marxin marxin force-pushed the support-note-stapsdt branch from f4a39c3 to 4da6d65 Compare October 13, 2025 21:45
@marxin marxin requested a review from davidlattimore October 13, 2025 21:46
@marxin marxin force-pushed the support-note-stapsdt branch from 4da6d65 to 5bf0cba Compare October 13, 2025 21:46
@mati865

mati865 commented Oct 13, 2025

Copy link
Copy Markdown
Member

Maybe other notes sections should also be unignored from linker-diff?

@marxin

marxin commented Oct 13, 2025

Copy link
Copy Markdown
Collaborator Author

Maybe other notes sections should also be unignored from linker-diff?

Heh, what a good idea. Let's see where can we go.

@davidlattimore davidlattimore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks :-)

@marxin marxin merged commit 822c76a into wild-linker:main Oct 14, 2025
20 checks passed
@marxin marxin deleted the support-note-stapsdt branch October 14, 2025 12:04
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.

USDT probes not properly included in linked binary

3 participants