]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Add some patches from the disasm-branch branch.
authorUlrich Drepper <drepper@redhat.com>
Wed, 3 Aug 2005 02:05:39 +0000 (02:05 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 3 Aug 2005 02:05:39 +0000 (02:05 +0000)
The asm_begin interface changed.
In text mode output is really written to the file.

33 files changed:
NEWS
libasm/ChangeLog
libasm/Makefile.am
libasm/asm_abort.c
libasm/asm_addint8.c
libasm/asm_addsleb128.c
libasm/asm_adduleb128.c
libasm/asm_align.c
libasm/asm_begin.c
libasm/asm_end.c
libasm/asm_error.c
libasm/asm_newscn.c
libasm/libasm.h
libasm/libasmP.h
libebl/ChangeLog
libebl/Makefile.am
libebl/eblelfclass.c [new file with mode: 0644]
libebl/eblelfdata.c [new file with mode: 0644]
libebl/eblelfmachine.c [new file with mode: 0644]
libebl/eblopenbackend.c
libebl/libebl.h
libebl/libeblP.h
tests/ChangeLog
tests/Makefile.am
tests/asm-tst1.c
tests/asm-tst2.c
tests/asm-tst3.c
tests/asm-tst4.c
tests/asm-tst5.c
tests/asm-tst6.c
tests/asm-tst7.c
tests/asm-tst8.c
tests/asm-tst9.c

diff --git a/NEWS b/NEWS
index 24f1741663570717cf246a3fc943a73e28269478..28d6815945c81d909fd84bcec763568f4520247d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,11 @@ elflint: some more tests.
 
 libelf: Add elfXX_offscn and gelf_offscn.
 
+libasm: asm_begin interface changes.
+
+libebl: Add three new interfaces to directly access machine, class, and
+data encoding information.
+
 Version 0.111:
 
 libdw: now contains all of libdwfl.  The latter is not installed anymore.
index 8b7b44d24e39a95b4f21d7446a913fc2cc116215..6adeef1e0aabc7e7375613ed3704edb11b724f11 100644 (file)
@@ -1,6 +1,22 @@
+2005-08-02  Ulrich Drepper  <drepper@redhat.com>
+
+       * Makefile.am (AM_CFLAGS): Add -std=gnu99.
+       * asm_abort.c: Don't try to remove output file if there is none.
+       * asm_addint8.c: In print mode, print to file not stdout.
+       * asm_addsleb128.c: Likewise.
+       * asm_adduleb128.c: Likewise.
+       * asm_newscn.c: Likewise.
+       * asm_align.c: Implement print mode.
+       * asm_begin.c (asm_begin): Change interface.  Take binary class and
+       byte order information from new Ebl parameter.
+       * libasm.h: Adjust prototype.
+       * asm_end.c (text_end): Close file if necesary.
+       * asm_error.c: Add new error ASM_E_IOERROR.
+       * libasmP.h: Add ASM_E_IOERROR definition.
+
 2005-02-15  Ulrich Drepper  <drepper@redhat.com>
 
-       * Makefile (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2.
+       * Makefile.am (AM_CFLAGS): Add -Wunused -Wextra -Wformat=2.
 
        * asm_end.c (text_end): Mark parameter as possibly unused.
 
index 34b19d24787b31000dd9de98de12a28c10eec03d..7802a5c041533d1fec33eeded21071bb358bfbf4 100644 (file)
@@ -18,7 +18,7 @@ AM_CFLAGS = -fmudflap
 else
 AM_CFLAGS =
 endif
-AM_CFLAGS += -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2
+AM_CFLAGS += -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2
 INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl \
           -I$(top_srcdir)/lib
 GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
index f35757ca9d708b6b495bb62349ef2c38df82fa7a..3353a023ba53ebfb9a41b9def57157ab4ac42fea 100644 (file)
@@ -1,5 +1,5 @@
 /* Abort operations on the assembler context, free all resources.
-   Copyright (C) 2002 Red Hat, Inc.
+   Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -36,7 +36,8 @@ asm_abort (ctx)
     (void) elf_end (ctx->out.elf);
 
   /* Now close the temporary file and remove it.  */
-  (void) unlink (ctx->tmp_fname);
+  if (ctx->fd != -1)
+    (void) unlink (ctx->tmp_fname);
 
   /* Free the resources.  */
   __libasm_finictx (ctx);
index 35d9bf574cf4106589aa83814c8ff668e43c4a0e..bbd8e5f7d6c25ee543bf88e58439d3c921fd616e 100644 (file)
@@ -1,5 +1,5 @@
 /* Add integer to a section.
-   Copyright (C) 2002 Red Hat, Inc.
+   Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -53,22 +53,25 @@ FCT(SIZE) (asmscn, num)
     {
       // XXX Needs to use backend specified pseudo-ops
       if (SIZE == 8)
-       printf ("\t.byte\t%" PRId8 "\n", (int8_t) num);
+       fprintf (asmscn->ctx->out.file, "\t.byte\t%" PRId8 "\n", (int8_t) num);
       else if (SIZE == 16)
-       printf ("\t.value\t%" PRId16 "\n", (int16_t) num);
+       fprintf (asmscn->ctx->out.file, "\t.value\t%" PRId16 "\n",
+                (int16_t) num);
       else if (SIZE == 32)
-       printf ("\t.long\t%" PRId32 "\n", (int32_t) num);
+       fprintf (asmscn->ctx->out.file, "\t.long\t%" PRId32 "\n",
+                (int32_t) num);
       else
        {
          // XXX This is not necessary for 64-bit machines
          bool is_leb = (elf_getident (asmscn->ctx->out.elf, NULL)[EI_DATA]
                         == ELFDATA2LSB);
 
-         printf ("\t.long\t%" PRId32 "\n\t.long\t%" PRId32 "\n",
-                 (int32_t) (is_leb
-                            ? num % 0x100000000ll : num / 0x100000000ll),
-                 (int32_t) (is_leb
-                            ? num / 0x100000000ll : num % 0x100000000ll));
+         fprintf (asmscn->ctx->out.file,
+                  "\t.long\t%" PRId32 "\n\t.long\t%" PRId32 "\n",
+                  (int32_t) (is_leb
+                             ? num % 0x100000000ll : num / 0x100000000ll),
+                  (int32_t) (is_leb
+                             ? num / 0x100000000ll : num % 0x100000000ll));
        }
     }
   else
index 0661b36ef8716488bb381672986c004a63b07044..fdefd01b6331de204a90ed4393f6b4f597c34181 100644 (file)
@@ -1,5 +1,5 @@
 /* Add signed little endian base 128 integer to a section.
-   Copyright (C) 2002 Red Hat, Inc.
+   Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -37,7 +37,7 @@ asm_addsleb128 (asmscn, num)
     }
 
   if (unlikely (asmscn->ctx->textp))
-    printf ("\t.sleb128\t%" PRId32 "\n", num);
+    fprintf (asmscn->ctx->out.file, "\t.sleb128\t%" PRId32 "\n", num);
   else
     {
       char tmpbuf[(sizeof (num) * 8 + 6) / 7];
index 521d265a2c0f7e2918644164a47257ddbf37f37b..1685b5eb3bfbe7a4d8c445c71eb52fe2593ac9b7 100644 (file)
@@ -1,5 +1,5 @@
 /* Add integer to a section.
-   Copyright (C) 2002 Red Hat, Inc.
+   Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -37,7 +37,7 @@ asm_adduleb128 (asmscn, num)
     }
 
   if (unlikely (asmscn->ctx->textp))
-    printf ("\t.uleb128\t%" PRIu32 "\n", num);
+    fprintf (asmscn->ctx->out.file, "\t.uleb128\t%" PRIu32 "\n", num);
   else
     {
       char tmpbuf[(sizeof (num) * 8 + 6) / 7];
index e73509246ed25ecb72210a50ad3ba3476f1f818e..a52fc86d7025b19f7c7439ed37763b373bc5e13b 100644 (file)
@@ -1,5 +1,5 @@
 /* Align section.
-   Copyright (C) 2002 Red Hat, Inc.
+   Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -16,6 +16,7 @@
 # include <config.h>
 #endif
 
+#include <inttypes.h>
 #include <stdlib.h>
 #include <sys/param.h>
 
@@ -39,6 +40,25 @@ asm_align (asmscn, value)
       return -1;
     }
 
+  if (unlikely (asmscn->ctx->textp))
+    {
+      fprintf (asmscn->ctx->out.file, "\t.align %" PRId32 ", ",
+              (int32_t) value);
+      if (asmscn->pattern->len == 1)
+       fprintf (asmscn->ctx->out.file, "%02hhx\n", asmscn->pattern->bytes[0]);
+      else
+       {
+         fputc_unlocked ('"', asmscn->ctx->out.file);
+
+         for (size_t cnt = 0; cnt < asmscn->pattern->len; ++cnt)
+           fprintf (asmscn->ctx->out.file, "\\x%02hhx",
+                    asmscn->pattern->bytes[cnt]);
+
+         fputs_unlocked ("\"\n", asmscn->ctx->out.file);
+       }
+      return 0;
+    }
+
   rwlock_wrlock (asmscn->ctx->lock);
 
   int result = 0;
@@ -47,10 +67,7 @@ asm_align (asmscn, value)
   if ((asmscn->offset & (value - 1)) != 0)
     {
       /* Add fillbytes.  */
-      size_t cnt;
-      size_t byteptr;
-
-      cnt = value - (asmscn->offset & (value - 1));
+      size_t cnt = value - (asmscn->offset & (value - 1));
 
       /* Ensure there is enough room to add the fill bytes.  */
       result = __libasm_ensure_section_space (asmscn, cnt);
@@ -59,7 +76,7 @@ asm_align (asmscn, value)
 
       /* Fill in the bytes.  We align the pattern according to the
         current offset.  */
-      byteptr = asmscn->offset % asmscn->pattern->len;
+      size_t byteptr = asmscn->offset % asmscn->pattern->len;
 
       /* Update the total size.  */
       asmscn->offset += cnt;
index 3896f78f07ef99e57aeba246125d6821fd7cfc66..1ded3474b0a20814bacd9bf2ab498f73b54077cc 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <assert.h>
 #include <errno.h>
+#include <stdio.h>
+#include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 static AsmCtx_t *
 prepare_text_output (AsmCtx_t *result)
 {
+  if (result->fd == -1)
+    result->out.file = stdout;
+  else
+    {
+      result->out.file = fdopen (result->fd, "a");
+      if (result->out.file == NULL)
+       {
+         close (result->fd);
+         free (result);
+         result = NULL;
+       }
+
+      __fsetlocking (result->out.file, FSETLOCKING_BYCALLER);
+    }
+
   return result;
 }
 
 
 static AsmCtx_t *
-prepare_binary_output (AsmCtx_t *result, int machine, int klass, int data)
+prepare_binary_output (AsmCtx_t *result, Ebl *ebl)
 {
   GElf_Ehdr *ehdr;
   GElf_Ehdr ehdr_mem;
@@ -53,7 +70,8 @@ prepare_binary_output (AsmCtx_t *result, int machine, int klass, int data)
     }
 
   /* Create the ELF header for the output file.  */
-  if (gelf_newehdr (result->out.elf, klass) == 0)
+  int class = ebl_get_elfclass (ebl);
+  if (gelf_newehdr (result->out.elf, class) == 0)
     goto err_libelf;
 
   ehdr = gelf_getehdr (result->out.elf, &ehdr_mem);
@@ -65,11 +83,10 @@ prepare_binary_output (AsmCtx_t *result, int machine, int klass, int data)
   /* Set the ELF version.  */
   ehdr->e_version = EV_CURRENT;
 
-  /* Use the machine value the user provided.  */
-  ehdr->e_machine = machine;
-  /* Same for the class and endianness.  */
-  ehdr->e_ident[EI_CLASS] = klass;
-  ehdr->e_ident[EI_DATA] = data;
+  /* Use the machine, class, and endianess values from the Ebl descriptor.  */
+  ehdr->e_machine = ebl_get_elfmachine (ebl);
+  ehdr->e_ident[EI_CLASS] = class;
+  ehdr->e_ident[EI_DATA] = ebl_get_elfdata (ebl);
 
   memcpy (&ehdr->e_ident[EI_MAG0], ELFMAG, SELFMAG);
 
@@ -95,47 +112,48 @@ prepare_binary_output (AsmCtx_t *result, int machine, int klass, int data)
 
 
 AsmCtx_t *
-asm_begin (fname, textp, machine, klass, data)
+asm_begin (fname, ebl, textp)
      const char *fname;
+     Ebl *ebl;
      bool textp;
-     int machine;
-     int klass;
-     int data;
 {
-  size_t fname_len = strlen (fname);
-  AsmCtx_t *result;
-
+  if (fname == NULL && ! textp)
+    return NULL;
 
-  /* First order of business: find the appropriate backend.  If it
-     does not exist we don't have to look further.  */
-  // XXX
+  size_t fname_len = fname != NULL ? strlen (fname) : 0;
 
   /* Create the file descriptor.  We do not generate the output file
      right away.  Instead we create a temporary file in the same
      directory which, if everything goes alright, will replace a
      possibly existing file with the given name.  */
-  result = (AsmCtx_t *) malloc (sizeof (AsmCtx_t) + 2 * fname_len + 9);
+  AsmCtx_t *result
+    = (AsmCtx_t *) malloc (sizeof (AsmCtx_t) + 2 * fname_len + 9);
   if (result == NULL)
     return NULL;
 
-  /* Initialize the lock.  */
-  rwlock_init (result->lock);
-
-  /* Create the name of the temporary file.  */
-  result->fname = stpcpy (mempcpy (result->tmp_fname, fname, fname_len),
-                         ".XXXXXX") + 1;
-  memcpy (result->fname, fname, fname_len + 1);
+      /* Initialize the lock.  */
+      rwlock_init (result->lock);
 
-  /* Create the temporary file.  */
-  result->fd = mkstemp (result->tmp_fname);
-  if (result->fd == -1)
+  if (fname != NULL)
     {
-      int save_errno = errno;
-      free (result);
-      __libasm_seterrno (ASM_E_CANNOT_CREATE);
-      errno = save_errno;
-      return NULL;
+      /* Create the name of the temporary file.  */
+      result->fname = stpcpy (mempcpy (result->tmp_fname, fname, fname_len),
+                             ".XXXXXX") + 1;
+      memcpy (result->fname, fname, fname_len + 1);
+
+      /* Create the temporary file.  */
+      result->fd = mkstemp (result->tmp_fname);
+      if (result->fd == -1)
+       {
+         int save_errno = errno;
+         free (result);
+         __libasm_seterrno (ASM_E_CANNOT_CREATE);
+         errno = save_errno;
+         return NULL;
+       }
     }
+  else
+    result->fd = -1;
 
   /* Initialize the counter for temporary symbols.  */
   result->tempsym_count = 0;
@@ -145,7 +163,7 @@ asm_begin (fname, textp, machine, klass, data)
   if (textp)
     result = prepare_text_output (result);
   else
-    result = prepare_binary_output (result, machine, klass, data);
+    result = prepare_binary_output (result, ebl);
 
   return result;
 }
index 74f01f0864dadbcb9d869f9f7d56fae6454187b6..33191f9c472959a5f8a81e443d19a312fb6aee7f 100644 (file)
 static int
 text_end (AsmCtx_t *ctx __attribute__ ((unused)))
 {
-  // XXX Does anything have to be done?
+  if (fclose (ctx->out.file) != 0)
+    {
+      __libasm_seterrno (ASM_E_IOERROR);
+      return -1;
+    }
+
   return 0;
 }
 
index 9d2d81ed9cfda3ab59864002eb5ece7027e0aa0c..3b5aa0556b9277f76d72fffbc511cf4e166a6d57 100644 (file)
@@ -1,5 +1,5 @@
 /* Error handling in libasm.
-   Copyright (C) 2002, 2004 Red Hat, Inc.
+   Copyright (C) 2002, 2004, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -112,7 +112,8 @@ static const char *msgs[ASM_E_NUM] =
   [ASM_E_CANNOT_CHMOD] = N_("cannot change mode of output file"),
   [ASM_E_CANNOT_RENAME] = N_("cannot rename output file"),
   [ASM_E_DUPLSYM] = N_("duplicate symbol"),
-  [ASM_E_TYPE] = N_("invalid section type for operation")
+  [ASM_E_TYPE] = N_("invalid section type for operation"),
+  [ASM_E_IOERROR] = N_("error during output of data"),
 };
 
 const char *
index 75890a601b49bd5e6d5c3f0fefec50e15424e776..7e5853254c3ad2c8a8b7c43f671ee2855d6e6103 100644 (file)
@@ -1,5 +1,5 @@
 /* Create new section in output file.
-   Copyright (C) 2002 Red Hat, Inc.
+   Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -81,7 +81,8 @@ text_newscn (AsmScn_t *result, GElf_Word type, GElf_Xword flags)
   /* Terminate the string.  */
   *wp = '\0';
 
-  printf ("\t.section \"%s\"%s%s\n", result->name, flagstr, typestr);
+  fprintf (result->ctx->out.file, "\t.section \"%s\"%s%s\n",
+          result->name, flagstr, typestr);
 
   return result;
 }
index dbdd6fc2510ccea245a03b338c9fff5537a2d3b7..46d5e8db4fd67e0f7ea81f2c25a5d0cea25f3158 100644 (file)
@@ -1,5 +1,5 @@
 /* Interface for libasm.
-   Copyright (C) 2002 Red Hat, Inc.
+   Copyright (C) 2002, 2005 Red Hat, Inc.
 
    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
@@ -17,7 +17,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 
-#include <gelf.h>
+#include <libebl.h>
 
 
 /* Opaque type for the assembler context descriptor.  */
@@ -43,8 +43,7 @@ extern "C" {
    corresponds to an EM_ constant from <elf.h>, KLASS specifies the
    class (32- or 64-bit), and DATA specifies the byte order (little or
    big endian).  */
-extern AsmCtx_t *asm_begin (const char *fname, bool textp, int machine,
-                           int klass, int data);
+extern AsmCtx_t *asm_begin (const char *fname, Ebl *ebl, bool textp);
 
 /* Abort the operation on the assembler context and free all resources.  */
 extern int asm_abort (AsmCtx_t *ctx);
index 2e4954f6e27bf8813edbd6cb035398623c0e341b..1cbec55c8b24c7253fcab6f502a0769171a0e3d6 100644 (file)
@@ -1,5 +1,5 @@
 /* Internal definitions for libasm.
-   Copyright (C) 2002, 2004 Red Hat, Inc.
+   Copyright (C) 2002, 2004, 2005 Red Hat, Inc.
 
    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
@@ -17,7 +17,6 @@
 #include <stdio.h>
 
 #include <libasm.h>
-#include <libebl.h>
 
 /* gettext helper macros.  */
 #define _(Str) dgettext ("elfutils", Str)
@@ -35,6 +34,7 @@ enum
     ASM_E_DUPLSYM,             /* Duplicate symbol definition.  */
     ASM_E_LIBELF,              /* Refer to error in libelf.  */
     ASM_E_TYPE,                        /* Invalid section type for operation.  */
+    ASM_E_IOERROR,             /* Error during output of data.  */
     ASM_E_NUM                  /* Keep this entry as the last.  */
   };
 
index a14572c0f66c338c3802564d7c1936ea233f15b2..9f9a3ef96655814ad2736afa46569606b600c874 100644 (file)
@@ -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.
index 5f7be50bf28e9e050dc6ea95b75c01cefb2822cf..eeac7e542b2984dedcead7918beb49bf10d74e63 100644 (file)
@@ -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 (file)
index 0000000..9108050
--- /dev/null
@@ -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 (file)
index 0000000..a1b8476
--- /dev/null
@@ -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 (file)
index 0000000..74847b1
--- /dev/null
@@ -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;
+}
index dc2f7c30778000943585caaa2c025382305a4ef1..a104d737293f54171376dc5b9a608ce39a75b805 100644 (file)
@@ -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
index aff9ca5ea59ec71312a0f769bb940a900b7e0396..a59d4dd4eb464a5cc1dd14a19ee1fbe0a6dd81cd 100644 (file)
@@ -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.  */
 
