○ glibcの設定 4 Xen



・ログイン端末で "#" はroot、"$" は一般ユーザのプロンプトの記号です
・設定ファイルで "#" で始まる行はコメントとして解釈されます


:glibc-2.12-1.209.el6.src.rpm (http://vault.centos.org/)


最初の設定 (Xen)


:OS CentOS 6.9
:selinux disabled
:kernel kernel-2.6.32-696.el6
:glibc glibc-2.12-1.209.el6
:作業 ~/src ~/rpmbuild
:言語 LANG=en_US.UTF-8
:ユーザー rootで実行




  ** WARNING: Currently emulating unsupported memory accesses  **
  **          in /lib/tls glibc libraries. The emulation is    **
  **          slow. To ensure full performance you should      **
  **          install a 'xen-friendly' (nosegneg) version of   **
  **          the library, or disable tls support by executing **
  **          the following as root:                           **
  **          mv /lib/tls /lib/tls.disabled                    **
  ** Offending process: iconvconfig.i68 (pid=1256)             **




 * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
 * Here we can supply some information useful to userland.

#include <linux/version.h>
#include <linux/elfnote.h>

/* Ideally this would use UTS_NAME, but using a quoted string here
   doesn't work. Remember to change this when changing the
   kernel's name. */
ELFNOTE_START(Linux, 0, "a")

#if defined(CONFIG_X86_XEN) || defined(CONFIG_PARAVIRT_XEN)
 * Add a special note telling glibc's dynamic linker a fake hardware
 * flavor that it will use to choose the search path for libraries in the
 * same way it uses real hardware capabilities like "mmx".
 * We supply "nosegneg" as the fake capability, to indicate that we
 * do not like negative offsets in instructions using segment overrides,
 * since we implement those inefficiently.  This makes it possible to
 * install libraries optimized to avoid those access patterns in someplace
 * like /lib/i686/tls/nosegneg.  Note that an /etc/ld.so.conf.d/file
 * corresponding to the bits here is needed to make ldconfig work right.
 * It should contain:
 *	hwcap 1 nosegneg
 * to match the mapping of bit to name that we give here.
 * At runtime, the fake hardware feature will be considered to be present
 * if its bit is set in the mask word.  So, we start with the mask 0, and
 * at boot time we set VDSO_NOTE_NONEGSEG_BIT if running under Xen.

#include "../../xen/vdso.h"	/* Defines VDSO_NOTE_NONEGSEG_BIT.  */

	.long 1			/* ncaps */
VDSO32_NOTE_MASK:		/* Symbol used by arch/x86/xen/setup.c */
	.long 0			/* mask */
	.long 1 << VDSO_NOTE_NONEGSEG_BIT /* mask */
	.byte VDSO_NOTE_NONEGSEG_BIT; .asciz "nosegneg"	/* bit, name */


・kernel-2.6.32-220以降 'hwcap 1 nosegneg'に設定されています
・設定ファイルがない場合は、新しく作成します (下記)


# echo 'hwcap 1 nosegneg' > /etc/ld.so.conf.d/xen-glibc.conf
# ldconfig


# echo 'hwcap 0 nosegneg' > /etc/ld.so.conf.d/xen-glibc.conf
# ldconfig


# ldd /bin/bash
	linux-gate.so.1 =>  (0xb7741000)
	libtinfo.so.5 => /lib/libtinfo.so.5 (0x4ff4e000)
	libdl.so.2 => /lib/libdl.so.2 (0x4febc000)
	libc.so.6 => /lib/i686/nosegneg/libc.so.6 (0x4fd20000)
	/lib/ld-linux.so.2 (0x4fcfe000)


# ldd /usr/sbin/prelink
	not a dynamic executable



・nosegneg が働かない場合は、全てのglibcパッケージを

# cd ~/src
# mkdir glibc
# rpm -ivh glibc-2.12-1.209.el6.src.rpm
# cd ~/rpmbuild/SPECS

・glibc.specファイルの修正 (下記)

# vi glibc.spec

# rpmbuild -bb --clean --rmsource \
--define 'dist .mn' glibc.spec




%ifarch %{ix86}
BuildFlags="-march=%{_target_cpu} -mtune=generic -mno-tls-direct-seg-refs"
%ifarch i686
BuildFlags="-march=i686 -mtune=generic -mno-tls-direct-seg-refs"
%ifarch i386 i486 i586
BuildFlags="$BuildFlags -mno-tls-direct-seg-refs"


○ Copyright(c) 528p.com All Rights Reserved.