| Index: tools/ld_bfd/ld
|
| diff --git a/tools/ld_bfd/ld b/tools/ld_bfd/ld
|
| index 124f202a5fa89d9b5dd2f9613611cd6e8bd3b40b..b43fd974f8383fc19f7e576792c18fb1eebeb94b 100755
|
| --- a/tools/ld_bfd/ld
|
| +++ b/tools/ld_bfd/ld
|
| @@ -15,29 +15,38 @@ import os
|
| import subprocess
|
| import sys
|
|
|
| -# TODO(bradchen): Delete this script when Gold supports -Ttext properly.
|
| -# It should be fixed by this patch:
|
| -# http://sourceware.org/ml/binutils/2011-07/msg00206.html
|
| +# TODO(bradchen): Delete this script when Gold supports linker scripts properly.
|
| +
|
| +def PathTo(fname):
|
| + if fname[0] == os.pathsep:
|
| + return fname
|
| + for p in os.environ["PATH"].split(os.pathsep):
|
| + fpath = os.path.join(p, fname)
|
| + if os.path.exists(fpath):
|
| + return fpath
|
| + return fname
|
| +
|
| +def FindLDBFD():
|
| + cxx = os.getenv("CXX")
|
| + if not cxx:
|
| + cxx = "gcc"
|
| + popen = subprocess.Popen(cxx + " -print-prog-name=ld",
|
| + shell=True,
|
| + stdout=subprocess.PIPE,
|
| + stdin=subprocess.PIPE)
|
| + (ld, error) = popen.communicate()
|
| + if popen.wait() != 0:
|
| + print "Could not find ld:" + error
|
| + return "ld"
|
| + ld = ld.strip()
|
| + ld_bfd = PathTo(ld + ".bfd")
|
| + if os.path.exists(ld_bfd) and os.access(ld_bfd, os.X_OK):
|
| + return ld_bfd
|
| + return ld
|
| +
|
| def main():
|
| - LD_BFD = "/usr/bin/ld.bfd"
|
| - if not (os.path.exists(LD_BFD) and os.access(LD_BFD, os.X_OK)):
|
| - # Can't find the BFD loader, so invoke the unmodified argv
|
| - args = sys.argv
|
| - args[0] = "ld"
|
| - print "ld_bfd/ld: using ld"
|
| - sys.exit(subprocess.call(args))
|
| - # found the BFD loader, so use it
|
| - args = list()
|
| - args.append("/usr/bin/ld.bfd")
|
| - for arg in sys.argv[1:]:
|
| - if arg == "-Wl,--threads" or arg == "--threads":
|
| - continue
|
| - if arg == "-Wl,--thread-count=4" or arg == "--thread-count=4":
|
| - continue
|
| - if arg == "--icf=none":
|
| - continue
|
| - args.append(arg)
|
| - print("ld_bfd/ld: exec ", args)
|
| + args = [FindLDBFD()] + sys.argv[1:]
|
| + print("tools/ld_bfd/ld: exec ", args)
|
| sys.exit(subprocess.call(args))
|
|
|
| if __name__ == "__main__":
|
|
|