Bug 194091

Summary: Some modules are linked with wrong emulation (-m) type
Product: Other Reporter: georgerim
Component: OtherAssignee: other_other
Status: NEW ---    
Severity: normal CC: ndesaulniers, rafael
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: All Subsystem:
Regression: No Bisected commit-id:
Attachments: patch

Description georgerim 2017-02-06 14:23:59 UTC
Created attachment 254251 [details]
patch

Hello,

I am one of LLD linkers developer and we faced with a little issue while tried to link the kernel with our linker.

Next line specifies general -m option:
https://github.com/torvalds/linux/blob/master/arch/x86/Makefile#L173

Problem we are observing that arch/x86/boot and arch/x86/realmode/rm modules
has i386 object files, but linked with -m elf_x86_64 linker flag.

GNU linkers accepts that. Though out linker errors out when mets inconsistency of emulation and input files. And we think it is correct and probably do not want to relax this behavior without reasons.

So, I suggest to add -m elf_i386 option to the next lines:

https://github.com/torvalds/linux/blob/master/arch/x86/realmode/rm/Makefile#L50
https://github.com/torvalds/linux/blob/master/arch/x86/boot/Makefile#L102

This resolves the issue for us. Suggested patch attached.
Comment 1 Nick Desaulniers 2018-12-07 18:12:27 UTC
Thanks for the recommendation and patch.  That matches up with what other developers have suggested in https://github.com/ClangBuiltLinux/linux/issues/30.  I will send that patch upstream, as per discussions in https://bugs.llvm.org/show_bug.cgi?id=37432.  Thank you for taking the time to write it, and attach it here.
Comment 2 Nick Desaulniers 2018-12-11 21:01:20 UTC
We have sent the attached patch upstream to the kernel (trying to find a link...), will update this bug once we get feedback.
Comment 3 Nick Desaulniers 2018-12-18 18:20:18 UTC
https://lkml.org/lkml/2018/12/12/784