Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install tinycolinux64 kernel and toolchain on tinycolinux32

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to install tinycolinux64 kernel and toolchain on tinycolinux32". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to install tinycolinux64 kernel and toolchain on tinycolinux32.

Cross compile tinycolinux3.x 64

We cross-compiled the following tinycolinux 3.x 64 on gcc485 on a ubuntu14.04 64bit (do not compile this kernel directly with 32-bit gcc on tinycolinux):

Referring to the similar practice of "installing tinycolinux to the CVM in hard disk mode", we download 64-bit src and patch from http://mirrors.163.com/tinycorelinux/3.x/release/src/kernel/, open the virtio pci option in virtualization, compile it into virtio block and network drivers, and easily get bzimage under arch/x86/boot and start it in boot. It is found that it can start normally with the original rootfs. Uname-m shows x86x64. File / boot/bzimage, showing x86 bootable kernel. Guess this is because both 32 and 64 support are enabled in the .config file, 32-bit programs can run on 64-bit, and the 32-bit binutils and gcc in the original rootfs remain unchanged.

If you copy a 64-bit linux program to file, it displays 64bit elf, execution of it will prompt not found, this is because the binutils ld it depends on does not have, call gcc-o helloworld.c-64m, prompt unimplemented, this is because 3.x rootfs does not have a corresponding GCC 64. Next, you need a cross compile:

Boostrap compile gcc 4.4.3 64 three-piece set of for tinycolinux 3.x 64 target on 32 tinycolinux

In general, GCC supports crosscompile from high to low, and the reverse is a little more difficult. So here we take the easiest way: compile the same version of GCC from the same version of 32-bit GCC bootstrap, use the local 32-bit gcc bootstrap cross compile to produce 64-bit gcc, and no longer use the foreign cross compile solution (that's fine). Of course, this scheme is based on the fact that GCC already exists on tinycolinux, and if you pursue a more general practical purpose, it is better to come in from the external system cross compile.

The resulting GCC is only a gcc 443 version of target to x86_64-pc-linux-gnu, because it is built on this machine, so this build and host remain the same as the native system HOST, but it does not affect the continuation of our work. As for the things that you want to use this GCC to do raw chicken eggs in the future, for example, you can use this to bootstrap GCC443 to host 443 version inplace coverage again, these are all things in the future. GCC supports cross-builds from 32 to 64 or vice versa.

We choose make.tcz of 2.x repos (3.81 version, why not use 3.x make 382 next) and 3.x repos gcc443 32 bit (why not 4.x gcc471: because we will encounter repeated definition errors when compiling many programs after 4.x, we should think about the version problem at this time). Follow the scheme of compiling GCC443 64 from GCC443 32 bit, to ensure that the system is absolutely clean. Otherwise, you may encounter various pits (such as cant computer object file prefix,etc..). Here's how to make a pure tinycolinux system:

Reinstalling rootfs by "installing tinycolinux on hard disk" is equivalent to reinstalling the system. In addition to leaving the 64 bzimage in the first step to boot under boot, you may need to install openssh. Then download the 3.x toolchain and install:

Sudo unsquashfs-f-d / tce/gccbase/gmp.tczsudo unsquashfs-f-d / / tce/gccbase/libmpc.tczsudo unsquashfs-f-d / / tce/gccbase/mpfr.tczsudo unsquashfs-f-d / / tce/gccbase/ppl.tczsudo unsquashfs-f-d / / tce/gccbase/cloog.tczsudo unsquashfs-f-d / / tce/gccbase/binutils.tczsudo unsquashfs-f-d / / tce/gccbase/bison.tczsudo unsquashfs-f-d / / tce/gccbase/diffutils. Tczsudo unsquashfs-f-d / tce/gccbase/file.tczsudo unsquashfs-f-d / / tce/gccbase/findutils.tczsudo unsquashfs-f-d / / tce/gccbase/flex.tczsudo unsquashfs-f-d / / tce/gccbase/gawk.tczsudo unsquashfs-f-d / / tce/gccbase/gcc.tczsudo unsquashfs-f-d / / tce/gccbase/grep.tczsudo unsquashfs-f-d / / tce/gccbase/m4.tczsudo unsquashfs-f-d / / tce/gccbase/make. Tczsudo unsquashfs-f-d / / tce/gccbase/patch.tczsudo unsquashfs-f-d / / tce/gccbase/pkg-config.tczsudo unsquashfs-f-d / / tce/gccbase/sed.tczsudo unsquashfs-f-d / / tce/gccbase/base-dev.tcz#sudo unsquashfs-f-d / / tce/gccbase/gcc_libs.tcz#sudo unsquashfs-f-d / / tce/gccbase/linux-headers-2.6.33.3-tinycore.tcz

Then download the following and prepare it, unzip it to a directory.

Http://mirrors.163.com/tinycorelinux/3.x/release/src/compiletc_other/ (mpfr-2.4.2.tar.xz,gmp-4.3.2.tar.xz,binutils-2.20.tar.xz)

Http://mirrors.163.com/tinycorelinux/3.x/release/src/glibc-2.11.1.tar.bz2 (instead of 2.11.1, download 2.12.1 from ftp.glibc.gnu.com, which will be useful later)

Http://mirrors.163.com/tinycorelinux/3.x/release/src/gcc-4.4.3.tar.bz2( starting from GCC-4.3, the installation of GCC will depend on versions above GMP-4.1 and above MPFR-2.3.2. If you extract the two packages to the root directory of the GCC source tree and name them "gmp" and "mpfr" respectively)

1) compile binutils first:

