* umh build...
@ 2018-06-05 21:03 David Miller
2018-06-05 22:29 ` Alexei Starovoitov
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2018-06-05 21:03 UTC (permalink / raw)
To: alexei.starovoitov; +Cc: netdev
Alexei, I tried to build bpfilter on sparc64 and it shows that
CONFIG_OUTPUT_FORMAT is an x86 specific Kconfig value.
And, even if I added it, it's not clear what it should even be set to.
Right now, for example, my userland builds default to 32-bit sparc
even though I'm building a 64-bit kernel.
I think what ends up happening has to be in some way in response to
what kind of "native" binaries HOSTCC is actually building.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: umh build...
2018-06-05 21:03 umh build David Miller
@ 2018-06-05 22:29 ` Alexei Starovoitov
2018-06-05 23:42 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Alexei Starovoitov @ 2018-06-05 22:29 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On Tue, Jun 05, 2018 at 05:03:59PM -0400, David Miller wrote:
>
> Alexei, I tried to build bpfilter on sparc64 and it shows that
> CONFIG_OUTPUT_FORMAT is an x86 specific Kconfig value.
>
> And, even if I added it, it's not clear what it should even be set to.
>
> Right now, for example, my userland builds default to 32-bit sparc
> even though I'm building a 64-bit kernel.
>
> I think what ends up happening has to be in some way in response to
> what kind of "native" binaries HOSTCC is actually building.
I guess you mean native-ness not of HOSTCC, but what target rootfs will be.
I guess it's probably equal to 32 or 64-bitness of the kernel from CC.
I completely forgot that I need to fix CONFIG_OUTPUT_FORMAT.
On my arm64 I just did
export CONFIG_OUTPUT_FORMAT=elf64-littleaarch64
before doing 'make'.
I can do a hack to extract it from objdump
similar to the hack I do for '-B ...'
Like the patch below...
and it works on x64 too, but I'm not sure about sparc.
>From e216123e54041f73ecf1676e355bc83e80c63d1d Mon Sep 17 00:00:00 2001
Date: Tue, 5 Jun 2018 15:27:07 -0700
Subject: [PATCH] bpfilter: fix OUTPUT_FORMAT
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
net/bpfilter/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
index aafa72001fcd..e0bbe7583e58 100644
--- a/net/bpfilter/Makefile
+++ b/net/bpfilter/Makefile
@@ -21,7 +21,7 @@ endif
# which bpfilter_kern.c passes further into umh blob loader at run-time
quiet_cmd_copy_umh = GEN $@
cmd_copy_umh = echo ':' > $(obj)/.bpfilter_umh.o.cmd; \
- $(OBJCOPY) -I binary -O $(CONFIG_OUTPUT_FORMAT) \
+ $(OBJCOPY) -I binary -O `$(OBJDUMP) -f $<|grep format|cut -d' ' -f8` \
-B `$(OBJDUMP) -f $<|grep architecture|cut -d, -f1|cut -d' ' -f2` \
--rename-section .data=.init.rodata $< $@
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: umh build...
2018-06-05 22:29 ` Alexei Starovoitov
@ 2018-06-05 23:42 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2018-06-05 23:42 UTC (permalink / raw)
To: alexei.starovoitov; +Cc: netdev
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Date: Tue, 5 Jun 2018 15:29:34 -0700
> On Tue, Jun 05, 2018 at 05:03:59PM -0400, David Miller wrote:
>>
>> Alexei, I tried to build bpfilter on sparc64 and it shows that
>> CONFIG_OUTPUT_FORMAT is an x86 specific Kconfig value.
>>
>> And, even if I added it, it's not clear what it should even be set to.
>>
>> Right now, for example, my userland builds default to 32-bit sparc
>> even though I'm building a 64-bit kernel.
>>
>> I think what ends up happening has to be in some way in response to
>> what kind of "native" binaries HOSTCC is actually building.
>
> I guess you mean native-ness not of HOSTCC, but what target rootfs will be.
Target rootfs is where I am building the kernel in this case.
Kernel running is 64-bit, most of userland is 32-bit. Kernel is built
explicitly with "-m64" but gcc by default is building 32-bit.
> I guess it's probably equal to 32 or 64-bitness of the kernel from
> CC.
Nope, they are and can be different, even natively.
> I completely forgot that I need to fix CONFIG_OUTPUT_FORMAT.
> On my arm64 I just did
> export CONFIG_OUTPUT_FORMAT=elf64-littleaarch64
> before doing 'make'.
> I can do a hack to extract it from objdump
> similar to the hack I do for '-B ...'
> Like the patch below...
> and it works on x64 too, but I'm not sure about sparc.
...
> @@ -21,7 +21,7 @@ endif
> # which bpfilter_kern.c passes further into umh blob loader at run-time
> quiet_cmd_copy_umh = GEN $@
> cmd_copy_umh = echo ':' > $(obj)/.bpfilter_umh.o.cmd; \
> - $(OBJCOPY) -I binary -O $(CONFIG_OUTPUT_FORMAT) \
> + $(OBJCOPY) -I binary -O `$(OBJDUMP) -f $<|grep format|cut -d' ' -f8` \
> -B `$(OBJDUMP) -f $<|grep architecture|cut -d, -f1|cut -d' ' -f2` \
> --rename-section .data=.init.rodata $< $@
Yeah this doesn't do it in the 64-bit kernel 32-bit userspace scenerio.
We build UMH which ends up being a 32-bit ELF binary, then we later
try to link it:
ld -m elf64_sparc -r -o net/bpfilter/bpfilter.o net/bpfilter/bpfilter_kern.o net/bpfilter/bpfilter_umh.o ; scripts/mod/modpost net/bpfilter/bpfilter.o
ld: sparc:v8plusb architecture of input file `net/bpfilter/bpfilter_umh.o' is incompatible with sparc:v9 output
But your patch is a step in the right direction because it gets us
away from depending upon CONFIG_OUTPUT_FORMAT.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-05 23:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-05 21:03 umh build David Miller
2018-06-05 22:29 ` Alexei Starovoitov
2018-06-05 23:42 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).