From 92ad15a8f1d3e65f20fda3265c04ff26a642a2d0 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 15 Mar 2010 11:44:58 -0700 Subject: [PATCH] Implement handling of libc ABI in ELF header. --- ChangeLog | 8 ++++++++ Makerules | 16 ++++++++++++++-- csu/version.c | 8 ++++++-- elf/dl-load.c | 6 ++++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8781598a9..21137d77e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-03-15 Ulrich Drepper + + * 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 * sysdeps/unix/sysv/linux/sys/mount.h (UMOUNT_NOFOLLOW): Define. diff --git a/Makerules b/Makerules index 43fa5a701b..d5ff383770 100644 --- a/Makerules +++ b/Makerules @@ -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 $@ diff --git a/csu/version.c b/csu/version.c index db913be800..8e32f312a9 100644 --- a/csu/version.c +++ b/csu/version.c @@ -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 +#include #include 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 diff --git a/elf/dl-load.c b/elf/dl-load.c index e8c7be55f7..1cfab353d0 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -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; -- 2.11.4.GIT