index 21bb8fff117e7ed15d275c4a4c67c97b9b19c9b2..9d47e8c4c3cee74ae6b406be7a78d9bb9c1c8fdb 100644 (file)
@@ -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;
 
index 22aee322ec118833c23f15840fd5824f9ca2deba..d592648913cf65e49f6763a24746b3c08b658331 100644 (file)
@@ -1,5 +1,17 @@
 2005-08-02  Ulrich Drepper  <drepper@redhat.com>
 
+       * Makefile.am: Add -ldl to asm_tst[1-9]_LDASS.
+       * asm-tst1.c: Adjust for new asm_begin interface.  Open backend
+       library first.
+       * asm-tst2.c: Likewise.
+       * asm-tst3.c: Likewise.
+       * asm-tst4.c: Likewise.
+       * asm-tst5.c: Likewise.
+       * asm-tst6.c: Likewise.
+       * asm-tst7.c: Likewise.
+       * asm-tst8.c: Likewise.
+       * asm-tst9.c: Likewise.
+
        * msg_tst.c: Add new error message.
 
 2005-07-28  Ulrich Drepper  <drepper@redhat.com>
index 5560d6eed273aed49684468c4dafc6297716a175..07b87e0efee230f868f72e271f06799da2c3ed12 100644 (file)
@@ -101,15 +101,15 @@ allfcts_LDADD = $(libdw) $(libelf) $(libmudflap)
 line2addr_no_Wformat = yes
 line2addr_LDADD = $(libdw) $(libelf) $(libmudflap)
 #show_ciefde_LDADD = ../libdwarf/libdwarf.so $(libelf) $(libmudflap)
