eglibc 2.12: import from oe-core

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
This commit is contained in:
Koen Kooi 2011-10-06 16:12:16 +02:00
parent ea53d5c61b
commit 6aea5cdadf
22 changed files with 1884 additions and 0 deletions

View File

@ -0,0 +1,43 @@
DESCRIPTION = "Cross locale generation tool for eglibc"
HOMEPAGE = "http://www.eglibc.org/home"
SECTION = "libs"
LICENSE = "LGPL"
LIC_DIR = "${WORKDIR}/${EGLIBC_BRANCH}/libc"
LIC_FILES_CHKSUM = "file://${LIC_DIR}/LICENSES;md5=07a394b26e0902b9ffdec03765209770 \
file://${LIC_DIR}/COPYING;md5=393a5ca445f6965873eca0259a17f833 \
file://${LIC_DIR}/posix/rxspencer/COPYRIGHT;md5=dc5485bb394a13b2332ec1c785f5d83a \
file://${LIC_DIR}/COPYING.LIB;md5=bbb461211a33b134d42ed5ee802b37ff "
inherit native
inherit autotools
PR = "r1"
SRCREV="11982"
EGLIBC_BRANCH="eglibc-2_12"
SRC_URI = "svn://www.eglibc.org/svn/branches/;module=${EGLIBC_BRANCH};proto=http "
S = "${WORKDIR}/${EGLIBC_BRANCH}/localedef"
do_unpack_append() {
bb.build.exec_func('do_move_ports', d)
}
do_move_ports() {
if test -d ${WORKDIR}/${EGLIBC_BRANCH}/ports ; then
rm -rf ${WORKDIR}/libc/ports
mv ${WORKDIR}/${EGLIBC_BRANCH}/ports ${WORKDIR}/libc/
fi
}
EXTRA_OECONF = "--with-glibc=${WORKDIR}/${EGLIBC_BRANCH}/libc"
do_configure () {
./configure ${EXTRA_OECONF}
}
do_install() {
install -d ${D}${bindir}
install -m 0755 ${S}/localedef ${D}${bindir}/cross-localedef
}

View File

@ -0,0 +1,17 @@
Upstream-Status: Pending
import http://sourceware.org/ml/libc-ports/2007-12/msg00000.html
Index: libc/bits/stdio-lock.h
===================================================================
--- libc.orig/bits/stdio-lock.h 2009-10-28 14:34:19.000000000 -0700
+++ libc/bits/stdio-lock.h 2009-10-28 14:34:54.000000000 -0700
@@ -50,6 +50,8 @@ __libc_lock_define_recursive (typedef, _
_IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, (_fp)); \
_IO_flockfile (_fp)
+# define _IO_acquire_lock_clear_flags2(_fp) _IO_acquire_lock (_fp)
+
# define _IO_release_lock(_fp) \
_IO_funlockfile (_fp); \
_IO_cleanup_region_end (0)

View File

@ -0,0 +1,25 @@
Source: http://sourceware.org/bugzilla/show_bug.cgi?id=12097
Upstream-Status: Submitted
The patch should be merged into glibc-ports
-Khem
Index: libc/ports/sysdeps/unix/sysv/linux/arm/eabi/libc-do-syscall.S
===================================================================
--- libc.orig/ports/sysdeps/unix/sysv/linux/arm/eabi/libc-do-syscall.S
+++ libc/ports/sysdeps/unix/sysv/linux/arm/eabi/libc-do-syscall.S
@@ -16,6 +16,8 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#if defined(__thumb__)
+
#include <sysdep.h>
/* Out-of-line syscall stub. We expect the system call number in ip
@@ -41,3 +43,5 @@ ENTRY (__libc_do_syscall)
pop {r7, pc}
.fnend
END (__libc_do_syscall)
+
+#endif /* __thumb__ */

View File

@ -0,0 +1,21 @@
Upstream-Status: Pending
In file included from ../nptl/sysdeps/unix/sysv/linux/libc-lowlevellock.c:21:
../nptl/sysdeps/unix/sysv/linux/lowlevellock.c: In function '__lll_lock_wait_private':
../nptl/sysdeps/unix/sysv/linux/lowlevellock.c:34: warning: implicit declaration of function 'THREAD_GETMEM'
../nptl/sysdeps/unix/sysv/linux/lowlevellock.c:34: error: 'THREAD_SELF' undeclared (first use in this function)
../nptl/sysdeps/unix/sysv/linux/lowlevellock.c:34: error: (Each undeclared identifier is reported only once
../nptl/sysdeps/unix/sysv/linux/lowlevellock.c:34: error: for each function it appears in.)
../nptl/sysdeps/unix/sysv/linux/lowlevellock.c:34: error: 'header' undeclared (first use in this function)
make[4]: *** [/var/tmp/portage/sys-libs/glibc-2.7-r1/work/build-default-armv4l-unknown-linux-gnu-nptl/nptl/rtld-libc-lowlevellock.os] Error 1
--- libc/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h.orig
+++ libc/ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h
@@ -25,6 +25,7 @@
#include <atomic.h>
#include <sysdep.h>
#include <kernel-features.h>
+#include <tls.h>
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1

View File

@ -0,0 +1,11 @@
#!/usr/bin/make
include $(IN)
all:
rm -f $(OUT)
touch $(OUT)
for locale in $(SUPPORTED-LOCALES); do \
[ $$locale = true ] && continue; \
echo $$locale | sed 's,/, ,' >> $(OUT); \
done

View File

@ -0,0 +1,56 @@
Upstream-Status: Inappropriate [embedded specific]
The default lib search path order is:
1) LD_LIBRARY_PATH
2) RPATH from the binary
3) ld.so.cache
4) default search paths embedded in the linker
For nativesdk binaries which are being used alongside binaries on a host system, we
need the search paths to firstly search the shipped nativesdk libs but then also
cover the host system. For example we want the host system's libGL and this may be
in a non-standard location like /usr/lib/mesa. The only place the location is know
about is in the ld.so.cache of the host system.
Since nativesdk has a simple structure and doesn't need to use a cache itself, we
repurpose the cache for use as a last resort in finding host system binaries. This
means we need to switch the order of 3 and 4 above to make this work effectively.
RP 14/10/2010
Index: libc/elf/dl-load.c
===================================================================
--- libc.orig/elf/dl-load.c
+++ libc/elf/dl-load.c
@@ -2107,6 +2107,15 @@ _dl_map_object (struct link_map *loader,
&loader->l_runpath_dirs, &realname, &fb, loader,
LA_SER_RUNPATH, &found_other_class);
+ /* try the default path. */
+ if (fd == -1
+ && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL
+ || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1))
+ && rtld_search_dirs.dirs != (void *) -1)
+ fd = open_path (name, namelen, mode & __RTLD_SECURE, &rtld_search_dirs,
+ &realname, &fb, l, LA_SER_DEFAULT, &found_other_class);
+
+ /* Finally try ld.so.cache */
if (fd == -1
&& (__builtin_expect (! (mode & __RTLD_SECURE), 1)
|| ! INTUSE(__libc_enable_secure)))
@@ -2169,14 +2178,6 @@ _dl_map_object (struct link_map *loader,
}
}
- /* Finally, try the default path. */
- if (fd == -1
- && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL
- || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1))
- && rtld_search_dirs.dirs != (void *) -1)
- fd = open_path (name, namelen, mode & __RTLD_SECURE, &rtld_search_dirs,
- &realname, &fb, l, LA_SER_DEFAULT, &found_other_class);
-
/* Add another newline when we are tracing the library loading. */
if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0))
_dl_debug_printf ("\n");

View File

