diff options
Diffstat (limited to 'elfutils/backends')
48 files changed, 5300 insertions, 0 deletions
diff --git a/elfutils/backends/ChangeLog b/elfutils/backends/ChangeLog new file mode 100644 index 00000000..33d52a2f --- /dev/null +++ b/elfutils/backends/ChangeLog @@ -0,0 +1,77 @@ +2006-02-22 Roland McGrath <roland@redhat.com> + + * ppc64_retval.c (SVR4_STRUCT_RETURN): New macro. + (ppc64_return_value_location): Use registers for aggregate conditional + on that. + * ppc_retval.c (SVR4_STRUCT_RETURN): New macro. + (ppc_return_value_location): Use registers for aggregate conditional + on that. + +2006-01-12 Roland McGrath <roland@redhat.com> + + * s390_retval.c: New file. + * Makefile.am (s390_SRCS): Add it. + * s390_init.c (s390_init): Install return_value_location hook. + +2006-01-11 Roland McGrath <roland@redhat.com> + + * s390_regs.c: New file. + * Makefile.am (s390_SRCS): Add it. + * s390_init.c (s390_init): Install register_name hook. + + * s390_reloc.def: Update bits per + Martin Schwidefsky <schwidefsky@de.ibm.com>. + +2005-12-10 Ulrich Drepper + + * common-reloc.c (R_NAME): Generate string correctly. + +2005-12-05 Roland McGrath <roland@redhat.com> + + * i386_regs.c (i386_register_name): Use a table for the first 8 regs. + * x86_64_regs.c (x86_64_register_name): Likewise. + +2005-11-25 Roland McGrath <roland@redhat.com> + + * i386_regs.c (i386_register_name): Return 0, not 1, for gaps. + + * i386_regs.c: New file. + * ppc_regs.c: New file. + * sparc_regs.c: New file. + * x86_64_regs.c: New file. + * Makefile.am + (i386_SRCS, x86_64_SRCS, ppc_SRCS, ppc64_SRCS, sparc_SRCS): Add them. + * i386_init.c: Initialize register_name hook. + * ppc_init.c: Likewise. + * ppc64_init.c: Likewise. + * sparc_init.c: Likewise. + * x86_64_init.c: Likewise. + +2005-11-19 Roland McGrath <roland@redhat.com> + + * ppc64_reloc.def: REL30 -> ADDR30. + +2005-11-18 Roland McGrath <roland@redhat.com> + + * alpha_init.c: Use HOOK macro. + * arm_init.c: Likewise. + * i386_init.c: Likewise. + * ia64_init.c: Likewise. + * ppc64_init.c: Likewise. + * ppc_init.c: Likewise. + * s390_init.c: Likewise. + * sh_init.c: Likewise. + * sparc_init.c: Likewise. + * x86_64_init.c: Likewise. + +2005-11-17 Roland McGrath <roland@redhat.com> + + * Makefile.am (uninstall): Don't try to remove $(pkgincludedir). + (CLEANFILES): Add libebl_$(m).so. + + * ppc_reloc.def: Update bits per Alan Modra <amodra@bigpond.net.au>. + * ppc64_reloc.def: Likewise. + +2005-11-15 Roland McGrath <roland@redhat.com> + + * Contents moved here from ../libebl. diff --git a/elfutils/backends/Makefile.am b/elfutils/backends/Makefile.am new file mode 100644 index 00000000..13a809de --- /dev/null +++ b/elfutils/backends/Makefile.am @@ -0,0 +1,144 @@ +## Process this file with automake to create Makefile.in +## +## Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 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. +## +## 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>. +## +DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\" +if MUDFLAP +AM_CFLAGS = -fmudflap +else +AM_CFLAGS = +endif +AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \ + -std=gnu99 +INCLUDES = -I$(srcdir) -I$(top_srcdir)/libebl \ + -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ + -I$(top_srcdir)/lib -I.. +PACKAGE_VERSION = @PACKAGE_VERSION@ + + +modules = i386 sh x86_64 ia64 alpha arm sparc ppc ppc64 s390 +libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \ + libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \ + libebl_sparc_pic.a libebl_ppc_pic.a libebl_ppc64_pic.a \ + libebl_s390_pic.a +noinst_LIBRARIES = $(libebl_pic) +noinst_DATA = $(libebl_pic:_pic.a=.so) + + +if MUDFLAP +libelf = ../libelf/libelf.a +libdw = ../libdw/libdw.a +libmudflap = -lmudflap +else +libelf = ../libelf/libelf.so +libdw = ../libdw/libdw.so +libmudflap = +endif + + +textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi + +libebl_%.so: libebl_%_pic.a libebl_%.map $(libelf) $(libdw) + $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ + -Wl,--version-script,$(word 2,$^) \ + -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw) $(libmudflap) + $(textrel_check) + +libebl_%.map: Makefile + echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' > $@ + + +i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c \ + i386_retval.c i386_regs.c +libebl_i386_pic_a_SOURCES = $(i386_SRCS) +am_libebl_i386_pic_a_OBJECTS = $(i386_SRCS:.c=.os) + +sh_SRCS = sh_init.c sh_symbol.c +libebl_sh_pic_a_SOURCES = $(sh_SRCS) +am_libebl_sh_pic_a_OBJECTS = $(sh_SRCS:.c=.os) + +x86_64_SRCS = x86_64_init.c x86_64_symbol.c x86_64_corenote.c \ + x86_64_retval.c x86_64_regs.c +libebl_x86_64_pic_a_SOURCES = $(x86_64_SRCS) +am_libebl_x86_64_pic_a_OBJECTS = $(x86_64_SRCS:.c=.os) + +ia64_SRCS = ia64_init.c ia64_symbol.c +libebl_ia64_pic_a_SOURCES = $(ia64_SRCS) +am_libebl_ia64_pic_a_OBJECTS = $(ia64_SRCS:.c=.os) + +alpha_SRCS = alpha_init.c alpha_symbol.c alpha_retval.c +libebl_alpha_pic_a_SOURCES = $(alpha_SRCS) +am_libebl_alpha_pic_a_OBJECTS = $(alpha_SRCS:.c=.os) + +arm_SRCS = arm_init.c arm_symbol.c +libebl_arm_pic_a_SOURCES = $(arm_SRCS) +am_libebl_arm_pic_a_OBJECTS = $(arm_SRCS:.c=.os) + +sparc_SRCS = sparc_init.c sparc_symbol.c sparc_regs.c +libebl_sparc_pic_a_SOURCES = $(sparc_SRCS) +am_libebl_sparc_pic_a_OBJECTS = $(sparc_SRCS:.c=.os) + +ppc_SRCS = ppc_init.c ppc_symbol.c ppc_retval.c ppc_regs.c +libebl_ppc_pic_a_SOURCES = $(ppc_SRCS) +am_libebl_ppc_pic_a_OBJECTS = $(ppc_SRCS:.c=.os) + +ppc64_SRCS = ppc64_init.c ppc64_symbol.c ppc64_retval.c ppc_regs.c +libebl_ppc64_pic_a_SOURCES = $(ppc64_SRCS) +am_libebl_ppc64_pic_a_OBJECTS = $(ppc64_SRCS:.c=.os) + +s390_SRCS = s390_init.c s390_symbol.c s390_regs.c s390_retval.c +libebl_s390_pic_a_SOURCES = $(s390_SRCS) +am_libebl_s390_pic_a_OBJECTS = $(s390_SRCS:.c=.os) + + +%.os: %.c %.o + if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \ + -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \ + then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ + rm -f "$(DEPDIR)/$*.Tpo"; \ + else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ + fi + +install: install-am install-ebl-modules +install-ebl-modules: + $(mkinstalldirs) $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR) + for m in $(modules); do \ + $(INSTALL_PROGRAM) libebl_$${m}.so $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}-$(PACKAGE_VERSION).so; \ + ln -fs libebl_$${m}-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}.so; \ + done + +uninstall: uninstall-am + for m in $(modules); do \ + rm -f $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}-$(PACKAGE_VERSION).so; \ + rm -f $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}.so; \ + done + rmdir --ignore-fail-on-non-empty $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR) + +noinst_HEADERS = libebl_CPU.h common-reloc.c +EXTRA_DIST = $(foreach m,$(modules),$($(m)_SRCS)) $(modules:=_reloc.def) + +CLEANFILES = *.gcno *.gcda \ + $(foreach m,$(modules),\ + libebl_$(m).so $(am_libebl_$(m)_pic_a_OBJECTS)) diff --git a/elfutils/backends/Makefile.in b/elfutils/backends/Makefile.in new file mode 100644 index 00000000..2e4b65e4 --- /dev/null +++ b/elfutils/backends/Makefile.in @@ -0,0 +1,628 @@ +# Makefile.in generated by automake 1.9.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005 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@ + + + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = backends +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in ChangeLog +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) +AR = ar +ARFLAGS = cru +libebl_alpha_pic_a_AR = $(AR) $(ARFLAGS) +libebl_alpha_pic_a_LIBADD = +am__objects_1 = alpha_init.$(OBJEXT) alpha_symbol.$(OBJEXT) \ + alpha_retval.$(OBJEXT) +libebl_alpha_pic_a_OBJECTS = $(am_libebl_alpha_pic_a_OBJECTS) +libebl_arm_pic_a_AR = $(AR) $(ARFLAGS) +libebl_arm_pic_a_LIBADD = +am__objects_2 = arm_init.$(OBJEXT) arm_symbol.$(OBJEXT) +libebl_arm_pic_a_OBJECTS = $(am_libebl_arm_pic_a_OBJECTS) +libebl_i386_pic_a_AR = $(AR) $(ARFLAGS) +libebl_i386_pic_a_LIBADD = +am__objects_3 = i386_init.$(OBJEXT) i386_symbol.$(OBJEXT) \ + i386_corenote.$(OBJEXT) i386_retval.$(OBJEXT) \ + i386_regs.$(OBJEXT) +libebl_i386_pic_a_OBJECTS = $(am_libebl_i386_pic_a_OBJECTS) +libebl_ia64_pic_a_AR = $(AR) $(ARFLAGS) +libebl_ia64_pic_a_LIBADD = +am__objects_4 = ia64_init.$(OBJEXT) ia64_symbol.$(OBJEXT) +libebl_ia64_pic_a_OBJECTS = $(am_libebl_ia64_pic_a_OBJECTS) +libebl_ppc64_pic_a_AR = $(AR) $(ARFLAGS) +libebl_ppc64_pic_a_LIBADD = +am__objects_5 = ppc64_init.$(OBJEXT) ppc64_symbol.$(OBJEXT) \ + ppc64_retval.$(OBJEXT) ppc_regs.$(OBJEXT) +libebl_ppc64_pic_a_OBJECTS = $(am_libebl_ppc64_pic_a_OBJECTS) +libebl_ppc_pic_a_AR = $(AR) $(ARFLAGS) +libebl_ppc_pic_a_LIBADD = +am__objects_6 = ppc_init.$(OBJEXT) ppc_symbol.$(OBJEXT) \ + ppc_retval.$(OBJEXT) ppc_regs.$(OBJEXT) +libebl_ppc_pic_a_OBJECTS = $(am_libebl_ppc_pic_a_OBJECTS) +libebl_s390_pic_a_AR = $(AR) $(ARFLAGS) +libebl_s390_pic_a_LIBADD = +am__objects_7 = s390_init.$(OBJEXT) s390_symbol.$(OBJEXT) \ + s390_regs.$(OBJEXT) s390_retval.$(OBJEXT) +libebl_s390_pic_a_OBJECTS = $(am_libebl_s390_pic_a_OBJECTS) +libebl_sh_pic_a_AR = $(AR) $(ARFLAGS) +libebl_sh_pic_a_LIBADD = +am__objects_8 = sh_init.$(OBJEXT) sh_symbol.$(OBJEXT) +libebl_sh_pic_a_OBJECTS = $(am_libebl_sh_pic_a_OBJECTS) +libebl_sparc_pic_a_AR = $(AR) $(ARFLAGS) +libebl_sparc_pic_a_LIBADD = +am__objects_9 = sparc_init.$(OBJEXT) sparc_symbol.$(OBJEXT) \ + sparc_regs.$(OBJEXT) +libebl_sparc_pic_a_OBJECTS = $(am_libebl_sparc_pic_a_OBJECTS) +libebl_x86_64_pic_a_AR = $(AR) $(ARFLAGS) +libebl_x86_64_pic_a_LIBADD = +am__objects_10 = x86_64_init.$(OBJEXT) x86_64_symbol.$(OBJEXT) \ + x86_64_corenote.$(OBJEXT) x86_64_retval.$(OBJEXT) \ + x86_64_regs.$(OBJEXT) +libebl_x86_64_pic_a_OBJECTS = $(am_libebl_x86_64_pic_a_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libebl_alpha_pic_a_SOURCES) $(libebl_arm_pic_a_SOURCES) \ + $(libebl_i386_pic_a_SOURCES) $(libebl_ia64_pic_a_SOURCES) \ + $(libebl_ppc64_pic_a_SOURCES) $(libebl_ppc_pic_a_SOURCES) \ + $(libebl_s390_pic_a_SOURCES) $(libebl_sh_pic_a_SOURCES) \ + $(libebl_sparc_pic_a_SOURCES) $(libebl_x86_64_pic_a_SOURCES) +DIST_SOURCES = $(libebl_alpha_pic_a_SOURCES) \ + $(libebl_arm_pic_a_SOURCES) $(libebl_i386_pic_a_SOURCES) \ + $(libebl_ia64_pic_a_SOURCES) $(libebl_ppc64_pic_a_SOURCES) \ + $(libebl_ppc_pic_a_SOURCES) $(libebl_s390_pic_a_SOURCES) \ + $(libebl_sh_pic_a_SOURCES) $(libebl_sparc_pic_a_SOURCES) \ + $(libebl_x86_64_pic_a_SOURCES) +DATA = $(noinst_DATA) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BUILD_STATIC_FALSE = @BUILD_STATIC_FALSE@ +BUILD_STATIC_TRUE = @BUILD_STATIC_TRUE@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\" +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EXEEXT = @EXEEXT@ +GCOV_FALSE = @GCOV_FALSE@ +GCOV_TRUE = @GCOV_TRUE@ +GMSGFMT = @GMSGFMT@ +GPROF_FALSE = @GPROF_FALSE@ +GPROF_TRUE = @GPROF_TRUE@ +HAVE_LIBASM_FALSE = @HAVE_LIBASM_FALSE@ +HAVE_LIBASM_TRUE = @HAVE_LIBASM_TRUE@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBEBL_SUBDIR = @LIBEBL_SUBDIR@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LOCALEDIR = @LOCALEDIR@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MODVERSION = @MODVERSION@ +MSGFMT = @MSGFMT@ +MSGMERGE = @MSGMERGE@ +MUDFLAP_FALSE = @MUDFLAP_FALSE@ +MUDFLAP_TRUE = @MUDFLAP_TRUE@ +NATIVE_LD_FALSE = @NATIVE_LD_FALSE@ +NATIVE_LD_TRUE = @NATIVE_LD_TRUE@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STANDALONE_FALSE = @STANDALONE_FALSE@ +STANDALONE_TRUE = @STANDALONE_TRUE@ +STRIP = @STRIP@ +TESTS_RPATH_FALSE = @TESTS_RPATH_FALSE@ +TESTS_RPATH_TRUE = @TESTS_RPATH_TRUE@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +YACC = @YACC@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +base_cpu = @base_cpu@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +@MUDFLAP_FALSE@AM_CFLAGS = -fpic -Wall -Wshadow -Werror -Wunused \ +@MUDFLAP_FALSE@ -Wextra -Wformat=2 -std=gnu99 +@MUDFLAP_TRUE@AM_CFLAGS = -fmudflap -fpic -Wall -Wshadow -Werror \ +@MUDFLAP_TRUE@ -Wunused -Wextra -Wformat=2 -std=gnu99 +INCLUDES = -I$(srcdir) -I$(top_srcdir)/libebl \ + -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \ + -I$(top_srcdir)/lib -I.. + +modules = i386 sh x86_64 ia64 alpha arm sparc ppc ppc64 s390 +libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a \ + libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a \ + libebl_sparc_pic.a libebl_ppc_pic.a libebl_ppc64_pic.a \ + libebl_s390_pic.a + +noinst_LIBRARIES = $(libebl_pic) +noinst_DATA = $(libebl_pic:_pic.a=.so) +@MUDFLAP_FALSE@libelf = ../libelf/libelf.so +@MUDFLAP_TRUE@libelf = ../libelf/libelf.a +@MUDFLAP_FALSE@libdw = ../libdw/libdw.so +@MUDFLAP_TRUE@libdw = ../libdw/libdw.a +@MUDFLAP_FALSE@libmudflap = +@MUDFLAP_TRUE@libmudflap = -lmudflap +textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi +i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c \ + i386_retval.c i386_regs.c + +libebl_i386_pic_a_SOURCES = $(i386_SRCS) +am_libebl_i386_pic_a_OBJECTS = $(i386_SRCS:.c=.os) +sh_SRCS = sh_init.c sh_symbol.c +libebl_sh_pic_a_SOURCES = $(sh_SRCS) +am_libebl_sh_pic_a_OBJECTS = $(sh_SRCS:.c=.os) +x86_64_SRCS = x86_64_init.c x86_64_symbol.c x86_64_corenote.c \ + x86_64_retval.c x86_64_regs.c + +libebl_x86_64_pic_a_SOURCES = $(x86_64_SRCS) +am_libebl_x86_64_pic_a_OBJECTS = $(x86_64_SRCS:.c=.os) +ia64_SRCS = ia64_init.c ia64_symbol.c +libebl_ia64_pic_a_SOURCES = $(ia64_SRCS) +am_libebl_ia64_pic_a_OBJECTS = $(ia64_SRCS:.c=.os) +alpha_SRCS = alpha_init.c alpha_symbol.c alpha_retval.c +libebl_alpha_pic_a_SOURCES = $(alpha_SRCS) +am_libebl_alpha_pic_a_OBJECTS = $(alpha_SRCS:.c=.os) +arm_SRCS = arm_init.c arm_symbol.c +libebl_arm_pic_a_SOURCES = $(arm_SRCS) +am_libebl_arm_pic_a_OBJECTS = $(arm_SRCS:.c=.os) +sparc_SRCS = sparc_init.c sparc_symbol.c sparc_regs.c +libebl_sparc_pic_a_SOURCES = $(sparc_SRCS) +am_libebl_sparc_pic_a_OBJECTS = $(sparc_SRCS:.c=.os) +ppc_SRCS = ppc_init.c ppc_symbol.c ppc_retval.c ppc_regs.c +libebl_ppc_pic_a_SOURCES = $(ppc_SRCS) +am_libebl_ppc_pic_a_OBJECTS = $(ppc_SRCS:.c=.os) +ppc64_SRCS = ppc64_init.c ppc64_symbol.c ppc64_retval.c ppc_regs.c +libebl_ppc64_pic_a_SOURCES = $(ppc64_SRCS) +am_libebl_ppc64_pic_a_OBJECTS = $(ppc64_SRCS:.c=.os) +s390_SRCS = s390_init.c s390_symbol.c s390_regs.c s390_retval.c +libebl_s390_pic_a_SOURCES = $(s390_SRCS) +am_libebl_s390_pic_a_OBJECTS = $(s390_SRCS:.c=.os) +noinst_HEADERS = libebl_CPU.h common-reloc.c +EXTRA_DIST = $(foreach m,$(modules),$($(m)_SRCS)) $(modules:=_reloc.def) +CLEANFILES = *.gcno *.gcda \ + $(foreach m,$(modules),\ + libebl_$(m).so $(am_libebl_$(m)_pic_a_OBJECTS)) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnits backends/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnits backends/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libebl_alpha_pic.a: $(libebl_alpha_pic_a_OBJECTS) $(libebl_alpha_pic_a_DEPENDENCIES) + -rm -f libebl_alpha_pic.a + $(libebl_alpha_pic_a_AR) libebl_alpha_pic.a $(libebl_alpha_pic_a_OBJECTS) $(libebl_alpha_pic_a_LIBADD) + $(RANLIB) libebl_alpha_pic.a +libebl_arm_pic.a: $(libebl_arm_pic_a_OBJECTS) $(libebl_arm_pic_a_DEPENDENCIES) + -rm -f libebl_arm_pic.a + $(libebl_arm_pic_a_AR) libebl_arm_pic.a $(libebl_arm_pic_a_OBJECTS) $(libebl_arm_pic_a_LIBADD) + $(RANLIB) libebl_arm_pic.a +libebl_i386_pic.a: $(libebl_i386_pic_a_OBJECTS) $(libebl_i386_pic_a_DEPENDENCIES) + -rm -f libebl_i386_pic.a + $(libebl_i386_pic_a_AR) libebl_i386_pic.a $(libebl_i386_pic_a_OBJECTS) $(libebl_i386_pic_a_LIBADD) + $(RANLIB) libebl_i386_pic.a +libebl_ia64_pic.a: $(libebl_ia64_pic_a_OBJECTS) $(libebl_ia64_pic_a_DEPENDENCIES) + -rm -f libebl_ia64_pic.a + $(libebl_ia64_pic_a_AR) libebl_ia64_pic.a $(libebl_ia64_pic_a_OBJECTS) $(libebl_ia64_pic_a_LIBADD) + $(RANLIB) libebl_ia64_pic.a +libebl_ppc64_pic.a: $(libebl_ppc64_pic_a_OBJECTS) $(libebl_ppc64_pic_a_DEPENDENCIES) + -rm -f libebl_ppc64_pic.a + $(libebl_ppc64_pic_a_AR) libebl_ppc64_pic.a $(libebl_ppc64_pic_a_OBJECTS) $(libebl_ppc64_pic_a_LIBADD) + $(RANLIB) libebl_ppc64_pic.a +libebl_ppc_pic.a: $(libebl_ppc_pic_a_OBJECTS) $(libebl_ppc_pic_a_DEPENDENCIES) + -rm -f libebl_ppc_pic.a + $(libebl_ppc_pic_a_AR) libebl_ppc_pic.a $(libebl_ppc_pic_a_OBJECTS) $(libebl_ppc_pic_a_LIBADD) + $(RANLIB) libebl_ppc_pic.a +libebl_s390_pic.a: $(libebl_s390_pic_a_OBJECTS) $(libebl_s390_pic_a_DEPENDENCIES) + -rm -f libebl_s390_pic.a + $(libebl_s390_pic_a_AR) libebl_s390_pic.a $(libebl_s390_pic_a_OBJECTS) $(libebl_s390_pic_a_LIBADD) + $(RANLIB) libebl_s390_pic.a +libebl_sh_pic.a: $(libebl_sh_pic_a_OBJECTS) $(libebl_sh_pic_a_DEPENDENCIES) + -rm -f libebl_sh_pic.a + $(libebl_sh_pic_a_AR) libebl_sh_pic.a $(libebl_sh_pic_a_OBJECTS) $(libebl_sh_pic_a_LIBADD) + $(RANLIB) libebl_sh_pic.a +libebl_sparc_pic.a: $(libebl_sparc_pic_a_OBJECTS) $(libebl_sparc_pic_a_DEPENDENCIES) + -rm -f libebl_sparc_pic.a + $(libebl_sparc_pic_a_AR) libebl_sparc_pic.a $(libebl_sparc_pic_a_OBJECTS) $(libebl_sparc_pic_a_LIBADD) + $(RANLIB) libebl_sparc_pic.a +libebl_x86_64_pic.a: $(libebl_x86_64_pic_a_OBJECTS) $(libebl_x86_64_pic_a_DEPENDENCIES) + -rm -f libebl_x86_64_pic.a + $(libebl_x86_64_pic_a_AR) libebl_x86_64_pic.a $(libebl_x86_64_pic_a_OBJECTS) $(libebl_x86_64_pic_a_LIBADD) + $(RANLIB) libebl_x86_64_pic.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha_retval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha_symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm_symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386_corenote.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386_regs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386_retval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386_symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ia64_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ia64_symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppc64_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppc64_retval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppc64_symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppc_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppc_regs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppc_retval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppc_symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s390_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s390_regs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s390_retval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s390_symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sh_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sh_symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparc_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparc_regs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparc_symbol.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86_64_corenote.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86_64_init.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86_64_regs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86_64_retval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86_64_symbol.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +uninstall-info-am: + +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: TAGS + +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; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(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 "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_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 tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + 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"; \ + $(mkdir_p) "$(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 $(LIBRARIES) $(DATA) $(HEADERS) +installdirs: +install-exec: install-exec-am +install-data: install-data-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_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(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-noinstLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-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 + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-noinstLIBRARIES ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-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-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-info-am + + +libebl_%.so: libebl_%_pic.a libebl_%.map $(libelf) $(libdw) + $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ + -Wl,--version-script,$(word 2,$^) \ + -Wl,-z,defs -Wl,--as-needed $(libelf) $(libdw) $(libmudflap) + $(textrel_check) + +libebl_%.map: Makefile + echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' > $@ + +%.os: %.c %.o + if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \ + -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \ + then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ + rm -f "$(DEPDIR)/$*.Tpo"; \ + else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ + fi + +install: install-am install-ebl-modules +install-ebl-modules: + $(mkinstalldirs) $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR) + for m in $(modules); do \ + $(INSTALL_PROGRAM) libebl_$${m}.so $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}-$(PACKAGE_VERSION).so; \ + ln -fs libebl_$${m}-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}.so; \ + done + +uninstall: uninstall-am + for m in $(modules); do \ + rm -f $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}-$(PACKAGE_VERSION).so; \ + rm -f $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}.so; \ + done + rmdir --ignore-fail-on-non-empty $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR) +# 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/elfutils/backends/alpha_init.c b/elfutils/backends/alpha_init.c new file mode 100644 index 00000000..98400280 --- /dev/null +++ b/elfutils/backends/alpha_init.c @@ -0,0 +1,59 @@ +/* Initialization of Alpha specific backend library. + Copyright (C) 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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. + + 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 + +#define BACKEND alpha_ +#define RELOC_PREFIX R_ALPHA_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on alpha_reloc.def. */ +#include "common-reloc.c" + + +const char * +alpha_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + eh->name = "Alpha"; + alpha_init_reloc (eh); + HOOK (eh, dynamic_tag_name); + HOOK (eh, dynamic_tag_check); + HOOK (eh, reloc_simple_type); + HOOK (eh, return_value_location); + + return MODVERSION; +} diff --git a/elfutils/backends/alpha_reloc.def b/elfutils/backends/alpha_reloc.def new file mode 100644 index 00000000..347a483f --- /dev/null +++ b/elfutils/backends/alpha_reloc.def @@ -0,0 +1,60 @@ +/* List the relocation types for alpha. -*- C -*- + Copyright (C) 2005 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. + + 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>. */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (REFLONG, REL|EXEC|DYN) +RELOC_TYPE (REFQUAD, REL|EXEC|DYN) +RELOC_TYPE (GPREL32, REL) +RELOC_TYPE (LITERAL, REL) +RELOC_TYPE (LITUSE, REL) +RELOC_TYPE (GPDISP, REL) +RELOC_TYPE (BRADDR, REL) +RELOC_TYPE (HINT, REL) +RELOC_TYPE (SREL16, REL) +RELOC_TYPE (SREL32, REL) +RELOC_TYPE (SREL64, REL) +RELOC_TYPE (GPRELHIGH, REL) +RELOC_TYPE (GPRELLOW, REL) +RELOC_TYPE (GPREL16, REL) +RELOC_TYPE (COPY, 0) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (TLS_GD_HI, REL) +RELOC_TYPE (TLSGD, REL) +RELOC_TYPE (TLS_LDM, REL) +RELOC_TYPE (DTPMOD64, REL|EXEC|DYN) +RELOC_TYPE (GOTDTPREL, REL) +RELOC_TYPE (DTPREL64, REL|EXEC|DYN) +RELOC_TYPE (DTPRELHI, REL) +RELOC_TYPE (DTPRELLO, REL) +RELOC_TYPE (DTPREL16, REL) +RELOC_TYPE (GOTTPREL, REL) +RELOC_TYPE (TPREL64, REL|EXEC|DYN) +RELOC_TYPE (TPRELHI, REL) +RELOC_TYPE (TPRELLO, REL) +RELOC_TYPE (TPREL16, REL) diff --git a/elfutils/backends/alpha_retval.c b/elfutils/backends/alpha_retval.c new file mode 100644 index 00000000..09f8bb4c --- /dev/null +++ b/elfutils/backends/alpha_retval.c @@ -0,0 +1,160 @@ +/* Function return value location for Alpha ELF ABI. + Copyright (C) 2005 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. + + 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 <assert.h> +#include <dwarf.h> + +#define BACKEND alpha_ +#include "libebl_CPU.h" + + +/* $0. */ +static const Dwarf_Op loc_intreg[] = + { + { .atom = DW_OP_reg0 } + }; +#define nloc_intreg 1 + +/* $f0, or pair $f0, $f1. */ +static const Dwarf_Op loc_fpreg[] = + { + { .atom = DW_OP_regx, .number = 32 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_regx, .number = 33 }, { .atom = DW_OP_piece, .number = 4 }, + }; +#define nloc_fpreg 1 +#define nloc_fpregpair 4 + +/* The return value is a structure and is actually stored in stack space + passed in a hidden argument by the caller. But, the compiler + helpfully returns the address of that space in $0. */ +static const Dwarf_Op loc_aggregate[] = + { + { .atom = DW_OP_breg0, .number = 0 } + }; +#define nloc_aggregate 1 + +int +alpha_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + /* Start with the function's type, and get the DW_AT_type attribute, + which is the type of the return value. */ + + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = dwarf_attr (functypedie, DW_AT_type, &attr_mem); + if (attr == NULL) + /* The function has no return value, like a `void' function in C. */ + return 0; + + Dwarf_Die die_mem; + Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); + int tag = dwarf_tag (typedie); + + /* Follow typedefs and qualifiers to get to the actual type. */ + while (tag == DW_TAG_typedef + || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type + || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + + switch (tag) + { + case -1: + return -1; + + case DW_TAG_subrange_type: + if (! dwarf_hasattr (typedie, DW_AT_byte_size)) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + /* Fall through. */ + + case DW_TAG_base_type: + case DW_TAG_enumeration_type: + case DW_TAG_pointer_type: + case DW_TAG_ptr_to_member_type: + { + Dwarf_Word size; + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + { + if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + size = 8; + else + return -1; + } + if (tag == DW_TAG_base_type) + { + Dwarf_Word encoding; + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_encoding, + &attr_mem), &encoding) != 0) + return -1; + + *locp = loc_fpreg; + if (encoding == DW_ATE_float) + { + if (size <= 8) + return nloc_fpreg; + goto aggregate; + } + if (encoding == DW_ATE_complex_float) + { + if (size <= 8 * 2) + return nloc_fpregpair; + goto aggregate; + } + } + if (size <= 8) + { + *locp = loc_intreg; + return nloc_intreg; + } + } + + /* Else fall through. */ + + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + case DW_TAG_string_type: + case DW_TAG_array_type: + aggregate: + *locp = loc_aggregate; + return nloc_aggregate; + } + + /* XXX We don't have a good way to return specific errors from ebl calls. + This value means we do not understand the type, but it is well-formed + DWARF and might be valid. */ + return -2; +} diff --git a/elfutils/backends/alpha_symbol.c b/elfutils/backends/alpha_symbol.c new file mode 100644 index 00000000..ca93e2a8 --- /dev/null +++ b/elfutils/backends/alpha_symbol.c @@ -0,0 +1,71 @@ +/* Alpha specific symbolic name handling. + Copyright (C) 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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. + + 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 <elf.h> +#include <stddef.h> + +#define BACKEND alpha_ +#include "libebl_CPU.h" + + +const char * +alpha_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + switch (tag) + { + case DT_ALPHA_PLTRO: + return "ALPHA_PLTRO"; + default: + break; + } + return NULL; +} + +bool +alpha_dynamic_tag_check (int64_t tag) +{ + return tag == DT_ALPHA_PLTRO; +} + +/* Check for the simple reloc types. */ +Elf_Type +alpha_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_ALPHA_REFLONG: + return ELF_T_WORD; + case R_ALPHA_REFQUAD: + return ELF_T_XWORD; + default: + return ELF_T_NUM; + } +} diff --git a/elfutils/backends/arm_init.c b/elfutils/backends/arm_init.c new file mode 100644 index 00000000..172af198 --- /dev/null +++ b/elfutils/backends/arm_init.c @@ -0,0 +1,56 @@ +/* Initialization of Arm specific backend library. + Copyright (C) 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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. + + 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 + +#define BACKEND arm_ +#define RELOC_PREFIX R_ARM_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on arm_reloc.def. */ +#include "common-reloc.c" + + +const char * +arm_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + eh->name = "ARM"; + arm_init_reloc (eh); + HOOK (eh, reloc_simple_type); + + return MODVERSION; +} diff --git a/elfutils/backends/arm_reloc.def b/elfutils/backends/arm_reloc.def new file mode 100644 index 00000000..c5a72cc0 --- /dev/null +++ b/elfutils/backends/arm_reloc.def @@ -0,0 +1,77 @@ +/* List the relocation types for arm. -*- C -*- + Copyright (C) 2005 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. + + 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>. */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, REL) /* It really is used in ET_REL on ARM. */ +RELOC_TYPE (PC24, REL) +RELOC_TYPE (ABS32, REL) +RELOC_TYPE (REL32, REL) +RELOC_TYPE (PC13, REL) +RELOC_TYPE (ABS16, REL) +RELOC_TYPE (ABS12, REL) +RELOC_TYPE (THM_ABS5, REL) +RELOC_TYPE (ABS8, REL) +RELOC_TYPE (SBREL32, REL) +RELOC_TYPE (THM_PC22, REL) +RELOC_TYPE (THM_PC8, REL) +RELOC_TYPE (AMP_VCALL9, REL) +RELOC_TYPE (SWI24, REL) +RELOC_TYPE (THM_SWI8, REL) +RELOC_TYPE (XPC25, REL) +RELOC_TYPE (THM_XPC22, REL) +RELOC_TYPE (TLS_DTPMOD32, EXEC|DYN) +RELOC_TYPE (TLS_DTPOFF32, EXEC|DYN) +RELOC_TYPE (TLS_TPOFF32, EXEC|DYN) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JUMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (GOTOFF, REL) +RELOC_TYPE (GOTPC, REL) +RELOC_TYPE (GOT32, REL) +RELOC_TYPE (PLT32, REL) +RELOC_TYPE (ALU_PCREL_7_0, REL) +RELOC_TYPE (ALU_PCREL_15_8, REL) +RELOC_TYPE (ALU_PCREL_23_15, REL) +RELOC_TYPE (LDR_SBREL_11_0, REL) +RELOC_TYPE (ALU_SBREL_19_12, REL) +RELOC_TYPE (ALU_SBREL_27_20, REL) +RELOC_TYPE (GNU_VTENTRY, REL) +RELOC_TYPE (GNU_VTINHERIT, REL) +RELOC_TYPE (THM_PC11, REL) +RELOC_TYPE (THM_PC9, REL) +RELOC_TYPE (TLS_GD32, REL) +RELOC_TYPE (TLS_LDM32, REL) +RELOC_TYPE (TLS_LDO32, REL) +RELOC_TYPE (TLS_IE32, REL) +RELOC_TYPE (TLS_LE32, REL) +RELOC_TYPE (RXPC25, REL) +RELOC_TYPE (RSBREL32, REL) +RELOC_TYPE (THM_RPC22, REL) +RELOC_TYPE (RREL32, REL) +RELOC_TYPE (RABS22, REL) +RELOC_TYPE (RPC24, REL) +RELOC_TYPE (RBASE, REL) diff --git a/elfutils/backends/arm_symbol.c b/elfutils/backends/arm_symbol.c new file mode 100644 index 00000000..6d2f56d3 --- /dev/null +++ b/elfutils/backends/arm_symbol.c @@ -0,0 +1,52 @@ +/* Arm specific symbolic name handling. + Copyright (C) 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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. + + 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 <elf.h> +#include <stddef.h> + +#define BACKEND arm_ +#include "libebl_CPU.h" + +/* Check for the simple reloc types. */ +Elf_Type +arm_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_ARM_ABS32: + return ELF_T_WORD; + case R_ARM_ABS16: + return ELF_T_HALF; + case R_ARM_ABS8: + return ELF_T_BYTE; + default: + return ELF_T_NUM; + } +} diff --git a/elfutils/backends/common-reloc.c b/elfutils/backends/common-reloc.c new file mode 100644 index 00000000..b3b75530 --- /dev/null +++ b/elfutils/backends/common-reloc.c @@ -0,0 +1,125 @@ +/* Common code for ebl reloc functions. + Copyright (C) 2005 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. + + 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>. */ + +#include "libebl_CPU.h" +#include <assert.h> + +#define R_TYPE(name) PASTE (RELOC_PREFIX, name) +#define PASTE(a, b) PASTE_1 (a, b) +#define PASTE_1(a, b) a##b +#define R_NAME(name) R_NAME_1 (RELOC_PREFIX, name) +#define R_NAME_1(prefix, type) R_NAME_2 (prefix, type) +#define R_NAME_2(prefix, type) #prefix #type + +#define RELOC_TYPES STRINGIFIED_PASTE (BACKEND, reloc.def) +#define STRINGIFIED_PASTE(a, b) STRINGIFY (PASTE (a, b)) +#define STRINGIFY(x) STRINGIFY_1 (x) +#define STRINGIFY_1(x) #x + +/* Provide a table of reloc type names, in a PIC-friendly fashion. */ + +static const struct EBLHOOK(reloc_nametable) +{ + char zero; +#define RELOC_TYPE(type, uses) \ + char name_##type[sizeof R_NAME (type)]; +#include RELOC_TYPES +#undef RELOC_TYPE +} EBLHOOK(reloc_nametable) = + { + '\0', +#define RELOC_TYPE(type, uses) R_NAME (type), +#include RELOC_TYPES +#undef RELOC_TYPE + }; +#define reloc_namestr (&EBLHOOK(reloc_nametable).zero) + +static const uint_fast16_t EBLHOOK(reloc_nameidx)[] = +{ +#define RELOC_TYPE(type, uses) \ + [R_TYPE (type)] = offsetof (struct EBLHOOK(reloc_nametable), name_##type), +#include RELOC_TYPES +#undef RELOC_TYPE +}; +#define nreloc \ + ((int) (sizeof EBLHOOK(reloc_nameidx) / sizeof EBLHOOK(reloc_nameidx)[0])) + +#define REL (1 << (ET_REL - 1)) +#define EXEC (1 << (ET_EXEC - 1)) +#define DYN (1 << (ET_DYN - 1)) +static const uint8_t EBLHOOK(reloc_valid)[] = +{ +#define RELOC_TYPE(type, uses) [R_TYPE (type)] = uses, +#include RELOC_TYPES +#undef RELOC_TYPE +}; +#undef REL +#undef EXEC +#undef DYN + +const char * +EBLHOOK(reloc_type_name) (int reloc, + char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + if (reloc >= 0 && reloc < nreloc && EBLHOOK(reloc_nameidx)[reloc] != 0) + return &reloc_namestr[EBLHOOK(reloc_nameidx)[reloc]]; + return NULL; +} + +bool +EBLHOOK(reloc_type_check) (int reloc) +{ + return reloc >= 0 && reloc < nreloc && EBLHOOK(reloc_nameidx)[reloc] != 0; +} + +bool +EBLHOOK(reloc_valid_use) (Elf *elf, int reloc) +{ + uint8_t uses = EBLHOOK(reloc_valid)[reloc]; + + GElf_Ehdr ehdr_mem; + GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem); + assert (ehdr != NULL); + uint8_t type = ehdr->e_type; + + return type > ET_NONE && type < ET_CORE && (uses & (1 << (type - 1))); +} + + +bool +EBLHOOK(copy_reloc_p) (int reloc) +{ + return reloc == R_TYPE (COPY); +} + +static void +EBLHOOK(init_reloc) (Ebl *ebl) +{ + ebl->reloc_type_name = EBLHOOK(reloc_type_name); + ebl->reloc_type_check = EBLHOOK(reloc_type_check); + ebl->reloc_valid_use = EBLHOOK(reloc_valid_use); + ebl->copy_reloc_p = EBLHOOK(copy_reloc_p); +} diff --git a/elfutils/backends/i386_corenote.c b/elfutils/backends/i386_corenote.c new file mode 100644 index 00000000..c9d3e5fb --- /dev/null +++ b/elfutils/backends/i386_corenote.c @@ -0,0 +1,175 @@ +/* i386 specific core note handling. + Copyright (C) 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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. + + 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 <elf.h> +#include <inttypes.h> +#include <stddef.h> +#include <stdio.h> +#include <sys/time.h> + +#define BACKEND i386_ +#include "libebl_CPU.h" + + +/* We cannot include <sys/procfs.h> since the definition would be for + the host platform and not always x86 as required here. */ +struct elf_prstatus + { + struct + { + int32_t si_signo; /* Signal number. */ + int32_t si_code; /* Extra code. */ + int32_t si_errno; /* Errno. */ + } pr_info; /* Info associated with signal. */ + int16_t pr_cursig; /* Current signal. */ + uint32_t pr_sigpend; /* Set of pending signals. */ + uint32_t pr_sighold; /* Set of held signals. */ + int32_t pr_pid; + int32_t pr_ppid; + int32_t pr_pgrp; + int32_t pr_sid; + struct i386_timeval + { + int32_t tv_sec; + int32_t tv_usec; + } pr_utime; /* User time. */ + struct i386_timeval pr_stime; /* System time. */ + struct i386_timeval pr_cutime; /* Cumulative user time. */ + struct i386_timeval pr_cstime; /* Cumulative system time. */ + uint32_t pr_reg[17]; /* GP registers. */ + int32_t pr_fpvalid; /* True if math copro being used. */ + }; + + +struct elf_prpsinfo + { + char pr_state; /* Numeric process state. */ + char pr_sname; /* Char for pr_state. */ + char pr_zomb; /* Zombie. */ + char pr_nice; /* Nice val. */ + uint32_t pr_flag; /* Flags. */ + uint16_t pr_uid; + uint16_t pr_gid; + int32_t pr_pid; + int32_t pr_ppid; + int32_t pr_pgrp; + int32_t pr_sid; + /* Lots missing */ + char pr_fname[16]; /* Filename of executable. */ + char pr_psargs[80]; /* Initial part of arg list. */ + }; + + +bool +i386_core_note (name, type, descsz, desc) + const char *name __attribute__ ((unused)); + uint32_t type; + uint32_t descsz; + const char *desc; +{ + bool result = false; + + switch (type) + { + case NT_PRSTATUS: + if (descsz < sizeof (struct elf_prstatus)) + /* Not enough data. */ + break; + + struct elf_prstatus *stat = (struct elf_prstatus *) desc; + + printf (" SIGINFO: signo: %" PRId32 ", code = %" PRId32 + ", errno = %" PRId32 "\n" + " signal: %" PRId16 ", pending: %08" PRIx32 + ", holding: %8" PRIx32 "\n" + " pid: %" PRId32 ", ppid = %" PRId32 ", pgrp = %" PRId32 + ", sid = %" PRId32 "\n" + " utime: %6" PRId32 ".%06" PRId32 + "s, stime: %6" PRId32 ".%06" PRId32 "s\n" + " cutime: %6" PRId32 ".%06" PRId32 + "s, cstime: %6" PRId32 ".%06" PRId32 "s\n" + " eax: %08" PRIx32 " ebx: %08" PRIx32 " ecx: %08" PRIx32 + " edx: %08" PRIx32 "\n" + " esi: %08" PRIx32 " edi: %08" PRIx32 " ebp: %08" PRIx32 + " esp: %08" PRIx32 "\n" + " eip: %08" PRIx32 " eflags: %08" PRIx32 + " original eax: %08" PRIx32 "\n" + " cs: %04" PRIx32 " ds: %04" PRIx32 " es: %04" PRIx32 + " fs: %04" PRIx32 " gs: %04" PRIx32 " ss: %04" PRIx32 "\n\n", + stat->pr_info.si_signo, + stat->pr_info.si_code, + stat->pr_info.si_errno, + stat->pr_cursig, + stat->pr_sigpend, stat->pr_sighold, + stat->pr_pid, stat->pr_ppid, stat->pr_pgrp, stat->pr_sid, + stat->pr_utime.tv_sec, stat->pr_utime.tv_usec, + stat->pr_stime.tv_sec, stat->pr_stime.tv_usec, + stat->pr_cutime.tv_sec, stat->pr_cutime.tv_usec, + stat->pr_cstime.tv_sec, stat->pr_cstime.tv_usec, + stat->pr_reg[6], stat->pr_reg[0], stat->pr_reg[1], + stat->pr_reg[2], stat->pr_reg[3], stat->pr_reg[4], + stat->pr_reg[5], stat->pr_reg[15], stat->pr_reg[12], + stat->pr_reg[14], stat->pr_reg[11], stat->pr_reg[13] & 0xffff, + stat->pr_reg[7] & 0xffff, stat->pr_reg[8] & 0xffff, + stat->pr_reg[9] & 0xffff, stat->pr_reg[10] & 0xffff, + stat->pr_reg[16]); + + /* We handled this entry. */ + result = true; + break; + + case NT_PRPSINFO: + if (descsz < sizeof (struct elf_prpsinfo)) + /* Not enough data. */ + break; + + struct elf_prpsinfo *info = (struct elf_prpsinfo *) desc; + + printf (" state: %c (%hhd), zombie: %hhd, nice: %hhd\n" + " flags: %08" PRIx32 ", uid: %" PRId16 ", gid: %" PRId16"\n" + " pid: %" PRId32 ", ppid: %" PRId32 ", pgrp: %" PRId32 + ", sid: %" PRId32 "\n" + " fname: %.16s\n" + " args: %.80s\n\n", + info->pr_sname, info->pr_state, info->pr_zomb, info->pr_nice, + info->pr_flag, info->pr_uid, info->pr_gid, + info->pr_pid, info->pr_ppid, info->pr_pgrp, info->pr_sid, + info->pr_fname, info->pr_psargs); + + /* We handled this entry. */ + result = true; + break; + + default: + break; + } + + return result; +} diff --git a/elfutils/backends/i386_init.c b/elfutils/backends/i386_init.c new file mode 100644 index 00000000..e0742b70 --- /dev/null +++ b/elfutils/backends/i386_init.c @@ -0,0 +1,61 @@ +/* Initialization of i386 specific backend library. + Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2000. + + 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. + + 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 + +#define BACKEND i386_ +#define RELOC_PREFIX R_386_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on i386_reloc.def. */ +#include "common-reloc.c" + +const char * +i386_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + eh->name = "Intel 80386"; + i386_init_reloc (eh); + HOOK (eh, reloc_simple_type); + HOOK (eh, gotpc_reloc_check); + HOOK (eh, core_note); + generic_debugscn_p = eh->debugscn_p; + HOOK (eh, debugscn_p); + HOOK (eh, return_value_location); + HOOK (eh, register_name); + + return MODVERSION; +} diff --git a/elfutils/backends/i386_regs.c b/elfutils/backends/i386_regs.c new file mode 100644 index 00000000..c2c21423 --- /dev/null +++ b/elfutils/backends/i386_regs.c @@ -0,0 +1,121 @@ +/* Register names and numbers for i386 DWARF. + Copyright (C) 2005 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. + + 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> + +#define BACKEND i386_ +#include "libebl_CPU.h" + +ssize_t +i386_register_name (Ebl *ebl __attribute__ ((unused)), + int regno, char *name, size_t namelen, + const char **prefix, const char **setname) +{ + if (name == NULL) + return 46; + + if (regno < 0 || regno > 45 || namelen < 6) + return -1; + + *prefix = "%"; + if (regno < 11) + *setname = "integer"; + else if (regno < 19) + *setname = "x87"; + else if (regno < 29) + *setname = "SSE"; + else if (regno < 37) + *setname = "MMX"; + else if (regno < 40) + *setname = "FPU-control"; + else + *setname = "segment"; + + switch (regno) + { + static const char baseregs[][2] = + { + "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "ip" + }; + + case 0 ... 8: + name[0] = 'e'; + name[1] = baseregs[regno][0]; + name[2] = baseregs[regno][1]; + namelen = 3; + break; + + case 9: + return stpcpy (name, "eflags") - name; + case 10: + return stpcpy (name, "trapno") - name; + + case 11 ... 18: + name[0] = 's'; + name[1] = 't'; + name[2] = regno - 11 + '0'; + namelen = 3; + break; + + case 21 ... 28: + name[0] = 'x'; + name[1] = 'm'; + name[2] = 'm'; + name[3] = regno - 21 + '0'; + namelen = 4; + break; + + case 29 ... 36: + name[0] = 'm'; + name[1] = 'm'; + name[2] = regno - 29 + '0'; + namelen = 3; + break; + + case 37: + return stpcpy (name, "fctrl") - name; + case 38: + return stpcpy (name, "fstat") - name; + case 39: + return stpcpy (name, "mxcsr") - name; + + case 40 ... 45: + name[0] = "ecsdfg"[regno - 40]; + name[1] = 's'; + namelen = 2; + break; + + default: + *setname = NULL; + return 0; + } + + name[namelen++] = '\0'; + return namelen; +} diff --git a/elfutils/backends/i386_reloc.def b/elfutils/backends/i386_reloc.def new file mode 100644 index 00000000..d8116f3d --- /dev/null +++ b/elfutils/backends/i386_reloc.def @@ -0,0 +1,63 @@ +/* List the relocation types for i386. -*- C -*- + Copyright (C) 2000, 2001, 2002, 2003, 2005 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. + + 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>. */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (32, REL|EXEC|DYN) +RELOC_TYPE (PC32, REL|EXEC|DYN) +RELOC_TYPE (GOT32, REL) +RELOC_TYPE (PLT32, REL) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (GOTOFF, REL) +RELOC_TYPE (GOTPC, REL) +RELOC_TYPE (32PLT, REL) +RELOC_TYPE (TLS_TPOFF, EXEC|DYN) +RELOC_TYPE (TLS_IE, REL) +RELOC_TYPE (TLS_GOTIE, REL) +RELOC_TYPE (TLS_LE, REL) +RELOC_TYPE (TLS_GD, REL) +RELOC_TYPE (TLS_LDM, REL) +RELOC_TYPE (16, REL) +RELOC_TYPE (PC16, REL) +RELOC_TYPE (8, REL) +RELOC_TYPE (PC8, REL) +RELOC_TYPE (TLS_GD_32, REL) +RELOC_TYPE (TLS_GD_PUSH, REL) +RELOC_TYPE (TLS_GD_CALL, REL) +RELOC_TYPE (TLS_GD_POP, REL) +RELOC_TYPE (TLS_LDM_32, REL) +RELOC_TYPE (TLS_LDM_PUSH, REL) +RELOC_TYPE (TLS_LDM_CALL, REL) +RELOC_TYPE (TLS_LDM_POP, REL) +RELOC_TYPE (TLS_LDO_32, REL) +RELOC_TYPE (TLS_IE_32, REL) +RELOC_TYPE (TLS_LE_32, REL) +RELOC_TYPE (TLS_DTPMOD32, EXEC|DYN) +RELOC_TYPE (TLS_DTPOFF32, EXEC|DYN) +RELOC_TYPE (TLS_TPOFF32, EXEC|DYN) diff --git a/elfutils/backends/i386_retval.c b/elfutils/backends/i386_retval.c new file mode 100644 index 00000000..cfd50579 --- /dev/null +++ b/elfutils/backends/i386_retval.c @@ -0,0 +1,151 @@ +/* Function return value location for Linux/i386 ABI. + Copyright (C) 2005 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. + + 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 <assert.h> +#include <dwarf.h> + +#define BACKEND i386_ +#include "libebl_CPU.h" + + +/* %eax, or pair %eax, %edx. */ +static const Dwarf_Op loc_intreg[] = + { + { .atom = DW_OP_reg0 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_reg1 }, { .atom = DW_OP_piece, .number = 4 }, + }; +#define nloc_intreg 1 +#define nloc_intregpair 4 + +/* %st(0). */ +static const Dwarf_Op loc_fpreg[] = + { + { .atom = DW_OP_reg11 } + }; +#define nloc_fpreg 1 + +/* The return value is a structure and is actually stored in stack space + passed in a hidden argument by the caller. But, the compiler + helpfully returns the address of that space in %eax. */ +static const Dwarf_Op loc_aggregate[] = + { + { .atom = DW_OP_breg0, .number = 0 } + }; +#define nloc_aggregate 1 + +int +i386_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + /* Start with the function's type, and get the DW_AT_type attribute, + which is the type of the return value. */ + + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = dwarf_attr (functypedie, DW_AT_type, &attr_mem); + if (attr == NULL) + /* The function has no return value, like a `void' function in C. */ + return 0; + + Dwarf_Die die_mem; + Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); + int tag = dwarf_tag (typedie); + + /* Follow typedefs and qualifiers to get to the actual type. */ + while (tag == DW_TAG_typedef + || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type + || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + + switch (tag) + { + case -1: + return -1; + + case DW_TAG_subrange_type: + if (! dwarf_hasattr (typedie, DW_AT_byte_size)) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + /* Fall through. */ + + case DW_TAG_base_type: + case DW_TAG_enumeration_type: + case DW_TAG_pointer_type: + case DW_TAG_ptr_to_member_type: + { + Dwarf_Word size; + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + { + if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + size = 4; + else + return -1; + } + if (tag == DW_TAG_base_type) + { + Dwarf_Word encoding; + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_encoding, + &attr_mem), &encoding) != 0) + return -1; + if (encoding == DW_ATE_float) + { + if (size > 16) + return -2; + *locp = loc_fpreg; + return nloc_fpreg; + } + } + *locp = loc_intreg; + if (size <= 4) + return nloc_intreg; + if (size <= 8) + return nloc_intregpair; + + /* Else fall through. */ + } + + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + case DW_TAG_array_type: + *locp = loc_aggregate; + return nloc_aggregate; + } + + /* XXX We don't have a good way to return specific errors from ebl calls. + This value means we do not understand the type, but it is well-formed + DWARF and might be valid. */ + return -2; +} diff --git a/elfutils/backends/i386_symbol.c b/elfutils/backends/i386_symbol.c new file mode 100644 index 00000000..5d6c0efd --- /dev/null +++ b/elfutils/backends/i386_symbol.c @@ -0,0 +1,72 @@ +/* i386 specific symbolic name handling. + Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2000. + + 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. + + 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 <assert.h> +#include <elf.h> +#include <stddef.h> +#include <string.h> + +#define BACKEND i386_ +#include "libebl_CPU.h" + + +/* Return true if the symbol type is that referencing the GOT. */ +bool +i386_gotpc_reloc_check (Elf *elf __attribute__ ((unused)), int type) +{ + return type == R_386_GOTPC; +} + +/* Check for the simple reloc types. */ +Elf_Type +i386_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_386_32: + return ELF_T_SWORD; + case R_386_16: + return ELF_T_HALF; + case R_386_8: + return ELF_T_BYTE; + default: + return ELF_T_NUM; + } +} + +/* Check section name for being that of a debug information section. */ +bool (*generic_debugscn_p) (const char *); +bool +i386_debugscn_p (const char *name) +{ + return (generic_debugscn_p (name) + || strcmp (name, ".stab") == 0 + || strcmp (name, ".stabstr") == 0); +} diff --git a/elfutils/backends/ia64_init.c b/elfutils/backends/ia64_init.c new file mode 100644 index 00000000..42f0634b --- /dev/null +++ b/elfutils/backends/ia64_init.c @@ -0,0 +1,60 @@ +/* Initialization of IA-64 specific backend library. + Copyright (C) 2002, 2003, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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. + + 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 + +#define BACKEND ia64_ +#define RELOC_PREFIX R_IA64_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on ia64_reloc.def. */ +#include "common-reloc.c" + +const char * +ia64_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + eh->name = "Intel IA-64"; + ia64_init_reloc (eh); + HOOK (eh, reloc_simple_type); + HOOK (eh, segment_type_name); + HOOK (eh, section_type_name); + HOOK (eh, dynamic_tag_name); + HOOK (eh, dynamic_tag_check); + HOOK (eh, machine_flag_check); + + return MODVERSION; +} diff --git a/elfutils/backends/ia64_reloc.def b/elfutils/backends/ia64_reloc.def new file mode 100644 index 00000000..0dc001da --- /dev/null +++ b/elfutils/backends/ia64_reloc.def @@ -0,0 +1,108 @@ +/* List the relocation types for ia64. -*- C -*- + Copyright (C) 2005 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. + + 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>. */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (IMM14, REL) +RELOC_TYPE (IMM22, REL) +RELOC_TYPE (IMM64, REL) +RELOC_TYPE (DIR32MSB, REL|EXEC|DYN) +RELOC_TYPE (DIR32LSB, REL|EXEC|DYN) +RELOC_TYPE (DIR64MSB, REL|EXEC|DYN) +RELOC_TYPE (DIR64LSB, REL|EXEC|DYN) +RELOC_TYPE (GPREL22, REL) +RELOC_TYPE (GPREL64I, REL) +RELOC_TYPE (GPREL32MSB, REL) +RELOC_TYPE (GPREL32LSB, REL) +RELOC_TYPE (GPREL64MSB, REL) +RELOC_TYPE (GPREL64LSB, REL) +RELOC_TYPE (LTOFF22, REL) +RELOC_TYPE (LTOFF64I, REL) +RELOC_TYPE (PLTOFF22, REL) +RELOC_TYPE (PLTOFF64I, REL) +RELOC_TYPE (PLTOFF64MSB, REL) +RELOC_TYPE (PLTOFF64LSB, REL) +RELOC_TYPE (FPTR64I, REL) +RELOC_TYPE (FPTR32MSB, REL|EXEC|DYN) +RELOC_TYPE (FPTR32LSB, REL|EXEC|DYN) +RELOC_TYPE (FPTR64MSB, REL|EXEC|DYN) +RELOC_TYPE (FPTR64LSB, REL|EXEC|DYN) +RELOC_TYPE (PCREL60B, REL) +RELOC_TYPE (PCREL21B, REL) +RELOC_TYPE (PCREL21M, REL) +RELOC_TYPE (PCREL21F, REL) +RELOC_TYPE (PCREL32MSB, REL|EXEC|DYN) +RELOC_TYPE (PCREL32LSB, REL|EXEC|DYN) +RELOC_TYPE (PCREL64MSB, REL|EXEC|DYN) +RELOC_TYPE (PCREL64LSB, REL|EXEC|DYN) +RELOC_TYPE (LTOFF_FPTR22, REL) +RELOC_TYPE (LTOFF_FPTR64I, REL) +RELOC_TYPE (LTOFF_FPTR32MSB, REL) +RELOC_TYPE (LTOFF_FPTR32LSB, REL) +RELOC_TYPE (LTOFF_FPTR64MSB, REL) +RELOC_TYPE (LTOFF_FPTR64LSB, REL) +RELOC_TYPE (SEGREL32MSB, REL) +RELOC_TYPE (SEGREL32LSB, REL) +RELOC_TYPE (SEGREL64MSB, REL) +RELOC_TYPE (SEGREL64LSB, REL) +RELOC_TYPE (SECREL32MSB, REL) +RELOC_TYPE (SECREL32LSB, REL) +RELOC_TYPE (SECREL64MSB, REL) +RELOC_TYPE (SECREL64LSB, REL) +RELOC_TYPE (REL32MSB, EXEC|DYN) +RELOC_TYPE (REL32LSB, EXEC|DYN) +RELOC_TYPE (REL64MSB, EXEC|DYN) +RELOC_TYPE (REL64LSB, EXEC|DYN) +RELOC_TYPE (LTV32MSB, REL) +RELOC_TYPE (LTV32LSB, REL) +RELOC_TYPE (LTV64MSB, REL) +RELOC_TYPE (LTV64LSB, REL) +RELOC_TYPE (PCREL21BI, REL) +RELOC_TYPE (PCREL22, REL) +RELOC_TYPE (PCREL64I, REL) +RELOC_TYPE (IPLTMSB, REL|EXEC|DYN) +RELOC_TYPE (IPLTLSB, REL|EXEC|DYN) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (SUB, 0) +RELOC_TYPE (LTOFF22X, REL) +RELOC_TYPE (LDXMOV, REL) +RELOC_TYPE (TPREL14, REL) +RELOC_TYPE (TPREL22, REL) +RELOC_TYPE (TPREL64I, REL) +RELOC_TYPE (TPREL64MSB, REL|EXEC|DYN) +RELOC_TYPE (TPREL64LSB, REL|EXEC|DYN) +RELOC_TYPE (LTOFF_TPREL22, REL) +RELOC_TYPE (DTPMOD64MSB, REL|EXEC|DYN) +RELOC_TYPE (DTPMOD64LSB, REL|EXEC|DYN) +RELOC_TYPE (LTOFF_DTPMOD22, REL) +RELOC_TYPE (DTPREL14, REL) +RELOC_TYPE (DTPREL22, REL) +RELOC_TYPE (DTPREL64I, REL) +RELOC_TYPE (DTPREL32MSB, REL|EXEC|DYN) +RELOC_TYPE (DTPREL32LSB, REL|EXEC|DYN) +RELOC_TYPE (DTPREL64MSB, REL|EXEC|DYN) +RELOC_TYPE (DTPREL64LSB, REL|EXEC|DYN) +RELOC_TYPE (LTOFF_DTPREL22, REL) diff --git a/elfutils/backends/ia64_symbol.c b/elfutils/backends/ia64_symbol.c new file mode 100644 index 00000000..d7caaf38 --- /dev/null +++ b/elfutils/backends/ia64_symbol.c @@ -0,0 +1,131 @@ +/* IA-64 specific symbolic name handling. + Copyright (C) 2002, 2003, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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. + + 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 <elf.h> +#include <stddef.h> +#include <assert.h> + +#define BACKEND ia64_ +#include "libebl_CPU.h" + + +const char * +ia64_segment_type_name (int segment, char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + switch (segment) + { + case PT_IA_64_ARCHEXT: + return "IA_64_ARCHEXT"; + case PT_IA_64_UNWIND: + return "IA_64_UNWIND"; + case PT_IA_64_HP_OPT_ANOT: + return "IA_64_HP_OPT_ANOT"; + case PT_IA_64_HP_HSL_ANOT: + return "IA_64_HP_HSL_ANOT"; + case PT_IA_64_HP_STACK: + return "IA_64_HP_STACK"; + default: + break; + } + return NULL; +} + +const char * +ia64_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + switch (tag) + { + case DT_IA_64_PLT_RESERVE: + return "IA_64_PLT_RESERVE"; + default: + break; + } + return NULL; +} + +/* Check dynamic tag. */ +bool +ia64_dynamic_tag_check (int64_t tag) +{ + return tag == DT_IA_64_PLT_RESERVE; +} + +/* Check whether machine flags are valid. */ +bool +ia64_machine_flag_check (GElf_Word flags) +{ + return ((flags &~ EF_IA_64_ABI64) == 0); +} + +/* Return symbolic representation of section type. */ +const char * +ia64_section_type_name (int type, + char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + switch (type) + { + case SHT_IA_64_EXT: + return "SHT_IA_64_EXT"; + case SHT_IA_64_UNWIND: + return "HT_IA_64_UNWIND"; + } + + return NULL; +} + +/* Check for the simple reloc types. */ +Elf_Type +ia64_reloc_simple_type (Ebl *ebl, int type) +{ + switch (type) + { + case R_IA64_DIR32MSB: + if (ebl->data == ELFDATA2MSB) + return ELF_T_WORD; + break; + case R_IA64_DIR32LSB: + if (ebl->data == ELFDATA2LSB) + return ELF_T_WORD; + break; + case R_IA64_DIR64MSB: + if (ebl->data == ELFDATA2MSB) + return ELF_T_XWORD; + break; + case R_IA64_DIR64LSB: + if (ebl->data == ELFDATA2LSB) + return ELF_T_XWORD; + break; + } + + return ELF_T_NUM; +} diff --git a/elfutils/backends/libebl_CPU.h b/elfutils/backends/libebl_CPU.h new file mode 100644 index 00000000..b00e7231 --- /dev/null +++ b/elfutils/backends/libebl_CPU.h @@ -0,0 +1,46 @@ +/* Common interface for libebl modules. + Copyright (C) 2000, 2001, 2002, 2003, 2005 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. + + 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>. */ + +#ifndef _LIBEBL_CPU_H +#define _LIBEBL_CPU_H 1 + +#include <libeblP.h> + +#define EBLHOOK(name) EBLHOOK_1(BACKEND, name) +#define EBLHOOK_1(a, b) EBLHOOK_2(a, b) +#define EBLHOOK_2(a, b) a##b + +/* Constructor. */ +extern const char *EBLHOOK(init) (Elf *elf, GElf_Half machine, + Ebl *eh, size_t ehlen); + +#include "ebl-hooks.h" + +#define HOOK(eh, name) eh->name = EBLHOOK(name) + +extern bool (*generic_debugscn_p) (const char *) attribute_hidden; + + +#endif /* libebl_CPU.h */ diff --git a/elfutils/backends/ppc64_init.c b/elfutils/backends/ppc64_init.c new file mode 100644 index 00000000..1d4e8304 --- /dev/null +++ b/elfutils/backends/ppc64_init.c @@ -0,0 +1,63 @@ +/* Initialization of PPC64 specific backend library. + Copyright (C) 2004, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2004. + + 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. + + 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 + +#define BACKEND ppc64_ +#define RELOC_PREFIX R_PPC64_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on ppc64_reloc.def. */ +#include "common-reloc.c" + + +const char * +ppc64_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + eh->name = "PowerPC 64-bit"; + ppc64_init_reloc (eh); + HOOK (eh, reloc_simple_type); + HOOK (eh, dynamic_tag_name); + HOOK (eh, dynamic_tag_check); + HOOK (eh, copy_reloc_p); + HOOK (eh, check_special_symbol); + HOOK (eh, bss_plt_p); + HOOK (eh, return_value_location); + HOOK (eh, register_name); + + return MODVERSION; +} diff --git a/elfutils/backends/ppc64_reloc.def b/elfutils/backends/ppc64_reloc.def new file mode 100644 index 00000000..e51512be --- /dev/null +++ b/elfutils/backends/ppc64_reloc.def @@ -0,0 +1,143 @@ +/* List the relocation types for ppc64. -*- C -*- + Copyright (C) 2005 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. + + 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>. */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (ADDR32, REL|EXEC|DYN) +RELOC_TYPE (ADDR24, REL) +RELOC_TYPE (ADDR16, REL) /* note 1 */ +RELOC_TYPE (ADDR16_LO, REL) /* note 1 */ +RELOC_TYPE (ADDR16_HI, REL) /* note 1 */ +RELOC_TYPE (ADDR16_HA, REL) /* note 1 */ +RELOC_TYPE (ADDR14, REL) /* note 1 */ +RELOC_TYPE (ADDR14_BRTAKEN, REL) /* note 1 */ +RELOC_TYPE (ADDR14_BRNTAKEN, REL) /* note 1 */ +RELOC_TYPE (REL24, REL) +RELOC_TYPE (REL14, REL) +RELOC_TYPE (REL14_BRTAKEN, REL) +RELOC_TYPE (REL14_BRNTAKEN, REL) +RELOC_TYPE (GOT16, REL) +RELOC_TYPE (GOT16_LO, REL) +RELOC_TYPE (GOT16_HI, REL) +RELOC_TYPE (GOT16_HA, REL) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (UADDR32, REL|EXEC|DYN) +RELOC_TYPE (UADDR16, REL) +RELOC_TYPE (REL32, REL|EXEC|DYN) +RELOC_TYPE (PLT32, REL) +RELOC_TYPE (PLTREL32, REL) +RELOC_TYPE (PLT16_LO, REL) +RELOC_TYPE (PLT16_HI, REL) +RELOC_TYPE (PLT16_HA, REL) +RELOC_TYPE (SECTOFF, REL) +RELOC_TYPE (SECTOFF_LO, REL) +RELOC_TYPE (SECTOFF_HI, REL) +RELOC_TYPE (SECTOFF_HA, REL) +RELOC_TYPE (ADDR30, REL) /* note 1 */ +RELOC_TYPE (ADDR64, REL|EXEC|DYN) +RELOC_TYPE (ADDR16_HIGHER, REL) /* note 1 */ +RELOC_TYPE (ADDR16_HIGHERA, REL) /* note 1 */ +RELOC_TYPE (ADDR16_HIGHEST, REL) /* note 1 */ +RELOC_TYPE (ADDR16_HIGHESTA, REL) /* note 1 */ +RELOC_TYPE (UADDR64, REL|EXEC|DYN) +RELOC_TYPE (REL64, REL|EXEC|DYN) +RELOC_TYPE (PLT64, REL) +RELOC_TYPE (PLTREL64, REL) +RELOC_TYPE (TOC16, REL) +RELOC_TYPE (TOC16_LO, REL) +RELOC_TYPE (TOC16_HI, REL) +RELOC_TYPE (TOC16_HA, REL) +RELOC_TYPE (TOC, REL) +RELOC_TYPE (PLTGOT16, REL) +RELOC_TYPE (PLTGOT16_LO, REL) +RELOC_TYPE (PLTGOT16_HI, REL) +RELOC_TYPE (PLTGOT16_HA, REL) +RELOC_TYPE (ADDR16_DS, REL) /* note 1 */ +RELOC_TYPE (ADDR16_LO_DS, REL) /* note 1 */ +RELOC_TYPE (GOT16_DS, REL) +RELOC_TYPE (GOT16_LO_DS, REL) +RELOC_TYPE (PLT16_LO_DS, REL) +RELOC_TYPE (SECTOFF_DS, REL) +RELOC_TYPE (SECTOFF_LO_DS, REL) +RELOC_TYPE (TOC16_DS, REL) +RELOC_TYPE (TOC16_LO_DS, REL) +RELOC_TYPE (PLTGOT16_DS, REL) +RELOC_TYPE (PLTGOT16_LO_DS, REL) +RELOC_TYPE (TLS, REL) +RELOC_TYPE (DTPMOD64, REL|EXEC|DYN) /* note 3 */ +RELOC_TYPE (TPREL16, REL) /* note 2 */ +RELOC_TYPE (TPREL16_LO, REL) /* note 2 */ +RELOC_TYPE (TPREL16_HI, REL) /* note 2 */ +RELOC_TYPE (TPREL16_HA, REL) /* note 2 */ +RELOC_TYPE (TPREL64, REL|EXEC|DYN) /* note 3 */ +RELOC_TYPE (DTPREL16, REL) +RELOC_TYPE (DTPREL16_LO, REL) +RELOC_TYPE (DTPREL16_HI, REL) +RELOC_TYPE (DTPREL16_HA, REL) +RELOC_TYPE (DTPREL64, REL|EXEC|DYN) /* note 3 */ +RELOC_TYPE (GOT_TLSGD16, REL) +RELOC_TYPE (GOT_TLSGD16_LO, REL) +RELOC_TYPE (GOT_TLSGD16_HI, REL) +RELOC_TYPE (GOT_TLSGD16_HA, REL) +RELOC_TYPE (GOT_TLSLD16, REL) +RELOC_TYPE (GOT_TLSLD16_LO, REL) +RELOC_TYPE (GOT_TLSLD16_HI, REL) +RELOC_TYPE (GOT_TLSLD16_HA, REL) +RELOC_TYPE (GOT_TPREL16_DS, REL) +RELOC_TYPE (GOT_TPREL16_LO_DS, REL) +RELOC_TYPE (GOT_TPREL16_HI, REL) +RELOC_TYPE (GOT_TPREL16_HA, REL) +RELOC_TYPE (GOT_DTPREL16_DS, REL) +RELOC_TYPE (GOT_DTPREL16_LO_DS, REL) +RELOC_TYPE (GOT_DTPREL16_HI, REL) +RELOC_TYPE (GOT_DTPREL16_HA, REL) +RELOC_TYPE (TPREL16_DS, REL) /* note 2 */ +RELOC_TYPE (TPREL16_LO_DS, REL) /* note 2 */ +RELOC_TYPE (TPREL16_HIGHER, REL) /* note 2 */ +RELOC_TYPE (TPREL16_HIGHERA, REL) /* note 2 */ +RELOC_TYPE (TPREL16_HIGHEST, REL) /* note 2 */ +RELOC_TYPE (TPREL16_HIGHESTA, REL) /* note 2 */ +RELOC_TYPE (DTPREL16_DS, REL) +RELOC_TYPE (DTPREL16_LO_DS, REL) +RELOC_TYPE (DTPREL16_HIGHER, REL) +RELOC_TYPE (DTPREL16_HIGHERA, REL) +RELOC_TYPE (DTPREL16_HIGHEST, REL) +RELOC_TYPE (DTPREL16_HIGHESTA, REL) + +/* Notes from Alan Modra: + + 1) These can appear in DYN and EXEC with improper assembly, but they + aren't really kosher. + + 2) These can appear in DYN with improper assembly (or silly gcc + attributes, I think). Again, not kosher. + + 3) These are legal in REL for PowerOpen compatible assembler syntax, + ie. TOC managed by compiler. +*/ diff --git a/elfutils/backends/ppc64_retval.c b/elfutils/backends/ppc64_retval.c new file mode 100644 index 00000000..70a0de76 --- /dev/null +++ b/elfutils/backends/ppc64_retval.c @@ -0,0 +1,184 @@ +/* Function return value location for Linux/PPC64 ABI. + Copyright (C) 2005, 2006 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. + + 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 <assert.h> +#include <dwarf.h> + +#define BACKEND ppc64_ +#include "libebl_CPU.h" + + +/* This is the SVR4 ELF ABI convention, but AIX and Linux do not use it. */ +#define SVR4_STRUCT_RETURN 0 + + +/* r3. */ +static const Dwarf_Op loc_intreg[] = + { + { .atom = DW_OP_reg3 } + }; +#define nloc_intreg 1 + +/* f1, or f1:f2, or f1:f4. */ +static const Dwarf_Op loc_fpreg[] = + { + { .atom = DW_OP_regx, .number = 33 }, { .atom = DW_OP_piece, .number = 8 }, + { .atom = DW_OP_regx, .number = 34 }, { .atom = DW_OP_piece, .number = 8 }, + { .atom = DW_OP_regx, .number = 35 }, { .atom = DW_OP_piece, .number = 8 }, + { .atom = DW_OP_regx, .number = 36 }, { .atom = DW_OP_piece, .number = 8 }, + }; +#define nloc_fpreg 1 +#define nloc_fp2regs 4 +#define nloc_fp4regs 8 + +/* The return value is a structure and is actually stored in stack space + passed in a hidden argument by the caller. But, the compiler + helpfully returns the address of that space in r3. */ +static const Dwarf_Op loc_aggregate[] = + { + { .atom = DW_OP_breg3, .number = 0 } + }; +#define nloc_aggregate 1 + +int +ppc64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + /* Start with the function's type, and get the DW_AT_type attribute, + which is the type of the return value. */ + + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = dwarf_attr (functypedie, DW_AT_type, &attr_mem); + if (attr == NULL) + /* The function has no return value, like a `void' function in C. */ + return 0; + + Dwarf_Die die_mem; + Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); + int tag = dwarf_tag (typedie); + + /* Follow typedefs and qualifiers to get to the actual type. */ + while (tag == DW_TAG_typedef + || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type + || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + + Dwarf_Word size; + switch (tag) + { + case -1: + return -1; + + case DW_TAG_subrange_type: + if (! dwarf_hasattr (typedie, DW_AT_byte_size)) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + /* Fall through. */ + + case DW_TAG_base_type: + case DW_TAG_enumeration_type: + case DW_TAG_pointer_type: + case DW_TAG_ptr_to_member_type: + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + { + if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + size = 8; + else + return -1; + } + if (tag == DW_TAG_base_type) + { + Dwarf_Word encoding; + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_encoding, + &attr_mem), &encoding) != 0) + return -1; + + if (encoding == DW_ATE_float || encoding == DW_ATE_complex_float) + { + *locp = loc_fpreg; + if (size <= 8) + return nloc_fpreg; + if (size <= 16) + return nloc_fp2regs; + if (size <= 32) + return nloc_fp4regs; + } + } + if (size <= 8 && SVR4_STRUCT_RETURN) + { + intreg: + *locp = loc_intreg; + return nloc_intreg; + } + + /* Else fall through. */ + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + aggregate: + *locp = loc_aggregate; + return nloc_aggregate; + + case DW_TAG_string_type: + case DW_TAG_array_type: + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, + &attr_mem), &size) == 0 + && size <= 8) + { + if (tag == DW_TAG_array_type) + { + /* Check if it's a character array. */ + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + if (tag != DW_TAG_base_type) + goto aggregate; + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + return -1; + if (size != 1) + goto aggregate; + } + goto intreg; + } + goto aggregate; + } + + /* XXX We don't have a good way to return specific errors from ebl calls. + This value means we do not understand the type, but it is well-formed + DWARF and might be valid. */ + return -2; +} diff --git a/elfutils/backends/ppc64_symbol.c b/elfutils/backends/ppc64_symbol.c new file mode 100644 index 00000000..49fde0ca --- /dev/null +++ b/elfutils/backends/ppc64_symbol.c @@ -0,0 +1,109 @@ +/* PPC64 specific symbolic name handling. + Copyright (C) 2004, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2004. + + 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. + + 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 <assert.h> +#include <elf.h> +#include <stddef.h> +#include <string.h> + +#define BACKEND ppc64_ +#include "libebl_CPU.h" + + +/* Check for the simple reloc types. */ +Elf_Type +ppc64_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_PPC64_ADDR64: + case R_PPC64_UADDR64: + return ELF_T_XWORD; + case R_PPC64_ADDR32: + case R_PPC64_UADDR32: + return ELF_T_WORD; + case R_PPC64_UADDR16: + return ELF_T_HALF; + default: + return ELF_T_NUM; + } +} + + +const char * +ppc64_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + switch (tag) + { + case DT_PPC64_GLINK: + return "PPC64_GLINK"; + case DT_PPC64_OPD: + return "PPC64_OPD"; + case DT_PPC64_OPDSZ: + return "PPC64_OPDSZ"; + default: + break; + } + return NULL; +} + + +bool +ppc64_dynamic_tag_check (int64_t tag) +{ + return (tag == DT_PPC64_GLINK + || tag == DT_PPC64_OPD + || tag == DT_PPC64_OPDSZ); +} + + +/* Check whether given symbol's st_value and st_size are OK despite failing + normal checks. */ +bool +ppc64_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr, + const GElf_Sym *sym __attribute__ ((unused)), + const char *name __attribute__ ((unused)), + const GElf_Shdr *destshdr) +{ + const char *sname = elf_strptr (elf, ehdr->e_shstrndx, destshdr->sh_name); + if (sname == NULL) + return false; + return strcmp (sname, ".opd") == 0; +} + + +/* Check if backend uses a bss PLT in this file. */ +bool +ppc64_bss_plt_p (Elf *elf __attribute__ ((unused)), + GElf_Ehdr *ehdr __attribute__ ((unused))) +{ + return true; +} diff --git a/elfutils/backends/ppc_init.c b/elfutils/backends/ppc_init.c new file mode 100644 index 00000000..1663258c --- /dev/null +++ b/elfutils/backends/ppc_init.c @@ -0,0 +1,62 @@ +/* Initialization of PPC specific backend library. + Copyright (C) 2004, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2004. + + 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. + + 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 + +#define BACKEND ppc_ +#define RELOC_PREFIX R_PPC_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on ppc_reloc.def. */ +#include "common-reloc.c" + + +const char * +ppc_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + eh->name = "PowerPC"; + ppc_init_reloc (eh); + HOOK (eh, reloc_simple_type); + HOOK (eh, dynamic_tag_name); + HOOK (eh, dynamic_tag_check); + HOOK (eh, check_special_symbol); + HOOK (eh, bss_plt_p); + HOOK (eh, return_value_location); + HOOK (eh, register_name); + + return MODVERSION; +} diff --git a/elfutils/backends/ppc_regs.c b/elfutils/backends/ppc_regs.c new file mode 100644 index 00000000..3d3d904d --- /dev/null +++ b/elfutils/backends/ppc_regs.c @@ -0,0 +1,159 @@ +/* Register names and numbers for PowerPC DWARF. + Copyright (C) 2005 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. + + 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> + +#define BACKEND ppc_ +#include "libebl_CPU.h" + +ssize_t +ppc_register_name (Ebl *ebl __attribute__ ((unused)), + int regno, char *name, size_t namelen, + const char **prefix, const char **setname) +{ + if (name == NULL) + return 1156; + + if (regno < 0 || regno > 1155 || namelen < 7) + return -1; + + *prefix = NULL; + + if (regno < 32 || regno == 64 || regno == 66) + *setname = "integer"; + else if (regno < 64 || regno == 65) + *setname = "FPU"; + else if (regno < 1124) + *setname = "privileged"; + else + *setname = "vector"; + + switch (regno) + { + case 0 ... 9: + name[0] = 'r'; + name[1] = regno + '0'; + namelen = 2; + break; + + case 10 ... 31: + name[0] = 'r'; + name[1] = regno / 10 + '0'; + name[2] = regno % 10 + '0'; + namelen = 3; + break; + + case 32 + 0 ... 32 + 9: + name[0] = 'f'; + name[1] = (regno - 32) + '0'; + namelen = 2; + break; + + case 32 + 10 ... 32 + 31: + name[0] = 'f'; + name[1] = (regno - 32) / 10 + '0'; + name[2] = (regno - 32) % 10 + '0'; + namelen = 3; + break; + + case 64: + return stpcpy (name, "cr") - name; + case 65: + return stpcpy (name, "fpscr") - name; + case 66: + return stpcpy (name, "msr") - name; + + case 70 + 0 ... 70 + 9: + name[0] = 's'; + name[1] = 'r'; + name[2] = (regno - 70) + '0'; + namelen = 3; + break; + + case 70 + 10 ... 70 + 15: + name[0] = 's'; + name[1] = 'r'; + name[2] = (regno - 70) / 10 + '0'; + name[3] = (regno - 70) % 10 + '0'; + namelen = 4; + break; + + case 100 ... 109: + name[0] = 's'; + name[1] = 'p'; + name[2] = 'r'; + name[3] = (regno - 100) + '0'; + namelen = 4; + break; + + case 110 ... 199: + name[0] = 's'; + name[1] = 'p'; + name[2] = 'r'; + name[3] = (regno - 100) / 10 + '0'; + name[4] = (regno - 100) % 10 + '0'; + namelen = 5; + break; + + case 200 ... 999: + name[0] = 's'; + name[1] = 'p'; + name[2] = 'r'; + name[3] = (regno - 100) / 100 + '0'; + name[4] = ((regno - 100) % 100 / 10) + '0'; + name[5] = (regno - 100) % 10 + '0'; + namelen = 6; + break; + + case 1124 + 0 ... 1124 + 9: + name[0] = 'v'; + name[1] = 'r'; + name[2] = (regno - 1124) + '0'; + namelen = 3; + break; + + case 1124 + 10 ... 1124 + 31: + name[0] = 'v'; + name[1] = 'r'; + name[2] = (regno - 1124) / 10 + '0'; + name[3] = (regno - 1124) % 10 + '0'; + namelen = 4; + break; + + default: + *setname = NULL; + return 0; + } + + name[namelen++] = '\0'; + return namelen; +} + +__typeof (ppc_register_name) + ppc64_register_name __attribute__ ((alias ("ppc_register_name"))); diff --git a/elfutils/backends/ppc_reloc.def b/elfutils/backends/ppc_reloc.def new file mode 100644 index 00000000..974c24fc --- /dev/null +++ b/elfutils/backends/ppc_reloc.def @@ -0,0 +1,134 @@ +/* List the relocation types for ppc. -*- C -*- + Copyright (C) 2005 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. + + 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>. */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (ADDR32, REL|EXEC|DYN) +RELOC_TYPE (ADDR24, REL) +RELOC_TYPE (ADDR16, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (ADDR16_LO, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (ADDR16_HI, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (ADDR16_HA, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (ADDR14, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (ADDR14_BRTAKEN, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (ADDR14_BRNTAKEN, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (REL24, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (REL14, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (REL14_BRTAKEN, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (REL14_BRNTAKEN, REL|EXEC|DYN) /* note 1 */ +RELOC_TYPE (GOT16, REL) +RELOC_TYPE (GOT16_LO, REL) +RELOC_TYPE (GOT16_HI, REL) +RELOC_TYPE (GOT16_HA, REL) +RELOC_TYPE (PLTREL24, REL) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (LOCAL24PC, REL) +RELOC_TYPE (UADDR32, REL|EXEC|DYN) +RELOC_TYPE (UADDR16, REL) /* note 2 */ +RELOC_TYPE (REL32, REL|EXEC|DYN) +RELOC_TYPE (PLT32, REL) +RELOC_TYPE (PLTREL32, REL) +RELOC_TYPE (PLT16_LO, REL) +RELOC_TYPE (PLT16_HI, REL) +RELOC_TYPE (PLT16_HA, REL) +RELOC_TYPE (SDAREL16, REL) +RELOC_TYPE (SECTOFF, REL) +RELOC_TYPE (SECTOFF_LO, REL) +RELOC_TYPE (SECTOFF_HI, REL) +RELOC_TYPE (SECTOFF_HA, REL) +RELOC_TYPE (TLS, REL) +RELOC_TYPE (DTPMOD32, EXEC|DYN) /* note 2 */ +RELOC_TYPE (TPREL16, REL) /* note 2 */ +RELOC_TYPE (TPREL16_LO, REL) /* note 2 */ +RELOC_TYPE (TPREL16_HI, REL) /* note 2 */ +RELOC_TYPE (TPREL16_HA, REL) /* note 2 */ +RELOC_TYPE (TPREL32, EXEC|DYN) /* note 2 */ +RELOC_TYPE (DTPREL16, REL) +RELOC_TYPE (DTPREL16_LO, REL) +RELOC_TYPE (DTPREL16_HI, REL) +RELOC_TYPE (DTPREL16_HA, REL) +RELOC_TYPE (DTPREL32, EXEC|DYN) /* note 2 */ +RELOC_TYPE (GOT_TLSGD16, REL) +RELOC_TYPE (GOT_TLSGD16_LO, REL) +RELOC_TYPE (GOT_TLSGD16_HI, REL) +RELOC_TYPE (GOT_TLSGD16_HA, REL) +RELOC_TYPE (GOT_TLSLD16, REL) +RELOC_TYPE (GOT_TLSLD16_LO, REL) +RELOC_TYPE (GOT_TLSLD16_HI, REL) +RELOC_TYPE (GOT_TLSLD16_HA, REL) +RELOC_TYPE (GOT_TPREL16, REL) +RELOC_TYPE (GOT_TPREL16_LO, REL) +RELOC_TYPE (GOT_TPREL16_HI, REL) +RELOC_TYPE (GOT_TPREL16_HA, REL) +RELOC_TYPE (GOT_DTPREL16, REL) +RELOC_TYPE (GOT_DTPREL16_LO, REL) +RELOC_TYPE (GOT_DTPREL16_HI, REL) +RELOC_TYPE (GOT_DTPREL16_HA, REL) +RELOC_TYPE (EMB_NADDR32, REL) /* note 3 */ +RELOC_TYPE (EMB_NADDR16, REL) /* note 3 */ +RELOC_TYPE (EMB_NADDR16_LO, REL) /* note 3 */ +RELOC_TYPE (EMB_NADDR16_HI, REL) /* note 3 */ +RELOC_TYPE (EMB_NADDR16_HA, REL) /* note 3 */ +RELOC_TYPE (EMB_SDAI16, REL) /* note 3 */ +RELOC_TYPE (EMB_SDA2I16, REL) /* note 3 */ +RELOC_TYPE (EMB_SDA2REL, REL) /* note 3 */ +RELOC_TYPE (EMB_SDA21, REL) /* note 3 */ +RELOC_TYPE (EMB_MRKREF, REL) /* note 3 */ +RELOC_TYPE (EMB_RELSEC16, REL) /* note 3 */ +RELOC_TYPE (EMB_RELST_LO, REL) /* note 3 */ +RELOC_TYPE (EMB_RELST_HI, REL) /* note 3 */ +RELOC_TYPE (EMB_RELST_HA, REL) /* note 3 */ +RELOC_TYPE (EMB_BIT_FLD, REL) /* note 3 */ +RELOC_TYPE (EMB_RELSDA, REL) /* note 3 */ +RELOC_TYPE (DIAB_SDA21_LO, REL) /* note 3 */ +RELOC_TYPE (DIAB_SDA21_HI, REL) /* note 3 */ +RELOC_TYPE (DIAB_SDA21_HA, REL) /* note 3 */ +RELOC_TYPE (DIAB_RELSDA_LO, REL) /* note 3 */ +RELOC_TYPE (DIAB_RELSDA_HI, REL) /* note 3 */ +RELOC_TYPE (DIAB_RELSDA_HA, REL) /* note 3 */ +RELOC_TYPE (REL16, REL) /* note 2 */ +RELOC_TYPE (REL16_LO, REL) /* note 2 */ +RELOC_TYPE (REL16_HI, REL) /* note 2 */ +RELOC_TYPE (REL16_HA, REL) /* note 2 */ +RELOC_TYPE (TOC16, REL) /* note 2 */ + +/* Notes from Alan Modra: + + 1) These relocs should not really appear in EXEC or DYN, but they do, + primarily due to improper assembly or non-pic shared objects. They + will cause TEXTREL to be set. I marked them in the table, because + numerous people seem to think non-pic shared libs are a good idea. + + 2) As for (1), these relocs can appear anywhere with improper + assembler. I should probably make ld reject anything other than the + cases allowed in this table. Not seen in the wild, so I haven't + added the other cases. + + 3) Not used in SYSV4 +*/ diff --git a/elfutils/backends/ppc_retval.c b/elfutils/backends/ppc_retval.c new file mode 100644 index 00000000..b8d86aca --- /dev/null +++ b/elfutils/backends/ppc_retval.c @@ -0,0 +1,159 @@ +/* Function return value location for Linux/PPC ABI. + Copyright (C) 2005, 2006 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. + + 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 <assert.h> +#include <dwarf.h> + +#define BACKEND ppc_ +#include "libebl_CPU.h" + + +/* This is the SVR4 ELF ABI convention, but AIX and Linux do not use it. */ +#define SVR4_STRUCT_RETURN 0 + + +/* r3, or pair r3, r4. */ +static const Dwarf_Op loc_intreg[] = + { + { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_reg4 }, { .atom = DW_OP_piece, .number = 4 }, + }; +#define nloc_intreg 1 +#define nloc_intregpair 4 + +/* f1. */ +static const Dwarf_Op loc_fpreg[] = + { + { .atom = DW_OP_regx, .number = 33 } + }; +#define nloc_fpreg 1 + +/* The return value is a structure and is actually stored in stack space + passed in a hidden argument by the caller. But, the compiler + helpfully returns the address of that space in r3. */ +static const Dwarf_Op loc_aggregate[] = + { + { .atom = DW_OP_breg3, .number = 0 } + }; +#define nloc_aggregate 1 + + +int +ppc_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + /* Start with the function's type, and get the DW_AT_type attribute, + which is the type of the return value. */ + + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = dwarf_attr (functypedie, DW_AT_type, &attr_mem); + if (attr == NULL) + /* The function has no return value, like a `void' function in C. */ + return 0; + + Dwarf_Die die_mem; + Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); + int tag = dwarf_tag (typedie); + + /* Follow typedefs and qualifiers to get to the actual type. */ + while (tag == DW_TAG_typedef + || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type + || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + + Dwarf_Word size; + switch (tag) + { + case -1: + return -1; + + case DW_TAG_subrange_type: + if (! dwarf_hasattr (typedie, DW_AT_byte_size)) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + /* Fall through. */ + + case DW_TAG_base_type: + case DW_TAG_enumeration_type: + case DW_TAG_pointer_type: + case DW_TAG_ptr_to_member_type: + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + { + if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + size = 4; + else + return -1; + } + if (size <= 8) + { + if (tag == DW_TAG_base_type) + { + Dwarf_Word encoding; + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_encoding, + &attr_mem), &encoding) != 0) + return -1; + if (encoding == DW_ATE_float) + { + *locp = loc_fpreg; + return nloc_fpreg; + } + } + intreg: + *locp = loc_intreg; + return size <= 4 ? nloc_intreg : nloc_intregpair; + } + + aggregate: + *locp = loc_aggregate; + return nloc_aggregate; + + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + case DW_TAG_array_type: + if (SVR4_STRUCT_RETURN + && dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, + &attr_mem), &size) == 0 + && size > 0 && size <= 8) + goto intreg; + goto aggregate; + } + + /* XXX We don't have a good way to return specific errors from ebl calls. + This value means we do not understand the type, but it is well-formed + DWARF and might be valid. */ + return -2; +} diff --git a/elfutils/backends/ppc_symbol.c b/elfutils/backends/ppc_symbol.c new file mode 100644 index 00000000..8a1950c0 --- /dev/null +++ b/elfutils/backends/ppc_symbol.c @@ -0,0 +1,155 @@ +/* PPC specific symbolic name handling. + Copyright (C) 2004, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2004. + + 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. + + 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 <assert.h> +#include <elf.h> +#include <stddef.h> +#include <string.h> + +#define BACKEND ppc_ +#include "libebl_CPU.h" + + +/* Check for the simple reloc types. */ +Elf_Type +ppc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_PPC_ADDR32: + case R_PPC_UADDR32: + return ELF_T_WORD; + case R_PPC_UADDR16: + return ELF_T_HALF; + default: + return ELF_T_NUM; + } +} + + +const char * +ppc_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + switch (tag) + { + case DT_PPC_GOT: + return "PPC_GOT"; + default: + break; + } + return NULL; +} + + +bool +ppc_dynamic_tag_check (int64_t tag) +{ + return tag == DT_PPC_GOT; +} + + +/* Look for DT_PPC_GOT. */ +static bool +find_dyn_got (Elf *elf, GElf_Ehdr *ehdr, GElf_Addr *addr) +{ + for (int i = 0; i < ehdr->e_phnum; ++i) + { + GElf_Phdr phdr_mem; + GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem); + if (phdr == NULL || phdr->p_type != PT_DYNAMIC) + continue; + + Elf_Scn *scn = gelf_offscn (elf, phdr->p_offset); + GElf_Shdr shdr_mem; + GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); + Elf_Data *data = elf_getdata (scn, NULL); + if (shdr != NULL && shdr->sh_type == SHT_DYNAMIC && data != NULL) + for (unsigned int j = 0; j < shdr->sh_size / shdr->sh_entsize; ++j) + { + GElf_Dyn dyn_mem; + GElf_Dyn *dyn = gelf_getdyn (data, j, &dyn_mem); + if (dyn != NULL && dyn->d_tag == DT_PPC_GOT) + { + *addr = dyn->d_un.d_ptr; + return true; + } + } + + /* There is only one PT_DYNAMIC entry. */ + break; + } + + return false; +} + + +/* Check whether given symbol's st_value and st_size are OK despite failing + normal checks. */ +bool +ppc_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr, const GElf_Sym *sym, + const char *name, const GElf_Shdr *destshdr) +{ + if (name == NULL) + return false; + + if (strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0) + { + GElf_Addr gotaddr; + if (find_dyn_got (elf, ehdr, &gotaddr)) + return sym->st_value == gotaddr; + return sym->st_value == destshdr->sh_addr + 4; + } + + const char *sname = elf_strptr (elf, ehdr->e_shstrndx, destshdr->sh_name); + if (sname == NULL) + return false; + + if (strcmp (name, "_SDA_BASE_") == 0) + return (strcmp (sname, ".sdata") == 0 + && sym->st_value == destshdr->sh_addr + 0x8000 + && sym->st_size == 0); + + if (strcmp (name, "_SDA2_BASE_") == 0) + return (strcmp (sname, ".sdata2") == 0 + && sym->st_value == destshdr->sh_addr + 0x8000 + && sym->st_size == 0); + + return false; +} + + +/* Check if backend uses a bss PLT in this file. */ +bool +ppc_bss_plt_p (Elf *elf, GElf_Ehdr *ehdr) +{ + GElf_Addr addr; + return ! find_dyn_got (elf, ehdr, &addr); +} diff --git a/elfutils/backends/s390_init.c b/elfutils/backends/s390_init.c new file mode 100644 index 00000000..64e5639b --- /dev/null +++ b/elfutils/backends/s390_init.c @@ -0,0 +1,57 @@ +/* Initialization of S/390 specific backend library. + Copyright (C) 2005, 2006 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. + + 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 + +#define BACKEND s390_ +#define RELOC_PREFIX R_390_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on arm_reloc.def. */ +#include "common-reloc.c" + + +const char * +s390_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + eh->name = "IBM S/390"; + s390_init_reloc (eh); + HOOK (eh, reloc_simple_type); + HOOK (eh, register_name); + HOOK (eh, return_value_location); + + return MODVERSION; +} diff --git a/elfutils/backends/s390_regs.c b/elfutils/backends/s390_regs.c new file mode 100644 index 00000000..61c60744 --- /dev/null +++ b/elfutils/backends/s390_regs.c @@ -0,0 +1,128 @@ +/* Register names and numbers for S/390 DWARF. + Copyright (C) 2006 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. + + 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> + +#define BACKEND s390_ +#include "libebl_CPU.h" + + +/* +zseries (64) + +0-15 gpr0-gpr15 x +16-19 fpr[0246] +20-24 fpr[13578] +25-27 fpr1[024] +28 fpr9 +29-31 fpr1[135] +32-47 cr0-cr15 x +48-63 ar0-ar15 x +64 psw_mask +65 psw_address +*/ + + +ssize_t +s390_register_name (Ebl *ebl __attribute__ ((unused)), + int regno, char *name, size_t namelen, + const char **prefix, const char **setname) +{ + if (name == NULL) + return 66; + + if (regno < 0 || regno > 65 || namelen < 7) + return -1; + + *prefix = "%"; + + if (regno < 16) + *setname = "integer"; + else if (regno < 32) + *setname = "FPU"; + else if (regno < 48 || regno > 63) + *setname = "control"; + else + *setname = "access"; + + switch (regno) + { + case 0 ... 9: + name[0] = 'r'; + name[1] = regno + '0'; + namelen = 2; + break; + + case 10 ... 15: + name[0] = 'r'; + name[1] = '1'; + name[2] = regno - 10 + '0'; + namelen = 3; + break; + + case 16 ... 31: + name[0] = 'f'; + regno = (regno & 8) | ((regno & 4) >> 2) | ((regno & 3) << 1); + namelen = 1; + if (regno >= 10) + { + regno -= 10; + name[namelen++] = '1'; + } + name[namelen++] = regno + '0'; + break; + + case 32 + 0 ... 32 + 9: + case 48 + 0 ... 48 + 9: + name[0] = regno < 48 ? 'c' : 'a'; + name[1] = (regno & 15) + '0'; + namelen = 2; + break; + + case 32 + 10 ... 32 + 15: + case 48 + 10 ... 48 + 15: + name[0] = regno < 48 ? 'c' : 'a'; + name[1] = '1'; + name[2] = (regno & 15) - 10 + '0'; + namelen = 3; + break; + + case 64: + return stpcpy (name, "pswm") - name; + case 65: + return stpcpy (name, "pswa") - name; + + default: + *setname = NULL; + return 0; + } + + name[namelen++] = '\0'; + return namelen; +} diff --git a/elfutils/backends/s390_reloc.def b/elfutils/backends/s390_reloc.def new file mode 100644 index 00000000..b2bc9224 --- /dev/null +++ b/elfutils/backends/s390_reloc.def @@ -0,0 +1,88 @@ +/* List the relocation types for s390. -*- C -*- + Copyright (C) 2005, 2006 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. + + 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>. */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (8, REL|EXEC|DYN) +RELOC_TYPE (12, REL|EXEC|DYN) +RELOC_TYPE (16, REL|EXEC|DYN) +RELOC_TYPE (32, REL|EXEC|DYN) +RELOC_TYPE (PC32, REL|EXEC|DYN) +RELOC_TYPE (GOT12, REL) +RELOC_TYPE (GOT32, REL) +RELOC_TYPE (PLT32, REL) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (GOTOFF32, REL) +RELOC_TYPE (GOTPC, REL) +RELOC_TYPE (GOT16, REL) +RELOC_TYPE (PC16, REL|EXEC|DYN) +RELOC_TYPE (PC16DBL, REL|EXEC|DYN) +RELOC_TYPE (PLT16DBL, REL) +RELOC_TYPE (PC32DBL, REL|EXEC|DYN) +RELOC_TYPE (PLT32DBL, REL) +RELOC_TYPE (GOTPCDBL, REL) +RELOC_TYPE (64, REL|EXEC|DYN) +RELOC_TYPE (PC64, REL|EXEC|DYN) +RELOC_TYPE (GOT64, REL) +RELOC_TYPE (PLT64, REL) +RELOC_TYPE (GOTENT, REL) +RELOC_TYPE (GOTOFF16, REL) +RELOC_TYPE (GOTOFF64, REL) +RELOC_TYPE (GOTPLT12, REL) +RELOC_TYPE (GOTPLT16, REL) +RELOC_TYPE (GOTPLT32, REL) +RELOC_TYPE (GOTPLT64, REL) +RELOC_TYPE (GOTPLTENT, REL) +RELOC_TYPE (PLTOFF16, REL) +RELOC_TYPE (PLTOFF32, REL) +RELOC_TYPE (PLTOFF64, REL) +RELOC_TYPE (TLS_LOAD, REL) +RELOC_TYPE (TLS_GDCALL, REL) +RELOC_TYPE (TLS_LDCALL, REL) +RELOC_TYPE (TLS_GD32, REL) +RELOC_TYPE (TLS_GD64, REL) +RELOC_TYPE (TLS_GOTIE12, REL) +RELOC_TYPE (TLS_GOTIE32, REL) +RELOC_TYPE (TLS_GOTIE64, REL) +RELOC_TYPE (TLS_LDM32, REL) +RELOC_TYPE (TLS_LDM64, REL) +RELOC_TYPE (TLS_IE32, REL) +RELOC_TYPE (TLS_IE64, REL) +RELOC_TYPE (TLS_IEENT, REL) +RELOC_TYPE (TLS_LE32, REL) +RELOC_TYPE (TLS_LE64, REL) +RELOC_TYPE (TLS_LDO32, REL) +RELOC_TYPE (TLS_LDO64, REL) +RELOC_TYPE (TLS_DTPMOD, DYN) +RELOC_TYPE (TLS_DTPOFF, DYN) +RELOC_TYPE (TLS_TPOFF, DYN) +RELOC_TYPE (20, REL|EXEC|DYN) +RELOC_TYPE (GOT20, REL) +RELOC_TYPE (GOTPLT20, REL) +RELOC_TYPE (TLS_GOTIE20, REL) diff --git a/elfutils/backends/s390_retval.c b/elfutils/backends/s390_retval.c new file mode 100644 index 00000000..6c430828 --- /dev/null +++ b/elfutils/backends/s390_retval.c @@ -0,0 +1,154 @@ +/* Function return value location for S/390 ABI. + Copyright (C) 2006 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. + + 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 <assert.h> +#include <dwarf.h> + +#define BACKEND s390_ +#include "libebl_CPU.h" + + +/* %r2, or pair %r2, %r3. */ +static const Dwarf_Op loc_intreg[] = + { + { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 4 }, + { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 4 }, + }; +#define nloc_intreg 1 +#define nloc_intregpair 4 + +/* %f0. */ +static const Dwarf_Op loc_fpreg[] = + { + { .atom = DW_OP_reg16 }, + }; +#define nloc_fpreg 1 + +/* The return value is a structure and is actually stored in stack space + passed in a hidden argument by the caller. But, the compiler + helpfully returns the address of that space in %r2. */ +static const Dwarf_Op loc_aggregate[] = + { + { .atom = DW_OP_breg2, .number = 0 } + }; +#define nloc_aggregate 1 + + +int +s390_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + /* Start with the function's type, and get the DW_AT_type attribute, + which is the type of the return value. */ + + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = dwarf_attr (functypedie, DW_AT_type, &attr_mem); + if (attr == NULL) + /* The function has no return value, like a `void' function in C. */ + return 0; + + Dwarf_Die die_mem; + Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); + int tag = dwarf_tag (typedie); + + /* Follow typedefs and qualifiers to get to the actual type. */ + while (tag == DW_TAG_typedef + || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type + || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + + Dwarf_Word size; + switch (tag) + { + case -1: + return -1; + + case DW_TAG_subrange_type: + if (! dwarf_hasattr (typedie, DW_AT_byte_size)) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + /* Fall through. */ + + case DW_TAG_base_type: + case DW_TAG_enumeration_type: + case DW_TAG_pointer_type: + case DW_TAG_ptr_to_member_type: + { + Dwarf_Die cudie; + uint8_t asize; + if (dwarf_diecu (typedie, &cudie, &asize, NULL) == NULL) + return -1; + + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + { + if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + size = asize; + else + return -1; + } + if (tag == DW_TAG_base_type) + { + Dwarf_Word encoding; + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_encoding, + &attr_mem), &encoding) != 0) + return -1; + if (encoding == DW_ATE_float && size <= 8) + { + *locp = loc_fpreg; + return nloc_fpreg; + } + } + if (size <= 8) + { + *locp = loc_intreg; + return size <= asize ? nloc_intreg : nloc_intregpair; + } + } + /* Fall through. */ + + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + case DW_TAG_array_type: + *locp = loc_aggregate; + return nloc_aggregate; + } + + /* XXX We don't have a good way to return specific errors from ebl calls. + This value means we do not understand the type, but it is well-formed + DWARF and might be valid. */ + return -2; +} diff --git a/elfutils/backends/s390_symbol.c b/elfutils/backends/s390_symbol.c new file mode 100644 index 00000000..98c76530 --- /dev/null +++ b/elfutils/backends/s390_symbol.c @@ -0,0 +1,53 @@ +/* S/390-specific symbolic name handling. + Copyright (C) 2005 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. + + 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 <elf.h> +#include <stddef.h> + +#define BACKEND s390_ +#include "libebl_CPU.h" + +/* Check for the simple reloc types. */ +Elf_Type +s390_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_390_64: + return ELF_T_SXWORD; + case R_390_32: + return ELF_T_SWORD; + case R_390_16: + return ELF_T_HALF; + case R_390_8: + return ELF_T_BYTE; + default: + return ELF_T_NUM; + } +} diff --git a/elfutils/backends/sh_init.c b/elfutils/backends/sh_init.c new file mode 100644 index 00000000..02502ab2 --- /dev/null +++ b/elfutils/backends/sh_init.c @@ -0,0 +1,56 @@ +/* Initialization of SH specific backend library. + Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2000. + + 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. + + 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 + +#define BACKEND sh_ +#define RELOC_PREFIX R_SH_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on sh_reloc.def. */ +#include "common-reloc.c" + + +const char * +sh_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + eh->name = "Hitachi SH"; + sh_init_reloc (eh); + HOOK (eh, reloc_simple_type); + + return MODVERSION; +} diff --git a/elfutils/backends/sh_reloc.def b/elfutils/backends/sh_reloc.def new file mode 100644 index 00000000..e4f24427 --- /dev/null +++ b/elfutils/backends/sh_reloc.def @@ -0,0 +1,64 @@ +/* List the relocation types for SH. -*- C -*- + Copyright (C) 2005 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. + + 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>. */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (DIR32, REL|DYN) +RELOC_TYPE (REL32, REL|DYN) +RELOC_TYPE (DIR8WPN, REL) +RELOC_TYPE (IND12W, REL) +RELOC_TYPE (DIR8WPL, REL) +RELOC_TYPE (DIR8WPZ, REL) +RELOC_TYPE (DIR8BP, REL) +RELOC_TYPE (DIR8W, REL) +RELOC_TYPE (DIR8L, REL) +RELOC_TYPE (SWITCH16, REL) +RELOC_TYPE (SWITCH32, REL) +RELOC_TYPE (USES, REL) +RELOC_TYPE (COUNT, REL) +RELOC_TYPE (ALIGN, REL) +RELOC_TYPE (CODE, REL) +RELOC_TYPE (DATA, REL) +RELOC_TYPE (LABEL, REL) +RELOC_TYPE (SWITCH8, REL) +RELOC_TYPE (GNU_VTINHERIT, REL) +RELOC_TYPE (GNU_VTENTRY, REL) +RELOC_TYPE (TLS_GD_32, REL) +RELOC_TYPE (TLS_LD_32, REL) +RELOC_TYPE (TLS_LDO_32, REL) +RELOC_TYPE (TLS_IE_32, REL) +RELOC_TYPE (TLS_LE_32, REL) +RELOC_TYPE (TLS_DTPMOD32, DYN) +RELOC_TYPE (TLS_DTPOFF32, DYN) +RELOC_TYPE (TLS_TPOFF32, DYN) +RELOC_TYPE (GOT32, REL) +RELOC_TYPE (PLT32, REL) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (GOTOFF, REL) +RELOC_TYPE (GOTPC, REL) diff --git a/elfutils/backends/sh_symbol.c b/elfutils/backends/sh_symbol.c new file mode 100644 index 00000000..26000ccb --- /dev/null +++ b/elfutils/backends/sh_symbol.c @@ -0,0 +1,56 @@ +/* SH specific relocation handling. + Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2000. + + 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. + + 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 <elf.h> +#include <stddef.h> + +#define BACKEND sh_ +#include "libebl_CPU.h" + + +/* Return true if the symbol type is that referencing the GOT. */ +bool +sh_gotpc_reloc_check (Elf *elf __attribute__ ((unused)), int type) +{ + return type == R_SH_GOTPC; +} + +/* Check for the simple reloc types. */ +Elf_Type +sh_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_SH_DIR32: + return ELF_T_WORD; + default: + return ELF_T_NUM; + } +} diff --git a/elfutils/backends/sparc_init.c b/elfutils/backends/sparc_init.c new file mode 100644 index 00000000..3767c1a8 --- /dev/null +++ b/elfutils/backends/sparc_init.c @@ -0,0 +1,62 @@ +/* Initialization of SPARC specific backend library. + Copyright (C) 2002, 2005 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. + + 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 + +#define BACKEND sparc_ +#define RELOC_PREFIX R_SPARC_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on sparc_reloc.def. */ +#include "common-reloc.c" + + +const char * +sparc_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + if (machine == EM_SPARCV9) + eh->name = "SPARC v9"; + else if (machine == EM_SPARC32PLUS) + eh->name = "SPARC v8+"; + else + eh->name = "SPARC"; + sparc_init_reloc (eh); + HOOK (eh, reloc_simple_type); + //HOOK (eh, core_note); + HOOK (eh, register_name); + + return MODVERSION; +} diff --git a/elfutils/backends/sparc_regs.c b/elfutils/backends/sparc_regs.c new file mode 100644 index 00000000..8ee2a0cb --- /dev/null +++ b/elfutils/backends/sparc_regs.c @@ -0,0 +1,76 @@ +/* Register names and numbers for SPARC DWARF. + Copyright (C) 2005 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. + + 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> + +#define BACKEND sparc_ +#include "libebl_CPU.h" + +ssize_t +sparc_register_name (Ebl *ebl, + int regno, char *name, size_t namelen, + const char **prefix, const char **setname) +{ + const int nfp = ebl->machine == EM_SPARCV9 ? 64 : 32; + + if (name == NULL) + return 32 + nfp; + + if (regno < 0 || regno >= 32 + nfp || namelen < 4) + return -1; + + *prefix = "%"; + + if (regno < 32) + { + *setname = "integer"; + name[0] = "goli"[regno >> 3]; + name[1] = (regno & 7) + '0'; + namelen = 2; + } + else + { + *setname = "FPU"; + name[0] = 'f'; + if (regno < 32 + 10) + { + name[1] = (regno - 32) + '0'; + namelen = 2; + } + else + { + name[1] = (regno - 32) / 10 + '0'; + name[2] = (regno - 32) % 10 + '0'; + namelen = 3; + } + } + + name[namelen++] = '\0'; + return namelen; +} diff --git a/elfutils/backends/sparc_reloc.def b/elfutils/backends/sparc_reloc.def new file mode 100644 index 00000000..de650974 --- /dev/null +++ b/elfutils/backends/sparc_reloc.def @@ -0,0 +1,106 @@ +/* List the relocation types for sparc. -*- C -*- + Copyright (C) 2005 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. + + 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>. */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (8, 0) +RELOC_TYPE (16, 0) +RELOC_TYPE (32, 0) +RELOC_TYPE (DISP8, 0) +RELOC_TYPE (DISP16, 0) +RELOC_TYPE (DISP32, 0) +RELOC_TYPE (WDISP30, 0) +RELOC_TYPE (WDISP22, 0) +RELOC_TYPE (HI22, 0) +RELOC_TYPE (22, 0) +RELOC_TYPE (13, 0) +RELOC_TYPE (LO10, 0) +RELOC_TYPE (GOT10, 0) +RELOC_TYPE (GOT13, 0) +RELOC_TYPE (GOT22, 0) +RELOC_TYPE (PC10, 0) +RELOC_TYPE (PC22, 0) +RELOC_TYPE (WPLT30, 0) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (UA32, 0) +RELOC_TYPE (PLT32, 0) +RELOC_TYPE (HIPLT22, 0) +RELOC_TYPE (LOPLT10, 0) +RELOC_TYPE (PCPLT32, 0) +RELOC_TYPE (PCPLT22, 0) +RELOC_TYPE (PCPLT10, 0) +RELOC_TYPE (10, 0) +RELOC_TYPE (11, 0) +RELOC_TYPE (64, 0) +RELOC_TYPE (OLO10, 0) +RELOC_TYPE (HH22, 0) +RELOC_TYPE (HM10, 0) +RELOC_TYPE (LM22, 0) +RELOC_TYPE (PC_HH22, 0) +RELOC_TYPE (PC_HM10, 0) +RELOC_TYPE (PC_LM22, 0) +RELOC_TYPE (WDISP16, 0) +RELOC_TYPE (WDISP19, 0) +RELOC_TYPE (7, 0) +RELOC_TYPE (5, 0) +RELOC_TYPE (6, 0) +RELOC_TYPE (DISP64, 0) +RELOC_TYPE (PLT64, 0) +RELOC_TYPE (HIX22, 0) +RELOC_TYPE (LOX10, 0) +RELOC_TYPE (H44, 0) +RELOC_TYPE (M44, 0) +RELOC_TYPE (L44, 0) +RELOC_TYPE (REGISTER, 0) +RELOC_TYPE (UA64, 0) +RELOC_TYPE (UA16, 0) +RELOC_TYPE (TLS_GD_HI22, 0) +RELOC_TYPE (TLS_GD_LO10, 0) +RELOC_TYPE (TLS_GD_ADD, 0) +RELOC_TYPE (TLS_GD_CALL, 0) +RELOC_TYPE (TLS_LDM_HI22, 0) +RELOC_TYPE (TLS_LDM_LO10, 0) +RELOC_TYPE (TLS_LDM_ADD, 0) +RELOC_TYPE (TLS_LDM_CALL, 0) +RELOC_TYPE (TLS_LDO_HIX22, 0) +RELOC_TYPE (TLS_LDO_LOX10, 0) +RELOC_TYPE (TLS_LDO_ADD, 0) +RELOC_TYPE (TLS_IE_HI22, 0) +RELOC_TYPE (TLS_IE_LO10, 0) +RELOC_TYPE (TLS_IE_LD, 0) +RELOC_TYPE (TLS_IE_LDX, 0) +RELOC_TYPE (TLS_IE_ADD, 0) +RELOC_TYPE (TLS_LE_HIX22, 0) +RELOC_TYPE (TLS_LE_LOX10, 0) +RELOC_TYPE (TLS_DTPMOD32, 0) +RELOC_TYPE (TLS_DTPMOD64, 0) +RELOC_TYPE (TLS_DTPOFF32, 0) +RELOC_TYPE (TLS_DTPOFF64, 0) +RELOC_TYPE (TLS_TPOFF32, 0) +RELOC_TYPE (TLS_TPOFF64, 0) diff --git a/elfutils/backends/sparc_symbol.c b/elfutils/backends/sparc_symbol.c new file mode 100644 index 00000000..3a261a00 --- /dev/null +++ b/elfutils/backends/sparc_symbol.c @@ -0,0 +1,57 @@ +/* SPARC specific symbolic name handling. + Copyright (C) 2002, 2003, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Jakub Jelinek <jakub@redhat.com>, 2002. + + 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. + + 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 <elf.h> +#include <stddef.h> + +#define BACKEND sparc_ +#include "libebl_CPU.h" + +/* Check for the simple reloc types. */ +Elf_Type +sparc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_SPARC_8: + return ELF_T_BYTE; + case R_SPARC_16: + case R_SPARC_UA16: + return ELF_T_HALF; + case R_SPARC_32: + case R_SPARC_UA32: + return ELF_T_WORD; + case R_SPARC_64: + case R_SPARC_UA64: + return ELF_T_XWORD; + default: + return ELF_T_NUM; + } +} diff --git a/elfutils/backends/x86_64_corenote.c b/elfutils/backends/x86_64_corenote.c new file mode 100644 index 00000000..1a37c07b --- /dev/null +++ b/elfutils/backends/x86_64_corenote.c @@ -0,0 +1,184 @@ +/* x86-64 specific core note handling. + Copyright (C) 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2005. + + 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. + + 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 <elf.h> +#include <inttypes.h> +#include <stddef.h> +#include <stdio.h> +#include <sys/time.h> + +#define BACKEND x86_64_ +#include "libebl_CPU.h" + + +/* We cannot include <sys/procfs.h> since the definition would be for + the host platform and not always x86-64 as required here. */ +struct elf_prstatus + { + struct + { + int32_t si_signo; /* Signal number. */ + int32_t si_code; /* Extra code. */ + int32_t si_errno; /* Errno. */ + } pr_info; /* Info associated with signal. */ + int16_t pr_cursig; /* Current signal. */ + uint64_t pr_sigpend; /* Set of pending signals. */ + uint64_t pr_sighold; /* Set of held signals. */ + int32_t pr_pid; + int32_t pr_ppid; + int32_t pr_pgrp; + int32_t pr_sid; + struct x86_64_timeval + { + int64_t tv_sec; + int32_t tv_usec; + } pr_utime; /* User time. */ + struct x86_64_timeval pr_stime; /* System time. */ + struct x86_64_timeval pr_cutime; /* Cumulative user time. */ + struct x86_64_timeval pr_cstime; /* Cumulative system time. */ + uint64_t pr_reg[27]; /* GP registers. */ + int32_t pr_fpvalid; /* True if math copro being used. */ + }; + + +struct elf_prpsinfo + { + char pr_state; /* Numeric process state. */ + char pr_sname; /* Char for pr_state. */ + char pr_zomb; /* Zombie. */ + char pr_nice; /* Nice val. */ + uint64_t pr_flag; /* Flags. */ + uint32_t pr_uid; + uint32_t pr_gid; + int32_t pr_pid; + int32_t pr_ppid; + int32_t pr_pgrp; + int32_t pr_sid; + /* Lots missing */ + char pr_fname[16]; /* Filename of executable. */ + char pr_psargs[80]; /* Initial part of arg list. */ + }; + + +bool +x86_64_core_note (name, type, descsz, desc) + const char *name __attribute__ ((unused)); + uint32_t type; + uint32_t descsz; + const char *desc; +{ + bool result = false; + + switch (type) + { + case NT_PRSTATUS: + if (descsz < sizeof (struct elf_prstatus)) + /* Not enough data. */ + break; + + struct elf_prstatus *stat = (struct elf_prstatus *) desc; + + printf (" SIGINFO: signo: %" PRId32 ", code = %" PRId32 + ", errno = %" PRId32 "\n" + " signal: %" PRId16 ", pending: %#08" PRIx64 ", holding: %#08" + PRIx64 "\n" + " pid: %" PRId32 ", ppid = %" PRId32 ", pgrp = %" PRId32 + ", sid = %" PRId32 "\n" + " utime: %6" PRId64 ".%06" PRId32 + "s, stime: %6" PRId64 ".%06" PRId32 "s\n" + " cutime: %6" PRId64 ".%06" PRId32 + "s, cstime: %6" PRId64 ".%06" PRId32 "s\n" + " rax: %016" PRIx64 " rbx: %016" PRIx64 "\n" + " rcx: %016" PRIx64 " rdx: %016" PRIx64 "\n" + " rsi: %016" PRIx64 " rdi: %016" PRIx64 "\n" + " rbp: %016" PRIx64 " rsp: %016" PRIx64 "\n" + " r8: %016" PRIx64 " r9: %016" PRIx64 "\n" + " r10: %016" PRIx64 " r11: %016" PRIx64 "\n" + " r12: %016" PRIx64 " r13: %016" PRIx64 "\n" + " r14: %016" PRIx64 " r15: %016" PRIx64 "\n" + " rip: %016" PRIx64 " eflags: %08" PRIx64 "\n" + " original rax: %016" PRIx64 "\n" + " cs: %04" PRIx64 " ds: %04" PRIx64 " es: %04" PRIx64 + " ss: %04" PRIx64 "\n" + " fs: %04" PRIx64 " fs_base: %016" PRIx64 + " gs: %04" PRIx64 " gs_base: %016" PRIx64 "\n\n", + stat->pr_info. si_signo, + stat->pr_info. si_code, + stat->pr_info. si_errno, + stat->pr_cursig, + stat->pr_sigpend, stat->pr_sighold, + stat->pr_pid, stat->pr_ppid, stat->pr_pgrp, stat->pr_sid, + stat->pr_utime.tv_sec, stat->pr_utime.tv_usec, + stat->pr_stime.tv_sec, stat->pr_stime.tv_usec, + stat->pr_cutime.tv_sec, stat->pr_cutime.tv_usec, + stat->pr_cstime.tv_sec, stat->pr_cstime.tv_usec, + stat->pr_reg[10], stat->pr_reg[5], stat->pr_reg[11], + stat->pr_reg[12], stat->pr_reg[13], stat->pr_reg[14], + stat->pr_reg[4], stat->pr_reg[10], stat->pr_reg[9], + stat->pr_reg[7], stat->pr_reg[6], stat->pr_reg[5], + stat->pr_reg[3], stat->pr_reg[2], stat->pr_reg[1], + stat->pr_reg[0], stat->pr_reg[16], stat->pr_reg[18], + stat->pr_reg[15], stat->pr_reg[17], stat->pr_reg[23], + stat->pr_reg[24], stat->pr_reg[20], + stat->pr_reg[25], stat->pr_reg[21], + stat->pr_reg[26], stat->pr_reg[22]); + + /* We handled this entry. */ + result = true; + break; + + case NT_PRPSINFO: + if (descsz < sizeof (struct elf_prpsinfo)) + /* Not enough data. */ + break; + + struct elf_prpsinfo *info = (struct elf_prpsinfo *) desc; + + printf (" state: %c (%hhd), zombie: %hhd, nice: %hhd\n" + " flags: %08" PRIx64 " uid: %" PRIu32 " gid: %" PRIu32 "\n" + " pid: %" PRId32 " ppid: %" PRId32 " pgrp: %" PRId32 + " sid: %" PRId32 "\n" + " fname: %.16s\n" + " args: %.80s\n\n", + info->pr_sname, info->pr_state, info->pr_zomb, info->pr_nice, + info->pr_flag, info->pr_uid, info->pr_gid, + info->pr_pid, info->pr_ppid, info->pr_pgrp, info->pr_sid, + info->pr_fname, info->pr_psargs); + + /* We handled this entry. */ + result = true; + break; + + default: + break; + } + + return result; +} diff --git a/elfutils/backends/x86_64_init.c b/elfutils/backends/x86_64_init.c new file mode 100644 index 00000000..4951e1c7 --- /dev/null +++ b/elfutils/backends/x86_64_init.c @@ -0,0 +1,60 @@ +/* Initialization of x86-64 specific backend library. + Copyright (C) 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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. + + 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 + +#define BACKEND x86_64_ +#define RELOC_PREFIX R_X86_64_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on x86_64_reloc.def. */ +#include "common-reloc.c" + + + +const char * +x86_64_init (elf, machine, eh, ehlen) + Elf *elf __attribute__ ((unused)); + GElf_Half machine __attribute__ ((unused)); + Ebl *eh; + size_t ehlen; +{ + /* Check whether the Elf_BH object has a sufficent size. */ + if (ehlen < sizeof (Ebl)) + return NULL; + + /* We handle it. */ + eh->name = "AMD x86-64"; + x86_64_init_reloc (eh); + HOOK (eh, reloc_simple_type); + HOOK (eh, core_note); + HOOK (eh, return_value_location); + HOOK (eh, register_name); + + return MODVERSION; +} diff --git a/elfutils/backends/x86_64_regs.c b/elfutils/backends/x86_64_regs.c new file mode 100644 index 00000000..45ef94ea --- /dev/null +++ b/elfutils/backends/x86_64_regs.c @@ -0,0 +1,125 @@ +/* Register names and numbers for x86-64 DWARF. + Copyright (C) 2005 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. + + 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 <assert.h> +#include <dwarf.h> + +#define BACKEND x86_64_ +#include "libebl_CPU.h" + +ssize_t +x86_64_register_name (Ebl *ebl __attribute__ ((unused)), + int regno, char *name, size_t namelen, + const char **prefix, const char **setname) +{ + if (name == NULL) + return 49; + + if (regno < 0 || regno > 48 || namelen < 6) + return -1; + + *prefix = "%"; + if (regno < 17) + *setname = "integer"; + else if (regno < 33) + *setname = "SSE"; + else if (regno < 41) + *setname = "x87"; + else + *setname = "MMX"; + + switch (regno) + { + static const char baseregs[][2] = + { + "ax", "dx", "cx", "bx", "si", "di", "bp", "sp" + }; + + case 0 ... 7: + name[0] = 'r'; + name[1] = baseregs[regno][0]; + name[2] = baseregs[regno][1]; + namelen = 3; + break; + + case 8 ... 9: + name[0] = 'r'; + name[1] = regno - 8 + '8'; + namelen = 2; + break; + + case 10 ... 15: + name[0] = 'r'; + name[1] = '1'; + name[2] = regno - 10 + '0'; + namelen = 3; + break; + + case 16: + name[0] = 'r'; + name[1] = 'i'; + name[2] = 'p'; + namelen = 3; + break; + + case 17 ... 26: + name[0] = 'x'; + name[1] = 'm'; + name[2] = 'm'; + name[3] = regno - 17 + '0'; + namelen = 4; + break; + + case 27 ... 32: + name[0] = 'x'; + name[1] = 'm'; + name[2] = 'm'; + name[3] = '1'; + name[4] = regno - 27 + '0'; + namelen = 5; + break; + + case 33 ... 40: + name[0] = 's'; + name[1] = 't'; + name[2] = regno - 33 + '0'; + namelen = 3; + break; + + case 41 ... 48: + name[0] = 'm'; + name[1] = 'm'; + name[2] = regno - 41 + '0'; + namelen = 3; + break; + } + + name[namelen++] = '\0'; + return namelen; +} diff --git a/elfutils/backends/x86_64_reloc.def b/elfutils/backends/x86_64_reloc.def new file mode 100644 index 00000000..e6c5a84b --- /dev/null +++ b/elfutils/backends/x86_64_reloc.def @@ -0,0 +1,51 @@ +/* List the relocation types for x86-64. -*- C -*- + Copyright (C) 2000, 2001, 2002, 2003, 2005 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. + + 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>. */ + +/* NAME, REL|EXEC|DYN */ + +RELOC_TYPE (NONE, 0) +RELOC_TYPE (64, REL|EXEC|DYN) +RELOC_TYPE (PC32, REL|EXEC|DYN) +RELOC_TYPE (GOT32, REL) +RELOC_TYPE (PLT32, REL) +RELOC_TYPE (COPY, EXEC) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JUMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (GOTPCREL, REL) +RELOC_TYPE (32, REL|EXEC|DYN) +RELOC_TYPE (32S, REL) +RELOC_TYPE (16, REL) +RELOC_TYPE (PC16, REL) +RELOC_TYPE (8, REL) +RELOC_TYPE (PC8, REL) +RELOC_TYPE (DTPMOD64, EXEC|DYN) +RELOC_TYPE (DTPOFF64, EXEC|DYN) +RELOC_TYPE (TPOFF64, EXEC|DYN) +RELOC_TYPE (TLSGD, REL) +RELOC_TYPE (TLSLD, REL) +RELOC_TYPE (DTPOFF32, REL) +RELOC_TYPE (GOTTPOFF, REL) +RELOC_TYPE (TPOFF32, REL) diff --git a/elfutils/backends/x86_64_retval.c b/elfutils/backends/x86_64_retval.c new file mode 100644 index 00000000..1920abf9 --- /dev/null +++ b/elfutils/backends/x86_64_retval.c @@ -0,0 +1,201 @@ +/* Function return value location for Linux/x86-64 ABI. + Copyright (C) 2005 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. + + 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 <assert.h> +#include <dwarf.h> + +#define BACKEND x86_64_ +#include "libebl_CPU.h" + + +/* %rax, or pair %rax, %rdx. */ +static const Dwarf_Op loc_intreg[] = + { + { .atom = DW_OP_reg0 }, { .atom = DW_OP_piece, .number = 8 }, + { .atom = DW_OP_reg1 }, { .atom = DW_OP_piece, .number = 8 }, + }; +#define nloc_intreg 1 +#define nloc_intregpair 4 + +/* %st(0), or pair %st(0), %st(1). */ +static const Dwarf_Op loc_x87reg[] = + { + { .atom = DW_OP_regx, .number = 33 }, + { .atom = DW_OP_piece, .number = 10 }, + { .atom = DW_OP_regx, .number = 34 }, + { .atom = DW_OP_piece, .number = 10 }, + }; +#define nloc_x87reg 1 +#define nloc_x87regpair 4 + +/* %xmm0, or pair %xmm0, %xmm1. */ +static const Dwarf_Op loc_ssereg[] = + { + { .atom = DW_OP_reg17 }, { .atom = DW_OP_piece, .number = 16 }, + { .atom = DW_OP_reg18 }, { .atom = DW_OP_piece, .number = 16 }, + }; +#define nloc_ssereg 1 +#define nloc_sseregpair 4 + +/* The return value is a structure and is actually stored in stack space + passed in a hidden argument by the caller. But, the compiler + helpfully returns the address of that space in %rax. */ +static const Dwarf_Op loc_aggregate[] = + { + { .atom = DW_OP_breg0, .number = 0 } + }; +#define nloc_aggregate 1 + + +int +x86_64_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) +{ + /* Start with the function's type, and get the DW_AT_type attribute, + which is the type of the return value. */ + + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = dwarf_attr (functypedie, DW_AT_type, &attr_mem); + if (attr == NULL) + /* The function has no return value, like a `void' function in C. */ + return 0; + + Dwarf_Die die_mem; + Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem); + int tag = dwarf_tag (typedie); + + /* Follow typedefs and qualifiers to get to the actual type. */ + while (tag == DW_TAG_typedef + || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type + || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + + Dwarf_Word size; + switch (tag) + { + case -1: + return -1; + + case DW_TAG_subrange_type: + if (! dwarf_hasattr (typedie, DW_AT_byte_size)) + { + attr = dwarf_attr (typedie, DW_AT_type, &attr_mem); + typedie = dwarf_formref_die (attr, &die_mem); + tag = dwarf_tag (typedie); + } + /* Fall through. */ + + case DW_TAG_base_type: + case DW_TAG_enumeration_type: + case DW_TAG_pointer_type: + case DW_TAG_ptr_to_member_type: + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + { + if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) + size = 8; + else + return -1; + } + if (tag == DW_TAG_base_type) + { + Dwarf_Word encoding; + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_encoding, + &attr_mem), &encoding) != 0) + return -1; + + switch (encoding) + { + case DW_ATE_complex_float: + switch (size) + { + case 4 * 2: /* complex float */ + case 8 * 2: /* complex double */ + *locp = loc_ssereg; + return nloc_sseregpair; + case 16 * 2: /* complex long double */ + *locp = loc_x87reg; + return nloc_x87regpair; + } + return -2; + + case DW_ATE_float: + switch (size) + { + case 4: /* float */ + case 8: /* double */ + *locp = loc_ssereg; + return nloc_ssereg; + case 16: /* long double */ + /* XXX distinguish __float128, which is sseregpair?? */ + *locp = loc_x87reg; + return nloc_x87reg; + } + return -2; + } + } + + intreg: + *locp = loc_intreg; + if (size <= 8) + return nloc_intreg; + if (size <= 16) + return nloc_intregpair; + + large: + *locp = loc_aggregate; + return nloc_aggregate; + + case DW_TAG_structure_type: + case DW_TAG_class_type: + case DW_TAG_union_type: + case DW_TAG_array_type: + if (dwarf_formudata (dwarf_attr (typedie, DW_AT_byte_size, + &attr_mem), &size) != 0) + return -1; + if (size > 16) + goto large; + + /* XXX + Must examine the fields in picayune ways to determine the + actual answer. This will be right for small C structs + containing integer types and similarly simple cases. + */ + + goto intreg; + } + + /* XXX We don't have a good way to return specific errors from ebl calls. + This value means we do not understand the type, but it is well-formed + DWARF and might be valid. */ + return -2; +} diff --git a/elfutils/backends/x86_64_symbol.c b/elfutils/backends/x86_64_symbol.c new file mode 100644 index 00000000..97fd15b3 --- /dev/null +++ b/elfutils/backends/x86_64_symbol.c @@ -0,0 +1,57 @@ +/* x86_64 specific symbolic name handling. + Copyright (C) 2002, 2005 Red Hat, Inc. + This file is part of Red Hat elfutils. + Written by Ulrich Drepper <drepper@redhat.com>, 2002. + + 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. + + 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 <assert.h> +#include <elf.h> +#include <stddef.h> + +#define BACKEND x86_64_ +#include "libebl_CPU.h" + +/* Check for the simple reloc types. */ +Elf_Type +x86_64_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type) +{ + switch (type) + { + case R_X86_64_64: + return ELF_T_XWORD; + case R_X86_64_32: + return ELF_T_WORD; + case R_X86_64_32S: + return ELF_T_SWORD; + case R_X86_64_16: + return ELF_T_HALF; + case R_X86_64_8: + return ELF_T_BYTE; + default: + return ELF_T_NUM; + } +} |