-asm_tst1_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap)
-asm_tst2_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap)
-asm_tst3_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap)
-asm_tst4_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap)
-asm_tst5_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap)
-asm_tst6_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap)
-asm_tst7_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap)
-asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap)
-asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap)
+asm_tst1_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
+asm_tst2_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
+asm_tst3_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
+asm_tst4_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
+asm_tst5_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
+asm_tst6_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
+asm_tst7_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
+asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
+asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
 dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap)
 
 CLEANFILES = xxx
index b76930d02277a18c636cc4f27ecdfcd9f3b02b5c..cfaae345a73676933b476e818ca2df1ec77ee8d8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Red Hat, Inc.
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -66,7 +66,14 @@ main (void)
 
   elf_version (EV_CURRENT);
 
-  ctx = asm_begin (fname, false, EM_386, ELFCLASS32, ELFDATA2LSB);
+  Ebl *ebl = ebl_openbackend_machine (EM_386);
+  if (ebl == NULL)
+    {
+      puts ("cannot open backend library");
+      return 1;
+    }
+
+  ctx = asm_begin (fname, ebl, false);
   if (ctx == NULL)
     {
       printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
@@ -235,5 +242,7 @@ main (void)
   /* We don't need the file anymore.  */
   unlink (fname);
 
+  ebl_closebackend (ebl);
+
   return result;
 }