Cd binutils-2.20 & sudo make b & & cd bsudo.. / configure-- prefix=/usr/local/gcc443-- target=x86_64-pc-linux-gnu-- disable-multilib

Higher version of GCC can be added-- disable-werror to avoid causing various warning errors

Sudo make sudo make install

2) then export the linux header file to the tool chain:

Cd linux-2.6.33.3sudo make ARCH=x86_64 INSTALL_HDR_PATH=/usr/local/gcc443/x86_64-pc-linux-gnu headers_install

To use perl.tcz

Build the GCC tool framework without any libraries.

Cd gcc-4.4.3 & sudo make b & & cd bsudo.. / configure-- prefix=/usr/local/gcc443-- target=x86_64-pc-linux-gnu-- enable-languages=c,c++-- disable-multilib

If you use 3.x make 3.8.2, there will be a configure error: mixed rule

Sudo make all-gcc sudo make install-gcc

Generate the basic part of the glibc

The third step has generated the tool, and now the most important basic part of the base library, note that it is not the whole glibc.

Advance export PATH=$PATH:/usr/local/gcc443/bin helps the next configure find the newly compiled x86_64-pc-linux-gnu-gcc, although configure will find it automatically, so it is safer to do it manually.

Cd glibc-2.12.1 & sudo make b & & cd bsudo.. / configure-- prefix=/usr/local/gcc443/x86_64-pc-linux-gnu-- build=$MACHTYPE-- host=x86_64-pc-linux-gnu-- target=x86_64-pc-linux-gnu-- with-headers=/usr/local/gcc443/x86_64-pc-linux-gnu/include-- disable-multilib libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes

$MACHTYPE will output the word i686-pc-linux-gnu on a normal linux32, but it will be empty on tinycolinux. Continue

As the above sentence passed on tinycolinux, but on ordinary linux, configure seems to easily destroy the glibc source directory, even if it is cd to b, for example, you may encounter: cannot compute suffix of object files or: invalid host type: $CXX unregconnize-c, which can not be solved by online solutions. Often re-prepare the glibc source directory and re-configure it according to the above configure, on ordinary linux. Line 19 of scripts/gen-sorted.awk under the glibc source directory will later appear BUG that needs to change / [^ /] + $to / [^ /] + $. Just fix it.

