All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: GENERATE_SHLIB_SCRIPT vs. EMBEDDED
       [not found]               ` <20191107234842.GS6708@bubble.grove.modra.org>
@ 2019-11-08  5:18                 ` Nathan Chancellor
  2019-11-08 10:34                   ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2019-11-08  5:18 UTC (permalink / raw)
  To: Alan Modra
  Cc: Ard Biesheuvel, Catalin Marinas, Christophe Lyon, binutils,
	Will Deacon, linux-arm-kernel

CC'ing the arm64 Linux kernel maintainers + Ard and mailing list since I
am sure their input is more valuable than mine :) hopefully you all
don't mind, small discription of the issue below to key you in.

On Fri, Nov 08, 2019 at 10:18:43AM +1030, Alan Modra wrote:
> On Thu, Nov 07, 2019 at 10:25:14AM -0700, Nathan Chancellor wrote:
> > On Thu, Nov 07, 2019 at 06:13:30PM +1030, Alan Modra wrote:
> > > On Thu, Nov 07, 2019 at 12:37:00AM -0700, Nathan Chancellor wrote:
> > > > For what it's worth, this breaks building the Linux kernel for me:
> > > > 
> > > > aarch64-linux-ld: -shared not supported

This error occurs when building an arm64 defconfig kernel with master
binutils due to this commit in binutils interacting with the ELF
emulation added in the kernel commits linked below.

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=f2aaebdb97977ee7a5c83c02af871e758e7d594b

> > > An aarch64-linux ld will use emulparams/aarch64linux.sh, which does
> > > have shared support.  If you're trying to use binutils configured for
> > > aarch64-elf on Linux, well, good luck with that.
> > 
> > As it turns out, this error is related to the arm64 Linux kernel using
> > the ELF emulation mode by default, falling back to the Linux one if it
> > is not supported. See the following commits:
> > 
> > https://git.kernel.org/linus/38fc4248677552ce35efc09902fdcb06b61d7ef9
> > https://git.kernel.org/linus/96f95a17c1cfe65a002e525114d96616e91a8f2d
> > https://git.kernel.org/linus/c931d34ea0853d41349e93f871bd3f17f1c03a6b
> 
> Ah, now your report is starting to make more sense.  The Linux kernel
> makes use of -shared to build the kernel vdso and when building a
> relocatable kernel.  In both cases the ELF file header and program
> headers are not needed to load those images.
> 
> However, in any other shared library the headers must be present for
> the binary to be loaded by ld.so.  That's what I meant with my comment
> "good luck with that".  So attempting to build an aarch64-linux shared
> library using -maarch64elf or -maarch64elfb generally will result in a
> non-functional binary.  I think the linker should at least warn about
> that.

I suppose it has been working fine for the past year; otherwise someone
would have noticed something, right? How would the binary be
non-functional?

> I wonder if the following would work for the aarch64 kernel build?
> You might also need -Ttext-segment=0 along with -shared in the kernel
> Makefiles since otherwise you'd get a vsdo and relocatable kernel
> linked at something other than a zero base address.

<snip patch>

I applied that patch on top of binutils commit
f2aaebdb97 ("GENERATE_SHLIB_SCRIPT vs. EMBEDDED.") and it fixed that
error but revealed another one. I am using Segher Boessenkool's build
script available here, in case it is a configuration issue:

http://git.infradead.org/users/segher/buildall.git/blob/refs/heads/master:/build-binutils

aarch64-linux-ld: warning: -shared not supported
aarch64-linux-ld: unrecognized option '--hash-style=sysv'
aarch64-linux-ld: use the --help option for usage information
../arch/arm64/kernel/vdso/Makefile:60: recipe for target 'arch/arm64/kernel/vdso/vdso.so.dbg' failed
make[3]: *** [arch/arm64/kernel/vdso/vdso.so.dbg] Error 1
arch/arm64/Makefile:159: recipe for target 'vdso_prepare' failed
make[2]: *** [vdso_prepare] Error 2
/home/nathan/src/linux/Makefile:326: recipe for target '__build_one_by_one' failed
make[1]: *** [__build_one_by_one] Error 2
Makefile:179: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2

Happy to continue to test other solutions.

Cheers,
Nathan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: GENERATE_SHLIB_SCRIPT vs. EMBEDDED
  2019-11-08  5:18                 ` GENERATE_SHLIB_SCRIPT vs. EMBEDDED Nathan Chancellor
@ 2019-11-08 10:34                   ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2019-11-08 10:34 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Ard Biesheuvel, Catalin Marinas, Christophe Lyon, binutils,
	Will Deacon, linux-arm-kernel

I'm reverting the patch.  My reasons for making it in the first place
were bogus.  The ELF file header and program headers are of course
still present in a file created by targets that set EMBEDDED, and the
fact that EMBEDDED stops them being included in the memory image only
affects some uses of those headers.  I still don't recommend creating
shared libraries for Linux using -maarch64elf but the resulting shared
library isn't as silly as what I thought.

-- 
Alan Modra
Australia Development Lab, IBM

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-08 10:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <fb6030c6-f96d-8219-61f9-548dfc9c5b5a@redhat.com>
     [not found] ` <20191028235341.GD3663@bubble.grove.modra.org>
     [not found]   ` <20191105040135.GG6708@bubble.grove.modra.org>
     [not found]     ` <CAKdteOa8Mf_MOd4Hf8jkcCcgo4bPH8Lss2QCHMu5BBog6N+19Q@mail.gmail.com>
     [not found]       ` <20191105100317.GI6708@bubble.grove.modra.org>
     [not found]         ` <20191107073700.GA22249@ubuntu-m2-xlarge-x86>
     [not found]           ` <20191107074330.GP6708@bubble.grove.modra.org>
     [not found]             ` <20191107172514.GA9267@ubuntu-m2-xlarge-x86>
     [not found]               ` <20191107234842.GS6708@bubble.grove.modra.org>
2019-11-08  5:18                 ` GENERATE_SHLIB_SCRIPT vs. EMBEDDED Nathan Chancellor
2019-11-08 10:34                   ` Alan Modra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.