[PATCH AUTOSEL 4.19 3/3] scripts/recordmcount.pl: support big endian for ARCH sh

From: Sasha Levin
Date: Mon Feb 15 2021 - 13:42:58 EST


From: Rong Chen <rong.a.chen@xxxxxxxxx>

[ Upstream commit 93ca696376dd3d44b9e5eae835ffbc84772023ec ]

The kernel test robot reported the following issue:

CC [M] drivers/soc/litex/litex_soc_ctrl.o
sh4-linux-objcopy: Unable to change endianness of input file(s)
sh4-linux-ld: cannot find drivers/soc/litex/.tmp_gl_litex_soc_ctrl.o: No such file or directory
sh4-linux-objcopy: 'drivers/soc/litex/.tmp_mx_litex_soc_ctrl.o': No such file

The problem is that the format of input file is elf32-shbig-linux, but
sh4-linux-objcopy wants to output a file which format is elf32-sh-linux:

$ sh4-linux-objdump -d drivers/soc/litex/litex_soc_ctrl.o | grep format
drivers/soc/litex/litex_soc_ctrl.o: file format elf32-shbig-linux

Link: https://lkml.kernel.org/r/20210210150435.2171567-1-rong.a.chen@xxxxxxxxx
Link: https://lore.kernel.org/linux-mm/202101261118.GbbYSlHu-lkp@xxxxxxxxx
Signed-off-by: Rong Chen <rong.a.chen@xxxxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Cc: Yoshinori Sato <ysato@xxxxxxxxxxxxx>
Cc: Rich Felker <dalias@xxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
scripts/recordmcount.pl | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index f599031260d51..7f6f96256b09f 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -263,7 +263,11 @@ if ($arch eq "x86_64") {

# force flags for this arch
$ld .= " -m shlelf_linux";
- $objcopy .= " -O elf32-sh-linux";
+ if ($endian eq "big") {
+ $objcopy .= " -O elf32-shbig-linux";
+ } else {
+ $objcopy .= " -O elf32-sh-linux";
+ }

} elsif ($arch eq "powerpc") {
my $ldemulation;
--
2.27.0