diff options
author | Ulrich Drepper <drepper@redhat.com> | 2005-08-03 02:05:39 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2005-08-03 02:05:39 +0000 |
commit | a38998e815ccde5d90ff0800c31da255eb3430d3 (patch) | |
tree | e5f035b73eeaf4033f159351ecad375f63d3a0aa | |
parent | ef9c9c8fca98a8f9b6aa7c3604ba47e74094e181 (diff) | |
download | android_external_elfutils-a38998e815ccde5d90ff0800c31da255eb3430d3.tar.gz android_external_elfutils-a38998e815ccde5d90ff0800c31da255eb3430d3.tar.bz2 android_external_elfutils-a38998e815ccde5d90ff0800c31da255eb3430d3.zip |
Add some patches from the disasm-branch branch.
The asm_begin interface changed.
In text mode output is really written to the file.
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | libasm/ChangeLog | 18 | ||||
-rw-r--r-- | libasm/Makefile.am | 2 | ||||
-rw-r--r-- | libasm/asm_abort.c | 5 | ||||
-rw-r--r-- | libasm/asm_addint8.c | 21 | ||||
-rw-r--r-- | libasm/asm_addsleb128.c | 4 | ||||
-rw-r--r-- | libasm/asm_adduleb128.c | 4 | ||||
-rw-r--r-- | libasm/asm_align.c | 29 | ||||
-rw-r--r-- | libasm/asm_begin.c | 86 | ||||
-rw-r--r-- | libasm/asm_end.c | 7 | ||||
-rw-r--r-- | libasm/asm_error.c | 5 | ||||
-rw-r--r-- | libasm/asm_newscn.c | 5 | ||||
-rw-r--r-- | libasm/libasm.h | 7 | ||||
-rw-r--r-- | libasm/libasmP.h | 4 | ||||
-rw-r--r-- | libebl/ChangeLog | 10 | ||||
-rw-r--r-- | libebl/Makefile.am | 3 | ||||
-rw-r--r-- | libebl/eblelfclass.c | 27 | ||||
-rw-r--r-- | libebl/eblelfdata.c | 27 | ||||
-rw-r--r-- | libebl/eblelfmachine.c | 27 | ||||
-rw-r--r-- | libebl/eblopenbackend.c | 154 | ||||
-rw-r--r-- | libebl/libebl.h | 12 | ||||
-rw-r--r-- | libebl/libeblP.h | 5 | ||||
-rw-r--r-- | tests/ChangeLog | 12 | ||||
-rw-r--r-- | tests/Makefile.am | 18 | ||||
-rw-r--r-- | tests/asm-tst1.c | 13 | ||||
-rw-r--r-- | tests/asm-tst2.c | 13 | ||||
-rw-r--r-- | tests/asm-tst3.c | 13 | ||||
-rw-r--r-- | tests/asm-tst4.c | 13 | ||||
-rw-r--r-- | tests/asm-tst5.c | 13 | ||||
-rw-r--r-- | tests/asm-tst6.c | 13 | ||||
-rw-r--r-- | tests/asm-tst7.c | 13 | ||||
-rw-r--r-- | tests/asm-tst8.c | 13 | ||||
-rw-r--r-- | tests/asm-tst9.c | 13 |
33 files changed, 443 insertions, 171 deletions
@@ -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. diff --git a/libasm/ChangeLog b/libasm/ChangeLog index 8b7b44d2..6adeef1e 100644 --- a/libasm/ChangeLog +++ b/libasm/ChangeLog @@ -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. diff --git a/libasm/Makefile.am b/libasm/Makefile.am index 34b19d24..7802a5c0 100644 --- a/libasm/Makefile.am +++ b/libasm/Makefile.am @@ -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) diff --git a/libasm/asm_abort.c b/libasm/asm_abort.c index f35757ca..3353a023 100644 --- a/libasm/asm_abort.c +++ b/libasm/asm_abort.c @@ -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); diff --git a/libasm/asm_addint8.c b/libasm/asm_addint8.c index 35d9bf57..bbd8e5f7 100644 --- a/libasm/asm_addint8.c +++ b/libasm/asm_addint8.c @@ -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 diff --git a/libasm/asm_addsleb128.c b/libasm/asm_addsleb128.c index 0661b36e..fdefd01b 100644 --- a/libasm/asm_addsleb128.c +++ b/libasm/asm_addsleb128.c @@ -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]; diff --git a/libasm/asm_adduleb128.c b/libasm/asm_adduleb128.c index 521d265a..1685b5eb 100644 --- a/libasm/asm_adduleb128.c +++ b/libasm/asm_adduleb128.c @@ -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]; diff --git a/libasm/asm_align.c b/libasm/asm_align.c index e7350924..a52fc86d 100644 --- a/libasm/asm_align.c +++ b/libasm/asm_align.c @@ -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; diff --git a/libasm/asm_begin.c b/libasm/asm_begin.c index 3896f78f..1ded3474 100644 --- a/libasm/asm_begin.c +++ b/libasm/asm_begin.c @@ -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> @@ -30,12 +32,27 @@ 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; } diff --git a/libasm/asm_end.c b/libasm/asm_end.c index 74f01f08..33191f9c 100644 --- a/libasm/asm_end.c +++ b/libasm/asm_end.c @@ -33,7 +33,12 @@ 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; } diff --git a/libasm/asm_error.c b/libasm/asm_error.c index 9d2d81ed..3b5aa055 100644 --- a/libasm/asm_error.c +++ b/libasm/asm_error.c @@ -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 * diff --git a/libasm/asm_newscn.c b/libasm/asm_newscn.c index 75890a60..7e585325 100644 --- a/libasm/asm_newscn.c +++ b/libasm/asm_newscn.c @@ -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; } diff --git a/libasm/libasm.h b/libasm/libasm.h index dbdd6fc2..46d5e8db 100644 --- a/libasm/libasm.h +++ b/libasm/libasm.h @@ -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); diff --git a/libasm/libasmP.h b/libasm/libasmP.h index 2e4954f6..1cbec55c 100644 --- a/libasm/libasmP.h +++ b/libasm/libasmP.h @@ -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. */ }; 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; diff --git a/tests/ChangeLog b/tests/ChangeLog index 22aee322..d5926489 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -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> diff --git a/tests/Makefile.am b/tests/Makefile.am index 5560d6ee..07b87e0e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/asm-tst1.c b/tests/asm-tst1.c index b76930d0..cfaae345 100644 --- a/tests/asm-tst1.c +++ b/tests/asm-tst1.c @@ -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; } diff --git a/tests/asm-tst2.c b/tests/asm-tst2.c index a309976d..b9a1037f 100644 --- a/tests/asm-tst2.c +++ b/tests/asm-tst2.c @@ -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; } diff --git a/tests/asm-tst3.c b/tests/asm-tst3.c index fb79ea78..155613c5 100644 --- a/tests/asm-tst3.c +++ b/tests/asm-tst3.c @@ -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; } diff --git a/tests/asm-tst4.c b/tests/asm-tst4.c index 29d6485d..50c3c5a5 100644 --- a/tests/asm-tst4.c +++ b/tests/asm-tst4.c @@ -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; } diff --git a/tests/asm-tst5.c b/tests/asm-tst5.c index 4f761aed..e5881a53 100644 --- a/tests/asm-tst5.c +++ b/tests/asm-tst5.c @@ -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; } diff --git a/tests/asm-tst6.c b/tests/asm-tst6.c index ece69bc2..5ceded65 100644 --- a/tests/asm-tst6.c +++ b/tests/asm-tst6.c @@ -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; } diff --git a/tests/asm-tst7.c b/tests/asm-tst7.c index ebd45594..5c94d895 100644 --- a/tests/asm-tst7.c +++ b/tests/asm-tst7.c @@ -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; } diff --git a/tests/asm-tst8.c b/tests/asm-tst8.c index 6ce7c9c0..cfe53fca 100644 --- a/tests/asm-tst8.c +++ b/tests/asm-tst8.c @@ -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; } diff --git a/tests/asm-tst9.c b/tests/asm-tst9.c index 28bb4787..1f03d8d7 100644 --- a/tests/asm-tst9.c +++ b/tests/asm-tst9.c @@ -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; } |