index a309976d5ec55233e1cf241684e63ef64e258542..b9a1037f3a19c8746f85a2ed6b0261db6f4151c4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Red Hat, Inc.
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -65,7 +65,14 @@ main (void)
 
   elf_version (EV_CURRENT);
 
-  ctx = asm_begin (fname, false, EM_386, ELFCLASS32, ELFDATA2LSB);
+  Ebl *ebl = ebl_openbackend_machine (EM_386);
+  if (ebl == NULL)
+    {
+      puts ("cannot open backend library");
+      return 1;
+    }
+
+  ctx = asm_begin (fname, ebl, false);
   if (ctx == NULL)
     {
       printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
@@ -257,5 +264,7 @@ main (void)
   /* We don't need the file anymore.  */
   unlink (fname);
 
+  ebl_closebackend (ebl);
+
   return result;
 }
index fb79ea78e0b47e57b25f6a522706197fccf76fee..155613c5a66ccf0725287b138e46bb4420ba2563 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Red Hat, Inc.
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -57,7 +57,14 @@ main (void)
 
   elf_version (EV_CURRENT);
 
-  ctx = asm_begin (fname, false, EM_386, ELFCLASS32, ELFDATA2LSB);
+  Ebl *ebl = ebl_openbackend_machine (EM_386);
+  if (ebl == NULL)
+    {
+      puts ("cannot open backend library");
+      return 1;
+    }
+
+  ctx = asm_begin (fname, ebl, false);
   if (ctx == NULL)
     {
       printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
@@ -318,5 +325,7 @@ main (void)
   /* We don't need the file anymore.  */
   unlink (fname);
 
+  ebl_closebackend (ebl);
+
   return result;
 }
