Revert "Sandbox soong_build by changing to root directory"

This reverts commit 05c25ccb4adb5329add700b533416c226cdbfa96.

Reason for revert: broke absolute OUT_DIR
Bug: 146437378

Change-Id: I523ed79d40e1c1ef040212ba794a7a084abea75d
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 5744bb2..b8423be 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -16,6 +16,7 @@
 
 import (
 	"fmt"
+	"os"
 	"path/filepath"
 	"strings"
 
@@ -254,8 +255,16 @@
 	depsPath := android.PathForSource(ctx, "bionic/libc/versioner-dependencies")
 	depsGlob := ctx.Glob(filepath.Join(depsPath.String(), "**/*"), nil)
 	for i, path := range depsGlob {
-		if ctx.IsSymlink(path) {
-			dest := ctx.Readlink(path)
+		fileInfo, err := os.Lstat(path.String())
+		if err != nil {
+			ctx.ModuleErrorf("os.Lstat(%q) failed: %s", path.String, err)
+		}
+		if fileInfo.Mode()&os.ModeSymlink == os.ModeSymlink {
+			dest, err := os.Readlink(path.String())
+			if err != nil {
+				ctx.ModuleErrorf("os.Readlink(%q) failed: %s",
+					path.String, err)
+			}
 			// Additional .. to account for the symlink itself.
 			depsGlob[i] = android.PathForSource(
 				ctx, filepath.Clean(filepath.Join(path.String(), "..", dest)))