Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion libc/libc_aarch64.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,5 @@ func extractDTVInfoARM(code []byte) (DTVInfo, error) {
return DTVInfo{
Offset: dtvOffset,
Multiplier: uint8(entryWidth),
Indirect: 1,
}, nil
}
20 changes: 0 additions & 20 deletions libc/libc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ func TestExtractDTVOffset(t *testing.T) {
info: DTVInfo{
Offset: 8,
Multiplier: 16,
Indirect: 0,
},
},
"glibc 2.32 / Fedora 33 / x86_64": {
Expand Down Expand Up @@ -361,7 +360,6 @@ func TestExtractDTVOffset(t *testing.T) {
info: DTVInfo{
Offset: 8,
Multiplier: 16,
Indirect: 0,
},
},
"musl 1.2.5 / alpine 3.22.2 / x86_64": {
Expand All @@ -383,7 +381,6 @@ func TestExtractDTVOffset(t *testing.T) {
info: DTVInfo{
Offset: 8,
Multiplier: 8,
Indirect: 1,
},
},
"musl 1.1.5 / alpine 3.1 / x86_64": {
Expand Down Expand Up @@ -411,7 +408,6 @@ func TestExtractDTVOffset(t *testing.T) {
info: DTVInfo{
Offset: 8,
Multiplier: 8,
Indirect: 1,
},
},
"glibc 2.39 / ubuntu 24.04 / aarch64": {
Expand Down Expand Up @@ -447,7 +443,6 @@ func TestExtractDTVOffset(t *testing.T) {
info: DTVInfo{
Offset: 0,
Multiplier: 16,
Indirect: 1,
},
},
"glibc / Fedora 39 / aarch64": {
Expand Down Expand Up @@ -486,7 +481,6 @@ func TestExtractDTVOffset(t *testing.T) {
info: DTVInfo{
Offset: 0,
Multiplier: 16,
Indirect: 1,
},
},
"glibc / Fedora 33 / aarch64": {
Expand Down Expand Up @@ -515,7 +509,6 @@ func TestExtractDTVOffset(t *testing.T) {
info: DTVInfo{
Offset: 0,
Multiplier: 16,
Indirect: 1,
},
},

Expand All @@ -532,7 +525,6 @@ func TestExtractDTVOffset(t *testing.T) {
info: DTVInfo{
Offset: -8,
Multiplier: 8,
Indirect: 1,
},
},
}
Expand Down Expand Up @@ -575,7 +567,6 @@ func TestLibcInfoIsEqual(t *testing.T) {
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
right: LibcInfo{
Expand All @@ -587,7 +578,6 @@ func TestLibcInfoIsEqual(t *testing.T) {
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
expectEqual: true,
Expand All @@ -598,7 +588,6 @@ func TestLibcInfoIsEqual(t *testing.T) {
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
right: LibcInfo{
Expand Down Expand Up @@ -652,15 +641,13 @@ func TestLibcInfoMerge(t *testing.T) {
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
expected: LibcInfo{
TSDInfo{},
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
},
Expand All @@ -670,7 +657,6 @@ func TestLibcInfoMerge(t *testing.T) {
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
right: LibcInfo{
Expand All @@ -690,7 +676,6 @@ func TestLibcInfoMerge(t *testing.T) {
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
},
Expand All @@ -708,7 +693,6 @@ func TestLibcInfoMerge(t *testing.T) {
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
expected: LibcInfo{
Expand All @@ -720,7 +704,6 @@ func TestLibcInfoMerge(t *testing.T) {
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
},
Expand All @@ -737,7 +720,6 @@ func TestLibcInfoMerge(t *testing.T) {
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
right: LibcInfo{
Expand All @@ -749,7 +731,6 @@ func TestLibcInfoMerge(t *testing.T) {
DTVInfo{
Offset: 8,
Multiplier: 16,
Indirect: 1,
},
},
expected: LibcInfo{
Expand All @@ -761,7 +742,6 @@ func TestLibcInfoMerge(t *testing.T) {
DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 0,
},
},
},
Expand Down
8 changes: 3 additions & 5 deletions libc/libc_x86.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ func extractDTVInfoX86(code []byte) (DTVInfo, error) {
entryWidth = e.NewImmediateCapture("entryWidth")
)

// Pattern 1: glibc - Direct DTV access
// Pattern 1: glibc - DTV pointer loaded from FS:offset, then indexed
// FS:offset is a memory load that retrieves the DTV pointer, so this is
// indirect access (two dereferences: load DTV ptr, then index into DTV).
expected := e.Add(
e.Mem8(
e.Add(
Expand All @@ -122,7 +124,6 @@ func extractDTVInfoX86(code []byte) (DTVInfo, error) {
return DTVInfo{
Offset: int16(dtvOffset.CapturedValue() & 0xFFFF),
Multiplier: uint8(entryWidth.CapturedValue()),
Indirect: 0,
}, nil
}

Expand All @@ -145,7 +146,6 @@ func extractDTVInfoX86(code []byte) (DTVInfo, error) {
return DTVInfo{
Offset: int16(dtvOffset.CapturedValue() & 0xFFFF),
Multiplier: uint8(entryWidth.CapturedValue()),
Indirect: 1,
}, nil
}

Expand All @@ -164,7 +164,6 @@ func extractDTVInfoX86(code []byte) (DTVInfo, error) {
return DTVInfo{
Offset: int16(dtvOffset.CapturedValue() & 0xFFFF),
Multiplier: uint8(entryWidth.CapturedValue()),
Indirect: 1,
}, nil
}

Expand All @@ -184,7 +183,6 @@ func extractDTVInfoX86(code []byte) (DTVInfo, error) {
return DTVInfo{
Offset: int16(dtvOffset.CapturedValue() & 0xFFFF),
Multiplier: uint8(entryWidth.CapturedValue()),
Indirect: 1,
}, nil
}

Expand Down
1 change: 0 additions & 1 deletion processmanager/processinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func TestAssignLibcInfoMergesLibcInfo(t *testing.T) {
libc.DTVInfo{
Offset: -8,
Multiplier: 16,
Indirect: 1,
},
}

Expand Down
13 changes: 7 additions & 6 deletions support/ebpf/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,16 @@ typedef struct TSDInfo {
} TSDInfo;

// DTVInfo contains data needed to read Thread Local Storage (TLS) values, which
// are located using the Dynamic Thread Vector (DTV)
// are located using the Dynamic Thread Vector (DTV).
// DTV access is always indirect: TP+offset yields a pointer to the DTV array,
// which must be dereferenced before indexing by module ID. This is true for
// both glibc and musl (the DTV is a separately-allocated array, not inline
// in the thread control block).
typedef struct DTVInfo {
// Offset is the offset of DTV from FS base (or from thread pointer)
// Offset is the offset of the DTV pointer from the thread pointer base.
s16 offset;
// Multiplier is the size of each DTV entry in bytes
// Typically 8 bytes on 64bit musl and 16 bytes on 64bit glibc
// Multiplier is the size of each DTV entry in bytes.
u8 multiplier;
// Indirect is 0 if DTV is at FS+offset, 1 if at [FS+0]+offset
u8 indirect;
} DTVInfo;

// DotnetProcInfo is a container for the data needed to build stack trace for a dotnet process.
Expand Down
2 changes: 1 addition & 1 deletion support/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.