index 29d6485d155d82e6c882d4fd7e0cf49593fa0e48..50c3c5a5f85f8d2380e6a7b7324dbe641ca6961d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2004 Red Hat, Inc.
+/* Copyright (C) 2002, 2004, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -33,7 +33,14 @@ main (void)
 
   elf_version (EV_CURRENT);
 
-  ctx = asm_begin (fname, false, EM_386, ELFCLASS32, ELFDATA2LSB);
+  Ebl *ebl = ebl_openbackend_machine (EM_386);
+  if (ebl == NULL)
+    {
+      puts ("cannot open backend library");
+      return 1;
+    }
+
+  ctx = asm_begin (fname, ebl, false);
   if (ctx == NULL)
     {
       printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
@@ -84,5 +91,7 @@ env LD_LIBRARY_PATH=../libelf ../src/elflint -q asm-tst4-out.o"));
   /* We don't need the file anymore.  */
   unlink (fname);
 
+  ebl_closebackend (ebl);
+
   return result;
 }
index 4f761aed4a27c18205ec2dd8186fc8c3c41d05d0..e5881a53114e01bf1e1b511f98b5a42ee69ceb5c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2004 Red Hat, Inc.
+/* Copyright (C) 2002, 2004, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -35,7 +35,14 @@ main (void)
 
   elf_version (EV_CURRENT);
 
-  ctx = asm_begin (fname, false, EM_386, ELFCLASS32, ELFDATA2LSB);
+  Ebl *ebl = ebl_openbackend_machine (EM_386);
+  if (ebl == NULL)
+    {
+      puts ("cannot open backend library");
+      return 1;
+    }
+
+  ctx = asm_begin (fname, ebl, false);
   if (ctx == NULL)
     {
       printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
@@ -96,5 +103,7 @@ env LD_LIBRARY_PATH=../libelf ../src/elflint -q asm-tst5-out.o"));
   /* We don't need the file anymore.  */
   unlink (fname);
 
