]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Add new ebl_check_st_other_bits function. mpolacek/autotest
authorMark Wielaard <mjw@redhat.com>
Thu, 10 Mar 2011 12:02:32 +0000 (13:02 +0100)
committerMark Wielaard <mjw@redhat.com>
Fri, 11 Mar 2011 11:59:29 +0000 (12:59 +0100)
backends/ChangeLog
backends/alpha_init.c
backends/alpha_symbol.c
libebl/ChangeLog
libebl/Makefile.am
libebl/ebl-hooks.h
libebl/eblopenbackend.c
libebl/eblstother.c [new file with mode: 0644]
libebl/libebl.h
src/ChangeLog
src/elflint.c

index 2dcc9ef4cdb71b2a098814d109890fc0481c1427..744d1d55de91f8f3846ec2c47599806173b690b7 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-09  Mark Wielaard  <mjw@redhat.com>
+
+       * alpha_init.c (alpha_init): Initialize check_st_other_bits hook.
+       * alpha_symbol.c (alpha_check_st_other_bits): New function.
+
 2011-03-09  Roland McGrath  <roland@redhat.com>
 
        * alpha_symbol.c (alpha_check_special_symbol): New function.
index 14c085cc2de5775c679f291b0fedabe0d19b097f..30fe5c6c065119fca6fea3b250588e7e0651bae1 100644 (file)
@@ -57,6 +57,7 @@ alpha_init (elf, machine, eh, ehlen)
   HOOK (eh, machine_section_flag_check);
   HOOK (eh, check_special_section);
   HOOK (eh, check_special_symbol);
+  HOOK (eh, check_st_other_bits);
   HOOK (eh, register_info);
   HOOK (eh, core_note);
   HOOK (eh, auxv_info);
index 4bd8793a01bf7bfae5e96946e6c03ca0548dceec..5d25d3e48fc8227ff1fc627e7513ca1830137453 100644 (file)
@@ -141,3 +141,13 @@ alpha_check_special_symbol (Elf *elf __attribute__ ((unused)),
 
   return false;
 }
+
+/* Check whether only valid bits are set on the st_other symbol flag.
+   Standard ST_VISIBILITY have already been masked off.  */
+bool
+alpha_check_st_other_bits (unsigned char st_other)
+{
+  return ((((st_other & STO_ALPHA_STD_GPLOAD) == STO_ALPHA_NOPV)
+          || ((st_other & STO_ALPHA_STD_GPLOAD) == STO_ALPHA_STD_GPLOAD))
+         && (st_other &~ STO_ALPHA_STD_GPLOAD) == 0);
+}
index 96f70ff8d83e46cb7ea75b6fb9f43373e65dd622..bec6511fe789380b0642781c79169f775483f7b3 100644 (file)
@@ -1,3 +1,12 @@
+2011-03-10  Mark Wielaard  <mjw@redhat.com>
+
+       * Makefile.am (gen_SOURCES): Add eblstother.c.
+       * eblstother.c: New file.
+       * ebl-hooks.h: Add check_st_other_bits hook.
+       * eblopenbackend.c (default_check_st_other_bits): New function.
+       (fill_defaults): Hook default_check_st_other_bits.
+       * libebl.h (ebl_check_st_other_bits): New prototype.
+
 2010-07-07  Roland McGrath  <roland@redhat.com>
 
        * eblopenbackend.c (default_debugscn_p): Match .gdb_index section.
index d157195ef5f0034a5269c5bb32d4cdae1db4b812..ced5668b47361746d6fa97b54ff26461b3608557 100644 (file)
@@ -50,7 +50,8 @@ gen_SOURCES = eblopenbackend.c eblclosebackend.c eblstrtab.c \
              ebl_check_special_symbol.c eblbsspltp.c eblretval.c \
              eblreginfo.c eblnonerelocp.c eblrelativerelocp.c \
              eblsysvhashentrysize.c eblauxvinfo.c eblcheckobjattr.c \
-             ebl_check_special_section.c ebl_syscall_abi.c eblabicfi.c
+             ebl_check_special_section.c ebl_syscall_abi.c eblabicfi.c \
+             eblstother.c
 
 libebl_a_SOURCES = $(gen_SOURCES)
 
index 59e73c54e52400d3be8a648af8b043bb908a77fc..82c6c6400e19c1e900debebbb94b5cf6619d46e6 100644 (file)
@@ -1,5 +1,5 @@
 /* Backend hook signatures internal interface for libebl.
-   Copyright (C) 2000-2010 Red Hat, Inc.
+   Copyright (C) 2000-2011 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -144,6 +144,10 @@ bool EBLHOOK(relative_reloc_p) (int);
 bool EBLHOOK(check_special_symbol) (Elf *, GElf_Ehdr *, const GElf_Sym *,
                              const char *, const GElf_Shdr *);
 
+/* Check whether only valid bits are set on the st_other symbol flag.
+   Standard ST_VISIBILITY have already been masked off.  */
+bool EBLHOOK(check_st_other_bits) (unsigned char st_other);
+
 /* Check if backend uses a bss PLT in this file.  */
 bool EBLHOOK(bss_plt_p) (Elf *, GElf_Ehdr *);
 
