diff options
| author | Mark Wielaard <[email protected]> | 2016-07-08 14:08:22 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-08-03 18:19:47 +0200 |
| commit | dd906c1b4852be4dd34924017261f89cc5c4c723 (patch) | |
| tree | 6aac4ef30566095081089eed773711cf00e6e13d /tests/update4.c | |
| parent | e6ca75ddcf2ba9314077ddc9768eaac2405305e1 (diff) | |
dwelf: Add string table functions from ebl.
Move the strtab functions from libebl to libdw. Programs often want to
create ELF/DWARF string tables. We don't want (static) linking against
ebl since those are internal functions that might change.
This introduces dwelf_strtab_init, dwelf_strtab_add,
dwelf_strtab_add_len, dwelf_strtab_finalize, dwelf_strent_off,
dwelf_strent_str and dwelf_strtab_free. Documentation for each has
been added to libdwelf.h. The add fucntion got a variant that takes
the length explicitly and finalize was changed to return NULL on
out of memory instead of aborting. All code and tests now uses the
new functions.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests/update4.c')
| -rw-r--r-- | tests/update4.c | 42 |
1 files changed, 21 insertions, 21 deletions
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 <[email protected]>, 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); |
