diff options
author | Alper Nebi Yasak <alpernebiyasak@gmail.com> | 2020-09-06 14:46:05 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-09-22 12:54:13 -0600 |
commit | 1e4687aa47ed269bbc82497df872f614cfafb2e9 (patch) | |
tree | bc6741781e76cb31f6e8deca52dd3ad52328959c /tools/binman | |
parent | 5ac7687827d5b414bd26ceb7de17e7a14490af34 (diff) | |
download | u-boot-1e4687aa47ed269bbc82497df872f614cfafb2e9.zip u-boot-1e4687aa47ed269bbc82497df872f614cfafb2e9.tar.gz u-boot-1e4687aa47ed269bbc82497df872f614cfafb2e9.tar.bz2 |
binman: Use target-specific tools when cross-compiling
Currently, binman always runs the compile tools like cc, objcopy, strip,
etc. using their literal name. Instead, this patch makes it use the
target-specific versions by default, derived from the tool-specific
environment variables (CC, OBJCOPY, STRIP, etc.) or from the
CROSS_COMPILE environment variable.
For example, the u-boot-elf etype directly uses 'strip'. Trying to run
the tests with 'CROSS_COMPILE=i686-linux-gnu- binman test' on an arm64
host results in the '097_elf_strip.dts' test to fail as the arm64
version of 'strip' can't understand the format of the x86 ELF file.
This also adjusts some command.Output() calls that caused test errors or
failures to use the target versions of the tools they call. After this,
patch, an arm64 host can run all tests with no errors or failures using
a correct CROSS_COMPILE value.
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman')
-rw-r--r-- | tools/binman/elf.py | 6 | ||||
-rw-r--r-- | tools/binman/elf_test.py | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/tools/binman/elf.py b/tools/binman/elf.py index f88031c..5e566e5 100644 --- a/tools/binman/elf.py +++ b/tools/binman/elf.py @@ -234,8 +234,10 @@ SECTIONS # text section at the start # -m32: Build for 32-bit x86 # -T...: Specifies the link script, which sets the start address - stdout = command.Output('cc', '-static', '-nostdlib', '-Wl,--build-id=none', - '-m32','-T', lds_file, '-o', elf_fname, s_file) + cc, args = tools.GetTargetCompileTool('cc') + args += ['-static', '-nostdlib', '-Wl,--build-id=none', '-m32', '-T', + lds_file, '-o', elf_fname, s_file] + stdout = command.Output(cc, *args) shutil.rmtree(outdir) def DecodeElf(data, location): diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index 37e1b42..e3d218a 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -186,7 +186,9 @@ class TestElf(unittest.TestCase): # Make an Elf file and then convert it to a fkat binary file. This # should produce the original data. elf.MakeElf(elf_fname, expected_text, expected_data) - stdout = command.Output('objcopy', '-O', 'binary', elf_fname, bin_fname) + objcopy, args = tools.GetTargetCompileTool('objcopy') + args += ['-O', 'binary', elf_fname, bin_fname] + stdout = command.Output(objcopy, *args) with open(bin_fname, 'rb') as fd: data = fd.read() self.assertEqual(expected_text + expected_data, data) |