index e11ff067c73438b647cb9fb4873f454918f611ab..24f472ce34941571864af8b5da584eb44cc8a3d6 100644 (file)
@@ -1,5 +1,5 @@
 /* Generate ELF backend handle.
-   Copyright (C) 2000-2010 Red Hat, Inc.
+   Copyright (C) 2000-2011 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -202,6 +202,7 @@ static bool default_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr,
                                          const GElf_Sym *sym,
                                          const char *name,
                                          const GElf_Shdr *destshdr);
+static bool default_check_st_other_bits (unsigned char st_other);
 static bool default_check_special_section (Ebl *, int,
                                           const GElf_Shdr *, const char *);
 static bool default_bss_plt_p (Elf *elf, GElf_Ehdr *ehdr);
@@ -253,6 +254,7 @@ fill_defaults (Ebl *result)
   result->none_reloc_p = default_none_reloc_p;
   result->relative_reloc_p = default_relative_reloc_p;
   result->check_special_symbol = default_check_special_symbol;
+  result->check_st_other_bits = default_check_st_other_bits;
   result->bss_plt_p = default_bss_plt_p;
   result->return_value_location = default_return_value_location;
   result->register_info = default_register_info;
@@ -697,6 +699,13 @@ default_check_special_symbol (Elf *elf __attribute__ ((unused)),
   return false;
 }
 
+static bool
+default_check_st_other_bits (unsigned char st_other __attribute__ ((unused)))
+{
+  return false;
+}
+
+
 static bool
 default_bss_plt_p (Elf *elf __attribute__ ((unused)),
                   GElf_Ehdr *ehdr __attribute__ ((unused)))
diff --git a/libebl/eblstother.c b/libebl/eblstother.c
new file mode 100644 (file)
index 0000000..ba8c9da
--- /dev/null
@@ -0,0 +1,64 @@
+/* Check st_other flag.
+   Copyright (C) 2011 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils 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
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   In addition, as a special exception, Red Hat, Inc. gives You the
+   additional right to link the code of Red Hat elfutils with code licensed
+   under any Open Source Initiative certified open source license
+   (http://www.opensource.org/licenses/index.php) which requires the
+   distribution of source code with any binary distribution and to
+   distribute linked combinations of the two.  Non-GPL Code permitted under
+   this exception must only link to the code of Red Hat elfutils through
+   those well defined interfaces identified in the file named EXCEPTION
+   found in the source code files (the "Approved Interfaces").  The files
+   of Non-GPL Code may instantiate templates or use macros or inline
+   functions from the Approved Interfaces without causing the resulting
+   work to be covered by the GNU General Public License.  Only Red Hat,
+   Inc. may make changes or additions to the list of Approved Interfaces.
+   Red Hat's grant of this exception is conditioned upon your not adding
+   any new exceptions.  If you wish to add a new Approved Interface or
+   exception, please contact Red Hat.  You must obey the GNU General Public
+   License in all respects for all of the Red Hat elfutils code and other
+   code used in conjunction with Red Hat elfutils except the Non-GPL Code
+   covered by this exception.  If you modify this file, you may extend this
+   exception to your version of the file, but you are not obligated to do
+   so.  If you do not wish to provide this exception without modification,
+   you must delete this exception statement from your version and license
+   this file solely under the GPL without exception.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libeblP.h>
+
+
+bool
+ebl_check_st_other_bits (ebl, st_other)
+     Ebl *ebl;
+     unsigned char st_other;
+{
+  return ((st_other ^ GELF_ST_VISIBILITY (st_other)) == 0
+         || ebl->check_st_other_bits (st_other ^ GELF_ST_VISIBILITY (st_other)));
+}
index c94ad78f2079fc93be750ea2c08293c2ebb8cda4..b4307282db51ae49a5bb5928ea652182fb8c1b2c 100644 (file)
@@ -168,6 +168,9 @@ extern bool ebl_check_special_symbol (Ebl *ebl, GElf_Ehdr *ehdr,
                                      const GElf_Sym *sym, const char *name,
                                      const GElf_Shdr *destshdr);
 
+/* Check whether only valid bits are set on the st_other symbol flag.  */
+extern bool ebl_check_st_other_bits (Ebl *ebl, unsigned char st_other);
+
 /* Return combined section header flags value.  */
 extern GElf_Word ebl_sh_flags_combine (Ebl *ebl, GElf_Word flags1,
                                       GElf_Word flags2);
index 35d5f097944eda7980aa0d2fada1d39c228a7869..6ba890fd0370edcc3bd3b8e0487498b1ebd30e7a 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-10  Mark Wielaard  <mjw@redhat.com>
+
+       * elflint.c (check_symtab): Use ebl_check_st_other_bits.
+
 2011-02-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * readelf.c (reset_listptr): Clear TABLE->TABLE.
index c122735532a5e30631dea18e47dd2b3e5d94a976..5c8d0aafa065234bbd42fe08a23a423dacbdc988 100644 (file)
@@ -1011,7 +1011,7 @@ section [%2d] '%s': _DYNAMIC symbol size %" PRIu64 " does not match dynamic segm
        ERROR (gettext ("\
 section [%2d] '%s': symbol %zu: symbol in dynamic symbol table with non-default visibility\n"),
               idx, section_name (ebl, idx), cnt);
-      if ((sym->st_other ^ GELF_ST_VISIBILITY (sym->st_other)) != 0)
+      if (! ebl_check_st_other_bits (ebl, sym->st_other))
        ERROR (gettext ("\
 section [%2d] '%s': symbol %zu: unknown bit set in st_other\n"),
               idx, section_name (ebl, idx), cnt);