Re: Using a custom LDFLAG for all objects and binaries
From: Randy Dunlap
Date: Sun May 10 2020 - 15:08:32 EST
On 5/10/20 12:04 PM, Mahmood Naderan wrote:
>>> or
>>> 2- Editing arch/x86/Makefile with
>>> KBUILD_LDFLAGS := -m --emit-relocs elf_$(UTS_MACHINE)
>>
>> That should work.
>
>
> Seems not... I ran the following commands:
>
> $ cp -v /boot/config-$(uname -r) .config
> $ make menuconfig -> Exit -> Save
> $ vim arch/x86/Makefile
> KBUILD_LDFLAGS := -m --emit-relocs elf_$(UTS_MACHINE)
> $ make V=1
OK, I suggest that you reorder the options like so:
KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE) --emit-relocs
I.e., don't split -m and the machine type.
> This is the error that I get
>
> make -f ./scripts/Makefile.build obj=usr need-builtin=1
> /bin/bash ./usr/gen_initramfs_list.sh -l -d > usr/.initramfs_data.cpio.d
> (cat /dev/null; ) > usr/modules.order
> make -f ./scripts/Makefile.build obj=arch/x86 need-builtin=1
> make -f ./scripts/Makefile.build obj=arch/x86/crypto need-builtin=1
> make -f ./scripts/Makefile.build obj=arch/x86/crypto/sha1-mb need-builtin=
> (cat /dev/null; echo kernel/arch/x86/crypto/sha1-mb/sha1-mb.ko;) >
> arch/x86/crypto/sha1-mb/modules.order
> ld -m --emit-relocs elf_x86_64 -r -o
> arch/x86/crypto/sha1-mb/sha1-mb.o arch/x86/crypto/sha1-mb/sha1_mb.o
> arch/x86/crypto/sha1-mb/sha1_mb_mgr_flush_avx2.o
> arch/x86/crypto/sha1-mb/sha1_mb_mgr_init_avx2.o
> arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.o
> arch/x86/crypto/sha1-mb/sha1_x8_avx2.o
> ld: unrecognised emulation mode: --emit-relocs
> Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu
> i386linux elf_l1om elf_k1om i386pep i386pe
> scripts/Makefile.build:516: recipe for target
> 'arch/x86/crypto/sha1-mb/sha1-mb.o' failed
> make[3]: *** [arch/x86/crypto/sha1-mb/sha1-mb.o] Error 1
> scripts/Makefile.build:544: recipe for target 'arch/x86/crypto/sha1-mb' failed
> make[2]: *** [arch/x86/crypto/sha1-mb] Error 2
> scripts/Makefile.build:544: recipe for target 'arch/x86/crypto' failed
> make[1]: *** [arch/x86/crypto] Error 2
> Makefile:1053: recipe for target 'arch/x86' failed
> make: *** [arch/x86] Error 2
>
>
>
>
>
> ORIGINAL QUESTION:
>
>> Hi
>> I would like to modify the kernel makefile in a way to include
>> --emit-relocs for every file that is linked during the process of
>> kernel make.
>> I see
>>
>> KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
>> LDFLAGS_MODULE =
>> LDFLAGS_vmlinux =
>> ...
>>
>> But I don't know which one is the main. Should I put that option in
>> front of every LD* variable? Or it is possible to apply one variable
>> for every file that is linked?
>> Appreciate your help.
>>
>
>
> Regards,
> Mahmood
>
--
~Randy