+  ebl_closebackend (ebl);
+
   return result;
 }
index ece69bc20282c14b283dd076c89a73b5fe726562..5ceded6505d9aec0fafad150682030d28b7b96cc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2004 Red Hat, Inc.
+/* Copyright (C) 2002, 2004, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -33,7 +33,14 @@ main (void)
 
   elf_version (EV_CURRENT);
 
-  ctx = asm_begin (fname, false, EM_386, ELFCLASS32, ELFDATA2LSB);
+  Ebl *ebl = ebl_openbackend_machine (EM_386);
+  if (ebl == NULL)
+    {
+      puts ("cannot open backend library");
+      return 1;
+    }
+
+  ctx = asm_begin (fname, ebl, false);
   if (ctx == NULL)
     {
       printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
@@ -130,5 +137,7 @@ env LD_LIBRARY_PATH=../libelf ../src/elflint -q asm-tst6-out.o"));
   /* We don't need the file anymore.  */
   unlink (fname);
 
+  ebl_closebackend (ebl);
+
   return result;
 }
index ebd45594615f2e137f694745ac473739102d1e30..5c94d8950283d63f07dc3329e6cee85141f1986e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Red Hat, Inc.
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -33,7 +33,14 @@ main (void)
 
   elf_version (EV_CURRENT);
 
