Gentoo Archives: gentoo-soc

From: Jing Huang <jing.huang.pku@×××××.com>
To: gentoo-soc@l.g.o, lu_zero@g.o
Subject: [gentoo-soc] cross_container_support - progress report #10
Date: Tue, 07 Aug 2012 18:06:48
Message-Id: CAK8mDgrOoQhfeegM7k1YPgWvrD6yVq8sZnEC4i5UJq+0w-vk7g@mail.gmail.com
1 Hi,
2
3 == Progress of last Week ==
4
5 In the last week, I made armv7a-hardfloat-linux-gnueabi-gcc [ELF
6 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically
7 linked (uses shared libs), for GNU/Linux 2.6.9, stripped] run in the
8 arm chroot.
9
10 Firstly, I think it is very difficult to switch dynamic libraries
11 using ld.so.conf and ldconfig, because the generated ld.so.cache
12 always includes /lib.
13 My investigation shows:
14
15 glibc-2.14.1/Makeconfig:
16 # Where to install the shared library and dynamic linker.
17 ifndef slibdir
18 slibdir = $(exec_prefix)/lib
19 endif
20
21 glibc-2.14.1/elf/Makefile:
22 CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
23 -D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1
24
25 glibc-2.14.1/elf/ldconfig.c:
26 if (!opt_only_cline)
27 {
28 parse_conf (config_file, true);
29
30 /* Always add the standard search paths. */
31 add_system_dir (SLIBDIR);
32 if (strcmp (SLIBDIR, LIBDIR))
33 add_system_dir (LIBDIR);
34 }
35
36 Therefore, ldconfig will always include /lib library path unless using
37 "ldconfig -n xxx". But "ldconfig -n" won't generate new ld.so.cache.
38
39 Actually, the linker seeks libraries following the sequence:
40 a. DT_RPATH in dynamic section.
41 b. LD_LIBRARY_PATH environment variable.
42 c. ld.so.cache
43
44 Instead, I was using LD_LIBRARY_PATH rather than ld.so.conf. The steps are:
45
46 1. mount native libs to chroot
47 mount --bind /lib gentoo-rootfs/native/lib
48 mount --bind /usr/lib gentoo-rootfs/native/usr/lib
49 mount --bind /usr/local/lib gentoo-rootfs/native/usr/local/lib
50 mount --bind /usr/i686-pc-linux-gnu gentoo-rootfs/native/usr/i686-pc-linux-gnu
51
52 2. start arm chroot and link native libs
53 ./lxc.sh start -n gentoo-arm
54 export LD_LIBRARY_PATH="/native/lib:/native/usr/lib:/native/usr/local/lib"
55
56 3. set up dynamic library interpreter
57 ln -s /native/lib/ld-2.14.1.so /lib/ld-linux.so.2
58
59 4. running native armv7a-hardfloat-linux-gnueabi-gcc
60 ./native/usr/i686-pc-linux-gnu/armv7a-hardfloat-linux-gnueabi/gcc-bin/4.5.3/armv7a-hardfloat-linux-gnueabi-gcc
61 build an arm program using armv7a-hardfloat-linux-gnueabi-gcc successfully
62
63 == Plans for this week ==
64
65 1. Integrate my progress into lxc.sh script
66 2. get some valuations comparing native gcc and emulated gcc
67 3. document all the steps in the wiki

Replies

Subject Author
[gentoo-soc] Re: cross_container_support - progress report #10 Luca Barbato <lu_zero@g.o>