summaryrefslogtreecommitdiff
path: root/libebl
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-02-21 06:19:39 +0000
committerRoland McGrath <roland@redhat.com>2008-02-21 06:19:39 +0000
commit059c83e5db89955913a39fe6705acca571c32c3f (patch)
tree9eaf08fd255365d45be91bb3bf288194ffa423e5 /libebl
parent712d78eced9020ccfa1c27d32c2929cf16398293 (diff)
downloadelfutils-059c83e5db89955913a39fe6705acca571c32c3f.tar.gz
Finish elflint .gnu.attributes checking
Diffstat (limited to 'libebl')
-rw-r--r--libebl/ChangeLog22
-rw-r--r--libebl/Makefile.am4
-rw-r--r--libebl/ebl-hooks.h6
-rw-r--r--libebl/eblcheckobjattr.c81
-rw-r--r--libebl/eblcorenotetypename.c4
-rw-r--r--libebl/eblopenbackend.c19
-rw-r--r--libebl/eblsectiontypename.c51
-rw-r--r--libebl/libebl.h11
8 files changed, 170 insertions, 28 deletions
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 86c91781..8ebc6c19 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,25 @@
+2008-02-20 Roland McGrath <roland@redhat.com>
+
+ * libebl.h: Declare ebl_check_object_attribute.
+ * eblcheckobjattr.c: New file.
+ * Makefile.am (gen_SOURCES): Add it.
+ * ebl-hooks.h: Add check_object_attribute hook.
+ * eblopenbackend.c (default_check_object_attribute): New function.
+ (fill_defaults): Initialize pointer to it.
+
+2008-02-19 Roland McGrath <roland@redhat.com>
+
+ * eblsectiontypename.c (ebl_section_type_name):
+ Handle SHT_GNU_ATTRIBUTES.
+
+2008-02-08 Roland McGrath <roland@redhat.com>
+
+ * eblcorenotetypename.c (ebl_core_note_type_name): Handle NT_PPC_SPE.
+
+2008-01-30 Roland McGrath <roland@redhat.com>
+
+ * eblcorenotetypename.c (ebl_core_note_type_name): Handle NT_386_TLS.
+
2007-10-18 Roland McGrath <roland@redhat.com>
* eblcorenotetypename.c (ebl_core_note_type_name): Handle NT_PPC_VMX.
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index 2cf570e7..1e36b334 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to create Makefile.in
##
-## Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
+## Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008 Red Hat, Inc.
## This file is part of Red Hat elfutils.
##
## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -58,7 +58,7 @@ gen_SOURCES = eblopenbackend.c eblclosebackend.c eblstrtab.c \
eblelfclass.c eblelfdata.c eblelfmachine.c \
ebl_check_special_symbol.c eblbsspltp.c eblretval.c \
eblreginfo.c eblnonerelocp.c eblrelativerelocp.c \
- eblsysvhashentrysize.c eblauxvinfo.c
+ eblsysvhashentrysize.c eblauxvinfo.c eblcheckobjattr.c
libebl_a_SOURCES = $(gen_SOURCES)
diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h
index c0c929bd..c236b35e 100644
--- a/libebl/ebl-hooks.h
+++ b/libebl/ebl-hooks.h
@@ -115,6 +115,10 @@ int EBLHOOK(core_note) (GElf_Word, GElf_Word, GElf_Word *, size_t *,
/* Handle object file note. */
bool EBLHOOK(object_note) (const char *, uint32_t, uint32_t, const char *);
+/* Check object attribute. */
+bool EBLHOOK(check_object_attribute) (Ebl *, const char *, int, uint64_t,
+ const char **, const char **);
+
/* Describe auxv element type. */
int EBLHOOK(auxv_info) (GElf_Xword, const char **, const char **);
@@ -148,7 +152,7 @@ ssize_t EBLHOOK(register_info) (Ebl *ebl,
const char **prefix, const char **setname,
int *bits, int *type);
- /* Disassembler function. */
+/* Disassembler function. */
int EBLHOOK(disasm) (const uint8_t **startp, const uint8_t *end,
GElf_Addr addr, const char *fmt, DisasmOutputCB_t outcb,
DisasmGetSymCB_t symcb, void *outcbarg, void *symcbarg);
diff --git a/libebl/eblcheckobjattr.c b/libebl/eblcheckobjattr.c
new file mode 100644
index 00000000..fe75de74
--- /dev/null
+++ b/libebl/eblcheckobjattr.c
@@ -0,0 +1,81 @@
+/* Check object attributes.
+ Copyright (C) 2008 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 <string.h>
+#include <libeblP.h>
+
+
+bool
+ebl_check_object_attribute (ebl, vendor, tag, value, tag_name, value_name)
+ Ebl *ebl;
+ const char *vendor;
+ int tag;
+ uint64_t value;
+ const char **tag_name;
+ const char **value_name;
+{
+ if (ebl->check_object_attribute (ebl, vendor, tag, value,
+ tag_name, value_name))
+ return true;
+
+ if (strcmp (vendor, "gnu"))
+ return false;
+
+ if (tag == 32)
+ {
+ *tag_name = "compatibility";
+ return true;
+ }
+
+ return false;
+}
diff --git a/libebl/eblcorenotetypename.c b/libebl/eblcorenotetypename.c
index 44b02376..d01932fc 100644
--- a/libebl/eblcorenotetypename.c
+++ b/libebl/eblcorenotetypename.c
@@ -1,5 +1,5 @@
/* Return note type name.
- Copyright (C) 2002, 2007 Red Hat, Inc.
+ Copyright (C) 2002, 2007, 2008 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -99,6 +99,8 @@ ebl_core_note_type_name (ebl, type, buf, len)
#define KNOWNSTYPE(name) case NT_##name: res = #name; break
KNOWNSTYPE (PRXFPREG);
KNOWNSTYPE (PPC_VMX);
+ KNOWNSTYPE (PPC_SPE);
+ KNOWNSTYPE (386_TLS);
#undef KNOWNSTYPE
default:
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 8a44f904..08817f66 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -1,5 +1,5 @@
/* Generate ELF backend handle.
- Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
+ Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -210,6 +210,10 @@ static ssize_t default_register_info (Ebl *ebl,
const char **prefix,
const char **setname,
int *bits, int *type);
+static bool default_check_object_attribute (Ebl *ebl, const char *vendor,
+ int tag, uint64_t value,
+ const char **tag_name,
+ const char **value_name);
static void
@@ -246,6 +250,7 @@ fill_defaults (Ebl *result)
result->bss_plt_p = default_bss_plt_p;
result->return_value_location = default_return_value_location;
result->register_info = default_register_info;
+ result->check_object_attribute = default_check_object_attribute;
result->disasm = NULL;
result->destr = default_destr;
result->sysvhash_entrysize = sizeof (Elf32_Word);
@@ -700,3 +705,15 @@ default_register_info (Ebl *ebl __attribute__ ((unused)),
*type = DW_ATE_void;
return snprintf (name, namelen, "reg%d", regno);
}
+
+static bool
+default_check_object_attribute (Ebl *ebl __attribute__ ((unused)),
+ const char *vendor __attribute__ ((unused)),
+ int tag __attribute__ ((unused)),
+ uint64_t value __attribute__ ((unused)),
+ const char **tag_name, const char **value_name)
+{
+ *tag_name = NULL;
+ *value_name = NULL;
+ return false;
+}
diff --git a/libebl/eblsectiontypename.c b/libebl/eblsectiontypename.c
index b62c37b3..a37e5f6d 100644
--- a/libebl/eblsectiontypename.c
+++ b/libebl/eblsectiontypename.c
@@ -1,5 +1,5 @@
/* Return section type name.
- Copyright (C) 2001, 2002, 2006 Red Hat, Inc.
+ Copyright (C) 2001, 2002, 2006, 2008 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -110,31 +110,38 @@ ebl_section_type_name (ebl, section, buf, len)
res = sunwtypes[section - SHT_LOSUNW];
}
else
- {
- /* A few GNU additions. */
- if (section == SHT_CHECKSUM)
+ /* A few GNU additions. */
+ switch (section)
+ {
+ case SHT_CHECKSUM:
res = "CHECKSUM";
- else if (section == SHT_GNU_LIBLIST)
+ break;
+ case SHT_GNU_LIBLIST:
res = "GNU_LIBLIST";
- else if (section == SHT_GNU_HASH)
+ break;
+ case SHT_GNU_HASH:
res = "GNU_HASH";
- /* Handle OS-specific section names. */
- else
- {
- if (section >= SHT_LOOS && section <= SHT_HIOS)
- snprintf (buf, len, "SHT_LOOS+%x", section - SHT_LOOS);
- /* Handle processor-specific section names. */
- else if (section >= SHT_LOPROC && section <= SHT_HIPROC)
- snprintf (buf, len, "SHT_LOPROC+%x", section - SHT_LOPROC);
- else if ((unsigned int) section >= SHT_LOUSER
- && (unsigned int) section <= SHT_HIUSER)
- snprintf (buf, len, "SHT_LOUSER+%x", section - SHT_LOUSER);
- else
- snprintf (buf, len, "%s: %d", gettext ("<unknown>"), section);
+ break;
+ case SHT_GNU_ATTRIBUTES:
+ res = "GNU_ATTRIBUTES";
+ break;
- res = buf;
- }
- }
+ default:
+ /* Handle OS-specific section names. */
+ if (section >= SHT_LOOS && section <= SHT_HIOS)
+ snprintf (buf, len, "SHT_LOOS+%x", section - SHT_LOOS);
+ /* Handle processor-specific section names. */
+ else if (section >= SHT_LOPROC && section <= SHT_HIPROC)
+ snprintf (buf, len, "SHT_LOPROC+%x", section - SHT_LOPROC);
+ else if ((unsigned int) section >= SHT_LOUSER
+ && (unsigned int) section <= SHT_HIUSER)
+ snprintf (buf, len, "SHT_LOUSER+%x", section - SHT_LOUSER);
+ else
+ snprintf (buf, len, "%s: %d", gettext ("<unknown>"), section);
+
+ res = buf;
+ break;
+ }
}
return res;
diff --git a/libebl/libebl.h b/libebl/libebl.h
index 7e29168d..083de03a 100644
--- a/libebl/libebl.h
+++ b/libebl/libebl.h
@@ -1,5 +1,5 @@
/* Interface for libebl.
- Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2007 Red Hat, Inc.
+ Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -182,6 +182,15 @@ extern const char *ebl_object_note_type_name (Ebl *ebl, uint32_t type,
extern void ebl_object_note (Ebl *ebl, const char *name, uint32_t type,
uint32_t descsz, const char *desc);
+/* Check whether an attribute in a .gnu_attributes section is recognized.
+ Fills in *TAG_NAME with the name for this tag.
+ If VALUE is a known value for that tag, also fills in *VALUE_NAME. */
+extern bool ebl_check_object_attribute (Ebl *ebl, const char *vendor,
+ int tag, uint64_t value,
+ const char **tag_name,
+ const char **value_name);
+
+
/* Check section name for being that of a debug informatino section. */
extern bool ebl_debugscn_p (Ebl *ebl, const char *name);