aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Bosch <tbosch@google.com>2019-09-12 07:33:28 -0700
committerTobias Bosch <tbosch@google.com>2019-09-17 16:39:16 +0000
commit003bf2dfbca112a6ba8c19a25cab853288ea7b07 (patch)
treef3f43d0cbf5e6b50b69a3a507e6ff833f203bbce
parent858e145b7814df072f75de33ddb888b042787081 (diff)
downloadtoolchain-utils-003bf2dfbca112a6ba8c19a25cab853288ea7b07.tar.gz
Allow to pass in argv0 from ld.so via an env variable.
This is needed for the standalone toolchain that creates wrappers for all dynamically linked binaries that calls the binaries via `ld.so`. As `ld.so` does not support forwarding argv0, we are using this env variable in the wrapper script as workaround. See also https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1790440 BUG=chromium:1003841 TEST=verified manually that the standalone toolchain works with the TEST=new wrapper. Change-Id: I7b4cc056286c2da8a9c34d1cb79720b424fc2f25 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1801198 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
-rw-r--r--compiler_wrapper/command.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler_wrapper/command.go b/compiler_wrapper/command.go
index 925302fa..6c5beae1 100644
--- a/compiler_wrapper/command.go
+++ b/compiler_wrapper/command.go
@@ -24,8 +24,15 @@ type command struct {
}
func newProcessCommand() *command {
+ // This is a workaround for the fact that ld.so does not support
+ // passing in the executable name when ld.so is invoked as
+ // an executable (crbug/1003841).
+ path := os.Getenv("LD_ARGV0")
+ if path == "" {
+ path = os.Args[0]
+ }
return &command{
- Path: os.Args[0],
+ Path: path,
Args: os.Args[1:],
}
}