@ -0,0 +1,23 @@
Upstream-Status: Pending
On mips target, binutils currently sets DT_MIPS_RLD_MAP to 0 in dynamic
section if a --version-script sets _RLD_MAP to local. This is apparently
a binutils bug, but libc shouldn't segfault in this case.
see also: http://sourceware.org/bugilla/show_bug.cgi?id=11615
9/19/2010 - added by Qing He <qing.he@intel.com>
---
diff -ru glibc-2.10.1.orig/ports/sysdeps/mips/dl-machine.h glibc-2.10.1/ports/sysdeps/mips/dl-machine.h
--- glibc-2.10.1.orig/ports/sysdeps/mips/dl-machine.h 2009-05-16 16:36:20.000000000 +0800
+++ glibc-2.10.1/ports/sysdeps/mips/dl-machine.h 2010-09-19 09:11:53.000000000 +0800
@@ -70,7 +70,8 @@
/* If there is a DT_MIPS_RLD_MAP entry in the dynamic section, fill it in
with the run-time address of the r_debug structure */
#define ELF_MACHINE_DEBUG_SETUP(l,r) \
-do { if ((l)->l_info[DT_MIPS (RLD_MAP)]) \
+do { if ((l)->l_info[DT_MIPS (RLD_MAP)] && \
+ (l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) \
*(ElfW(Addr) *)((l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) = \
(ElfW(Addr)) (r); \
} while (0)

View File

@ -0,0 +1,26 @@
We now pass --with-cpu option to eglibc this ends up with configure errors if we do
not pass a cpu which eglibc has support for in sysdeps
| checking sysdep dirs... configure: error: The 603e subspecies of powerpc is not supported.
| + bbfatal 'oe_runconf failed'
| + echo 'ERROR: oe_runconf failed'
We fix this by adding the 603e sub directories with Implies to generic
powerpc to overcome this error
Upstream-Status: Inappropriate [OE config related]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Index: libc/ports/sysdeps/powerpc/powerpc32/603e/Implies
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ libc/ports/sysdeps/powerpc/powerpc32/603e/Implies 2011-09-17 19:18:57.593292084 -0700
@@ -0,0 +1 @@
+powerpc/powerpc32
Index: libc/ports/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/Implies
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ libc/ports/sysdeps/unix/sysv/linux/powerpc/powerpc32/603e/Implies 2011-09-17 19:17:48.613292100 -0700
@@ -0,0 +1 @@
+powerpc/powerpc32

View File

@ -0,0 +1,81 @@
Upstream-Status: Pending
Source: http://sourceware.org/ml/libc-alpha/2010-03/msg00064.html
This patch scratches an itch. Each individual gcc command in the
glibc build is over 1K, which means it takes up a good chunk of my
terminal. Most of that is include paths. Any version of GCC new
enough to build glibc supports response files, which were added in
2005. So use a response file for the static list of include paths.
Now the build commands are a lot shorter, and easier to use when
developing glibc.
Tested on x86_64-linux-gnu. Please apply if acceptable.
--
Daniel Jacobowitz
CodeSourcery
2010-03-30 Daniel Jacobowitz <dan@codesourcery.com>
* Makeconfig (+common-includes): Define.
(+includes): Use @$(common-objpfx)includes.
* Makefile (postclean): Remove includes and includes.mk.
* Makerules ($(common-objpfx)includes.mk): Include and create
includes.mk. Create includes.
Index: libc/Makeconfig
===================================================================
--- libc.orig/Makeconfig 2009-10-13 22:55:12.000000000 -0700
+++ libc/Makeconfig 2010-03-31 16:02:37.120489733 -0700
@@ -678,9 +678,10 @@ endif # $(+cflags) == ""
# library source directory, in the include directory, and in the
# current directory.
+sysdep-includes = $(addprefix -I,$(+sysdep_dirs))
++common-includes = $(+sysdep-includes) $(includes) $(sysincludes)
+includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
- $(+sysdep-includes) $(includes) \
- $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
+ @$(common-objpfx)includes \
+ $(patsubst %/,-I%,$(..)) $(libio-include) -I.
# Since libio has several internal header files, we use a -I instead
# of many little headers in the include directory.
Index: libc/Makefile
===================================================================
--- libc.orig/Makefile 2009-12-09 12:06:28.000000000 -0800
+++ libc/Makefile 2010-03-31 16:02:37.132481508 -0700
@@ -247,7 +247,7 @@ parent-mostlyclean: common-mostlyclean #
parent-clean: parent-mostlyclean common-clean
postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
- $(addprefix $(objpfx),sysd-dirs sysd-rules) \
+ $(addprefix $(objpfx),sysd-dirs sysd-rules includes includes.mk) \
$(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i)
clean: parent-clean
Index: libc/Makerules
===================================================================
--- libc.orig/Makerules 2009-12-09 12:06:28.000000000 -0800
+++ libc/Makerules 2010-03-31 16:02:37.140481645 -0700
@@ -254,6 +254,20 @@ ifndef sysd-rules-done
no_deps=t
endif
+-include $(common-objpfx)includes.mk
+ifneq ($(+common-includes),$(saved-includes))
+# Recreate includes.mk (and includes).
+includes-force = FORCE
+FORCE:
+endif
+$(common-objpfx)includes.mk: $(includes-force)
+ -@rm -f $@T $(common-objpfx)includesT
+ for inc in $(+common-includes); do echo "$$inc"; done \
+ > $(common-objpfx)includesT
+ mv -f $(common-objpfx)includesT $(common-objpfx)includes
+ echo 'saved-includes := $(+common-includes)' > $@T
+ mv -f $@T $@
+
define o-iterator-doit
$(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
endef

View File

@ -0,0 +1,6 @@
require eglibc_${PV}.bb
require recipes-core/eglibc/eglibc-initial.inc
do_configure_prepend () {
unset CFLAGS
}

View File

@ -0,0 +1 @@
require recipes-core/eglibc/eglibc-locale.inc

View File

@ -0,0 +1,109 @@
require recipes-core/eglibc/eglibc.inc
DEPENDS += "gperf-native"
PR = "r27"
SRCREV = "14158"
EGLIBC_BRANCH="eglibc-2_12"
SRC_URI = "svn://www.eglibc.org/svn/branches/;module=${EGLIBC_BRANCH};proto=http \
file://eglibc-svn-arm-lowlevellock-include-tls.patch \
file://IO-acquire-lock-fix.patch \
file://shorten-build-commands.patch \
file://mips-rld-map-check.patch \
file://armv4-eabi-compile-fix.patch \
file://ppc-enable-603e-cpu.patch \
file://etc/ld.so.conf \
file://generate-supported.mk \
"
SRC_URI_append_virtclass-nativesdk = " file://ld-search-order.patch"
S = "${WORKDIR}/${EGLIBC_BRANCH}/libc"
B = "${WORKDIR}/build-${TARGET_SYS}"
PACKAGES_DYNAMIC = "libc6*"
RPROVIDES_${PN}-dev = "libc6-dev virtual-libc-dev"
PROVIDES_${PN}-dbg = "glibc-dbg"
# the -isystem in bitbake.conf screws up glibc do_stage
BUILD_CPPFLAGS = "-I${STAGING_INCDIR_NATIVE}"
TARGET_CPPFLAGS = "-I${STAGING_DIR_TARGET}${layout_includedir}"
GLIBC_ADDONS ?= "ports,nptl,libidn"
GLIBC_BROKEN_LOCALES = " _ER _ET so_ET yn_ER sid_ET tr_TR mn_MN gez_ET gez_ER bn_BD te_IN es_CR.ISO-8859-1"
FILESPATH = "${@base_set_filespath([ '${FILE_DIRNAME}/eglibc-${PV}', '${FILE_DIRNAME}/eglibc', '${FILE_DIRNAME}/files', '${FILE_DIRNAME}' ], d)}"
#
# For now, we will skip building of a gcc package if it is a uclibc one
# and our build is not a uclibc one, and we skip a glibc one if our build
# is a uclibc build.
#
# See the note in gcc/gcc_3.4.0.oe
#
python __anonymous () {
import bb, re
uc_os = (re.match('.*uclibc$', bb.data.getVar('TARGET_OS', d, 1)) != None)
if uc_os:
raise bb.parse.SkipPackage("incompatible with target %s" %
bb.data.getVar('TARGET_OS', d, 1))
}
export libc_cv_slibdir = "${base_libdir}"
EXTRA_OECONF = "--enable-kernel=${OLDEST_KERNEL} \
--without-cvs --disable-profile --disable-debug --without-gd \
--enable-clocale=gnu \
--enable-add-ons=${GLIBC_ADDONS},ports \
--with-headers=${STAGING_INCDIR} \
--without-selinux \
${GLIBC_EXTRA_OECONF}"
EXTRA_OECONF += "${@get_libc_fpu_setting(bb, d)}"
do_unpack_append() {
bb.build.exec_func('do_move_ports', d)
}
do_move_ports() {
if test -d ${WORKDIR}/${EGLIBC_BRANCH}/ports ; then
rm -rf ${S}/ports
mv ${WORKDIR}/${EGLIBC_BRANCH}/ports ${S}/
fi
}
do_configure () {
# override this function to avoid the autoconf/automake/aclocal/autoheader
# calls for now
# don't pass CPPFLAGS into configure, since it upsets the kernel-headers
# version check and doesn't really help with anything
if [ -z "`which rpcgen`" ]; then
echo "rpcgen not found. Install glibc-devel."
exit 1
fi
(cd ${S} && gnu-configize) || die "failure in running gnu-configize"
find ${S} -name "configure" | xargs touch
CPPFLAGS="" oe_runconf
}
rpcsvc = "bootparam_prot.x nlm_prot.x rstat.x \
yppasswd.x klm_prot.x rex.x sm_inter.x mount.x \
rusers.x spray.x nfs_prot.x rquota.x key_prot.x"
do_compile () {
# -Wl,-rpath-link <staging>/lib in LDFLAGS can cause breakage if another glibc is in staging
unset LDFLAGS
base_do_compile
(
cd ${S}/sunrpc/rpcsvc
for r in ${rpcsvc}; do
h=`echo $r|sed -e's,\.x$,.h,'`
rpcgen -h $r -o $h || bbwarn "unable to generate header for $r"
done
)
}
require recipes-core/eglibc/eglibc-package.inc
BBCLASSEXTEND = "nativesdk"

View File

@ -0,0 +1,331 @@
Upstream-Status: Inappropriate [embedded specific]
We run the ldconfig in the cross fashion. make the code bitsize aware so that
we can cross build ldconfig cache for various architectures.
Richard Purdie <richard.purdie@linuxfoundation.org> 2009/05/19
Nitin A Kamble <nitin.a.kamble@intel.com> 2009/03/29
Index: ldconfig-native-2.12.1/readelflib.c
===================================================================
--- ldconfig-native-2.12.1.orig/readelflib.c
+++ ldconfig-native-2.12.1/readelflib.c
@@ -40,39 +40,212 @@ do \
/* Returns 0 if everything is ok, != 0 in case of error. */
int
-process_elf_file (const char *file_name, const char *lib, int *flag,
+process_elf_file32 (const char *file_name, const char *lib, int *flag,
unsigned int *osversion, char **soname, void *file_contents,
size_t file_length)
{
int i;
unsigned int j;
- ElfW(Addr) loadaddr;
+ Elf32_Addr loadaddr;
unsigned int dynamic_addr;
size_t dynamic_size;
char *program_interpreter;
- ElfW(Ehdr) *elf_header;
- ElfW(Phdr) *elf_pheader, *segment;
- ElfW(Dyn) *dynamic_segment, *dyn_entry;
+ Elf32_Ehdr *elf_header;
+ Elf32_Phdr *elf_pheader, *segment;
+ Elf32_Dyn *dynamic_segment, *dyn_entry;
char *dynamic_strings;
- elf_header = (ElfW(Ehdr) *) file_contents;
+ elf_header = (Elf32_Ehdr *) file_contents;
*osversion = 0;
- if (elf_header->e_ident [EI_CLASS] != ElfW (CLASS))
+ if (elf_header->e_type != ET_DYN)
{
- if (opt_verbose)
+ error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name,
+ elf_header->e_type);
+ return 1;
+ }
+
+ /* Get information from elf program header. */
+ elf_pheader = (Elf32_Phdr *) (elf_header->e_phoff + file_contents);
+ check_ptr (elf_pheader);
+
+ /* The library is an elf library, now search for soname and
+ libc5/libc6. */
+ *flag = FLAG_ELF;
+
+ loadaddr = -1;
+ dynamic_addr = 0;
+ dynamic_size = 0;
+ program_interpreter = NULL;
+ for (i = 0, segment = elf_pheader;
+ i < elf_header->e_phnum; i++, segment++)
+ {
+ check_ptr (segment);
+
+ switch (segment->p_type)
{
- if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
- error (0, 0, _("%s is a 32 bit ELF file.\n"), file_name);
- else if (elf_header->e_ident [EI_CLASS] == ELFCLASS64)
- error (0, 0, _("%s is a 64 bit ELF file.\n"), file_name);
- else
- error (0, 0, _("Unknown ELFCLASS in file %s.\n"), file_name);
+ case PT_LOAD:
+ if (loadaddr == (Elf32_Addr) -1)
+ loadaddr = segment->p_vaddr - segment->p_offset;
+ break;
+
+ case PT_DYNAMIC:
+ if (dynamic_addr)
+ error (0, 0, _("more than one dynamic segment\n"));
+
+ dynamic_addr = segment->p_offset;
+ dynamic_size = segment->p_filesz;
+ break;
+
+ case PT_INTERP:
+ program_interpreter = (char *) (file_contents + segment->p_offset);
+ check_ptr (program_interpreter);
+
+ /* Check if this is enough to classify the binary. */
+ for (j = 0; j < sizeof (interpreters) / sizeof (interpreters [0]);
+ ++j)
+ if (strcmp (program_interpreter, interpreters[j].soname) == 0)
+ {
+ *flag = interpreters[j].flag;
+ break;
+ }
+ break;
+
+ case PT_NOTE:
+ if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
+ {
+ Elf32_Word *abi_note = (Elf32_Word *) (file_contents
+ + segment->p_offset);
+ Elf32_Addr size = segment->p_filesz;
+
+ while (abi_note [0] != 4 || abi_note [1] != 16
+ || abi_note [2] != 1
+ || memcmp (abi_note + 3, "GNU", 4) != 0)
+ {
+#define ROUND(len) (((len) + sizeof (Elf32_Word)) - 1) & -sizeof (Elf32_Word)))
+ Elf32_Addr) note_size = 3 * sizeof (Elf32_Word))
+ + ROUND (abi_note[0])
+ + ROUND (abi_note[1]);
+
+ if (size - 32 < note_size || note_size == 0)
+ {
+ size = 0;
+ break;
+ }
+ size -= note_size;
+ abi_note = (void *) abi_note + note_size;
+ }
+
+ if (size == 0)
+ break;
+
+ *osversion = (abi_note [4] << 24) |
+ ((abi_note [5] & 0xff) << 16) |
+ ((abi_note [6] & 0xff) << 8) |
+ (abi_note [7] & 0xff);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ }
+ if (loadaddr == (Elf32_Addr) -1)
+ {
+ /* Very strange. */
+ loadaddr = 0;
+ }
+
+ /* Now we can read the dynamic sections. */
+ if (dynamic_size == 0)
+ return 1;
+
+ dynamic_segment = (Elf32_Dyn *) (file_contents + dynamic_addr);
+ check_ptr (dynamic_segment);
+
+ /* Find the string table. */
+ dynamic_strings = NULL;
+ for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
+ ++dyn_entry)
+ {
+ check_ptr (dyn_entry);
+ if (dyn_entry->d_tag == DT_STRTAB)
+ {
+ dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr);
+ check_ptr (dynamic_strings);
+ break;
}
- return 1;
}
+ if (dynamic_strings == NULL)
+ return 1;
+
+ /* Now read the DT_NEEDED and DT_SONAME entries. */
+ for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
+ ++dyn_entry)
+ {
+ if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
+ {
+ char *name = dynamic_strings + dyn_entry->d_un.d_val;
+ check_ptr (name);
+
+ if (dyn_entry->d_tag == DT_NEEDED)
+ {
+
+ if (*flag == FLAG_ELF)
+ {
+ /* Check if this is enough to classify the binary. */
+ for (j = 0;
+ j < sizeof (known_libs) / sizeof (known_libs [0]);
+ ++j)
+ if (strcmp (name, known_libs [j].soname) == 0)
+ {
+ *flag = known_libs [j].flag;
+ break;
+ }
+ }
+ }
+
+ else if (dyn_entry->d_tag == DT_SONAME)
+ *soname = xstrdup (name);
+
+ /* Do we have everything we need? */
+ if (*soname && *flag != FLAG_ELF)
+ return 0;
+ }
+ }
+
+ /* We reach this point only if the file doesn't contain a DT_SONAME
+ or if we can't classify the library. If it doesn't have a
+ soname, return the name of the library. */
+ if (*soname == NULL)
+ *soname = xstrdup (lib);
+
+ return 0;
+}
+
+int
+process_elf_file64 (const char *file_name, const char *lib, int *flag,
+ unsigned int *osversion, char **soname, void *file_contents,
+ size_t file_length)
+{
+ int i;
+ unsigned int j;
+ Elf64_Addr loadaddr;
+ unsigned int dynamic_addr;
+ size_t dynamic_size;
+ char *program_interpreter;
+
+ Elf64_Ehdr *elf_header;
+ Elf64_Phdr *elf_pheader, *segment;
+ Elf64_Dyn *dynamic_segment, *dyn_entry;
+ char *dynamic_strings;
+
+ elf_header = (Elf64_Ehdr *) file_contents;
+ *osversion = 0;
+
if (elf_header->e_type != ET_DYN)
{
error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name,
@@ -81,7 +254,7 @@ process_elf_file (const char *file_name,
}
/* Get information from elf program header. */
- elf_pheader = (ElfW(Phdr) *) (elf_header->e_phoff + file_contents);
+ elf_pheader = (Elf64_Phdr *) (elf_header->e_phoff + file_contents);
check_ptr (elf_pheader);
/* The library is an elf library, now search for soname and
@@ -100,7 +273,7 @@ process_elf_file (const char *file_name,
switch (segment->p_type)
{
case PT_LOAD:
- if (loadaddr == (ElfW(Addr)) -1)
+ if (loadaddr == (Elf64_Addr) -1)
loadaddr = segment->p_vaddr - segment->p_offset;
break;
@@ -129,16 +302,16 @@ process_elf_file (const char *file_name,
case PT_NOTE:
if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
{
- ElfW(Word) *abi_note = (ElfW(Word) *) (file_contents
+ Elf64_Word *abi_note = (Elf64_Word *) (file_contents
+ segment->p_offset);
- ElfW(Addr) size = segment->p_filesz;
+ Elf64_Addr size = segment->p_filesz;
while (abi_note [0] != 4 || abi_note [1] != 16
|| abi_note [2] != 1
|| memcmp (abi_note + 3, "GNU", 4) != 0)
{
-#define ROUND(len) (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word)))
- ElfW(Addr) note_size = 3 * sizeof (ElfW(Word))
+#define ROUND(len) (((len) + sizeof (Elf64_Word) - 1) & -sizeof (Elf64_Word))
+ Elf64_Addr note_size = 3 * sizeof (Elf64_Word)
+ ROUND (abi_note[0])
+ ROUND (abi_note[1]);
@@ -166,7 +339,7 @@ process_elf_file (const char *file_name,
}
}
- if (loadaddr == (ElfW(Addr)) -1)
+ if (loadaddr == (Elf64_Addr) -1)
{
/* Very strange. */
loadaddr = 0;
@@ -176,7 +349,7 @@ process_elf_file (const char *file_name,
if (dynamic_size == 0)
return 1;
- dynamic_segment = (ElfW(Dyn) *) (file_contents + dynamic_addr);
+ dynamic_segment = (Elf64_Dyn *) (file_contents + dynamic_addr);
check_ptr (dynamic_segment);
/* Find the string table. */
@@ -233,3 +406,33 @@ process_elf_file (const char *file_name,
return 0;
}
+/* Returns 0 if everything is ok, != 0 in case of error. */
+int
+process_elf_file (const char *file_name, const char *lib, int *flag,
+ unsigned int *osversion, char **soname, void *file_contents,
+ size_t file_length)
+{
+ int i;
+ unsigned int j;
+ ElfW(Addr) loadaddr;
+ unsigned int dynamic_addr;
+ size_t dynamic_size;
+ char *program_interpreter;
+
+ ElfW(Ehdr) *elf_header;
+ ElfW(Phdr) *elf_pheader, *segment;
+ ElfW(Dyn) *dynamic_segment, *dyn_entry;
+ char *dynamic_strings;
+
+ elf_header = (ElfW(Ehdr) *) file_contents;
+ *osversion = 0;
+
+ if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
+ return process_elf_file32(file_name, lib,flag, osversion, soname, file_contents, file_length);
+ else if (elf_header->e_ident [EI_CLASS] == ELFCLASS64)
+ return process_elf_file64(file_name, lib,flag, osversion, soname, file_contents, file_length);
+ error (0, 0, _("Unknown ELFCLASS in file %s.\n"), file_name);
+ return 1;
+}
+
+

View File

@ -0,0 +1,8 @@
The files are pulled verbatim from glibc 2.5 and then patched to allow
standalone compilation of ldconfig.
Richard Purdie
OpenedHand Ltd.
Upgraded the ldconfig recipe to eglibc 2.12.1
Nitin A Kamble <nitin.a.kamble@intel.com> 2011/03/29

View File

@ -0,0 +1,454 @@
Upstream-Status: Inappropriate [embedded specific]
Do data input/output handling according to endien-ness of the library file. That
enables use of ldconfig in the cross fashion for any architecture.
2011/04/04
Richard Purdie <richard.purdie@linuxfoundation.org>
Nitin Kamble <nitin.a.kamble@intel.com>
Index: ldconfig-native-2.12.1/readelflib.c
===================================================================
--- ldconfig-native-2.12.1.orig/readelflib.c
+++ ldconfig-native-2.12.1/readelflib.c
@@ -38,6 +38,28 @@ do \
} \
while (0);
+int be;
+static uint16_t read16(uint16_t x, int be)
+{
+ if (be)
+ return be16toh(x);
+ return le16toh(x);
+}
+
+static uint32_t read32(uint32_t x, int be)
+{
+ if (be)
+ return be32toh(x);
+ return le32toh(x);
+}
+
+static uint64_t read64(uint64_t x, int be)
+{
+ if (be)
+ return be64toh(x);
+ return le64toh(x);
+}
+
/* Returns 0 if everything is ok, != 0 in case of error. */
int
process_elf_file32 (const char *file_name, const char *lib, int *flag,
@@ -59,15 +81,17 @@ process_elf_file32 (const char *file_nam
elf_header = (Elf32_Ehdr *) file_contents;
*osversion = 0;
- if (elf_header->e_type != ET_DYN)
+ be = (elf_header->e_ident[EI_DATA] == ELFDATA2MSB);
+
+ if (read16(elf_header->e_type, be) != ET_DYN)
{
error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name,
- elf_header->e_type);
+ read16(elf_header->e_type, be));
return 1;
}
/* Get information from elf program header. */
- elf_pheader = (Elf32_Phdr *) (elf_header->e_phoff + file_contents);
+ elf_pheader = (Elf32_Phdr *) (read32(elf_header->e_phoff, be) + file_contents);
check_ptr (elf_pheader);
/* The library is an elf library, now search for soname and
@@ -79,27 +103,27 @@ process_elf_file32 (const char *file_nam
dynamic_size = 0;
program_interpreter = NULL;
for (i = 0, segment = elf_pheader;
- i < elf_header->e_phnum; i++, segment++)
+ i < read16(elf_header->e_phnum, be); i++, segment++)
{
check_ptr (segment);
- switch (segment->p_type)
+ switch (read32(segment->p_type, be))
{
case PT_LOAD:
if (loadaddr == (Elf32_Addr) -1)
- loadaddr = segment->p_vaddr - segment->p_offset;
+ loadaddr = read32(segment->p_vaddr, be) - read32(segment->p_offset, be);
break;
case PT_DYNAMIC:
if (dynamic_addr)
error (0, 0, _("more than one dynamic segment\n"));
- dynamic_addr = segment->p_offset;
- dynamic_size = segment->p_filesz;
+ dynamic_addr = read32(segment->p_offset, be);
+ dynamic_size = read32(segment->p_filesz, be);
break;
case PT_INTERP:
- program_interpreter = (char *) (file_contents + segment->p_offset);
+ program_interpreter = (char *) (file_contents + read32(segment->p_offset, be));
check_ptr (program_interpreter);
/* Check if this is enough to classify the binary. */
@@ -113,20 +137,20 @@ process_elf_file32 (const char *file_nam
break;
case PT_NOTE:
- if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
+ if (!*osversion && read32(segment->p_filesz, be) >= 32 && segment->p_align >= 4)
{
Elf32_Word *abi_note = (Elf32_Word *) (file_contents
- + segment->p_offset);
- Elf32_Addr size = segment->p_filesz;
+ + read32(segment->p_offset, be));
+ Elf32_Addr size = read32(segment->p_filesz, be);
- while (abi_note [0] != 4 || abi_note [1] != 16
- || abi_note [2] != 1
+ while (read32(abi_note [0], be) != 4 || read32(abi_note [1], be) != 16
+ || read32(abi_note [2], be) != 1
|| memcmp (abi_note + 3, "GNU", 4) != 0)
{
-#define ROUND(len) (((len) + sizeof (Elf32_Word)) - 1) & -sizeof (Elf32_Word)))
- Elf32_Addr) note_size = 3 * sizeof (Elf32_Word))
- + ROUND (abi_note[0])
- + ROUND (abi_note[1]);
+#define ROUND(len) (((len) + sizeof (Elf32_Word) - 1) & -sizeof (Elf32_Word))
+ Elf32_Addr note_size = 3 * sizeof (Elf32_Word)
+ + ROUND (read32(abi_note[0], be))
+ + ROUND (read32(abi_note[1], be));
if (size - 32 < note_size || note_size == 0)
{
@@ -140,10 +164,10 @@ process_elf_file32 (const char *file_nam
if (size == 0)
break;
- *osversion = (abi_note [4] << 24) |
- ((abi_note [5] & 0xff) << 16) |
- ((abi_note [6] & 0xff) << 8) |
- (abi_note [7] & 0xff);
+ *osversion = (read32(abi_note [4], be) << 24) |
+ ((read32(abi_note [5], be) & 0xff) << 16) |
+ ((read32(abi_note [6], be) & 0xff) << 8) |
+ (read32(abi_note [7], be) & 0xff);
}
break;
@@ -167,13 +191,13 @@ process_elf_file32 (const char *file_nam
/* Find the string table. */
dynamic_strings = NULL;
- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
+ for (dyn_entry = dynamic_segment; read32(dyn_entry->d_tag, be) != DT_NULL;
++dyn_entry)
{
check_ptr (dyn_entry);
- if (dyn_entry->d_tag == DT_STRTAB)
+ if (read32(dyn_entry->d_tag, be) == DT_STRTAB)
{
- dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr);
+ dynamic_strings = (char *) (file_contents + read32(dyn_entry->d_un.d_val, be) - loadaddr);
check_ptr (dynamic_strings);
break;
}
@@ -183,15 +207,15 @@ process_elf_file32 (const char *file_nam
return 1;
/* Now read the DT_NEEDED and DT_SONAME entries. */
- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
+ for (dyn_entry = dynamic_segment; read32(dyn_entry->d_tag, be) != DT_NULL;
++dyn_entry)
{
- if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
+ if (read32(dyn_entry->d_tag, be) == DT_NEEDED || read32(dyn_entry->d_tag, be) == DT_SONAME)
{
- char *name = dynamic_strings + dyn_entry->d_un.d_val;
+ char *name = dynamic_strings + read32(dyn_entry->d_un.d_val, be);
check_ptr (name);
- if (dyn_entry->d_tag == DT_NEEDED)
+ if (read32(dyn_entry->d_tag, be) == DT_NEEDED)
{
if (*flag == FLAG_ELF)
@@ -208,7 +232,7 @@ process_elf_file32 (const char *file_nam
}
}
- else if (dyn_entry->d_tag == DT_SONAME)
+ else if (read32(dyn_entry->d_tag, be) == DT_SONAME)
*soname = xstrdup (name);
/* Do we have everything we need? */
@@ -246,15 +270,17 @@ process_elf_file64 (const char *file_nam
elf_header = (Elf64_Ehdr *) file_contents;
*osversion = 0;
- if (elf_header->e_type != ET_DYN)
+ be = (elf_header->e_ident[EI_DATA] == ELFDATA2MSB);
+
+ if (read16(elf_header->e_type, be) != ET_DYN)
{
error (0, 0, _("%s is not a shared object file (Type: %d).\n"), file_name,
- elf_header->e_type);
+ read16(elf_header->e_type, be));
return 1;
}
/* Get information from elf program header. */
- elf_pheader = (Elf64_Phdr *) (elf_header->e_phoff + file_contents);
+ elf_pheader = (Elf64_Phdr *) (read64(elf_header->e_phoff, be) + file_contents);
check_ptr (elf_pheader);
/* The library is an elf library, now search for soname and
@@ -266,27 +292,27 @@ process_elf_file64 (const char *file_nam
dynamic_size = 0;
program_interpreter = NULL;
for (i = 0, segment = elf_pheader;
- i < elf_header->e_phnum; i++, segment++)
+ i < read16(elf_header->e_phnum, be); i++, segment++)
{
check_ptr (segment);
- switch (segment->p_type)
+ switch (read32(segment->p_type, be))
{
case PT_LOAD:
if (loadaddr == (Elf64_Addr) -1)
- loadaddr = segment->p_vaddr - segment->p_offset;
+ loadaddr = read64(segment->p_vaddr, be) - read64(segment->p_offset, be);
break;
case PT_DYNAMIC:
if (dynamic_addr)
error (0, 0, _("more than one dynamic segment\n"));
- dynamic_addr = segment->p_offset;
- dynamic_size = segment->p_filesz;
+ dynamic_addr = read64(segment->p_offset, be);
+ dynamic_size = read32(segment->p_filesz, be);
break;
case PT_INTERP:
- program_interpreter = (char *) (file_contents + segment->p_offset);
+ program_interpreter = (char *) (file_contents + read64(segment->p_offset, be));
check_ptr (program_interpreter);
/* Check if this is enough to classify the binary. */
@@ -300,20 +326,21 @@ process_elf_file64 (const char *file_nam
break;
case PT_NOTE:
- if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
+ if (!*osversion && read32(segment->p_filesz, be) >= 32 && read32(segment->p_align, be) >= 4)
{
Elf64_Word *abi_note = (Elf64_Word *) (file_contents
- + segment->p_offset);
- Elf64_Addr size = segment->p_filesz;
+ + read64(segment->p_offset, be));
+ Elf64_Addr size = read32(segment->p_filesz, be);
- while (abi_note [0] != 4 || abi_note [1] != 16
- || abi_note [2] != 1
+ while (read32(abi_note [0], be) != 4 || read32(abi_note [1], be) != 16
+ || read32(abi_note [2], be) != 1
|| memcmp (abi_note + 3, "GNU", 4) != 0)
{
+#undef ROUND
#define ROUND(len) (((len) + sizeof (Elf64_Word) - 1) & -sizeof (Elf64_Word))
Elf64_Addr note_size = 3 * sizeof (Elf64_Word)
- + ROUND (abi_note[0])
- + ROUND (abi_note[1]);
+ + ROUND (read32(abi_note[0], be))
+ + ROUND (read32(abi_note[1], be));
if (size - 32 < note_size || note_size == 0)
{
@@ -327,10 +354,10 @@ process_elf_file64 (const char *file_nam
if (size == 0)
break;
- *osversion = (abi_note [4] << 24) |
- ((abi_note [5] & 0xff) << 16) |
- ((abi_note [6] & 0xff) << 8) |
- (abi_note [7] & 0xff);
+ *osversion = (read32(abi_note [4], be) << 24) |
+ ((read32(abi_note [5], be) & 0xff) << 16) |
+ ((read32(abi_note [6], be) & 0xff) << 8) |
+ (read32(abi_note [7], be) & 0xff);
}
break;
@@ -354,13 +381,13 @@ process_elf_file64 (const char *file_nam
/* Find the string table. */
dynamic_strings = NULL;
- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
+ for (dyn_entry = dynamic_segment; read64(dyn_entry->d_tag, be) != DT_NULL;
++dyn_entry)
{
check_ptr (dyn_entry);
- if (dyn_entry->d_tag == DT_STRTAB)
+ if (read64(dyn_entry->d_tag, be) == DT_STRTAB)
{
- dynamic_strings = (char *) (file_contents + dyn_entry->d_un.d_val - loadaddr);
+ dynamic_strings = (char *) (file_contents + read64(dyn_entry->d_un.d_val, be) - loadaddr);
check_ptr (dynamic_strings);
break;
}
@@ -370,15 +397,15 @@ process_elf_file64 (const char *file_nam
return 1;
/* Now read the DT_NEEDED and DT_SONAME entries. */
- for (dyn_entry = dynamic_segment; dyn_entry->d_tag != DT_NULL;
+ for (dyn_entry = dynamic_segment; read64(dyn_entry->d_tag, be) != DT_NULL;
++dyn_entry)
{
- if (dyn_entry->d_tag == DT_NEEDED || dyn_entry->d_tag == DT_SONAME)
+ if (read64(dyn_entry->d_tag, be) == DT_NEEDED || read64(dyn_entry->d_tag, be) == DT_SONAME)
{
- char *name = dynamic_strings + dyn_entry->d_un.d_val;
+ char *name = dynamic_strings + read64(dyn_entry->d_un.d_val, be);
check_ptr (name);
- if (dyn_entry->d_tag == DT_NEEDED)
+ if (read64(dyn_entry->d_tag, be) == DT_NEEDED)
{
if (*flag == FLAG_ELF)
@@ -395,7 +422,7 @@ process_elf_file64 (const char *file_nam
}
}
- else if (dyn_entry->d_tag == DT_SONAME)
+ else if (read64(dyn_entry->d_tag, be) == DT_SONAME)
*soname = xstrdup (name);
/* Do we have everything we need? */
Index: ldconfig-native-2.12.1/readlib.c
===================================================================
--- ldconfig-native-2.12.1.orig/readlib.c
+++ ldconfig-native-2.12.1/readlib.c
@@ -169,7 +169,8 @@ process_file (const char *real_file_name
ret = 1;
}
/* Libraries have to be shared object files. */
- else if (elf_header->e_type != ET_DYN)
+ else if ((elf_header->e_ident[EI_DATA] == ELFDATA2MSB && be16toh(elf_header->e_type) != ET_DYN) ||
+ (elf_header->e_ident[EI_DATA] == ELFDATA2LSB && le16toh(elf_header->e_type) != ET_DYN))
ret = 1;
else if (process_elf_file (file_name, lib, flag, osversion, soname,
file_contents, statbuf.st_size))
Index: ldconfig-native-2.12.1/cache.c
===================================================================
--- ldconfig-native-2.12.1.orig/cache.c
+++ ldconfig-native-2.12.1/cache.c
@@ -39,6 +39,29 @@
# define N_(msgid) msgid
#define _(msg) msg
+extern int be;
+
+static uint16_t write16(uint16_t x, int be)
+{
+ if (be)
+ return htobe16(x);
+ return htole16(x);
+}
+
+static uint32_t write32(uint32_t x, int be)
+{
+ if (be)
+ return htobe32(x);
+ return htole32(x);
+}
+
+static uint64_t write64(uint64_t x, int be)
+{
+ if (be)
+ return htobe64(x);
+ return htole64(x);
+}
+
struct cache_entry
{
char *lib; /* Library name. */
@@ -279,7 +302,12 @@ save_cache (const char *cache_name)
/* Number of normal cache entries. */
int cache_entry_old_count = 0;
- for (entry = entries; entry != NULL; entry = entry->next)
+ if (be)
+ printf("saving cache in big endian encoding\n");
+ else
+ printf("saving cache in little endian encoding\n");
+
+ for (entry = entries; entry != NULL; entry = entry->next)
{
/* Account the final NULs. */
total_strlen += strlen (entry->lib) + strlen (entry->path) + 2;
@@ -310,7 +338,7 @@ save_cache (const char *cache_name)
memset (file_entries, '\0', sizeof (struct cache_file));
memcpy (file_entries->magic, CACHEMAGIC, sizeof CACHEMAGIC - 1);
- file_entries->nlibs = cache_entry_old_count;
+ file_entries->nlibs = write32(cache_entry_old_count, be);
}
struct cache_file_new *file_entries_new = NULL;
@@ -330,8 +358,8 @@ save_cache (const char *cache_name)
memcpy (file_entries_new->version, CACHE_VERSION,
sizeof CACHE_VERSION - 1);
- file_entries_new->nlibs = cache_entry_count;
- file_entries_new->len_strings = total_strlen;
+ file_entries_new->nlibs = write32(cache_entry_count, be);
+ file_entries_new->len_strings = write32(total_strlen, be);
}
/* Pad for alignment of cache_file_new. */
@@ -358,9 +386,9 @@ save_cache (const char *cache_name)
/* First the library. */
if (opt_format != 2 && entry->hwcap == 0)
{
- file_entries->libs[idx_old].flags = entry->flags;
+ file_entries->libs[idx_old].flags = write32(entry->flags, be);
/* XXX: Actually we can optimize here and remove duplicates. */
- file_entries->libs[idx_old].key = str_offset + pad;
+ file_entries->libs[idx_old].key = write32(str_offset + pad, be);
}
if (opt_format != 0)
{
@@ -368,10 +396,10 @@ save_cache (const char *cache_name)
not doing so makes the code easier, the string table
always begins at the beginning of the the new cache
struct. */
- file_entries_new->libs[idx_new].flags = entry->flags;
- file_entries_new->libs[idx_new].osversion = entry->osversion;
- file_entries_new->libs[idx_new].hwcap = entry->hwcap;
- file_entries_new->libs[idx_new].key = str_offset;
+ file_entries_new->libs[idx_new].flags = write32(entry->flags, be);
+ file_entries_new->libs[idx_new].osversion = write32(entry->osversion, be);
+ file_entries_new->libs[idx_new].hwcap = write64(entry->hwcap, be);
+ file_entries_new->libs[idx_new].key = write32(str_offset, be);
}
size_t len = strlen (entry->lib) + 1;
@@ -379,9 +407,9 @@ save_cache (const char *cache_name)
str_offset += len;
/* Then the path. */
if (opt_format != 2 && entry->hwcap == 0)
- file_entries->libs[idx_old].value = str_offset + pad;
+ file_entries->libs[idx_old].value = write32(str_offset + pad, be);
if (opt_format != 0)
- file_entries_new->libs[idx_new].value = str_offset;
+ file_entries_new->libs[idx_new].value = write32(str_offset, be);
len = strlen (entry->path) + 1;
str = mempcpy (str, entry->path, len);
str_offset += len;

View File

@ -0,0 +1,113 @@
Upstream-Status: Inappropriate [fix poky patch]
This patch fixes build issues with a previous endian-ness_handling.patch on
distros that don't have macros referenced
7/20/2011
Matthew McClintock <msm@freescale.com>
diff -purN ldconfig-native-2.12.1.orig/endian_extra.h ldconfig-native-2.12.1/endian_extra.h
--- ldconfig-native-2.12.1.orig/endian_extra.h 1969-12-31 18:00:00.000000000 -0600
+++ ldconfig-native-2.12.1/endian_extra.h 2011-07-19 18:09:14.323048417 -0500
@@ -0,0 +1,64 @@
+/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <endian.h>
+
+#ifndef _ENDIAN_EXTRA_H
+#define _ENDIAN_EXTRA_H 1
+
+/* Don't redefine these macros if they already exist */
+#ifndef htobe16
+#ifdef __USE_BSD
+/* Conversion interfaces. */
+# include <byteswap.h>
+
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define htobe16(x) __bswap_16 (x)
+# define htole16(x) (x)
+# define be16toh(x) __bswap_16 (x)
+# define le16toh(x) (x)
+
+# define htobe32(x) __bswap_32 (x)
+# define htole32(x) (x)
+# define be32toh(x) __bswap_32 (x)
+# define le32toh(x) (x)
+
+# define htobe64(x) __bswap_64 (x)
+# define htole64(x) (x)
+# define be64toh(x) __bswap_64 (x)
+# define le64toh(x) (x)
+# else
+# define htobe16(x) (x)
+# define htole16(x) __bswap_16 (x)
+# define be16toh(x) (x)
+# define le16toh(x) __bswap_16 (x)
+
+# define htobe32(x) (x)
+# define htole32(x) __bswap_32 (x)
+# define be32toh(x) (x)
+# define le32toh(x) __bswap_32 (x)
+
+# define htobe64(x) (x)
+# define htole64(x) __bswap_64 (x)
+# define be64toh(x) (x)
+# define le64toh(x) __bswap_64 (x)
+# endif
+#endif
+#endif
+
+#endif /* endian_extra.h */
diff -purN ldconfig-native-2.12.1.orig/cache.c ldconfig-native-2.12.1/cache.c
--- ldconfig-native-2.12.1.orig/cache.c 2011-07-19 18:21:28.347041301 -0500
+++ ldconfig-native-2.12.1/cache.c 2011-07-19 18:22:54.118048064 -0500
@@ -39,6 +39,8 @@
# define N_(msgid) msgid
#define _(msg) msg
+#include "endian_extra.h"
+
extern int be;
static uint16_t write16(uint16_t x, int be)
diff -purN ldconfig-native-2.12.1.orig/readelflib.c ldconfig-native-2.12.1/readelflib.c
--- ldconfig-native-2.12.1.orig/readelflib.c 2011-07-19 18:21:28.346041593 -0500
+++ ldconfig-native-2.12.1/readelflib.c 2011-07-19 18:23:05.324059875 -0500
@@ -25,6 +25,9 @@
/* check_ptr checks that a pointer is in the mmaped file and doesn't
point outside it. */
+
+#include "endian_extra.h"
+
#undef check_ptr
#define check_ptr(ptr) \
do \
diff -purN ldconfig-native-2.12.1.orig/readlib.c ldconfig-native-2.12.1/readlib.c
--- ldconfig-native-2.12.1.orig/readlib.c 2011-07-19 18:21:28.346041593 -0500
+++ ldconfig-native-2.12.1/readlib.c 2011-07-19 18:23:23.877046210 -0500
@@ -40,6 +40,8 @@
#include "ldconfig.h"
+#include "endian_extra.h"
+
#define _(msg) msg
#define Elf32_CLASS ELFCLASS32

View File

@ -0,0 +1,24 @@
Upstream-Status: Inappropriate [embedded specific]
The native version of ldconfig was using native definition of LD_SO (i.e.
ld-linux-x86-64.so.2 ) which is not correct for doing the cross ldconfig.
This was causing libc.so on the target marked as ELF lib rather than
FLAG_ELF_LIBC6 in the ld.so.cache.
Nitin A Kamble <nitin.a.kamble@intel.com> 2011/04/4
Index: ldconfig-native-2.12.1/readlib.c
===================================================================
--- ldconfig-native-2.12.1.orig/readlib.c
+++ ldconfig-native-2.12.1/readlib.c
@@ -51,6 +51,10 @@ struct known_names
int flag;
};
+/* don't use host's definition of LD_SO */
+#undef LD_SO
+#define LD_SO "ld.so.1"
+
static struct known_names interpreters[] =
{
{ "/lib/" LD_SO, FLAG_ELF_LIBC6 },

View File

@ -0,0 +1,471 @@
Upstream-Status: Inappropriate [embedded specific]
enable standalone building of ldconfig
---
cache.c | 11 +-
chroot_canon.c | 7 +
dl-cache.c | 235 ---------------------------------------------------------
dl-cache.h | 3
ldconfig.c | 27 ++++--
readlib.c | 7 +
xstrdup.c | 11 --
7 files changed, 45 insertions(+), 256 deletions(-)
Index: ldconfig-native-2.12.1/cache.c
===================================================================
--- ldconfig-native-2.12.1.orig/cache.c
+++ ldconfig-native-2.12.1/cache.c
@@ -16,6 +16,9 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+#define _LARGEFILE64_SOURCE
+#define _GNU_SOURCE
+
#include <errno.h>
#include <error.h>
#include <dirent.h>
@@ -31,8 +34,10 @@
#include <sys/stat.h>
#include <sys/types.h>
-#include <ldconfig.h>
-#include <dl-cache.h>
+#include "ldconfig.h"
+#include "dl-cache.h"
+# define N_(msgid) msgid
+#define _(msg) msg
struct cache_entry
{
Index: ldconfig-native-2.12.1/chroot_canon.c
===================================================================
--- ldconfig-native-2.12.1.orig/chroot_canon.c
+++ ldconfig-native-2.12.1/chroot_canon.c
@@ -17,6 +17,9 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+#define _LARGEFILE64_SOURCE
+#define _GNU_SOURCE
+
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -27,7 +30,9 @@
#include <stddef.h>
#include <stdint.h>
-#include <ldconfig.h>
+#include "ldconfig.h"
+
+#define __set_errno(Val) errno = (Val)
#ifndef PATH_MAX
#define PATH_MAX 1024
Index: ldconfig-native-2.12.1/dl-cache.c
===================================================================
--- ldconfig-native-2.12.1.orig/dl-cache.c
+++ ldconfig-native-2.12.1/dl-cache.c
@@ -20,12 +20,12 @@
#include <assert.h>
#include <unistd.h>
-#include <ldsodefs.h>
+//#include "ldsodefs.h"
#include <sys/mman.h>
#include <dl-cache.h>
#include <dl-procinfo.h>
-#include <stdio-common/_itoa.h>
+//#include "_itoa.h"
#ifndef _DL_PLATFORMS_COUNT
# define _DL_PLATFORMS_COUNT 0
@@ -39,103 +39,7 @@ static size_t cachesize;
/* 1 if cache_data + PTR points into the cache. */
#define _dl_cache_verify_ptr(ptr) (ptr < cache_data_size)
-#define SEARCH_CACHE(cache) \
-/* We use binary search since the table is sorted in the cache file. \
- The first matching entry in the table is returned. \
- It is important to use the same algorithm as used while generating \
- the cache file. */ \
-do \
- { \
- left = 0; \
- right = cache->nlibs - 1; \
- \
- while (left <= right) \
- { \
- __typeof__ (cache->libs[0].key) key; \
- \
- middle = (left + right) / 2; \
- \
- key = cache->libs[middle].key; \
- \
- /* Make sure string table indices are not bogus before using \
- them. */ \
- if (! _dl_cache_verify_ptr (key)) \
- { \
- cmpres = 1; \
- break; \
- } \
- \
- /* Actually compare the entry with the key. */ \
- cmpres = _dl_cache_libcmp (name, cache_data + key); \
- if (__builtin_expect (cmpres == 0, 0)) \
- { \
- /* Found it. LEFT now marks the last entry for which we \
- know the name is correct. */ \
- left = middle; \
- \
- /* There might be entries with this name before the one we \
- found. So we have to find the beginning. */ \
- while (middle > 0) \
- { \
- __typeof__ (cache->libs[0].key) key; \
- \
- key = cache->libs[middle - 1].key; \
- /* Make sure string table indices are not bogus before \
- using them. */ \
- if (! _dl_cache_verify_ptr (key) \
- /* Actually compare the entry. */ \
- || _dl_cache_libcmp (name, cache_data + key) != 0) \
- break; \
- --middle; \
- } \
- \
- do \
- { \
- int flags; \
- __typeof__ (cache->libs[0]) *lib = &cache->libs[middle]; \
- \
- /* Only perform the name test if necessary. */ \
- if (middle > left \
- /* We haven't seen this string so far. Test whether the \
- index is ok and whether the name matches. Otherwise \
- we are done. */ \
- && (! _dl_cache_verify_ptr (lib->key) \
- || (_dl_cache_libcmp (name, cache_data + lib->key) \
- != 0))) \
- break; \
- \
- flags = lib->flags; \
- if (_dl_cache_check_flags (flags) \
- && _dl_cache_verify_ptr (lib->value)) \
- { \
- if (best == NULL || flags == GLRO(dl_correct_cache_id)) \
- { \
- HWCAP_CHECK; \
- best = cache_data + lib->value; \
- \
- if (flags == GLRO(dl_correct_cache_id)) \
- /* We've found an exact match for the shared \
- object and no general `ELF' release. Stop \
- searching. */ \
- break; \
- } \
- } \
- } \
- while (++middle <= right); \
- break; \
- } \
- \
- if (cmpres < 0) \
- left = middle + 1; \
- else \
- right = middle - 1; \
- } \
- } \
-while (0)
-
-
int
-internal_function
_dl_cache_libcmp (const char *p1, const char *p2)
{
while (*p1 != '\0')
@@ -172,139 +76,3 @@ _dl_cache_libcmp (const char *p1, const
}
return *p1 - *p2;
}
-
-
-/* Look up NAME in ld.so.cache and return the file name stored there,
- or null if none is found. */
-
-const char *
-internal_function
-_dl_load_cache_lookup (const char *name)
-{
- int left, right, middle;
- int cmpres;
- const char *cache_data;
- uint32_t cache_data_size;
- const char *best;
-
- /* Print a message if the loading of libs is traced. */
- if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0))
- _dl_debug_printf (" search cache=%s\n", LD_SO_CACHE);
-
- if (cache == NULL)
- {
- /* Read the contents of the file. */
- void *file = _dl_sysdep_read_whole_file (LD_SO_CACHE, &cachesize,
- PROT_READ);
-
- /* We can handle three different cache file formats here:
- - the old libc5/glibc2.0/2.1 format
- - the old format with the new format in it
- - only the new format
- The following checks if the cache contains any of these formats. */
- if (file != MAP_FAILED && cachesize > sizeof *cache
- && memcmp (file, CACHEMAGIC, sizeof CACHEMAGIC - 1) == 0)
- {
- size_t offset;
- /* Looks ok. */
- cache = file;
-
- /* Check for new version. */
- offset = ALIGN_CACHE (sizeof (struct cache_file)
- + cache->nlibs * sizeof (struct file_entry));
-
- cache_new = (struct cache_file_new *) ((void *) cache + offset);
- if (cachesize < (offset + sizeof (struct cache_file_new))
- || memcmp (cache_new->magic, CACHEMAGIC_VERSION_NEW,
- sizeof CACHEMAGIC_VERSION_NEW - 1) != 0)
- cache_new = (void *) -1;
- }
- else if (file != MAP_FAILED && cachesize > sizeof *cache_new
- && memcmp (file, CACHEMAGIC_VERSION_NEW,
- sizeof CACHEMAGIC_VERSION_NEW - 1) == 0)
- {
- cache_new = file;
- cache = file;
- }
- else
- {
- if (file != MAP_FAILED)
- __munmap (file, cachesize);
- cache = (void *) -1;
- }
-
- assert (cache != NULL);
- }
-
- if (cache == (void *) -1)
- /* Previously looked for the cache file and didn't find it. */
- return NULL;
-
- best = NULL;
-
- if (cache_new != (void *) -1)
- {
- uint64_t platform;
-
- /* This is where the strings start. */
- cache_data = (const char *) cache_new;
-
- /* Now we can compute how large the string table is. */
- cache_data_size = (const char *) cache + cachesize - cache_data;
-
- platform = _dl_string_platform (GLRO(dl_platform));
- if (platform != (uint64_t) -1)
- platform = 1ULL << platform;
-
-#define _DL_HWCAP_TLS_MASK (1LL << 63)
- uint64_t hwcap_exclude = ~((GLRO(dl_hwcap) & GLRO(dl_hwcap_mask))
- | _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK);
-
- /* Only accept hwcap if it's for the right platform. */
-#define HWCAP_CHECK \
- if (lib->hwcap & hwcap_exclude) \
- continue; \
- if (GLRO(dl_osversion) && lib->osversion > GLRO(dl_osversion)) \
- continue; \
- if (_DL_PLATFORMS_COUNT \
- && (lib->hwcap & _DL_HWCAP_PLATFORM) != 0 \
- && (lib->hwcap & _DL_HWCAP_PLATFORM) != platform) \
- continue
- SEARCH_CACHE (cache_new);
- }
- else
- {
- /* This is where the strings start. */
- cache_data = (const char *) &cache->libs[cache->nlibs];
-
- /* Now we can compute how large the string table is. */
- cache_data_size = (const char *) cache + cachesize - cache_data;
-
-#undef HWCAP_CHECK
-#define HWCAP_CHECK do {} while (0)
- SEARCH_CACHE (cache);
- }
-
- /* Print our result if wanted. */
- if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)
- && best != NULL)
- _dl_debug_printf (" trying file=%s\n", best);
-
- return best;
-}
-
-#ifndef MAP_COPY
-/* If the system does not support MAP_COPY we cannot leave the file open
- all the time since this would create problems when the file is replaced.
- Therefore we provide this function to close the file and open it again
- once needed. */
-void
-_dl_unload_cache (void)
-{
- if (cache != NULL && cache != (struct cache_file *) -1)
- {
- __munmap (cache, cachesize);
- cache = NULL;
- }
-}
-#endif
Index: ldconfig-native-2.12.1/dl-cache.h
===================================================================
--- ldconfig-native-2.12.1.orig/dl-cache.h
+++ ldconfig-native-2.12.1/dl-cache.h
@@ -101,5 +101,4 @@ struct cache_file_new
(((addr) + __alignof__ (struct cache_file_new) -1) \
& (~(__alignof__ (struct cache_file_new) - 1)))
-extern int _dl_cache_libcmp (const char *p1, const char *p2)
- internal_function;
+extern int _dl_cache_libcmp (const char *p1, const char *p2);
Index: ldconfig-native-2.12.1/ldconfig.c
===================================================================
--- ldconfig-native-2.12.1.orig/ldconfig.c
+++ ldconfig-native-2.12.1/ldconfig.c
@@ -16,6 +16,9 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+#define _LARGEFILE64_SOURCE
+#define _GNU_SOURCE
+
#define PROCINFO_CLASS static
#include <alloca.h>
#include <argp.h>
@@ -39,10 +42,20 @@
#include <glob.h>
#include <libgen.h>
-#include <ldconfig.h>
-#include <dl-cache.h>
+#include "ldconfig.h"
+#include "dl-cache.h"
+
+#include "dl-procinfo.h"
+
+#include "argp.h"
+
+
+#define SYSCONFDIR "/etc"
+#define LIBDIR "/usr/lib"
+#define SLIBDIR "/lib"
+# define N_(msgid) msgid
+#define _(msg) msg
-#include <dl-procinfo.h>
#ifdef _DL_FIRST_PLATFORM
# define _DL_FIRST_EXTRA (_DL_FIRST_PLATFORM + _DL_PLATFORMS_COUNT)
@@ -55,7 +68,7 @@
#endif
/* Get libc version number. */
-#include <version.h>
+#include "version.h"
#define PACKAGE _libc_intl_domainname
@@ -152,8 +165,8 @@ static const struct argp_option options[
{ NULL, 0, NULL, 0, NULL, 0 }
};
-#define PROCINFO_CLASS static
-#include <dl-procinfo.c>
+//#define PROCINFO_CLASS static
+//#include <dl-procinfo.c>
/* Short description of program. */
static const char doc[] = N_("Configure Dynamic Linker Run Time Bindings.");
@@ -291,6 +304,7 @@ parse_opt (int key, char *arg, struct ar
return 0;
}
+#define REPORT_BUGS_TO "mailing list : poky@yoctoproject.org"
/* Print bug-reporting information in the help message. */
static char *
more_help (int key, const char *text, void *input)
@@ -315,7 +329,7 @@ For bug reporting instructions, please s
static void
print_version (FILE *stream, struct argp_state *state)
{
- fprintf (stream, "ldconfig %s%s\n", PKGVERSION, VERSION);
+ fprintf (stream, "ldconfig (Hacked Poky Version)\n");
fprintf (stream, gettext ("\
Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\
@@ -1233,6 +1247,7 @@ set_hwcap (void)
hwcap_mask = strtoul (mask, NULL, 0);
}
+const char _libc_intl_domainname[] = "libc";
int
main (int argc, char **argv)
Index: ldconfig-native-2.12.1/readlib.c
===================================================================
--- ldconfig-native-2.12.1.orig/readlib.c
+++ ldconfig-native-2.12.1/readlib.c
@@ -22,6 +22,9 @@
development version. Besides the simplification, it has also been
modified to read some other file formats. */
+#define _LARGEFILE64_SOURCE
+#define _GNU_SOURCE
+
#include <a.out.h>
#include <elf.h>
#include <error.h>
@@ -35,7 +38,9 @@
#include <sys/stat.h>
#include <gnu/lib-names.h>
-#include <ldconfig.h>
+#include "ldconfig.h"
+
+#define _(msg) msg
#define Elf32_CLASS ELFCLASS32
#define Elf64_CLASS ELFCLASS64
Index: ldconfig-native-2.12.1/xstrdup.c
===================================================================
--- ldconfig-native-2.12.1.orig/xstrdup.c
+++ ldconfig-native-2.12.1/xstrdup.c
@@ -16,15 +16,10 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#define _GNU_SOURCE
+
+#include <string.h>
-#if defined STDC_HEADERS || defined HAVE_STRING_H || _LIBC
-# include <string.h>
-#else
-# include <strings.h>
-#endif
void *xmalloc (size_t n) __THROW;
char *xstrdup (char *string) __THROW;

View File

@ -0,0 +1,36 @@
Upstream-Status: Pending
Coming from this bug: http://sourceware.org/bugzilla/show_bug.cgi?id=11149
Nitin A Kamble <nitin.a.kamble@intel.com>2011/03/29
--- ldconfig-native-2.12.1.orig/ldconfig.c
+++ ldconfig-native-2.12.1/ldconfig.c
@@ -1359,14 +1359,9 @@ main (int argc, char **argv)
const char *aux_cache_file = _PATH_LDCONFIG_AUX_CACHE;
if (opt_chroot)
- {
- aux_cache_file = chroot_canon (opt_chroot, aux_cache_file);
- if (aux_cache_file == NULL)
- error (EXIT_FAILURE, errno, _("Can't open cache file %s\n"),
- _PATH_LDCONFIG_AUX_CACHE);
- }
+ aux_cache_file = chroot_canon (opt_chroot, aux_cache_file);
- if (! opt_ignore_aux_cache)
+ if (! opt_ignore_aux_cache && aux_cache_file)
load_aux_cache (aux_cache_file);
else
init_aux_cache ();
@@ -1376,7 +1371,8 @@ main (int argc, char **argv)
if (opt_build_cache)
{
save_cache (cache_file);
- save_aux_cache (aux_cache_file);
+ if (aux_cache_file)
+ save_aux_cache (aux_cache_file);
}
return 0;

View File

@ -0,0 +1,28 @@
DESCRIPTION = "A standalone native ldconfig build"
LICENSE = "GPLv2.1"
LIC_FILES_CHKSUM = "file://${S}/ldconfig.c;endline=17;md5=1d15f20937c055cb5de2329a4c054399"
SRC_URI = "file://ldconfig-native-2.12.1.tar.bz2 \
file://ldconfig.patch \
file://ldconfig_aux-cache_path_fix.patch \
file://32and64bit.patch \
file://endian-ness_handling.patch \
file://flag_fix.patch \
file://endianess-header.patch"
PR = "r1"
inherit native
S = "${WORKDIR}/${PN}-${PV}"
do_compile () {
$CC ldconfig.c -std=gnu99 chroot_canon.c xmalloc.c xstrdup.c cache.c readlib.c -I. dl-cache.c -o ldconfig
}
do_install () {
install -d ${D}/${bindir}/
install ldconfig ${D}/${bindir}/
}