summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libasm/ChangeLog17
-rw-r--r--libasm/Makefile.am5
-rw-r--r--libasm/asm_begin.c6
-rw-r--r--libasm/asm_end.c46
-rw-r--r--libasm/asm_newabssym.c4
-rw-r--r--libasm/asm_newcomsym.c4
-rw-r--r--libasm/asm_newscn.c6
-rw-r--r--libasm/asm_newscngrp.c6
-rw-r--r--libasm/asm_newsym.c8
-rw-r--r--libasm/libasmP.h14
-rw-r--r--libasm/symbolhash.c4
-rw-r--r--libasm/symbolhash.h2
-rw-r--r--libdw/ChangeLog6
-rw-r--r--libdw/libdw.map11
-rw-r--r--libdwelf/ChangeLog14
-rw-r--r--libdwelf/Makefile.am3
-rw-r--r--libdwelf/dwelf_strtab.c (renamed from libebl/eblstrtab.c)99
-rw-r--r--libdwelf/libdwelf.h55
-rw-r--r--libebl/ChangeLog13
-rw-r--r--libebl/Makefile.am2
-rw-r--r--libebl/libebl.h25
-rw-r--r--src/ChangeLog8
-rw-r--r--src/Makefile.am2
-rw-r--r--src/elfcompress.c31
-rw-r--r--src/strip.c24
-rw-r--r--src/unstrip.c50
-rw-r--r--tests/ChangeLog12
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/alldts.c24
-rw-r--r--tests/elfstrmerge.c31
-rw-r--r--tests/update3.c18
-rw-r--r--tests/update4.c42
32 files changed, 369 insertions, 231 deletions
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index afc7e8ec..4c6cb286 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,20 @@
+2016-07-08 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (AM_CPPFLAGS): Add libdwelf.
+ (libasm.so): Add libdw.
+ * asm_begin.c (prepare_binary_output): Use dwelf_strtab instead of
+ ebl_strtab.
+ * asm_end.c (binary_end): Likewise.
+ (__libasm_finictx): Likewise.
+ * asm_newabssym.c (asm_newabssym): Likewise.
+ * asm_newcomsym.c (asm_newcomsym): Likewise.
+ * asm_newscn.c (binary_newscn): Likewise.
+ * asm_newscngrp.c (asm_newscngrp): Likewise.
+ * asm_newsym.c (asm_newsym): Likewise.
+ * libasmP.h: Likewise.
+ * symbolhash.c (COMPARE): Likewise.
+ * symbolhash.h (COMPARE): Likewise.
+
2016-06-28 Richard Henderson <rth@redhat.com>
* disasm_cb.c (disasm_cb): Pass ebl to disasm hook.
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index a4bf293a..8094b05c 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -28,7 +28,7 @@
## not, see <http://www.gnu.org/licenses/>.
##
include $(top_srcdir)/config/eu.am
-AM_CPPFLAGS += -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl -I$(top_srcdir)/libdw
+AM_CPPFLAGS += -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl -I$(top_srcdir)/libdw -I$(top_srcdir)/libdwelf
GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
VERSION = 1
@@ -65,7 +65,8 @@ libasm.so$(EXEEXT): libasm_pic.a libasm.map
$(AM_V_CCLD)$(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
-Wl,--version-script,$(srcdir)/libasm.map,--no-undefined \
-Wl,--soname,$@.$(VERSION) \
- ../libebl/libebl.a ../libelf/libelf.so $(libasm_so_LDLIBS)
+ ../libebl/libebl.a ../libelf/libelf.so ../libdw/libdw.so \
+ $(libasm_so_LDLIBS)
@$(textrel_check)
$(AM_V_at)ln -fs $@ $@.$(VERSION)
diff --git a/libasm/asm_begin.c b/libasm/asm_begin.c
index dc83cd8b..6248786c 100644
--- a/libasm/asm_begin.c
+++ b/libasm/asm_begin.c
@@ -1,5 +1,5 @@
/* Create descriptor for assembling.
- Copyright (C) 2002 Red Hat, Inc.
+ Copyright (C) 2002, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -115,8 +115,8 @@ prepare_binary_output (AsmCtx_t *result, Ebl *ebl)
asm_symbol_tab_init (&result->symbol_tab, 67);
result->nsymbol_tab = 0;
/* And the string tables. */
- result->section_strtab = ebl_strtabinit (true);
- result->symbol_strtab = ebl_strtabinit (true);
+ result->section_strtab = dwelf_strtab_init (true);
+ result->symbol_strtab = dwelf_strtab_init (true);
/* We have no section groups so far. */
result->groups = NULL;
diff --git a/libasm/asm_end.c b/libasm/asm_end.c
index d21a70a3..191a535a 100644
--- a/libasm/asm_end.c
+++ b/libasm/asm_end.c
@@ -1,5 +1,5 @@
/* Finalize operations on the assembler context, free all resources.
- Copyright (C) 2002, 2003, 2005 Red Hat, Inc.
+ Copyright (C) 2002, 2003, 2005, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -62,11 +62,11 @@ static int
binary_end (AsmCtx_t *ctx)
{
void *symtab = NULL;
- struct Ebl_Strent *symscn_strent = NULL;
- struct Ebl_Strent *strscn_strent = NULL;
- struct Ebl_Strent *xndxscn_strent = NULL;
+ Dwelf_Strent *symscn_strent = NULL;
+ Dwelf_Strent *strscn_strent = NULL;
+ Dwelf_Strent *xndxscn_strent = NULL;
Elf_Scn *shstrscn;
- struct Ebl_Strent *shstrscn_strent;
+ Dwelf_Strent *shstrscn_strent;
size_t shstrscnndx;
size_t symscnndx = 0;
size_t strscnndx = 0;
@@ -136,8 +136,8 @@ binary_end (AsmCtx_t *ctx)
if (ctx->nsymbol_tab > 0)
{
/* Create the symbol table and string table section names. */
- symscn_strent = ebl_strtabadd (ctx->section_strtab, ".symtab", 8);
- strscn_strent = ebl_strtabadd (ctx->section_strtab, ".strtab", 8);
+ symscn_strent = dwelf_strtab_add_len (ctx->section_strtab, ".symtab", 8);
+ strscn_strent = dwelf_strtab_add_len (ctx->section_strtab, ".strtab", 8);
/* Create the symbol string table section. */
Elf_Scn *strscn = elf_newscn (ctx->out.elf);
@@ -150,7 +150,7 @@ binary_end (AsmCtx_t *ctx)
}
strscnndx = elf_ndxscn (strscn);
- ebl_strtabfinalize (ctx->symbol_strtab, strtabdata);
+ dwelf_strtab_finalize (ctx->symbol_strtab, strtabdata);
shdr->sh_type = SHT_STRTAB;
assert (shdr->sh_entsize == 0);
@@ -190,11 +190,11 @@ binary_end (AsmCtx_t *ctx)
uint32_t *xshndx = NULL;
AsmSym_t *sym;
while ((sym = asm_symbol_tab_iterate (&ctx->symbol_tab, &runp)) != NULL)
- if (asm_emit_symbol_p (ebl_string (sym->strent)))
+ if (asm_emit_symbol_p (dwelf_strent_str (sym->strent)))
{
assert (ptr_local <= ptr_nonlocal);
- syment.st_name = ebl_strtaboffset (sym->strent);
+ syment.st_name = dwelf_strent_off (sym->strent);
syment.st_info = GELF_ST_INFO (sym->binding, sym->type);
syment.st_other = 0;
syment.st_value = sym->scn->offset + sym->offset;
@@ -240,8 +240,9 @@ binary_end (AsmCtx_t *ctx)
(void) gelf_update_shdr (xndxscn, shdr);
- xndxscn_strent = ebl_strtabadd (ctx->section_strtab,
- ".symtab_shndx", 14);
+ xndxscn_strent = dwelf_strtab_add_len (ctx->section_strtab,
+ ".symtab_shndx",
+ 14);
/* Note that using 'elf32_fsize' instead of
'gelf_fsize' here is correct. */
@@ -299,13 +300,14 @@ binary_end (AsmCtx_t *ctx)
/* Add the name of the section header string table. */
- shstrscn_strent = ebl_strtabadd (ctx->section_strtab, ".shstrtab", 10);
+ shstrscn_strent = dwelf_strtab_add_len (ctx->section_strtab,
+ ".shstrtab", 10);
- ebl_strtabfinalize (ctx->section_strtab, shstrtabdata);
+ dwelf_strtab_finalize (ctx->section_strtab, shstrtabdata);
shdr->sh_type = SHT_STRTAB;
assert (shdr->sh_entsize == 0);
- shdr->sh_name = ebl_strtaboffset (shstrscn_strent);
+ shdr->sh_name = dwelf_strent_off (shstrscn_strent);
(void) gelf_update_shdr (shstrscn, shdr);
@@ -364,7 +366,7 @@ binary_end (AsmCtx_t *ctx)
}
/* Construct the section header. */
- shdr->sh_name = ebl_strtaboffset (runp->strent);
+ shdr->sh_name = dwelf_strent_off (runp->strent);
shdr->sh_type = SHT_GROUP;
shdr->sh_flags = 0;
shdr->sh_link = symscnndx;
@@ -386,7 +388,7 @@ binary_end (AsmCtx_t *ctx)
shdr = gelf_getshdr (scn, &shdr_mem);
- shdr->sh_name = ebl_strtaboffset (symscn_strent);
+ shdr->sh_name = dwelf_strent_off (symscn_strent);
(void) gelf_update_shdr (scn, shdr);
@@ -397,7 +399,7 @@ binary_end (AsmCtx_t *ctx)
shdr = gelf_getshdr (scn, &shdr_mem);
- shdr->sh_name = ebl_strtaboffset (strscn_strent);
+ shdr->sh_name = dwelf_strent_off (strscn_strent);
(void) gelf_update_shdr (scn, shdr);
@@ -409,7 +411,7 @@ binary_end (AsmCtx_t *ctx)
shdr = gelf_getshdr (scn, &shdr_mem);
- shdr->sh_name = ebl_strtaboffset (xndxscn_strent);
+ shdr->sh_name = dwelf_strent_off (xndxscn_strent);
(void) gelf_update_shdr (scn, shdr);
}
@@ -423,7 +425,7 @@ binary_end (AsmCtx_t *ctx)
/* This better should not fail. */
assert (shdr != NULL);
- shdr->sh_name = ebl_strtaboffset (asmscn->data.main.strent);
+ shdr->sh_name = dwelf_strent_off (asmscn->data.main.strent);
/* We now know the maximum alignment. */
shdr->sh_addralign = asmscn->max_align;
@@ -600,8 +602,8 @@ __libasm_finictx (AsmCtx_t *ctx)
(void) close (ctx->fd);
/* And the string tables. */
- ebl_strtabfree (ctx->section_strtab);
- ebl_strtabfree (ctx->symbol_strtab);
+ dwelf_strtab_free (ctx->section_strtab);
+ dwelf_strtab_free (ctx->symbol_strtab);
}
/* Initialize the lock. */
diff --git a/libasm/asm_newabssym.c b/libasm/asm_newabssym.c
index c5b7beaa..34fef3e3 100644
--- a/libasm/asm_newabssym.c
+++ b/libasm/asm_newabssym.c
@@ -1,5 +1,5 @@
/* Create new ABS symbol.
- Copyright (C) 2002 Red Hat, Inc.
+ Copyright (C) 2002, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -80,7 +80,7 @@ asm_newabssym (AsmCtx_t *ctx, const char *name, GElf_Xword size,
result->type = type;
result->binding = binding;
result->symidx = 0;
- result->strent = ebl_strtabadd (ctx->symbol_strtab, name, 0);
+ result->strent = dwelf_strtab_add (ctx->symbol_strtab, name);
/* The value of an ABS symbol must not be modified. Since there are
no subsection and the initial offset of the section is 0 we can
diff --git a/libasm/asm_newcomsym.c b/libasm/asm_newcomsym.c
index ee5c1409..ee3b6966 100644
--- a/libasm/asm_newcomsym.c
+++ b/libasm/asm_newcomsym.c
@@ -1,5 +1,5 @@
/* Create new COMMON symbol.
- Copyright (C) 2002 Red Hat, Inc.
+ Copyright (C) 2002, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -82,7 +82,7 @@ asm_newcomsym (AsmCtx_t *ctx, const char *name, GElf_Xword size,
/* XXX Do we have to allow a different binding? */
result->binding = STB_GLOBAL;
result->symidx = 0;
- result->strent = ebl_strtabadd (ctx->symbol_strtab, name, 0);
+ result->strent = dwelf_strtab_add (ctx->symbol_strtab, name);
/* The value of a COM symbol is the alignment. Since there are no
subsection and the initial offset of the section is 0 we can get
diff --git a/libasm/asm_newscn.c b/libasm/asm_newscn.c
index e2367693..ddbb25df 100644
--- a/libasm/asm_newscn.c
+++ b/libasm/asm_newscn.c
@@ -1,5 +1,5 @@
/* Create new section in output file.
- Copyright (C) 2002-2011 Red Hat, Inc.
+ Copyright (C) 2002-2011, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -129,8 +129,8 @@ binary_newscn (AsmScn_t *result, GElf_Word type, GElf_Xword flags,
result->subnext = NULL;
/* Add the name to the section header string table. */
- result->data.main.strent = ebl_strtabadd (result->ctx->section_strtab,
- result->name, scnname_len);
+ result->data.main.strent = dwelf_strtab_add_len (result->ctx->section_strtab,
+ result->name, scnname_len);
assert (result->data.main.strent != NULL);
/* Create the new ELF section. */
diff --git a/libasm/asm_newscngrp.c b/libasm/asm_newscngrp.c
index c5968c1f..80757a9a 100644
--- a/libasm/asm_newscngrp.c
+++ b/libasm/asm_newscngrp.c
@@ -1,5 +1,5 @@
/* Create new section group.
- Copyright (C) 2002 Red Hat, Inc.
+ Copyright (C) 2002, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -67,8 +67,8 @@ asm_newscngrp (AsmCtx_t *ctx, const char *grpname, AsmSym_t *signature,
result->flags = flags;
memcpy (result->name, grpname, grpname_len);
- result->strent = ebl_strtabadd (ctx->section_strtab, result->name,
- grpname_len);
+ result->strent = dwelf_strtab_add_len (ctx->section_strtab, result->name,
+ grpname_len);
if (unlikely (ctx->textp))
// XXX TBI. What is the format?
diff --git a/libasm/asm_newsym.c b/libasm/asm_newsym.c
index 7f522910..332432a9 100644
--- a/libasm/asm_newsym.c
+++ b/libasm/asm_newsym.c
@@ -1,5 +1,5 @@
/* Define new symbol for current position in given section.
- Copyright (C) 2002, 2005 Red Hat, Inc.
+ Copyright (C) 2002, 2005, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -83,8 +83,8 @@ asm_newsym (AsmScn_t *asmscn, const char *name, GElf_Xword size,
result->type = type;
result->binding = binding;
result->symidx = 0;
- result->strent = ebl_strtabadd (asmscn->ctx->symbol_strtab,
- memcpy (result + 1, name, name_len), 0);
+ result->strent = dwelf_strtab_add (asmscn->ctx->symbol_strtab,
+ memcpy (result + 1, name, name_len));
if (unlikely (asmscn->ctx->textp))
{
@@ -118,7 +118,7 @@ asm_newsym (AsmScn_t *asmscn, const char *name, GElf_Xword size,
reference in the string table to the string. We can only
fail to insert the symbol into the symbol table if there
is already a symbol with this name. In this case the
- ebl_strtabadd function would use the previously provided
+ dwelf_strtab_add function would use the previously provided
name. */
free (result);
result = NULL;
diff --git a/libasm/libasmP.h b/libasm/libasmP.h
index 49b64846..54460cf9 100644
--- a/libasm/libasmP.h
+++ b/libasm/libasmP.h
@@ -1,5 +1,5 @@
/* Internal definitions for libasm.
- Copyright (C) 2002, 2004, 2005 Red Hat, Inc.
+ Copyright (C) 2002, 2004, 2005, 2016 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -33,6 +33,8 @@
#include <libasm.h>
+#include "libdwelf.h"
+
/* gettext helper macros. */
#define _(Str) dgettext ("elfutils", Str)
@@ -85,7 +87,7 @@ struct AsmScn
Elf_Scn *scn;
/* Entry in the section header string table. */
- struct Ebl_Strent *strent;
+ Dwelf_Strent *strent;
/* Next member of group. */
struct AsmScn *next_in_group;
@@ -156,14 +158,14 @@ struct AsmCtx
/* List with defined sections. */
AsmScn_t *section_list;
/* Section header string table. */
- struct Ebl_Strtab *section_strtab;
+ Dwelf_Strtab *section_strtab;
/* Table with defined symbols. */
asm_symbol_tab symbol_tab;
/* Number of symbols in the table. */
unsigned int nsymbol_tab;
/* Symbol string table. */
- struct Ebl_Strtab *symbol_strtab;
+ Dwelf_Strtab *symbol_strtab;
/* List of section groups. */
struct AsmScnGrp *groups;
@@ -207,7 +209,7 @@ struct AsmSym
size_t symidx;
/* Reference to name of the symbol. */
- struct Ebl_Strent *strent;
+ Dwelf_Strent *strent;
};
@@ -215,7 +217,7 @@ struct AsmSym
struct AsmScnGrp
{
/* Entry in the section header string table. */
- struct Ebl_Strent *strent;
+ Dwelf_Strent *strent;
/* The ELF section. */
Elf_Scn *scn;
diff --git a/libasm/symbolhash.c b/libasm/symbolhash.c
index 1c954182..57c9e76d 100644
--- a/libasm/symbolhash.c
+++ b/libasm/symbolhash.c
@@ -1,5 +1,5 @@
/* Symbol hash table implementation.
- Copyright (C) 2001, 2002 Red Hat, Inc.
+ Copyright (C) 2001, 2002, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2001.
@@ -42,7 +42,7 @@
#define ITERATE 1
#define REVERSE 1
#define COMPARE(a, b) \
- strcmp (ebl_string ((a)->strent), ebl_string ((b)->strent))
+ strcmp (dwelf_strent_str ((a)->strent), dwelf_strent_str ((b)->strent))
#define next_prime __libasm_next_prime
extern size_t next_prime (size_t) attribute_hidden;
diff --git a/libasm/symbolhash.h b/libasm/symbolhash.h
index a5bceffb..d05a40a5 100644
--- a/libasm/symbolhash.h
+++ b/libasm/symbolhash.h
@@ -34,7 +34,7 @@
#define NAME asm_symbol_tab
#define ITERATE 1
#define COMPARE(a, b) \
- strcmp (ebl_string ((a)->strent), ebl_string ((b)->strent))
+ strcmp (dwelf_strent_str ((a)->strent), dwelf_strent_str ((b)->strent))
#include <dynamicsizehash.h>
#endif /* symbolhash.h */
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 36c332ae..8071fc14 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,9 @@
+2016-07-08 Mark Wielaard <mjw@redhat.com>
+
+ * libdw.map (ELFUTILS_0.167): New. Add dwelf_strtab_init,
+ dwelf_strtab_add, dwelf_strtab_add_len, dwelf_strtab_finalize,
+ dwelf_strent_off, dwelf_strent_str and dwelf_strtab_free.
+
2016-02-13 Mark Wielaard <mjw@redhat.com>
* dwarf_getsrclines.c (read_srclines): Calculate ndirs first, then
diff --git a/libdw/libdw.map b/libdw/libdw.map
index 1681b6b5..83cb1d97 100644
--- a/libdw/libdw.map
+++ b/libdw/libdw.map
@@ -327,3 +327,14 @@ ELFUTILS_0.165 {
global:
dwelf_scn_gnu_compressed_size;
} ELFUTILS_0.161;
+
+ELFUTILS_0.167 {
+ global:
+ dwelf_strtab_init;
+ dwelf_strtab_add;
+ dwelf_strtab_add_len;
+ dwelf_strtab_finalize;
+ dwelf_strent_off;
+ dwelf_strent_str;
+ dwelf_strtab_free;
+} ELFUTILS_0.165;
diff --git a/libdwelf/ChangeLog b/libdwelf/ChangeLog
index fe8af1b4..4211023c 100644
--- a/libdwelf/ChangeLog
+++ b/libdwelf/ChangeLog
@@ -1,3 +1,17 @@
+2016-07-08 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (libdwelf_a_SOURCES): Add dwelf_strtab.c.
+ * dwelf_strtab.c: New file.
+ * libdwelf.h (Dwelf_Strtab): New typedef.
+ (Dwelf_Strent): Likewise.
+ (dwelf_strtab_init): New function.
+ (dwelf_strtab_add): Likewise.
+ (dwelf_strtab_add_len): Likewise.
+ (dwelf_strtab_finalize): Likewise.
+ (dwelf_strent_off): Likewise.
+ (dwelf_strent_str): Likewise.
+ (dwelf_strtab_free): Likewise.
+
2015-10-28 Mark Wielaard <mjw@redhat.com>
* Makefile.am (libdwelf_a_SOURCES): Add
diff --git a/libdwelf/Makefile.am b/libdwelf/Makefile.am
index 4de4b2ed..7ca767a9 100644
--- a/libdwelf/Makefile.am
+++ b/libdwelf/Makefile.am
@@ -40,7 +40,8 @@ pkginclude_HEADERS = libdwelf.h
noinst_HEADERS = libdwelfP.h
libdwelf_a_SOURCES = dwelf_elf_gnu_debuglink.c dwelf_dwarf_gnu_debugaltlink.c \
- dwelf_elf_gnu_build_id.c dwelf_scn_gnu_compressed_size.c
+ dwelf_elf_gnu_build_id.c dwelf_scn_gnu_compressed_size.c \
+ dwelf_strtab.c
libdwelf = $(libdw)
diff --git a/libebl/eblstrtab.c b/libdwelf/dwelf_strtab.c
index 798c34c3..c1b93d4a 100644
--- a/libebl/eblstrtab.c
+++ b/libdwelf/dwelf_strtab.c
@@ -1,5 +1,5 @@
-/* ELF string table handling.
- Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
+/* ELF/DWARF string table handling.
+ Copyright (C) 2000, 2001, 2002, 2005, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -40,7 +40,7 @@
#include <unistd.h>
#include <sys/param.h>
-#include "libebl.h"
+#include "libdwelfP.h"
#include <system.h>
#ifndef MIN
@@ -48,13 +48,13 @@
#endif
-struct Ebl_Strent
+struct Dwelf_Strent
{
const char *string;
size_t len;
- struct Ebl_Strent *next;
- struct Ebl_Strent *left;
- struct Ebl_Strent *right;
+ struct Dwelf_Strent *next;
+ struct Dwelf_Strent *left;
+ struct Dwelf_Strent *right;
size_t offset;
char reverse[0];
};
@@ -67,16 +67,16 @@ struct memoryblock
};
-struct Ebl_Strtab
+struct Dwelf_Strtab
{
- struct Ebl_Strent *root;
+ struct Dwelf_Strent *root;
struct memoryblock *memory;
char *backp;
size_t left;
size_t total;
bool nullstr;
- struct Ebl_Strent null;
+ struct Dwelf_Strent null;
};
@@ -87,8 +87,8 @@ static size_t ps;
#define MALLOC_OVERHEAD (2 * sizeof (void *))
-struct Ebl_Strtab *
-ebl_strtabinit (bool nullstr)
+Dwelf_Strtab *
+dwelf_strtab_init (bool nullstr)
{
if (ps == 0)
{
@@ -96,8 +96,8 @@ ebl_strtabinit (bool nullstr)
assert (sizeof (struct memoryblock) < ps - MALLOC_OVERHEAD);
}
- struct Ebl_Strtab *ret
- = (struct Ebl_Strtab *) calloc (1, sizeof (struct Ebl_Strtab));
+ Dwelf_Strtab *ret
+ = (Dwelf_Strtab *) calloc (1, sizeof (struct Dwelf_Strtab));
if (ret != NULL)
{
ret->nullstr = nullstr;
@@ -114,7 +114,7 @@ ebl_strtabinit (bool nullstr)
static int
-morememory (struct Ebl_Strtab *st, size_t len)
+morememory (Dwelf_Strtab *st, size_t len)
{
size_t overhead = offsetof (struct memoryblock, memory);
len += overhead + MALLOC_OVERHEAD;
@@ -136,7 +136,7 @@ morememory (struct Ebl_Strtab *st, size_t len)
void
-ebl_strtabfree (struct Ebl_Strtab *st)
+dwelf_strtab_free (Dwelf_Strtab *st)
{
struct memoryblock *mb = st->memory;
@@ -151,26 +151,26 @@ ebl_strtabfree (struct Ebl_Strtab *st)
}
-static struct Ebl_Strent *
-newstring (struct Ebl_Strtab *st, const char *str, size_t len)
+static Dwelf_Strent *
+newstring (Dwelf_Strtab *st, const char *str, size_t len)
{
/* Compute the amount of padding needed to make the structure aligned. */
- size_t align = ((__alignof__ (struct Ebl_Strent)
+ size_t align = ((__alignof__ (struct Dwelf_Strent)
- (((uintptr_t) st->backp)
- & (__alignof__ (struct Ebl_Strent) - 1)))
- & (__alignof__ (struct Ebl_Strent) - 1));
+ & (__alignof__ (struct Dwelf_Strent) - 1)))
+ & (__alignof__ (struct Dwelf_Strent) - 1));
/* Make sure there is enough room in the memory block. */
- if (st->left < align + sizeof (struct Ebl_Strent) + len)
+ if (st->left < align + sizeof (struct Dwelf_Strent) + len)
{
- if (morememory (st, sizeof (struct Ebl_Strent) + len))
+ if (morememory (st, sizeof (struct Dwelf_Strent) + len))
return NULL;
align = 0;
}
/* Create the reserved string. */
- struct Ebl_Strent *newstr = (struct Ebl_Strent *) (st->backp + align);
+ Dwelf_Strent *newstr = (Dwelf_Strent *) (st->backp + align);
newstr->string = str;
newstr->len = len;
newstr->next = NULL;
@@ -180,8 +180,8 @@ newstring (struct Ebl_Strtab *st, const char *str, size_t len)
for (int i = len - 2; i >= 0; --i)
newstr->reverse[i] = str[len - 2 - i];
newstr->reverse[len - 1] = '\0';
- st->backp += align + sizeof (struct Ebl_Strent) + len;
- st->left -= align + sizeof (struct Ebl_Strent) + len;
+ st->backp += align + sizeof (struct Dwelf_Strent) + len;
+ st->left -= align + sizeof (struct Dwelf_Strent) + len;
return newstr;
}
@@ -190,8 +190,8 @@ newstring (struct Ebl_Strtab *st, const char *str, size_t len)
/* XXX This function should definitely be rewritten to use a balancing
tree algorith (AVL, red-black trees). For now a simple, correct
implementation is enough. */
-static struct Ebl_Strent **
-searchstring (struct Ebl_Strent **sep, struct Ebl_Strent *newstr)
+static Dwelf_Strent **
+searchstring (Dwelf_Strent **sep, Dwelf_Strent *newstr)
{
/* More strings? */
if (*sep == NULL)
@@ -214,34 +214,30 @@ searchstring (struct Ebl_Strent **sep, struct Ebl_Strent *newstr)
/* Add new string. The actual string is assumed to be permanent. */
-struct Ebl_Strent *
-ebl_strtabadd (struct Ebl_Strtab *st, const char *str, size_t len)
+static Dwelf_Strent *
+strtab_add (Dwelf_Strtab *st, const char *str, size_t len)
{
- /* Compute the string length if the caller doesn't know it. */
- if (len == 0)
- len = strlen (str) + 1;
-
/* Make sure all "" strings get offset 0 but only if the table was
created with a special null entry in mind. */
if (len == 1 && st->null.string != NULL)
return &st->null;
/* Allocate memory for the new string and its associated information. */
- struct Ebl_Strent *newstr = newstring (st, str, len);
+ Dwelf_Strent *newstr = newstring (st, str, len);
if (newstr == NULL)
return NULL;
/* Search in the array for the place to insert the string. If there
is no string with matching prefix and no string with matching
leading substring, create a new entry. */
- struct Ebl_Strent **sep = searchstring (&st->root, newstr);
+ Dwelf_Strent **sep = searchstring (&st->root, newstr);
if (*sep != newstr)
{
/* This is not the same entry. This means we have a prefix match. */
if ((*sep)->len > newstr->len)
{
/* Check whether we already know this string. */
- for (struct Ebl_Strent *subs = (*sep)->next; subs != NULL;
+ for (Dwelf_Strent *subs = (*sep)->next; subs != NULL;
subs = subs->next)
if (subs->len == newstr->len)
{
@@ -287,9 +283,20 @@ ebl_strtabadd (struct Ebl_Strtab *st, const char *str, size_t len)
return newstr;
}
+Dwelf_Strent *
+dwelf_strtab_add (Dwelf_Strtab *st, const char *str)
+{
+ return strtab_add (st, str, strlen (str) + 1);
+}
+
+Dwelf_Strent *
+dwelf_strtab_add_len (Dwelf_Strtab *st, const char *str, size_t len)
+{
+ return strtab_add (st, str, len);
+}
static void
-copystrings (struct Ebl_Strent *nodep, char **freep, size_t *offsetp)
+copystrings (Dwelf_Strent *nodep, char **freep, size_t *offsetp)
{
if (nodep->left != NULL)
copystrings (nodep->left, freep, offsetp);
@@ -299,7 +306,7 @@ copystrings (struct Ebl_Strent *nodep, char **freep, size_t *offsetp)
*freep = (char *) mempcpy (*freep, nodep->string, nodep->len);
*offsetp += nodep->len;
- for (struct Ebl_Strent *subs = nodep->next; subs != NULL; subs = subs->next)
+ for (Dwelf_Strent *subs = nodep->next; subs != NULL; subs = subs->next)
{
assert (subs->len < nodep->len);
subs->offset = nodep->offset + nodep->len - subs->len;
@@ -311,15 +318,15 @@ copystrings (struct Ebl_Strent *nodep, char **freep, size_t *offsetp)
}
-void
-ebl_strtabfinalize (struct Ebl_Strtab *st, Elf_Data *data)
+Elf_Data *
+dwelf_strtab_finalize (Dwelf_Strtab *st, Elf_Data *data)
{
size_t nulllen = st->nullstr ? 1 : 0;
/* Fill in the information. */
data->d_buf = malloc (st->total + nulllen);
if (data->d_buf == NULL)
- abort ();
+ return NULL;
/* The first byte must always be zero if we created the table with a
null string. */
@@ -339,20 +346,20 @@ ebl_strtabfinalize (struct Ebl_Strtab *st, Elf_Data *data)
if (st->root)
copystrings (st->root, &endp, &copylen);
assert (copylen == st->total + nulllen);
+
+ return data;
}
size_t
-ebl_strtaboffset (struct Ebl_Strent *se)
+dwelf_strent_off (Dwelf_Strent *se)
{
return se->offset;
}
const char *
-ebl_string (struct Ebl_Strent *se)
+dwelf_strent_str (Dwelf_Strent *se)
{
- assert (se->string != NULL);
-
return se->string;
}
diff --git a/libdwelf/libdwelf.h b/libdwelf/libdwelf.h
index 7f7f679a..72089dbf 100644
--- a/libdwelf/libdwelf.h
+++ b/libdwelf/libdwelf.h
@@ -1,5 +1,5 @@
/* Interfaces for libdwelf. DWARF ELF Low-level Functions.
- Copyright (C) 2014, 2015 Red Hat, Inc.
+ Copyright (C) 2014, 2015, 2016 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -72,6 +72,59 @@ extern ssize_t dwelf_elf_gnu_build_id (Elf *elf, const void **build_idp);
error occured -1 is returned and elf_errno is set. */
extern ssize_t dwelf_scn_gnu_compressed_size (Elf_Scn *scn);
+/* ELF/DWARF string table handling. */
+typedef struct Dwelf_Strtab Dwelf_Strtab;
+typedef struct Dwelf_Strent Dwelf_Strent;
+
+/* Create a new ELF/DWARF string table object in memory. ELF string
+ tables have a required zero length null string at offset zero.
+ DWARF string tables don't require such a null entry (unless they
+ are shared with an ELF string table). If NULLSTR is true then a
+ null entry is always created (even if the string table is empty
+ otherwise). */
+extern Dwelf_Strtab *dwelf_strtab_init (bool nullstr);
+
+/* Add string STR to string table ST. Returns NULL if no memory could
+ be allocated. The given STR is owned by the called and must be
+ valid till dwelf_strtab_free is called. dwelf_strtab_finalize
+ might copy the string into the final table and dwelf_strent_str
+ might return it, or a reference to an identical copy/substring
+ added to the string table. */
+extern Dwelf_Strent *dwelf_strtab_add (Dwelf_Strtab *st, const char *str)
+ __nonnull_attribute__ (1, 2);
+
+/* This is an optimized version of dwelf_strtab_add if the length of
+ the string is already known. LEN is the length of STR including
+ zero terminator. Calling dwelf_strtab_add (st, str) is similar to
+ calling dwelf_strtab_len (st, str, strlen (str) + 1). */
+extern Dwelf_Strent *dwelf_strtab_add_len (Dwelf_Strtab *st,
+ const char *str, size_t len)
+ __nonnull_attribute__ (1, 2);
+
+/* Finalize string table ST and store size and memory location
+ information in DATA d_size and d_buf. DATA d_type will be set to
+ ELF_T_BYTE, d_off will be zero, d_align will be 1 and d_version
+ will be set to EV_CURRENT. If no memory could be allocated NULL is
+ returned and DATA->d_buf will be set to NULL. Otherwise DATA will
+ be returned. */
+extern Elf_Data *dwelf_strtab_finalize (Dwelf_Strtab *st,
+ Elf_Data *data)
+ __nonnull_attribute__ (1, 2);
+
+/* Get offset in string table for string associated with entry. Only
+ valid after dwelf_strtab_finalize has been called. */
+extern size_t dwelf_strent_off (Dwelf_Strent *se)
+ __nonnull_attribute__ (1);
+
+/* Return the string associated with the entry. */
+extern const char *dwelf_strent_str (Dwelf_Strent *se)
+ __nonnull_attribute__ (1);
+
+/* Free resources allocated for the string table. This invalidates
+ any Dwelf_Strent references returned earlier. */
+extern void dwelf_strtab_free (Dwelf_Strtab *st)
+ __nonnull_attribute__ (1);
+
#ifdef __cplusplus
}
#endif
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index fc3cf3b8..0560c6ac 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,16 @@
+2016-07-08 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (gen_SOURCES): Remove eblstrtab.c.
+ * eblstrtab.c: Removed.
+ * libebl.h (Ebl_Strtab): Removed.
+ (Ebl_Strent): Removed.
+ (ebl_strtabinit): Removed.
+ (ebl_strtabfree): Removed.
+ (ebl_strtabadd): Removed.
+ (ebl_strtabfinalize): Removed.
+ (ebl_strtaboffset): Removed.
+ (ebl_string): Removed.
+
2016-07-06 Mark Wielaard <mjw@redhat.com>
* Makefile.am (gen_SOURCES): Remove eblobjecttypename.c,
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index 3bd4abea..6f945eb8 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -37,7 +37,7 @@ lib_LIBRARIES = libebl.a
pkginclude_HEADERS = libebl.h
-gen_SOURCES = eblopenbackend.c eblclosebackend.c eblstrtab.c \
+gen_SOURCES = eblopenbackend.c eblclosebackend.c \
eblreloctypename.c eblsegmenttypename.c \
eblsectiontypename.c eblmachineflagname.c \
eblsymboltypename.c ebldynamictagname.c eblsectionname.c \
diff --git a/libebl/libebl.h b/libebl/libebl.h
index cef71574..c8e01fe9 100644
--- a/libebl/libebl.h
+++ b/libebl/libebl.h
@@ -287,31 +287,6 @@ extern int ebl_syscall_abi (Ebl *ebl, int *sp, int *pc,
extern int ebl_abi_cfi (Ebl *ebl, Dwarf_CIE *abi_info)
__nonnull_attribute__ (2);
-/* ELF string table handling. */
-struct Ebl_Strtab;
-struct Ebl_Strent;
-
-/* Create new ELF string table object in memory. */
-extern struct Ebl_Strtab *ebl_strtabinit (bool nullstr);
-
-/* Free resources allocated for ELF string table ST. */
-extern void ebl_strtabfree (struct Ebl_Strtab *st);
-
-/* Add string STR (length LEN is != 0) to ELF string table ST. */
-extern struct Ebl_Strent *ebl_strtabadd (struct Ebl_Strtab *st,
- const char *str, size_t len);
-
-/* Finalize string table ST and store size and memory location information
- in DATA. */
-extern void ebl_strtabfinalize (struct Ebl_Strtab *st, Elf_Data *data);
-
-/* Get offset in string table for string associated with SE. */
-extern size_t ebl_strtaboffset (struct Ebl_Strent *se);
-
-/* Return the string associated with SE. */
-extern const char *ebl_string (struct Ebl_Strent *se);
-
-
/* Register map info. */
typedef struct
{
diff --git a/src/ChangeLog b/src/ChangeLog
index d8de529a..e5a3fce3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
+2016-07-08 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (strip_LDADD): Add libdw.
+ * elfcompress.c (process_file): Use dwelf_strtab functions instead of
+ ebl_strtab.
+ * strip.c (handle_elf): Likewise.
+ * unstrip.c (new_shstrtab): Likewise.
+
2016-07-06 Mark Wielaard <mjw@redhat.com>
* elf32-i386.script, i386_ld.c, ld.c, ld.h, ldgeneric.c, ldlex.l,
diff --git a/src/Makefile.am b/src/Makefile.am
index 6f796b33..9bb47651 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -71,7 +71,7 @@ readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl \
$(demanglelib)
size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
-strip_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
+strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl
elflint_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
findtextrel_LDADD = $(libdw) $(libelf) $(argp_LDADD)
addr2line_LDADD = $(libdw) $(libelf) $(argp_LDADD) $(demanglelib)
diff --git a/src/elfcompress.c b/src/elfcompress.c
index d0ca469c..86cc7165 100644
--- a/src/elfcompress.c
+++ b/src/elfcompress.c
@@ -32,6 +32,7 @@
#include <unistd.h>
#include ELFUTILS_HEADER(elf)
#include ELFUTILS_HEADER(ebl)
+#include ELFUTILS_HEADER(dwelf)
#include <gelf.h>
#include "system.h"
@@ -265,9 +266,9 @@ process_file (const char *fname)
char *snamebuf = NULL;
/* String table (and symbol table), if section names need adjusting. */
- struct Ebl_Strtab *names = NULL;
- struct Ebl_Strent **scnstrents = NULL;
- struct Ebl_Strent **symstrents = NULL;
+ Dwelf_Strtab *names = NULL;
+ Dwelf_Strent **scnstrents = NULL;
+ Dwelf_Strent **symstrents = NULL;
char **scnnames = NULL;
/* Section data from names. */
@@ -308,7 +309,7 @@ process_file (const char *fname)
free (snamebuf);
if (names != NULL)
{
- ebl_strtabfree (names);
+ dwelf_strtab_free (names);
free (scnstrents);
free (symstrents);
free (namesbuf);
@@ -524,14 +525,14 @@ process_file (const char *fname)
if (adjust_names)
{
- names = ebl_strtabinit (true);
+ names = dwelf_strtab_init (true);
if (names == NULL)
{
error (0, 0, "Not enough memory for new strtab");
return cleanup (-1);
}
scnstrents = xmalloc (shnum
- * sizeof (struct Ebl_Strent *));
+ * sizeof (Dwelf_Strent *));
scnnames = xcalloc (shnum, sizeof (char *));
}
@@ -870,7 +871,7 @@ process_file (const char *fname)
/* We need to keep a copy of the name till the strtab is done. */
name = scnnames[ndx] = xstrdup (name);
- if ((scnstrents[ndx] = ebl_strtabadd (names, name, 0)) == NULL)
+ if ((scnstrents[ndx] = dwelf_strtab_add (names, name)) == NULL)
{
error (0, 0, "No memory to add section name string table");
return cleanup (-1);
@@ -916,7 +917,7 @@ process_file (const char *fname)
}
size_t elsize = gelf_fsize (elfnew, ELF_T_SYM, 1, EV_CURRENT);
size_t syms = symd->d_size / elsize;
- symstrents = xmalloc (syms * sizeof (struct Ebl_Strent *));
+ symstrents = xmalloc (syms * sizeof (Dwelf_Strent *));
for (size_t i = 0; i < syms; i++)
{
GElf_Sym sym_mem;
@@ -938,7 +939,7 @@ process_file (const char *fname)
error (0, 0, "Couldn't get symbol %zd name", i);
return cleanup (-1);
}
- symstrents[i] = ebl_strtabadd (names, symname, 0);
+ symstrents[i] = dwelf_strtab_add (names, symname);
if (symstrents[i] == NULL)
{
error (0, 0, "No memory to add to symbol name");
@@ -970,7 +971,11 @@ process_file (const char *fname)
error (0, 0, "Couldn't create new section header string table data");
return cleanup (-1);
}
- ebl_strtabfinalize (names, data);
+ if (dwelf_strtab_finalize (names, data) == NULL)
+ {
+ error (0, 0, "Not enough memory to create string table");
+ return cleanup (-1);
+ }
namesbuf = data->d_buf;
GElf_Shdr shdr_mem;
@@ -984,7 +989,7 @@ process_file (const char *fname)
/* Note that we also might have to compress and possibly set
sh_off below */
- shdr->sh_name = ebl_strtaboffset (scnstrents[shdrstrndx]);
+ shdr->sh_name = dwelf_strent_off (scnstrents[shdrstrndx]);
shdr->sh_type = SHT_STRTAB;
shdr->sh_flags = 0;
shdr->sh_addr = 0;
@@ -1099,7 +1104,7 @@ process_file (const char *fname)
}
if (adjust_names)
- shdr->sh_name = ebl_strtaboffset (scnstrents[ndx]);
+ shdr->sh_name = dwelf_strent_off (scnstrents[ndx]);
if (gelf_update_shdr (scn, shdr) == 0)
{
@@ -1133,7 +1138,7 @@ process_file (const char *fname)
if (sym->st_name != 0)
{
- sym->st_name = ebl_strtaboffset (symstrents[i]);
+ sym->st_name = dwelf_strent_off (symstrents[i]);
if (gelf_update_sym (symd, i, sym) == 0)
{
diff --git a/src/strip.c b/src/strip.c
index a6042445..23d3d51b 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -42,6 +42,7 @@
#include <elf-knowledge.h>
#include <libebl.h>
+#include "libdwelf.h"
#include <system.h>
typedef uint8_t GElf_Byte;
@@ -432,7 +433,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
Elf32_Word group_idx;
Elf32_Word group_cnt;
Elf_Scn *newscn;
- struct Ebl_Strent *se;
+ Dwelf_Strent *se;
Elf32_Word *newsymidx;
} *shdr_info = NULL;
Elf_Scn *scn;
@@ -443,7 +444,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
GElf_Ehdr *newehdr;
GElf_Ehdr debugehdr_mem;
GElf_Ehdr *debugehdr;
- struct Ebl_Strtab *shst = NULL;
+ Dwelf_Strtab *shst = NULL;
Elf_Data debuglink_crc_data;
bool any_symtab_changes = false;
Elf_Data *shstrtab_data = NULL;
@@ -1043,7 +1044,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
will already be marked as unused. */
/* We need a string table for the section headers. */
- shst = ebl_strtabinit (true);
+ shst = dwelf_strtab_init (true);
if (shst == NULL)
{
cleanup_debug ();
@@ -1071,7 +1072,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
elf_assert (elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
/* Add this name to the section header string table. */
- shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
+ shdr_info[cnt].se = dwelf_strtab_add (shst, shdr_info[cnt].name);
}
/* Test whether we are doing anything at all. */
@@ -1083,7 +1084,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
if (debug_fname != NULL && !remove_shdrs)
{
/* Add the section header string table section name. */
- shdr_info[cnt].se = ebl_strtabadd (shst, ".gnu_debuglink", 15);
+ shdr_info[cnt].se = dwelf_strtab_add_len (shst, ".gnu_debuglink", 15);
shdr_info[cnt].idx = idx++;
/* Create the section header. */
@@ -1146,7 +1147,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
shdridx = cnt;
/* Add the section header string table section name. */
- shdr_info[cnt].se = ebl_strtabadd (shst, ".shstrtab", 10);
+ shdr_info[cnt].se = dwelf_strtab_add_len (shst, ".shstrtab", 10);
shdr_info[cnt].idx = idx;
/* Create the section header. */
@@ -1183,7 +1184,12 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
gettext ("while create section header string table: %s"),
elf_errmsg (-1));
}
- ebl_strtabfinalize (shst, shstrtab_data);
+ if (dwelf_strtab_finalize (shst, shstrtab_data) == NULL)
+ {
+ cleanup_debug ();
+ error (EXIT_FAILURE, 0,
+ gettext ("no memory to create section header string table"));
+ }
/* We have to set the section size. */
shdr_info[cnt].shdr.sh_size = shstrtab_data->d_size;
@@ -1199,7 +1205,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
elf_assert (scn != NULL);
/* Update the name. */
- shdr_info[cnt].shdr.sh_name = ebl_strtaboffset (shdr_info[cnt].se);
+ shdr_info[cnt].shdr.sh_name = dwelf_strent_off (shdr_info[cnt].se);
/* Update the section header from the input file. Some fields
might be section indeces which now have to be adjusted. */
@@ -2171,7 +2177,7 @@ while computing checksum for debug information"));
if (shstrtab_data != NULL)
free (shstrtab_data->d_buf);
if (shst != NULL)
- ebl_strtabfree (shst);
+ dwelf_strtab_free (shst);
/* That was it. Close the descriptors. */
if (elf_end (newelf) != 0)
diff --git a/src/unstrip.c b/src/unstrip.c
index adeb5991..46737381 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -48,6 +48,7 @@
#include <gelf.h>
#include <libebl.h>
#include <libdwfl.h>
+#include "libdwelf.h"
#include "system.h"
#ifndef _
@@ -686,7 +687,7 @@ struct section
Elf_Scn *scn;
const char *name;
Elf_Scn *outscn;
- struct Ebl_Strent *strent;
+ Dwelf_Strent *strent;
GElf_Shdr shdr;
};
@@ -757,7 +758,7 @@ struct symbol
union
{
const char *name;
- struct Ebl_Strent *strent;
+ Dwelf_Strent *strent;
};
union
{
@@ -1214,12 +1215,12 @@ static Elf_Data *
new_shstrtab (Elf *unstripped, size_t unstripped_shnum,
Elf_Data *shstrtab, size_t unstripped_shstrndx,
struct section *sections, size_t stripped_shnum,
- struct Ebl_Strtab *strtab)
+ Dwelf_Strtab *strtab)
{
if (strtab == NULL)
return NULL;
- struct Ebl_Strent *unstripped_strent[unstripped_shnum - 1];
+ Dwelf_Strent *unstripped_strent[unstripped_shnum - 1];
memset (unstripped_strent, 0, sizeof unstripped_strent);
for (struct section *sec = sections;
sec < &sections[stripped_shnum - 1];
@@ -1228,7 +1229,7 @@ new_shstrtab (Elf *unstripped, size_t unstripped_shnum,
{
if (sec->strent == NULL)
{
- sec->strent = ebl_strtabadd (strtab, sec->name, 0);
+ sec->strent = dwelf_strtab_add (strtab, sec->name);
ELF_CHECK (sec->strent != NULL,
_("cannot add section name to string table: %s"));
}
@@ -1243,7 +1244,7 @@ new_shstrtab (Elf *unstripped, size_t unstripped_shnum,
GElf_Shdr shdr_mem;
GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
const char *name = get_section_name (i + 1, shdr, shstrtab);
- unstripped_strent[i] = ebl_strtabadd (strtab, name, 0);
+ unstripped_strent[i] = dwelf_strtab_add (strtab, name);
ELF_CHECK (unstripped_strent[i] != NULL,
_("cannot add section name to string table: %s"));
}
@@ -1255,7 +1256,8 @@ new_shstrtab (Elf *unstripped, size_t unstripped_shnum,
unstripped_shstrndx), NULL);
ELF_CHECK (elf_flagdata (strtab_data, ELF_C_SET, ELF_F_DIRTY),
_("cannot update section header string table data: %s"));
- ebl_strtabfinalize (strtab, strtab_data);
+ if (dwelf_strtab_finalize (strtab, strtab_data) == NULL)
+ error (EXIT_FAILURE, 0, "Not enough memory to create string table");
/* Update the sh_name fields of sections we aren't modifying later. */
for (size_t i = 0; i < unstripped_shnum - 1; ++i)
@@ -1264,7 +1266,7 @@ new_shstrtab (Elf *unstripped, size_t unstripped_shnum,
Elf_Scn *scn = elf_getscn (unstripped, i + 1);
GElf_Shdr shdr_mem;
GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
- shdr->sh_name = ebl_strtaboffset (unstripped_strent[i]);
+ shdr->sh_name = dwelf_strent_off (unstripped_strent[i]);
if (i + 1 == unstripped_shstrndx)
shdr->sh_size = strtab_data->d_size;
update_shdr (scn, shdr);
@@ -1456,7 +1458,7 @@ more sections in stripped file than debug file -- arguments reversed?"));
const struct section *stripped_dynsym = NULL;
size_t debuglink = SHN_UNDEF;
size_t ndx_section[stripped_shnum - 1];
- struct Ebl_Strtab *strtab = NULL;
+ Dwelf_Strtab *strtab = NULL;
for (struct section *sec = sections;
sec < &sections[stripped_shnum - 1];
++sec)
@@ -1508,8 +1510,8 @@ more sections in stripped file than debug file -- arguments reversed?"));
_("cannot add new section: %s"));
if (strtab == NULL)
- strtab = ebl_strtabinit (true);
- sec->strent = ebl_strtabadd (strtab, sec->name, 0);
+ strtab = dwelf_strtab_init (true);
+ sec->strent = dwelf_strtab_add (strtab, sec->name);
ELF_CHECK (sec->strent != NULL,
_("cannot add section name to string table: %s"));
}
@@ -1570,7 +1572,7 @@ more sections in stripped file than debug file -- arguments reversed?"));
shdr_mem.sh_info = ndx_section[sec->shdr.sh_info - 1];
if (strtab != NULL)
- shdr_mem.sh_name = ebl_strtaboffset (sec->strent);
+ shdr_mem.sh_name = dwelf_strent_off (sec->strent);
Elf_Data *indata = elf_getdata (sec->scn, NULL);
ELF_CHECK (indata != NULL, _("cannot get section data: %s"));
@@ -1641,7 +1643,7 @@ more sections in stripped file than debug file -- arguments reversed?"));
/* We may need to update the symbol table. */
Elf_Data *symdata = NULL;
- struct Ebl_Strtab *symstrtab = NULL;
+ Dwelf_Strtab *symstrtab = NULL;
Elf_Data *symstrdata = NULL;
if (unstripped_symtab != NULL && (stripped_symtab != NULL
|| check_prelink /* Section adjustments. */
@@ -1721,13 +1723,13 @@ more sections in stripped file than debug file -- arguments reversed?"));
/* Now a final pass updates the map with the final order,
and builds up the new string table. */
- symstrtab = ebl_strtabinit (true);
+ symstrtab = dwelf_strtab_init (true);
for (size_t i = 0; i < nsym; ++i)
{
assert (symbols[i].name != NULL);
assert (*symbols[i].map != 0);
*symbols[i].map = 1 + i;
- symbols[i].strent = ebl_strtabadd (symstrtab, symbols[i].name, 0);
+ symbols[i].strent = dwelf_strtab_add (symstrtab, symbols[i].name);
}
/* Scan the discarded symbols too, just to update their slots
@@ -1752,7 +1754,7 @@ more sections in stripped file than debug file -- arguments reversed?"));
/* If symtab and the section header table share the string table
add the section names to the strtab and then (after finalizing)
fixup the section header sh_names. Also dispose of the old data. */
- struct Ebl_Strent *unstripped_strent[unstripped_shnum - 1];
+ Dwelf_Strent *unstripped_strent[unstripped_shnum - 1];
if (unstripped_shstrndx == elf_ndxscn (unstripped_strtab))
{
for (size_t i = 0; i < unstripped_shnum - 1; ++i)
@@ -1761,20 +1763,22 @@ more sections in stripped file than debug file -- arguments reversed?"));
GElf_Shdr mem;
GElf_Shdr *hdr = gelf_getshdr (sec, &mem);
const char *name = get_section_name (i + 1, hdr, shstrtab);
- unstripped_strent[i] = ebl_strtabadd (symstrtab, name, 0);
+ unstripped_strent[i] = dwelf_strtab_add (symstrtab, name);
ELF_CHECK (unstripped_strent[i] != NULL,
_("cannot add section name to string table: %s"));
}
if (strtab != NULL)
{
- ebl_strtabfree (strtab);
+ dwelf_strtab_free (strtab);
free (strtab_data->d_buf);
strtab = NULL;
}
}
- ebl_strtabfinalize (symstrtab, symstrdata);
+ if (dwelf_strtab_finalize (symstrtab, symstrdata) == NULL)
+ error (EXIT_FAILURE, 0, "Not enough memory to create symbol table");
+
elf_flagdata (symstrdata, ELF_C_SET, ELF_F_DIRTY);
/* And update the section header names if necessary. */
@@ -1785,7 +1789,7 @@ more sections in stripped file than debug file -- arguments reversed?"));
Elf_Scn *sec = elf_getscn (unstripped, i + 1);
GElf_Shdr mem;
GElf_Shdr *hdr = gelf_getshdr (sec, &mem);
- shdr->sh_name = ebl_strtaboffset (unstripped_strent[i]);
+ shdr->sh_name = dwelf_strent_off (unstripped_strent[i]);
update_shdr (sec, hdr);
}
}
@@ -1810,7 +1814,7 @@ more sections in stripped file than debug file -- arguments reversed?"));
struct symbol *s = &symbols[i];
/* Fill in the symbol details. */
- sym.st_name = ebl_strtaboffset (s->strent);
+ sym.st_name = dwelf_strent_off (s->strent);
sym.st_value = s->value; /* Already biased to output address. */
sym.st_size = s->size;
sym.st_shndx = s->shndx; /* Already mapped to output index. */
@@ -1959,13 +1963,13 @@ more sections in stripped file than debug file -- arguments reversed?"));
if (strtab != NULL)
{
- ebl_strtabfree (strtab);
+ dwelf_strtab_free (strtab);
free (strtab_data->d_buf);
}
if (symstrtab != NULL)
{
- ebl_strtabfree (symstrtab);
+ dwelf_strtab_free (symstrtab);
free (symstrdata->d_buf);
}
free_new_data ();
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 8fe9ee86..58a023c2 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,15 @@
+2016-07-08 Mark Wielaard <mjw@redhat.com>
+
+ * update3_LDADD: Use libdw instead of libebl.
+ * update4_LDADD: Likewise.
+ * alldts_LDADD: Likewise.
+ * elfstrmerge_LDADD: Likewise.
+ * alldts.c (main): Use dwelf_strtab instead of ebl_strtab.
+ * elfstrmerge.c (release): Likewise.
+ (main): Likewise.
+ * update3.c (main): Likewise.
+ * update4.c (main): Likewise.
+
2016-07-10 Andreas Schwab <schwab@linux-m68k.org>
* Makefile.am (TESTS): Add run-strip-test11.sh.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a64adca3..fcfb9358 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -406,8 +406,8 @@ early_offscn_LDADD = $(libelf)
ecp_LDADD = $(libelf)
update1_LDADD = $(libelf)
update2_LDADD = $(libelf)
-update3_LDADD = $(libebl) $(libelf)
-update4_LDADD = $(libebl) $(libelf)
+update3_LDADD = $(libdw) $(libelf)
+update4_LDADD = $(libdw) $(libelf)
show_die_info_LDADD = $(libdw) $(libelf)
get_pubnames_LDADD = $(libdw) $(libelf)
show_abbrev_LDADD = $(libdw) $(libelf)
@@ -445,7 +445,7 @@ dwarf_getstring_LDADD = $(libdw)
addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) -ldl
test_flag_nobits_LDADD = $(libelf)
rerequest_tag_LDADD = $(libdw)
-alldts_LDADD = $(libebl) $(libelf)
+alldts_LDADD = $(libdw) $(libelf)
md5_sha1_test_LDADD = $(libeu)
typeiter_LDADD = $(libdw) $(libelf)
typeiter2_LDADD = $(libdw) $(libelf)
@@ -478,7 +478,7 @@ elfstrtab_LDADD = $(libelf)
dwfl_proc_attach_LDADD = $(libdw)
dwfl_proc_attach_LDFLAGS = -pthread $(AM_LDFLAGS)
elfshphehdr_LDADD =$(libelf)
-elfstrmerge_LDADD = $(libebl) $(libelf)
+elfstrmerge_LDADD = $(libdw) $(libelf)
dwelfgnucompressed_LDADD = $(libelf) $(libdw)
elfgetchdr_LDADD = $(libelf) $(libdw)
elfgetzdata_LDADD = $(libelf)
diff --git a/tests/alldts.c b/tests/alldts.c
index eaecaf57..28b3063c 100644
--- a/tests/alldts.c
+++ b/tests/alldts.c
@@ -1,5 +1,5 @@
/* Create an ELF file with all the DT_* flags set.
- Copyright (C) 2011 Red Hat, Inc.
+ Copyright (C) 2011, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Marek Polacek <mpolacek@redhat.com>, 2011.
@@ -20,7 +20,7 @@
# include <config.h>
#endif
-#include ELFUTILS_HEADER(ebl)
+#include ELFUTILS_HEADER(dwelf)
#include <elf.h>
#include <gelf.h>
#include <fcntl.h>
@@ -38,9 +38,9 @@ int
main (void)
{
static const char fname[] = "testfile-alldts";
- struct Ebl_Strtab *shst;
- struct Ebl_Strent *dynscn;
- struct Ebl_Strent *shstrtabse;
+ Dwelf_Strtab *shst;
+ Dwelf_Strent *dynscn;
+ Dwelf_Strent *shstrtabse;
const Elf32_Sword dtflags[] =
{
DT_NULL, DT_NEEDED, DT_PLTRELSZ, DT_PLTGOT,
@@ -117,7 +117,7 @@ main (void)
phdr[1].p_type = PT_DYNAMIC;
elf_flagphdr (elf, ELF_C_SET, ELF_F_DIRTY);
- shst = ebl_strtabinit (true);
+ shst = dwelf_strtab_init (true);
/* Create the .dynamic section. */
Elf_Scn *scn = elf_newscn (elf);
@@ -134,7 +134,7 @@ main (void)
return 1;
}
- dynscn = ebl_strtabadd (shst, ".dynamic", 0);
+ dynscn = dwelf_strtab_add (shst, ".dynamic");
/* We'll need to know the section offset. But this will be set up
by elf_update later, so for now just store the address. */
@@ -191,7 +191,7 @@ main (void)
return 1;
}
- shstrtabse = ebl_strtabadd (shst, ".shstrtab", 0);
+ shstrtabse = dwelf_strtab_add (shst, ".shstrtab");
shdr->sh_type = SHT_STRTAB;
shdr->sh_flags = 0;
@@ -211,10 +211,10 @@ main (void)
}
/* No more sections, finalize the section header string table. */
- ebl_strtabfinalize (shst, data);
+ dwelf_strtab_finalize (shst, data);
- elf32_getshdr (elf_getscn (elf, 1))->sh_name = ebl_strtaboffset (dynscn);
- shdr->sh_name = ebl_strtaboffset (shstrtabse);
+ elf32_getshdr (elf_getscn (elf, 1))->sh_name = dwelf_strent_off (dynscn);
+ shdr->sh_name = dwelf_strent_off (shstrtabse);
/* Let the library compute the internal structure information. */
if (elf_update (elf, ELF_C_NULL) < 0)
@@ -251,7 +251,7 @@ main (void)
}
/* We don't need the string table anymore. */
- ebl_strtabfree (shst);
+ dwelf_strtab_free (shst);
/* And the data allocated in the .shstrtab section. */
free (data->d_buf);
diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c
index 4149ca6e..c2c3fb97 100644
--- a/tests/elfstrmerge.c
+++ b/tests/elfstrmerge.c
@@ -1,5 +1,5 @@
/* Merge string sections.
- Copyright (C) 2015 Red Hat, Inc.
+ Copyright (C) 2015, 2016 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -30,7 +30,8 @@
#include <unistd.h>
#include <gelf.h>
-#include ELFUTILS_HEADER(ebl)
+#include ELFUTILS_HEADER(dwelf)
+#include "elf-knowledge.h"
/* The original ELF file. */
static int fd = -1;
@@ -43,13 +44,13 @@ static int fdnew = -1;
static Elf *elfnew = NULL;
/* The merged string table. */
-static struct Ebl_Strtab *strings = NULL;
+static Dwelf_Strtab *strings = NULL;
/* Section name strents. */
-static struct Ebl_Strent **scnstrents = NULL;
+static Dwelf_Strent **scnstrents = NULL;
/* Symbol name strends. */
-static struct Ebl_Strent **symstrents = NULL;
+static Dwelf_Strent **symstrents = NULL;
/* New ELF file buffers. */
static Elf_Data newstrtabdata = { .d_buf = NULL };
@@ -62,7 +63,7 @@ release (void)
{
/* The new string table. */
if (strings != NULL)
- ebl_strtabfree (strings);
+ dwelf_strtab_free (strings);
free (scnstrents);
free (symstrents);
@@ -241,7 +242,7 @@ main (int argc, char **argv)
bool layout = phnum != 0;
/* Create a new merged strings table that starts with the empty string. */
- strings = ebl_strtabinit (true);
+ strings = dwelf_strtab_init (true);
if (strings == NULL)
fail ("No memory to create merged string table", NULL);
@@ -249,7 +250,7 @@ main (int argc, char **argv)
size_t shdrnum;
if (elf_getshdrnum (elf, &shdrnum) != 0)
fail_elf ("Couldn't get number of sections", fname);
- scnstrents = malloc (shdrnum * sizeof (struct Ebl_Strent *));
+ scnstrents = malloc (shdrnum * sizeof (Dwelf_Strent *));
if (scnstrents == NULL)
fail ("couldn't allocate memory for section strings", NULL);
@@ -275,8 +276,8 @@ main (int argc, char **argv)
const char *sname = elf_strptr (elf, shdrstrndx, shdr->sh_name);
if (sname == NULL)
fail_elf_idx ("couldn't get section name", fname, scnnum);
- if ((scnstrents[scnnum] = ebl_strtabadd (strings, sname, 0)) == NULL)
- fail ("No memory to add to merged string table", NULL);
+ if ((scnstrents[scnnum] = dwelf_strtab_add (strings, sname)) == NULL)
+ fail ("No memory to add to merged string table", NULL);
}
if (layout)
@@ -295,7 +296,7 @@ main (int argc, char **argv)
if (symd == NULL)
fail_elf ("couldn't get symtab data", fname);
size_t symsnum = symd->d_size / elsize;
- symstrents = malloc (symsnum * sizeof (struct Ebl_Strent *));
+ symstrents = malloc (symsnum * sizeof (Dwelf_Strent *));
if (symstrents == NULL)
fail_errno ("Couldn't allocate memory for symbol strings", NULL);
for (size_t i = 0; i < symsnum; i++)
@@ -309,7 +310,7 @@ main (int argc, char **argv)
const char *sname = elf_strptr (elf, strtabndx, sym->st_name);
if (sname == NULL)
fail_elf_idx ("Couldn't get symbol name", fname, i);
- if ((symstrents[i] = ebl_strtabadd (strings, sname, 0)) == NULL)
+ if ((symstrents[i] = dwelf_strtab_add (strings, sname)) == NULL)
fail_idx ("No memory to add to merged string table symbol",
fname, i);
}
@@ -317,7 +318,7 @@ main (int argc, char **argv)
/* We got all strings, build the new string table and store it as
new strtab. */
- ebl_strtabfinalize (strings, &newstrtabdata);
+ dwelf_strtab_finalize (strings, &newstrtabdata);
/* We share at least the empty string so the result is at least 1
byte smaller. */
@@ -453,7 +454,7 @@ main (int argc, char **argv)
GElf_Shdr newshdr;
newshdr.sh_name = (shdr->sh_name != 0
- ? ebl_strtaboffset (scnstrents[ndx]) : 0);
+ ? dwelf_strent_off (scnstrents[ndx]) : 0);
newshdr.sh_type = shdr->sh_type;
newshdr.sh_flags = shdr->sh_flags;
newshdr.sh_addr = shdr->sh_addr;
@@ -528,7 +529,7 @@ main (int argc, char **argv)
sym.st_shndx = newsecndx (sym.st_shndx, "section", ndx,
"symbol", i);
if (update_name && sym.st_name != 0)
- sym.st_name = ebl_strtaboffset (symstrents[i]);
+ sym.st_name = dwelf_strent_off (symstrents[i]);
/* We explicitly don't update the SHNDX table at
the same time, we do that below. */
diff --git a/tests/update3.c b/tests/update3.c
index d760687a..7a4224dd 100644
--- a/tests/update3.c
+++ b/tests/update3.c
@@ -1,5 +1,5 @@
/* Test program for elf_update function.
- Copyright (C) 2000, 2002, 2005 Red Hat, Inc.
+ Copyright (C) 2000, 2002, 2005, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -28,7 +28,7 @@
#include <string.h>
#include <unistd.h>
-#include ELFUTILS_HEADER(ebl)
+#include ELFUTILS_HEADER(dwelf)
int
@@ -42,8 +42,8 @@ main (int argc, char *argv[] __attribute__ ((unused)))
Elf_Scn *scn;
Elf32_Shdr *shdr;
Elf_Data *data;
- struct Ebl_Strtab *shst;
- struct Ebl_Strent *shstrtabse;
+ Dwelf_Strtab *shst;
+ Dwelf_Strent *shstrtabse;
int i;
fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
@@ -107,7 +107,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
phdr[0].p_type = PT_PHDR;
elf_flagphdr (elf, ELF_C_SET, ELF_F_DIRTY);
- shst = ebl_strtabinit (true);
+ shst = dwelf_strtab_init (true);
scn = elf_newscn (elf);
if (scn == NULL)
@@ -122,7 +122,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
exit (1);
}
- shstrtabse = ebl_strtabadd (shst, ".shstrtab", 0);
+ shstrtabse = dwelf_strtab_add (shst, ".shstrtab");
shdr->sh_type = SHT_STRTAB;
shdr->sh_flags = 0;
@@ -143,9 +143,9 @@ main (int argc, char *argv[] __attribute__ ((unused)))
}
/* No more sections, finalize the section header string table. */
- ebl_strtabfinalize (shst, data);
+ dwelf_strtab_finalize (shst, data);
- shdr->sh_name = ebl_strtaboffset (shstrtabse);
+ shdr->sh_name = dwelf_strent_off (shstrtabse);
/* Let the library compute the internal structure information. */
if (elf_update (elf, ELF_C_NULL) < 0)
@@ -173,7 +173,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
}
/* We don't need the string table anymore. */
- ebl_strtabfree (shst);
+ dwelf_strtab_free (shst);
/* And the data allocated in the .shstrtab section. */
free (data->d_buf);
diff --git a/tests/update4.c b/tests/update4.c
index 85de6c35..a9bd4bf9 100644
--- a/tests/update4.c
+++ b/tests/update4.c
@@ -1,5 +1,5 @@
/* Test program for elf_update function.
- Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc.
+ Copyright (C) 2000, 2001, 2002, 2005, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -28,7 +28,7 @@
#include <string.h>
#include <unistd.h>
-#include ELFUTILS_HEADER(ebl)
+#include ELFUTILS_HEADER(dwelf)
int
@@ -42,12 +42,12 @@ main (int argc, char *argv[] __attribute__ ((unused)))
Elf_Scn *scn;
Elf32_Shdr *shdr;
Elf_Data *data;
- struct Ebl_Strtab *shst;
- struct Ebl_Strent *firstse;
- struct Ebl_Strent *secondse;
- struct Ebl_Strent *thirdse;
- struct Ebl_Strent *fourthse;
- struct Ebl_Strent *shstrtabse;
+ Dwelf_Strtab *shst;
+ Dwelf_Strent *firstse;
+ Dwelf_Strent *secondse;
+ Dwelf_Strent *thirdse;
+ Dwelf_Strent *fourthse;
+ Dwelf_Strent *shstrtabse;
int i;
fd = open (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
@@ -111,7 +111,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
phdr[0].p_type = PT_PHDR;
elf_flagphdr (elf, ELF_C_SET, ELF_F_DIRTY);
- shst = ebl_strtabinit (true);
+ shst = dwelf_strtab_init (true);
scn = elf_newscn (elf);
if (scn == NULL)
@@ -126,7 +126,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
exit (1);
}
- firstse = ebl_strtabadd (shst, ".first", 0);
+ firstse = dwelf_strtab_add (shst, ".first");
shdr->sh_type = SHT_PROGBITS;
shdr->sh_flags = SHF_ALLOC | SHF_EXECINSTR;
@@ -162,7 +162,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
exit (1);
}
- secondse = ebl_strtabadd (shst, ".second", 0);
+ secondse = dwelf_strtab_add (shst, ".second");
shdr->sh_type = SHT_PROGBITS;
shdr->sh_flags = SHF_ALLOC | SHF_WRITE;
@@ -198,7 +198,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
exit (1);
}
- thirdse = ebl_strtabadd (shst, ".third", 0);
+ thirdse = dwelf_strtab_add (shst, ".third");
shdr->sh_type = SHT_PROGBITS;
shdr->sh_flags = SHF_ALLOC | SHF_EXECINSTR;
@@ -234,7 +234,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
exit (1);
}
- fourthse = ebl_strtabadd (shst, ".fourth", 0);
+ fourthse = dwelf_strtab_add (shst, ".fourth");
shdr->sh_type = SHT_NOBITS;
shdr->sh_flags = SHF_ALLOC | SHF_EXECINSTR;
@@ -271,7 +271,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
exit (1);
}
- shstrtabse = ebl_strtabadd (shst, ".shstrtab", 0);
+ shstrtabse = dwelf_strtab_add (shst, ".shstrtab");
shdr->sh_type = SHT_STRTAB;
shdr->sh_flags = 0;
@@ -291,13 +291,13 @@ main (int argc, char *argv[] __attribute__ ((unused)))
}
/* No more sections, finalize the section header string table. */
- ebl_strtabfinalize (shst, data);
+ dwelf_strtab_finalize (shst, data);
- elf32_getshdr (elf_getscn (elf, 1))->sh_name = ebl_strtaboffset (firstse);
- elf32_getshdr (elf_getscn (elf, 2))->sh_name = ebl_strtaboffset (secondse);
- elf32_getshdr (elf_getscn (elf, 3))->sh_name = ebl_strtaboffset (thirdse);
- elf32_getshdr (elf_getscn (elf, 4))->sh_name = ebl_strtaboffset (fourthse);
- shdr->sh_name = ebl_strtaboffset (shstrtabse);
+ elf32_getshdr (elf_getscn (elf, 1))->sh_name = dwelf_strent_off (firstse);
+ elf32_getshdr (elf_getscn (elf, 2))->sh_name = dwelf_strent_off (secondse);
+ elf32_getshdr (elf_getscn (elf, 3))->sh_name = dwelf_strent_off (thirdse);
+ elf32_getshdr (elf_getscn (elf, 4))->sh_name = dwelf_strent_off (fourthse);
+ shdr->sh_name = dwelf_strent_off (shstrtabse);
/* Let the library compute the internal structure information. */
if (elf_update (elf, ELF_C_NULL) < 0)
@@ -325,7 +325,7 @@ main (int argc, char *argv[] __attribute__ ((unused)))
}
/* We don't need the string table anymore. */
- ebl_strtabfree (shst);
+ dwelf_strtab_free (shst);
/* And the data allocated in the .shstrtab section. */
free (data->d_buf);