Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Wrapper for invoking the BFD loader | 6 """Wrapper for invoking the BFD loader |
| 7 | 7 |
| 8 A simple script to invoke the bfd loader instead of gold, removing | 8 A simple script to invoke the bfd loader instead of gold, removing |
| 9 threading command line options that the bfd loader doesn't support. | 9 threading command line options that the bfd loader doesn't support. |
| 10 Because this script is invoked from gcc via the -B flag, it needs | 10 Because this script is invoked from gcc via the -B flag, it needs |
| 11 to be in a file named "ld". | 11 to be in a file named "ld". |
| 12 """ | 12 """ |
| 13 | 13 |
| 14 import os | 14 import os |
| 15 import subprocess | 15 import subprocess |
| 16 import sys | 16 import sys |
| 17 | 17 |
| 18 # TODO(bradchen): Delete this script when Gold supports -Ttext properly. | 18 # TODO(bradchen): Delete this script when Gold supports -Ttext properly. |
| 19 # It should be fixed by this patch: | 19 # It should be fixed by this patch: |
| 20 # http://sourceware.org/ml/binutils/2011-07/msg00206.html | 20 # http://sourceware.org/ml/binutils/2011-07/msg00206.html |
| 21 def main(): | 21 def main(): |
| 22 LD_BFD = "/usr/bin/ld.bfd" | 22 LD_BFD = "/usr/bin/ld.bfd" |
| 23 if not (os.path.exists(LD_BFD) and os.access(LD_BFD, os.X_OK)): | 23 CROS_TARGET = os.getenv("CTARGET") |
| 24 # Can't find the BFD loader, so invoke the unmodified argv | 24 LD_TO_USE = "ld" # Default to ld on search path |
| 25 args = sys.argv | 25 |
| 26 args[0] = "ld" | 26 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
| |
| 27 print "ld_bfd/ld: using ld" | 27 CROS_LD_BFD = "/usr/bin/" + CROS_TARGET + "-ld.bfd" |
| 28 sys.exit(subprocess.call(args)) | 28 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.
| |
| 29 # found the BFD loader, so use it | 29 LD_TO_USE = CROS_LD_BFD |
| 30 elif (os.path.exists(LD_BFD) and os.access(LD_BFD, os.X_OK)): | |
| 31 LD_TO_USE = LD_BFD | |
| 32 | |
| 30 args = list() | 33 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.
| |
| 31 args.append("/usr/bin/ld.bfd") | 34 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.
| |
| 35 # 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.
| |
| 32 for arg in sys.argv[1:]: | 36 for arg in sys.argv[1:]: |
| 33 if arg == "-Wl,--threads" or arg == "--threads": | 37 if arg == "-Wl,--threads" or arg == "--threads": |
| 34 continue | 38 continue |
| 35 if arg == "-Wl,--thread-count=4" or arg == "--thread-count=4": | 39 if arg == "-Wl,--thread-count=4" or arg == "--thread-count=4": |
| 36 continue | 40 continue |
| 37 if arg == "--icf=none": | 41 if arg == "--icf=none": |
| 38 continue | 42 continue |
| 39 args.append(arg) | 43 args.append(arg) |
| 40 print("ld_bfd/ld: exec ", args) | 44 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
| |
| 41 sys.exit(subprocess.call(args)) | 45 sys.exit(subprocess.call(args)) |
| 42 | 46 |
| 43 if __name__ == "__main__": | 47 if __name__ == "__main__": |
| 44 main() | 48 main() |
| OLD | NEW |