summaryrefslogtreecommitdiff
path: root/libebl
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-08-03 02:05:39 +0000
committerUlrich Drepper <drepper@redhat.com>2005-08-03 02:05:39 +0000
commita38998e815ccde5d90ff0800c31da255eb3430d3 (patch)
treee5f035b73eeaf4033f159351ecad375f63d3a0aa /libebl
parentef9c9c8fca98a8f9b6aa7c3604ba47e74094e181 (diff)
downloadelfutils-a38998e815ccde5d90ff0800c31da255eb3430d3.tar.gz
Add some patches from the disasm-branch branch.
The asm_begin interface changed. In text mode output is really written to the file.
Diffstat (limited to 'libebl')
-rw-r--r--libebl/ChangeLog10
-rw-r--r--libebl/Makefile.am3
-rw-r--r--libebl/eblelfclass.c27
-rw-r--r--libebl/eblelfdata.c27
-rw-r--r--libebl/eblelfmachine.c27
-rw-r--r--libebl/eblopenbackend.c154
-rw-r--r--libebl/libebl.h12
-rw-r--r--libebl/libeblP.h5
8 files changed, 189 insertions, 76 deletions
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index a14572c0..9f9a3ef9 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,13 @@
+2005-08-02 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am (libebl_a_SOURCES): Add eblelfclass.c, eblelfdata.c,
+ and eblelfmachine.c.
+ * elbopenbackend.c (machines): Add class and data fields. Initialize
+ them.
+ (ebl_openbackend): Initialize machine, class, data fields in result.
+ * libebl.h: Declare Add eblelfclass, eblelfdata, and eblelfmachine.
+ * libeblP.h (Ebl): Add machine, class, data fields.
+
2005-07-23 Ulrich Drepper <drepper@redhat.com>
* eblsectionstripp.c: New file.
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index 5f7be50b..eeac7e54 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -47,7 +47,8 @@ gen_SOURCES = eblopenbackend.c eblclosebackend.c eblstrtab.c \
eblreloctypecheck.c eblrelocvaliduse.c eblrelocsimpletype.c \
ebldynamictagcheck.c eblcorenotetypename.c eblobjnotetypename.c \
eblcorenote.c eblobjnote.c ebldebugscnp.c \
- eblgotpcreloccheck.c eblcopyrelocp.c eblsectionstripp.c
+ eblgotpcreloccheck.c eblcopyrelocp.c eblsectionstripp.c \
+ eblelfclass.c eblelfdata.c eblelfmachine.c
libebl_a_SOURCES = $(gen_SOURCES)
diff --git a/libebl/eblelfclass.c b/libebl/eblelfclass.c
new file mode 100644
index 00000000..9108050f
--- /dev/null
+++ b/libebl/eblelfclass.c
@@ -0,0 +1,27 @@
+/* Return ELF class.
+ Copyright (C) 2005 Red Hat, Inc.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+
+ This program is Open Source software; you can redistribute it and/or
+ modify it under the terms of the Open Software License version 1.0 as
+ published by the Open Source Initiative.
+
+ You should have received a copy of the Open Software License along
+ with this program; if not, you may obtain a copy of the Open Software
+ License version 1.0 from http://www.opensource.org/licenses/osl.php or
+ by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
+ 3001 King Ranch Road, Ukiah, CA 95482. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libeblP.h>
+
+
+int
+ebl_get_elfclass (ebl)
+ Ebl *ebl;
+{
+ return ebl->class;
+}
diff --git a/libebl/eblelfdata.c b/libebl/eblelfdata.c
new file mode 100644
index 00000000..a1b84768
--- /dev/null
+++ b/libebl/eblelfdata.c
@@ -0,0 +1,27 @@
+/* Return ELF data encoding.
+ Copyright (C) 2005 Red Hat, Inc.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+
+ This program is Open Source software; you can redistribute it and/or
+ modify it under the terms of the Open Software License version 1.0 as
+ published by the Open Source Initiative.
+
+ You should have received a copy of the Open Software License along
+ with this program; if not, you may obtain a copy of the Open Software
+ License version 1.0 from http://www.opensource.org/licenses/osl.php or
+ by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
+ 3001 King Ranch Road, Ukiah, CA 95482. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libeblP.h>
+
+
+int
+ebl_get_elfdata (ebl)
+ Ebl *ebl;
+{
+ return ebl->data;
+}
diff --git a/libebl/eblelfmachine.c b/libebl/eblelfmachine.c
new file mode 100644
index 00000000..74847b1e
--- /dev/null
+++ b/libebl/eblelfmachine.c
@@ -0,0 +1,27 @@
+/* Return ELF machine.
+ Copyright (C) 2005 Red Hat, Inc.
+ Written by Ulrich Drepper <drepper@redhat.com>, 2005.
+
+ This program is Open Source software; you can redistribute it and/or
+ modify it under the terms of the Open Software License version 1.0 as
+ published by the Open Source Initiative.
+
+ You should have received a copy of the Open Software License along
+ with this program; if not, you may obtain a copy of the Open Software
+ License version 1.0 from http://www.opensource.org/licenses/osl.php or
+ by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
+ 3001 King Ranch Road, Ukiah, CA 95482. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libeblP.h>
+
+
+int
+ebl_get_elfmachine (ebl)
+ Ebl *ebl;
+{
+ return ebl->machine;
+}
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index dc2f7c30..a104d737 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -36,83 +36,83 @@ static const struct
const char *prefix;
int prefix_len;
int em;
+ int class;
+ int data;
} machines[] =
{
- { "i386", "elf_i386", "i386", 4, EM_386 },
- { "ia64", "elf_ia64", "ia64", 4, EM_IA_64 },
- { "alpha", "elf_alpha", "alpha", 5, EM_ALPHA },
- { "x86_64", "elf_x86_64", "x86_64", 6, EM_X86_64 },
- { "sh", "elf_sh", "sh", 2, EM_SH },
- { "arm", "ebl_arm", "arm", 3, EM_ARM },
- { "sparc", "elf_sparcv9", "sparc", 5, EM_SPARCV9 },
- { "sparc", "elf_sparc", "sparc", 5, EM_SPARC },
- { "sparc", "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS },
-
- { "m32", "elf_m32", "m32", 3, EM_M32 },
- { "m68k", "elf_m68k", "m68k", 4, EM_68K },
- { "m88k", "elf_m88k", "m88k", 4, EM_88K },
- { "i860", "elf_i860", "i860", 4, EM_860 },
- { "mips", "elf_mips", "mips", 4, EM_MIPS },
- { "s370", "ebl_s370", "s370", 4, EM_S370 },
- { "mips", "elf_mipsel", "mips", 4, EM_MIPS_RS3_LE },
- { "parisc", "elf_parisc", "parisc", 6, EM_PARISC },
- { "vpp500", "elf_vpp500", "vpp500", 5, EM_VPP500 },
- { "sparc", "elf_v8plus", "v8plus", 6, EM_SPARC32PLUS },
- { "i960", "elf_i960", "i960", 4, EM_960 },
- { "ppc", "elf_ppc", "ppc", 3, EM_PPC },
- { "ppc64", "elf_ppc64", "ppc64", 5, EM_PPC64 },
- { "s390", "ebl_s390", "s390", 4, EM_S390 },
- { "v800", "ebl_v800", "v800", 4, EM_V800 },
- { "fr20", "ebl_fr20", "fr20", 4, EM_FR20 },
- { "rh32", "ebl_rh32", "rh32", 4, EM_RH32 },
- { "rce", "ebl_rce", "rce", 3, EM_RCE },
- { "tricore", "elf_tricore", "tricore", 7, EM_TRICORE },
- { "arc", "elf_arc", "arc", 3, EM_ARC },
- { "h8", "elf_h8_300", "h8_300", 6, EM_H8_300 },
- { "h8", "elf_h8_300h", "h8_300h", 6, EM_H8_300H },
- { "h8", "elf_h8s", "h8s", 6, EM_H8S },
- { "h8", "elf_h8_500", "h8_500", 6, EM_H8_500 },
- { "mips_x", "elf_mips_x", "mips_x", 6, EM_MIPS_X },
- { "coldfire", "elf_coldfire", "coldfire", 8, EM_COLDFIRE },
- { "m68k", "elf_68hc12", "68hc12", 6, EM_68HC12 },
- { "mma", "elf_mma", "mma", 3, EM_MMA },
- { "pcp", "elf_pcp", "pcp", 3, EM_PCP },
- { "ncpu", "elf_ncpu", "ncpu", 4, EM_NCPU },
- { "ndr1", "elf_ndr1", "ndr1", 4, EM_NDR1 },
- { "starcore", "elf_starcore", "starcore", 8, EM_STARCORE },
- { "me16", "elf_me16", "em16", 4, EM_ME16 },
- { "st100", "elf_st100", "st100", 5, EM_ST100 },
- { "tinyj", "elf_tinyj", "tinyj", 5, EM_TINYJ },
- { "pdsp", "elf_pdsp", "pdsp", 4, EM_PDSP },
- { "fx66", "elf_fx66", "fx66", 4, EM_FX66 },
- { "st9plus", "elf_st9plus", "st9plus", 7, EM_ST9PLUS },
- { "st7", "elf_st7", "st7", 3, EM_ST7 },
- { "m68k", "elf_68hc16", "68hc16", 6, EM_68HC16 },
- { "m68k", "elf_68hc11", "68hc11", 6, EM_68HC11 },
- { "m68k", "elf_68hc08", "68hc08", 6, EM_68HC08 },
- { "m68k", "elf_68hc05", "68hc05", 6, EM_68HC05 },
- { "svx", "elf_svx", "svx", 3, EM_SVX },
- { "st19", "elf_st19", "st19", 4, EM_ST19 },
- { "vax", "elf_vax", "vax", 3, EM_VAX },
- { "cris", "elf_cris", "cris", 4, EM_CRIS },
- { "javelin", "elf_javelin", "javelin", 7, EM_JAVELIN },
- { "firepath", "elf_firepath", "firepath", 8, EM_FIREPATH },
- { "zsp", "elf_zsp", "zsp", 3, EM_ZSP},
- { "mmix", "elf_mmix", "mmix", 4, EM_MMIX },
- { "hunay", "elf_huany", "huany", 5, EM_HUANY },
- { "prism", "elf_prism", "prism", 5, EM_PRISM },
- { "avr", "elf_avr", "avr", 3, EM_AVR },
- { "fr30", "elf_fr30", "fr30", 4, EM_FR30 },
- { "dv10", "elf_dv10", "dv10", 4, EM_D10V },
- { "dv30", "elf_dv30", "dv30", 4, EM_D30V },
- { "v850", "elf_v850", "v850", 4, EM_V850 },
- { "m32r", "elf_m32r", "m32r", 4, EM_M32R },
- { "mn10300", "elf_mn10300", "mn10300", 7, EM_MN10300 },
- { "mn10200", "elf_mn10200", "mn10200", 7, EM_MN10200 },
- { "pj", "elf_pj", "pj", 2, EM_PJ },
- { "openrisc", "elf_openrisc", "openrisc", 8, EM_OPENRISC },
- { "arc", "elf_arc_a5", "arc_a5", 6, EM_ARC_A5 },
- { "xtensa", "elf_xtensa", "xtensa", 6, EM_XTENSA },
+ { "i386", "elf_i386", "i386", 4, EM_386, ELFCLASS32, ELFDATA2LSB },
+ { "ia64", "elf_ia64", "ia64", 4, EM_IA_64, ELFCLASS64, ELFDATA2LSB },
+ { "alpha", "elf_alpha", "alpha", 5, EM_ALPHA, ELFCLASS64, ELFDATA2LSB },
+ { "x86_64", "elf_x86_64", "x86_64", 6, EM_X86_64, ELFCLASS64, ELFDATA2LSB },
+ { "ppc", "elf_ppc", "ppc", 3, EM_PPC, ELFCLASS32, ELFDATA2MSB },
+ { "ppc64", "elf_ppc64", "ppc64", 5, EM_PPC64, ELFCLASS64, ELFDATA2MSB },
+ // XXX class and machine fields need to be filled in for all archs.
+ { "sh", "elf_sh", "sh", 2, EM_SH, 0, 0 },
+ { "arm", "ebl_arm", "arm", 3, EM_ARM, 0, 0 },
+ { "sparc", "elf_sparcv9", "sparc", 5, EM_SPARCV9, 0, 0 },
+ { "sparc", "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 },
+ { "sparc", "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 },
+
+ { "m32", "elf_m32", "m32", 3, EM_M32, 0, 0 },
+ { "m68k", "elf_m68k", "m68k", 4, EM_68K, 0, 0 },
+ { "m88k", "elf_m88k", "m88k", 4, EM_88K, 0, 0 },
+ { "i860", "elf_i860", "i860", 4, EM_860, 0, 0 },
+ { "s370", "ebl_s370", "s370", 4, EM_S370, 0, 0 },
+ { "parisc", "elf_parisc", "parisc", 6, EM_PARISC, 0, 0 },
+ { "vpp500", "elf_vpp500", "vpp500", 5, EM_VPP500, 0, 0 },
+ { "sparc", "elf_v8plus", "v8plus", 6, EM_SPARC32PLUS, 0, 0 },
+ { "i960", "elf_i960", "i960", 4, EM_960, 0, 0 },
+ { "s390", "ebl_s390", "s390", 4, EM_S390, 0, 0 },
+ { "v800", "ebl_v800", "v800", 4, EM_V800, 0, 0 },
+ { "fr20", "ebl_fr20", "fr20", 4, EM_FR20, 0, 0 },
+ { "rh32", "ebl_rh32", "rh32", 4, EM_RH32, 0, 0 },
+ { "rce", "ebl_rce", "rce", 3, EM_RCE, 0, 0 },
+ { "tricore", "elf_tricore", "tricore", 7, EM_TRICORE, 0, 0 },
+ { "arc", "elf_arc", "arc", 3, EM_ARC, 0, 0 },
+ { "h8", "elf_h8_300", "h8_300", 6, EM_H8_300, 0, 0 },
+ { "h8", "elf_h8_300h", "h8_300h", 6, EM_H8_300H, 0, 0 },
+ { "h8", "elf_h8s", "h8s", 6, EM_H8S, 0, 0 },
+ { "h8", "elf_h8_500", "h8_500", 6, EM_H8_500, 0, 0 },
+ { "coldfire", "elf_coldfire", "coldfire", 8, EM_COLDFIRE, 0, 0 },
+ { "m68k", "elf_68hc12", "68hc12", 6, EM_68HC12, 0, 0 },
+ { "mma", "elf_mma", "mma", 3, EM_MMA, 0, 0 },
+ { "pcp", "elf_pcp", "pcp", 3, EM_PCP, 0, 0 },
+ { "ncpu", "elf_ncpu", "ncpu", 4, EM_NCPU, 0, 0 },
+ { "ndr1", "elf_ndr1", "ndr1", 4, EM_NDR1, 0, 0 },
+ { "starcore", "elf_starcore", "starcore", 8, EM_STARCORE, 0, 0 },
+ { "me16", "elf_me16", "em16", 4, EM_ME16, 0, 0 },
+ { "st100", "elf_st100", "st100", 5, EM_ST100, 0, 0 },
+ { "tinyj", "elf_tinyj", "tinyj", 5, EM_TINYJ, 0, 0 },
+ { "pdsp", "elf_pdsp", "pdsp", 4, EM_PDSP, 0, 0 },
+ { "fx66", "elf_fx66", "fx66", 4, EM_FX66, 0, 0 },
+ { "st9plus", "elf_st9plus", "st9plus", 7, EM_ST9PLUS, 0, 0 },
+ { "st7", "elf_st7", "st7", 3, EM_ST7, 0, 0 },
+ { "m68k", "elf_68hc16", "68hc16", 6, EM_68HC16, 0, 0 },
+ { "m68k", "elf_68hc11", "68hc11", 6, EM_68HC11, 0, 0 },
+ { "m68k", "elf_68hc08", "68hc08", 6, EM_68HC08, 0, 0 },
+ { "m68k", "elf_68hc05", "68hc05", 6, EM_68HC05, 0, 0 },
+ { "svx", "elf_svx", "svx", 3, EM_SVX, 0, 0 },
+ { "st19", "elf_st19", "st19", 4, EM_ST19, 0, 0 },
+ { "vax", "elf_vax", "vax", 3, EM_VAX, 0, 0 },
+ { "cris", "elf_cris", "cris", 4, EM_CRIS, 0, 0 },
+ { "javelin", "elf_javelin", "javelin", 7, EM_JAVELIN, 0, 0 },
+ { "firepath", "elf_firepath", "firepath", 8, EM_FIREPATH, 0, 0 },
+ { "zsp", "elf_zsp", "zsp", 3, EM_ZSP, 0, 0 },
+ { "mmix", "elf_mmix", "mmix", 4, EM_MMIX, 0, 0 },
+ { "hunay", "elf_huany", "huany", 5, EM_HUANY, 0, 0 },
+ { "prism", "elf_prism", "prism", 5, EM_PRISM, 0, 0 },
+ { "avr", "elf_avr", "avr", 3, EM_AVR, 0, 0 },
+ { "fr30", "elf_fr30", "fr30", 4, EM_FR30, 0, 0 },
+ { "dv10", "elf_dv10", "dv10", 4, EM_D10V, 0, 0 },
+ { "dv30", "elf_dv30", "dv30", 4, EM_D30V, 0, 0 },
+ { "v850", "elf_v850", "v850", 4, EM_V850, 0, 0 },
+ { "m32r", "elf_m32r", "m32r", 4, EM_M32R, 0, 0 },
+ { "mn10300", "elf_mn10300", "mn10300", 7, EM_MN10300, 0, 0 },
+ { "mn10200", "elf_mn10200", "mn10200", 7, EM_MN10200, 0, 0 },
+ { "pj", "elf_pj", "pj", 2, EM_PJ, 0, 0 },
+ { "openrisc", "elf_openrisc", "openrisc", 8, EM_OPENRISC, 0, 0 },
+ { "arc", "elf_arc_a5", "arc_a5", 6, EM_ARC_A5, 0, 0 },
+ { "xtensa", "elf_xtensa", "xtensa", 6, EM_XTENSA, 0, 0 },
};
#define nmachines (sizeof (machines) / sizeof (machines[0]))
@@ -226,6 +226,10 @@ openbackend (elf, emulation, machine)
/* Well, we know the emulation name now. */
result->emulation = machines[cnt].emulation;
+ result->machine = machines[cnt].em;
+ result->class = machines[cnt].class;
+ result->data = machines[cnt].data;
+
#ifndef LIBEBL_SUBDIR
# define LIBEBL_SUBDIR PACKAGE
#endif
diff --git a/libebl/libebl.h b/libebl/libebl.h
index aff9ca5e..a59d4dd4 100644
--- a/libebl/libebl.h
+++ b/libebl/libebl.h
@@ -37,6 +37,18 @@ extern Ebl *ebl_openbackend_emulation (const char *emulation);
extern void ebl_closebackend (Ebl *bh);
+/* Information about the descriptor. */
+
+/* Get ELF machine. */
+extern int ebl_get_elfmachine (Ebl *ebl) __attribute__ ((__pure__));
+
+/* Get ELF class. */
+extern int ebl_get_elfclass (Ebl *ebl) __attribute__ ((__pure__));
+
+/* Get ELF data encoding. */
+extern int ebl_get_elfdata (Ebl *ebl) __attribute__ ((__pure__));
+
+
/* Function to call the callback functions including default ELF
handling. */
diff --git a/libebl/libeblP.h b/libebl/libeblP.h
index 21bb8fff..9d47e8c4 100644
--- a/libebl/libeblP.h
+++ b/libebl/libeblP.h
@@ -28,6 +28,11 @@ struct ebl
/* Emulation name. */
const char *emulation;
+ /* ELF machine, class, and data encoding. */
+ int machine;
+ int class;
+ int data;
+
/* The libelf handle (if known). */
Elf *elf;