summaryrefslogtreecommitdiff
path: root/ld/ldmain.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-10-29 18:09:39 +1030
committerAlan Modra <amodra@gmail.com>2018-10-29 18:21:05 +1030
commit55d5520ae35a2b0ce788bd6d43dd619043e887f7 (patch)
tree0314724392e129e42a5fb3ea0fdb19182080555b /ld/ldmain.c
parent8d1015a887c18c363d9bd707b13348daf4e5f556 (diff)
downloadbinutils-gdb-55d5520ae35a2b0ce788bd6d43dd619043e887f7.tar.gz
Simplify --sysroot=/
Prepending '/' to absolute paths doesn't gain us much, and results in the current implementation of --trace emitting silly path-in-sysroot output, eg. /lib/ld-linux-x86-64.so.2 (//lib/ld-linux-x86-64.so.2) * ldmain.c (get_sysroot): Return "" for "--sysroot=/".
Diffstat (limited to 'ld/ldmain.c')
-rw-r--r--ld/ldmain.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 464192049ab..6f3ce6f8100 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -584,21 +584,25 @@ static const char *
get_sysroot (int argc, char **argv)
{
int i;
- const char *path;
+ const char *path = NULL;
for (i = 1; i < argc; i++)
if (CONST_STRNEQ (argv[i], "--sysroot="))
- return argv[i] + strlen ("--sysroot=");
+ path = argv[i] + strlen ("--sysroot=");
- path = get_relative_sysroot (BINDIR);
- if (path)
- return path;
+ if (!path)
+ path = get_relative_sysroot (BINDIR);
- path = get_relative_sysroot (TOOLBINDIR);
- if (path)
- return path;
+ if (!path)
+ path = get_relative_sysroot (TOOLBINDIR);
+
+ if (!path)
+ path = TARGET_SYSTEM_ROOT;
+
+ if (IS_DIR_SEPARATOR (*path) && path[1] == 0)
+ path = "";
- return TARGET_SYSTEM_ROOT;
+ return path;
}
/* We need to find any explicitly given emulation in order to initialize the