summaryrefslogtreecommitdiffstats
path: root/trunk/gelfx32
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/gelfx32')
-rw-r--r--trunk/gelfx32/Makefile.am5
-rw-r--r--trunk/gelfx32/Makefile.in268
-rw-r--r--trunk/gelfx32/gelfx.h227
3 files changed, 500 insertions, 0 deletions
diff --git a/trunk/gelfx32/Makefile.am b/trunk/gelfx32/Makefile.am
new file mode 100644
index 0000000..ae51b93
--- /dev/null
+++ b/trunk/gelfx32/Makefile.am
@@ -0,0 +1,5 @@
+## Process this file with automake to create Makefile.in
+
+AUTOMAKE_OPTIONS = 1.4 gnu
+
+noinst_HEADERS = gelfx.h
diff --git a/trunk/gelfx32/Makefile.in b/trunk/gelfx32/Makefile.in
new file mode 100644
index 0000000..4f6898a
--- /dev/null
+++ b/trunk/gelfx32/Makefile.in
@@ -0,0 +1,268 @@
+# Makefile.in generated by automake 1.6.3 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = @program_transform_name@
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+host_alias = @host_alias@
+host_triplet = @host@
+
+EXEEXT = @EXEEXT@
+OBJEXT = @OBJEXT@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AWK = @AWK@
+CC = @CC@
+CPP = @CPP@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+ECHO = @ECHO@
+EGREP = @EGREP@
+F77 = @F77@
+GCJ = @GCJ@
+GCJFLAGS = @GCJFLAGS@
+GELFINCLUDE = @GELFINCLUDE@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LIBGELF = @LIBGELF@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+OBJDUMP = @OBJDUMP@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+RC = @RC@
+STRIP = @STRIP@
+VERSION = @VERSION@
+am__include = @am__include@
+am__quote = @am__quote@
+install_sh = @install_sh@
+
+AUTOMAKE_OPTIONS = 1.4 gnu
+
+noinst_HEADERS = gelfx.h
+subdir = gelfx32
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+DIST_SOURCES =
+HEADERS = $(noinst_HEADERS)
+
+DIST_COMMON = $(noinst_HEADERS) Makefile.am Makefile.in
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu gelfx32/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+
+ETAGS = etags
+ETAGSFLAGS =
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$tags$$unique" \
+ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+ @list='$(DISTFILES)'; for file in $$list; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkinstalldirs) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(HEADERS)
+
+installdirs:
+
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+
+distclean-am: clean-am distclean-generic distclean-libtool \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+uninstall-am: uninstall-info-am
+
+.PHONY: GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool distclean distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am info info-am install \
+ install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am install-man \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic mostlyclean-libtool tags uninstall \
+ uninstall-am uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/trunk/gelfx32/gelfx.h b/trunk/gelfx32/gelfx.h
new file mode 100644
index 0000000..7668a84
--- /dev/null
+++ b/trunk/gelfx32/gelfx.h
@@ -0,0 +1,227 @@
+/* gelf API which supports ELFCLASS32 only.
+ Copyright (C) 2001 Red Hat, Inc.
+ Written by Jakub Jelinek <jakub@redhat.com>, 2001.
+
+ This program 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; either version 2, or (at your option)
+ any later version.
+
+ This program 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 this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef GELFX_H
+#define GELFX_H
+
+#include <error.h>
+#include <libelf.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef Elf32_Half GElf_Half;
+typedef Elf32_Word GElf_Word;
+typedef Elf32_Sword GElf_Sword;
+typedef Elf32_Xword GElf_Xword;
+typedef Elf32_Sxword GElf_Sxword;
+typedef Elf32_Addr GElf_Addr;
+typedef Elf32_Off GElf_Off;
+typedef Elf32_Ehdr GElf_Ehdr;
+typedef Elf32_Shdr GElf_Shdr;
+typedef Elf32_Section GElf_Section;
+typedef Elf32_Sym GElf_Sym;
+typedef Elf32_Rel GElf_Rel;
+typedef Elf32_Rela GElf_Rela;
+typedef Elf32_Phdr GElf_Phdr;
+typedef Elf32_Dyn GElf_Dyn;
+#define GELF_ST_BIND ELF32_ST_BIND
+#define GELF_ST_TYPE ELF32_ST_TYPE
+#define GELF_ST_INFO ELF32_ST_INFO
+#define GELF_R_SYM ELF32_R_SYM
+#define GELF_R_TYPE ELF32_R_TYPE
+#define GELF_R_INFO ELF32_R_INFO
+
+extern inline int
+gelf_getclass (Elf *elf)
+{
+ size_t size;
+ char *e_ident = elf_getident (elf, &size);
+ if (e_ident [EI_CLASS] == ELFCLASS64)
+ error (EXIT_FAILURE, 0, "64-bit ELF not supported");
+ return e_ident [EI_CLASS] == ELFCLASS32 ? ELFCLASS32 : ELFCLASSNONE;
+}
+
+#define gelf_fsize(e,t,c,v) elf32_fsize(t,c,v)
+
+extern inline GElf_Ehdr *gelf_getehdr (Elf *elf, GElf_Ehdr *dst)
+{
+ Elf32_Ehdr *ehdr = elf32_getehdr (elf);
+ if (ehdr == NULL)
+ return NULL;
+ return memcpy (dst, ehdr, sizeof (Elf32_Ehdr));
+}
+
+extern inline int
+gelf_update_ehdr (Elf *elf, GElf_Ehdr *src)
+{
+ Elf32_Ehdr *ehdr = elf32_getehdr (elf);
+ if (ehdr == NULL)
+ return 0;
+ memcpy (ehdr, src, sizeof (Elf32_Ehdr));
+ return 1;
+}
+
+extern inline unsigned long
+gelf_newehdr (Elf *elf, int class)
+{
+ if (class != ELFCLASS32)
+ return 0;
+ return (unsigned long) elf32_newehdr (elf);
+}
+
+extern inline GElf_Phdr *
+gelf_getphdr (Elf *elf, int ndx, GElf_Phdr *dst)
+{
+ Elf32_Ehdr *ehdr = elf32_getehdr (elf);
+ Elf32_Phdr *phdr = elf32_getphdr (elf);
+ if (ehdr == NULL || phdr == NULL || ndx >= ehdr->e_phnum)
+ return NULL;
+ return memcpy (dst, phdr + ndx, sizeof (Elf32_Phdr));
+}
+
+extern inline int
+gelf_update_phdr (Elf *elf, int ndx, GElf_Phdr *src)
+{
+ Elf32_Ehdr *ehdr = elf32_getehdr (elf);
+ Elf32_Phdr *phdr = elf32_getphdr (elf);
+ if (ehdr == NULL || phdr == NULL || ndx >= ehdr->e_phnum)
+ return 0;
+ memcpy (phdr + ndx, src, sizeof (Elf32_Phdr));
+ return 1;
+}
+
+extern inline unsigned long
+gelf_newphdr (Elf *elf, size_t phnum)
+{
+ return (unsigned long) elf32_newphdr (elf, phnum);
+}
+
+#define gelf_xlatetom(e,d,s,n) elf32_xlatetom(e,d,s,n)
+#define gelf_xlatetof(e,d,s,n) elf32_xlatetof(e,d,s,n)
+
+extern inline GElf_Shdr *
+gelf_getshdr (Elf_Scn *scn, GElf_Shdr *dst)
+{
+ Elf32_Shdr *shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ return NULL;
+ return memcpy (dst, shdr, sizeof (Elf32_Shdr));
+}
+
+extern inline int
+gelf_update_shdr (Elf_Scn *scn, GElf_Shdr *src)
+{
+ Elf32_Shdr *shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ return 0;
+ memcpy (shdr, src, sizeof (Elf32_Shdr));
+ return 1;
+}
+
+extern inline GElf_Sym *
+gelf_getsym (Elf_Data *data, int ndx, GElf_Sym *dst)
+{
+ if (data->d_type != ELF_T_SYM
+ || (ndx + 1) * sizeof (Elf32_Sym) > data->d_size)
+ return NULL;
+ *dst = ((GElf_Sym *) data->d_buf)[ndx];
+ return dst;
+}
+
+extern inline int
+gelf_update_sym (Elf_Data *data, int ndx, GElf_Sym *src)
+{
+ if (data->d_type != ELF_T_SYM
+ || (ndx + 1) * sizeof (Elf32_Sym) > data->d_size)
+ return 0;
+ ((GElf_Sym *) data->d_buf)[ndx] = *src;
+ return 1;
+}
+
+extern inline GElf_Dyn *
+gelf_getdyn (Elf_Data *data, int ndx, GElf_Dyn *dst)
+{
+ if (data->d_type != ELF_T_DYN
+ || (ndx + 1) * sizeof (Elf32_Dyn) > data->d_size)
+ return NULL;
+ *dst = ((GElf_Dyn *) data->d_buf)[ndx];
+ return dst;
+}
+
+extern inline int
+gelf_update_dyn (Elf_Data *data, int ndx, GElf_Dyn *src)
+{
+ if (data->d_type != ELF_T_DYN
+ || (ndx + 1) * sizeof (Elf32_Dyn) > data->d_size)
+ return 0;
+ ((GElf_Dyn *) data->d_buf)[ndx] = *src;
+ return 1;
+}
+
+extern inline GElf_Rel *
+gelf_getrel (Elf_Data *data, int ndx, GElf_Rel *dst)
+{
+ if (data->d_type != ELF_T_REL
+ || (ndx + 1) * sizeof (Elf32_Rel) > data->d_size)
+ return NULL;
+ *dst = ((GElf_Rel *) data->d_buf)[ndx];
+ return dst;
+}
+
+extern inline int
+gelf_update_rel (Elf_Data *data, int ndx, GElf_Rel *src)
+{
+ if (data->d_type != ELF_T_REL
+ || (ndx + 1) * sizeof (Elf32_Rel) > data->d_size)
+ return 0;
+ ((GElf_Rel *) data->d_buf)[ndx] = *src;
+ return 1;
+}
+
+extern inline GElf_Rela *
+gelf_getrela (Elf_Data *data, int ndx, GElf_Rela *dst)
+{
+ if (data->d_type != ELF_T_RELA
+ || (ndx + 1) * sizeof (Elf32_Rela) > data->d_size)
+ return NULL;
+ *dst = ((GElf_Rela *) data->d_buf)[ndx];
+ return dst;
+}
+
+extern inline int
+gelf_update_rela (Elf_Data *data, int ndx, GElf_Rela *src)
+{
+ if (data->d_type != ELF_T_RELA
+ || (ndx + 1) * sizeof (Elf32_Rela) > data->d_size)
+ return 0;
+ ((GElf_Rela *) data->d_buf)[ndx] = *src;
+ return 1;
+}
+
+#define gelfx_getshdr(elf,scn,shdr) gelf_getshdr(scn,shdr)
+#define gelfx_update_shdr(elf,scn,shdr) gelf_update_shdr(scn,shdr)
+#define gelfx_getsym(elf,data,ndx,x) gelf_getsym(data,ndx,x)
+#define gelfx_update_sym(elf,data,ndx,x) gelf_update_sym(data,ndx,x)
+#define gelfx_getdyn(elf,data,ndx,x) gelf_getdyn(data,ndx,x)
+#define gelfx_update_dyn(elf,data,ndx,x) gelf_update_dyn(data,ndx,x)
+#define gelfx_getrel(elf,data,ndx,x) gelf_getrel(data,ndx,x)
+#define gelfx_update_rel(elf,data,ndx,x) gelf_update_rel(data,ndx,x)
+#define gelfx_getrela(elf,data,ndx,x) gelf_getrela(data,ndx,x)
+#define gelfx_update_rela(elf,data,ndx,x) gelf_update_rela(data,ndx,x)
+
+#endif /* GELFX_H */