Chromium Code Reviews| Index: tools/ld_bfd/ld |
| diff --git a/tools/ld_bfd/ld b/tools/ld_bfd/ld |
| index 124f202a5fa89d9b5dd2f9613611cd6e8bd3b40b..71c4cd01f74d5c00de9737d8ebe40779f5c8ffb4 100755 |
| --- a/tools/ld_bfd/ld |
| +++ b/tools/ld_bfd/ld |
| @@ -20,15 +20,19 @@ import sys |
| # http://sourceware.org/ml/binutils/2011-07/msg00206.html |
| 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 |
| + CROS_TARGET = os.getenv("CTARGET") |
| + LD_TO_USE = "ld" # Default to ld on search path |
| + |
| + if (CROS_TARGET): |
|
Roland McGrath
2011/09/07 17:21:17
Parens are superfluous here and contrary to standa
Brad Chen
2011/09/07 19:05:40
This if statement has been removed.
On 2011/09/07
|
| + CROS_LD_BFD = "/usr/bin/" + CROS_TARGET + "-ld.bfd" |
| + if (os.path.exists(CROS_LD_BFD) and os.access(CROS_LD_BFD, os.X_OK)): |
|
Roland McGrath
2011/09/07 17:21:17
Parens superfluous. os.path.exists test is superf
Brad Chen
2011/09/07 19:05:40
Done.
|
| + LD_TO_USE = CROS_LD_BFD |
| + elif (os.path.exists(LD_BFD) and os.access(LD_BFD, os.X_OK)): |
| + LD_TO_USE = LD_BFD |
| + |
| args = list() |
|
Roland McGrath
2011/09/07 17:21:17
Standard style would use [] here instead of list()
Brad Chen
2011/09/07 19:05:40
Done.
|
| - args.append("/usr/bin/ld.bfd") |
| + args.append(LD_TO_USE) |
|
Roland McGrath
2011/09/07 17:21:17
In fact, just replace both lines with: args = [LD_
Brad Chen
2011/09/07 19:05:40
Done.
|
| + # Omit arguments that are gold-specific, not supported by BFD loader |
|
Roland McGrath
2011/09/07 17:21:17
This logic is pretty fragile, and it's wholly unne
Brad Chen
2011/09/07 19:05:40
Done.
|
| for arg in sys.argv[1:]: |
| if arg == "-Wl,--threads" or arg == "--threads": |
| continue |
| @@ -37,7 +41,7 @@ def main(): |
| if arg == "--icf=none": |
| continue |
| args.append(arg) |
| - print("ld_bfd/ld: exec ", args) |
| + print("tools/ld_bfd/ld: exec ", args) |
|
Roland McGrath
2011/09/07 17:21:17
This would be easier to cut&paste for debugging pu
Brad Chen
2011/09/07 19:05:40
I don't quite understand what you're looking for h
|
| sys.exit(subprocess.call(args)) |
| if __name__ == "__main__": |