Implement handling of libc ABI in ELF header.

This commit is contained in:
Ulrich Drepper 2010-03-15 11:44:58 -07:00
parent 94db8db8e8
commit 92ad15a8f1
4 changed files with 32 additions and 6 deletions

View File

@ -1,3 +1,11 @@
2010-03-15 Ulrich Drepper <drepper@redhat.com>
* Makerules: Add rule for libc-abis.h.
* csu/version.c: Use LIBC_ABIS_STRING string if available.
* elf/dl-load.c (VALID_ELF_ABIVERSION): Check using LIBC_ABI_MAX.
(open_verify): Only check EI_ABIVERSION bytes using VALID_ELF_HEADER.
Add extra call to VALID_ELF_ABIVERSION.
2010-03-12 Ulrich Drepper <drepper@redhat.com>
* sysdeps/unix/sysv/linux/sys/mount.h (UMOUNT_NOFOLLOW): Define.

View File

@ -1,4 +1,4 @@
# Copyright (C) 1991-2006,2007,2008,2009 Free Software Foundation, Inc.
# Copyright (C) 1991-2006,2007,2008,2009,2010 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
@ -109,6 +109,18 @@ $(common-objpfx)%.latest: $(common-objpfx)abi-versions.h
endif # avoid-generated
endif # $(versioning) = yes
ifndef avoid-generated
before-compile := $(common-objpfx)libc-abis.h $(before-compile)
libc-abis := $(firstword $(wildcard $(foreach D,$(add-ons), $(..)libc-abis)) \
libc-abis)
$(common-objpfx)libc-abis.h: $(..)scripts/gen-libc-abis $(libc-abis)
$(SHELL) $(..)scripts/gen-libc-abis \
$(base-machine)-$(config-vendor)-$(config-os) \
< $(libc-abis) > $@T
$(move-if-change) $@T $@
common-generated += $(common-objpfx)libc-abis.h
endif # avoid-generated
# Make sure the subdirectory for object files gets created.
ifdef objpfx
ifeq (,$(wildcard $(objpfx).))
@ -1395,7 +1407,7 @@ $(objpfx)stubs: $(objs-for-stubs)
ifneq (,$(strip $(objs-for-stubs)))
(cd $(objpfx).; $(OBJDUMP) -h $(patsubst $(objpfx)%,%,$^)) | \
$(AWK) '/\.gnu\.glibc-stub\./ { \
sub(/\.gnu\.glibc-stub\./, "", $$2); \
sub(/\.gnu\.glibc-stub\./, "", $$2); \
stubs[$$2] = 1; } \
END { for (s in stubs) print "#define __stub_" s }' > $@T
mv -f $@T $@

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1992-2008, 2009 Free Software Foundation, Inc.
/* Copyright (C) 1992-2008, 2009, 2010 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
@ -18,6 +18,7 @@
#include "version.h"
#include <tls.h>
#include <libc-abis.h>
#include <gnu/libc-version.h>
static const char __libc_release[] = RELEASE;
@ -25,12 +26,15 @@ static const char __libc_version[] = VERSION;
static const char banner[] =
"GNU C Library "RELEASE" release version "VERSION", by Roland McGrath et al.\n\
Copyright (C) 2009 Free Software Foundation, Inc.\n\
Copyright (C) 2010 Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
PARTICULAR PURPOSE.\n\
Compiled by GNU CC version "__VERSION__".\n"
#include "version-info.h"
#ifdef LIBC_ABIS_STRING
LIBC_ABIS_STRING
#endif
#ifdef GLIBC_OLDEST_ABI
"The oldest ABI supported: " GLIBC_OLDEST_ABI ".\n"
#endif

View File

@ -1569,7 +1569,7 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
#ifndef VALID_ELF_HEADER
# define VALID_ELF_HEADER(hdr,exp,size) (memcmp (hdr, exp, size) == 0)
# define VALID_ELF_OSABI(osabi) (osabi == ELFOSABI_SYSV)
# define VALID_ELF_ABIVERSION(ver) (ver == 0)
# define VALID_ELF_ABIVERSION(ver) (ver < LIBC_ABI_MAX)
#elif defined MORE_ELF_HEADER_DATA
MORE_ELF_HEADER_DATA;
#endif
@ -1655,7 +1655,9 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
/* See whether the ELF header is what we expect. */
if (__builtin_expect (! VALID_ELF_HEADER (ehdr->e_ident, expected,
EI_PAD), 0))
EI_ABIVERSION)
|| !VALID_ELF_ABIVERSION (ehdr->e_ident[EI_ABIVERSION]),
0))
{
/* Something is wrong. */
const Elf32_Word *magp = (const void *) ehdr->e_ident;