Skip to content

Commit 5f07a80

Browse files
committed
fix: handle situations where linked binary does not link against a libc flavor
We have seen in the Dash0 operator that there are situations in which a dynamically linked binary does not actually link *also* to a libc flavor (in our case it was a Go binaru with cgo disable, with the flag `-buildmode=pie` set at build time. THis causes the linker to fail because the weak symbol __environ required by the injector did not exist. This commit provides a fallback weak __environ symbol, which will be overwritten by the strong __environ symbol of any libc flavor.
1 parent 4334932 commit 5f07a80

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

autoinstrumentation/injector/src/injector.c

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"-javaagent:" \
1313
"/otel-auto-instrumentation-injector/instrumentation/jvm/javaagent.jar"
1414

15+
// Provide a fallback weak symbol, in case the linked binary
16+
// does not actually link against a libc flavor.
17+
__attribute__((weak)) char **__environ = NULL;
18+
1519
extern char **__environ;
1620

1721
size_t __strlen(const char *s) {
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
global:
33
getenv;
4+
__environ;
45
local:
56
*;
67
};

0 commit comments

Comments
 (0)