foss-for-synopsys-dwc-arc-processors / linux

Helpful resources for users & developers of Linux kernel for ARC
22 stars 13 forks source link

ARC: elf: print warning on arch mismatch #45

Closed VVIsaev closed 3 years ago

VVIsaev commented 3 years ago

In some shells (e.g. busybox's ash) it is not clear why the binary is not executed. After this change kernel will print following message for such cases:

ELF is not built for bit ISA

Signed-off-by: Vladimir Isaev isaev@synopsys.com

VVIsaev commented 3 years ago

This is RFC review for the issue #44 .

I resurrected commit 33b1a2 for this branch, so now we have following messages (in console) on exec ARCv2 binaries on ARCv3:

# ./main
ELF is not built for ARCv3 64 bit ISA
ELF is not built for ARCv3 64 bit ISA
./main: line 1: syntax error: unexpected "("

Message is printed two times because exec in kernel uses this algorithm: exec -> try to modprobe module for missing binary format -> exec again.

So actually this change prints warning, but may confuse the user with the duplication.

vineetgarc commented 3 years ago

@VVIsaev did u rework the code per my comments ?

VVIsaev commented 3 years ago

My only concern about this solution is following: After this change for incorrect elf message will be printed twice:

# ./main
ELF is not built for ARCv3 64 bit ISA
ELF is not built for ARCv3 64 bit ISA
./main: line 1: syntax error: unexpected "("

As I can understand this is because kernel tries to load module with correct binary format and then tries to exec one more time. So maybe it is a little confusing for unaware user, but for developer needs I think this is OK.