-  ctx = asm_begin (fname, false, EM_386, ELFCLASS32, ELFDATA2LSB);
+  Ebl *ebl = ebl_openbackend_machine (EM_386);
+  if (ebl == NULL)
+    {
+      puts ("cannot open backend library");
+      return 1;
+    }
+
+  ctx = asm_begin (fname, ebl, false);
   if (ctx == NULL)
     {
       printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
@@ -160,5 +167,7 @@ main (void)
   /* We don't need the file anymore.  */
   unlink (fname);
 
+  ebl_closebackend (ebl);
+
   return result;
 }
index 6ce7c9c0983445da0e794922d24bf65a355b2b99..cfe53fcacaffaf19249aa58c569bef1b4a980847 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Red Hat, Inc.
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -33,7 +33,14 @@ main (void)
 
   elf_version (EV_CURRENT);
 
-  ctx = asm_begin (fname, false, EM_386, ELFCLASS32, ELFDATA2LSB);
+  Ebl *ebl = ebl_openbackend_machine (EM_386);
+  if (ebl == NULL)
+    {
+      puts ("cannot open backend library");
+      return 1;
+    }
+
+  ctx = asm_begin (fname, ebl, false);
   if (ctx == NULL)
     {
       printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
@@ -168,5 +175,7 @@ main (void)
   /* We don't need the file anymore.  */
   unlink (fname);
 
+  ebl_closebackend (ebl);
+
   return result;
 }
index 28bb47879e4823d1f6492e57cb2f532b923f0c89..1f03d8d78191f0d9263733ca1a6eeb0203a08a38 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Red Hat, Inc.
+/* Copyright (C) 2002, 2005 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    This program is Open Source software; you can redistribute it and/or
@@ -85,7 +85,14 @@ main (void)
 
   elf_version (EV_CURRENT);
 
-  ctx = asm_begin (fname, false, EM_386, ELFCLASS32, ELFDATA2LSB);
+  Ebl *ebl = ebl_openbackend_machine (EM_386);
+  if (ebl == NULL)
+    {
+      puts ("cannot open backend library");
+      return 1;
+    }
+
+  ctx = asm_begin (fname, ebl, false);
   if (ctx == NULL)
     {
       printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
@@ -314,5 +321,7 @@ main (void)
   /* We don't need the file anymore.  */
   unlink (fname);
 
+  ebl_closebackend (ebl);
+
   return result;
 }