And then there's make:

A) sudo make install-bootstrap-headers=yes install-headers

In the last pass of tinycolinux, on a regular linux, you may need to add CFLAGS= "- O2-U_FORTIFY_SOURCE" cross-compiling=yes after make to deal with the following possible errors.

Cross-compiling=yes: No rule to make target `elf/soinit.os' error CFLAGS=02: glibc cant continues without opt error-U_FORTIFY_SOURCE: inlining failed in call to 'syslog' error

If you execute a) on an impure tinycolinux, you may need tls support error

B) sudo make csu/subdir_lib

If you execute b) on an impure tinycolinux, errors will continue

C) install csu/crt1.o csu/crti.o csu/crtn.o / usr/local/gcc443/x86_64-pc-linux-gnu/lib

D) x86_64-pc-linux-gnu-gcc-nostdlib-nostartfiles-shared-x c / dev/null-o / usr/local/gcc443/x86_64-pc-linux-gnu/lib/libc.so

E) touch / usr/local/gcc443/x86_64-pc-linux-gnu/include/gnu/stubs.h

If you are on a pure tinycolinux, you can execute it all the way up to e), where the next two steps can be completed.

5) generate LIBGCC of GCC

Re-cd gcc-4.4.3/b sudo make all-target-libgcc sudo make install-target-libgcc

6) the last step is to generate the complete glibc and stdc++lib in gcc

Re-cd glibc-2.12.1/b sudo make sudo make install

Re-cd gcc-4.4.3/b sudo make sudo make install

In fact, there are many joint build options for the compilation of the above trilogy. But this article will not delve into it.

Test, compile and run the 64-bit program

Write a helloworld,test.cpp of CPP first.

# include int main () {printf ("Hello World"); return 0;}

Then / usr/local/gcc443/bin/x86_64-pc-linux-gnu-g++ test.cpp-o _ a _ We ask for ways to make it work with the newly compiled tool chain:

In fact, the reason is that we can't find the shared library, error cant find share libs, ELF64CLASS. We can't use 32-bit LDD to analyze its dependencies, but we can view it in the directory where cd an is located, x86_64-pc-linux-gnu-readelf-a. / a | grep "Shared" or x86_64-pc-linux-gnu-objdump-p. / a | grep NEEDED. It is found that it refers to libc.so.6 (- > libc-2.12.1.so), libstdc++.so.6 (- > libstdc++.so.6.0.13) and libgcc_s.so.1,libm.so.6 (- > libm-2.12.1.so). Of course, these libraries should be found in the lib or lib64 of the newly compiled tool chain, put in the directory of a, and then write a runa under the directory of a, with execution permission added.

Ld-linux-x86 $(dirname $0) $D/ld-linux-x86-64.so.2-- library-path $D:$D/lib:$D/usr/lib. / a $@ (ld-linux-x86-64.so.2 is also found in the tool chain, which can actually be executed, or you can customize the above-- library-path)

Execute. / runa and output the same result as static b.

This theoretically means that as long as the system supports the default ld-linux-x86-64, it supports running all programs generated by this new tool chain.

Now that there is a 64-bit kernel, there is a toolchain to generate 64-bit programs (it is still a 32-bit program and can only handle 64-bit generation), but the whole ROOTFS is still basically 32, and you can't even run the 64-bit programs it generates. You should recompile busybox to support the new 64-bit ld.

Also, based on this TOOLCHAIN, you can constantly bootstrap high versions of GCC, or inplace overlay, or change BUILD,HOST to generate new toolchains.

Thank you for your reading, the above is the content of "how to install tinycolinux64 kernel and toolchain on tinycolinux32". After the study of this article, I believe you have a deeper understanding of how to install tinycolinux64 kernel and toolchain on tinycolinux32, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report