summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2011-03-10 13:02:32 +0100
committerMark Wielaard <mjw@redhat.com>2011-03-11 12:59:29 +0100
commita062b6bcadd1565d360acf640f9d4c159b2270ea (patch)
tree67de26efa165a12f511b1278e112eb8460c0aff6
parenta70791179e61789e5108b3c68bae1d976da7be17 (diff)
Add new ebl_check_st_other_bits function.upstream/mpolacek/autotest
-rw-r--r--backends/ChangeLog5
-rw-r--r--backends/alpha_init.c1
-rw-r--r--backends/alpha_symbol.c10
-rw-r--r--libebl/ChangeLog9
-rw-r--r--libebl/Makefile.am3
-rw-r--r--libebl/ebl-hooks.h6
-rw-r--r--libebl/eblopenbackend.c11
-rw-r--r--libebl/eblstother.c64
-rw-r--r--libebl/libebl.h3
-rw-r--r--src/ChangeLog4
-rw-r--r--src/elflint.c2
11 files changed, 114 insertions, 4 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 2dcc9ef4..744d1d55 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -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.
diff --git a/backends/alpha_init.c b/backends/alpha_init.c
index 14c085cc..30fe5c6c 100644
--- a/backends/alpha_init.c
+++ b/backends/alpha_init.c
@@ -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);
diff --git a/backends/alpha_symbol.c b/backends/alpha_symbol.c
index 4bd8793a..5d25d3e4 100644
--- a/backends/alpha_symbol.c
+++ b/backends/alpha_symbol.c
@@ -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);
+}
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 96f70ff8..bec6511f 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -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.
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index d157195e..ced5668b 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -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)
diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h
index 59e73c54..82c6c640 100644
--- a/libebl/ebl-hooks.h
+++ b/libebl/ebl-hooks.h
@@ -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 *);
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index e11ff067..24f472ce 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -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;
@@ -698,6 +700,13 @@ default_check_special_symbol (Elf *elf __attribute__ ((unused)),
}
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
index 00000000..ba8c9dac
--- /dev/null
+++ b/libebl/eblstother.c
@@ -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)));
+}
diff --git a/libebl/libebl.h b/libebl/libebl.h
index c94ad78f..b4307282 100644
--- a/libebl/libebl.h
+++ b/libebl/libebl.h
@@ -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);
diff --git a/src/ChangeLog b/src/ChangeLog
index 35d5f097..6ba890fd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -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.
diff --git a/src/elflint.c b/src/elflint.c
index c1227355..5c8d0aaf 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -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);