Sun in their implementation messed up the semantics of these functions.
To get back to source code compatibility they asked for a solution.
We simply add aliases for the two affected functions, named
elf_getshdrnum and elf_getshdrstrndx. The semantics remains the
same. Users of the old interfaces receive a warning for now. In
future we might make it impossible to link programs which request
the old interfaces (binary compatibility will of course be maintained).
+Version 0.142:
+
+libelf: Add elf_getshdrnum alias for elf_getshnum and elf_getshdrstrndx alias
+ for elf_getshstrndx and deprecate original names. Sun screwed up
+ their implementation and asked for a solution.
+
Version 0.141:
libebl: sparc backend fixes;
dnl along with this program; if not, write to the Free Software Foundation,
dnl Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
dnl
-AC_INIT([Red Hat elfutils],[0.141],[http://bugzilla.redhat.com/bugzilla/],
+AC_INIT([Red Hat elfutils],[0.142],[http://bugzilla.redhat.com/bugzilla/],
[elfutils])
AC_CONFIG_AUX_DIR([config])
+2009-06-13 Ulrich Drepper <drepper@redhat.com>
+
+ * derelocate.c: Don't use deprecated libelf functions.
+ * dwfl_module_getdwarf.c: Likewise.
+ * relocate.c: Likewise.
+
2009-04-23 Ulrich Drepper <drepper@redhat.com>
* dwfl_module_build_id.c: Define versioned symbols only if SHARED is
size_t nrefs = 0;
size_t shstrndx;
- if (unlikely (elf_getshstrndx (mod->main.elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (mod->main.elf, &shstrndx) < 0))
{
elf_error:
__libdwfl_seterrno (DWFL_E_LIBELF);
find_debuglink (Elf *elf, GElf_Word *crc)
{
size_t shstrndx;
- if (elf_getshstrndx (elf, &shstrndx) < 0)
+ if (elf_getshdrstrndx (elf, &shstrndx) < 0)
return NULL;
Elf_Scn *scn = NULL;
address and update the section header. */
if (*shstrndx == SHN_UNDEF
- && unlikely (elf_getshstrndx (elf, shstrndx) < 0))
+ && unlikely (elf_getshdrstrndx (elf, shstrndx) < 0))
return DWFL_E_LIBELF;
const char *name = elf_strptr (elf, *shstrndx, refshdr->sh_name);
return DWFL_E_LIBELF;
size_t d_shstrndx;
- if (elf_getshstrndx (debugfile, &d_shstrndx) < 0)
+ if (elf_getshdrstrndx (debugfile, &d_shstrndx) < 0)
return DWFL_E_LIBELF;
RELOC_SYMTAB_CACHE (reloc_symtab);
RELOC_SYMTAB_CACHE (reloc_symtab);
size_t shstrndx;
- if (elf_getshstrndx (relocated, &shstrndx) < 0)
+ if (elf_getshdrstrndx (relocated, &shstrndx) < 0)
return DWFL_E_LIBELF;
return (__libdwfl_module_getebl (mod)
+2009-06-13 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile.am (libelf_a_SOURCES): Replace elf_getshnum.c and
+ elf_getshstrndx.c with elf_getshdrnum.c and elf_getshdrstrndx.c.
+ * elf_getshnum.c: Renamed to...
+ * elf_getshdrnum.c: ...this. Rename function and add old name as
+ alias. Likewise for internal functions with derived names.
+ * elf_getshstrndx.c: Renamed to...
+ * elf_getshdrstrndx.c: ...this. Rename function and add old name as
+ alias. Likewise for internal functions with derived names.
+ * libelf.h: Add prototypes for new names. Make old names as
+ deprecated.
+ * libelfP.h: Rename internal function prototypes.
+ * libelf.map: Export for names.
+ * elf32_checksum.c: Don't use deprecated functions.
+ * elf32_getshdr.c: Likewise.
+
2009-06-01 Ulrich Drepper <drepper@redhat.com>
* elf.h: Update from glibc.
gelf_update_versym.c gelf_update_verneed.c \
gelf_update_vernaux.c gelf_update_verdef.c \
gelf_update_verdaux.c \
- elf_getshnum.c elf_getshstrndx.c \
+ elf_getshdrnum.c elf_getshdrstrndx.c \
gelf_checksum.c elf32_checksum.c elf64_checksum.c \
libelf_crc32.c libelf_next_prime.c \
elf_clone.c \
/* Compute simple checksum from permanent parts of the ELF file.
- Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
return -1l;
/* Find the section header string table. */
- if (INTUSE(elf_getshstrndx) (elf, &shstrndx) < 0)
+ if (INTUSE(elf_getshdrstrndx) (elf, &shstrndx) < 0)
{
/* This can only happen if the ELF handle is not for real. */
__libelf_seterrno (ELF_E_INVALID_HANDLE);
/* Return section header.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007 Red Hat, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1998.
goto out;
size_t shnum;
- if (__elf_getshnum_rdlock (elf, &shnum) != 0)
+ if (__elf_getshdrnum_rdlock (elf, &shnum) != 0)
goto out;
size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr));
/* Return number of sections in the ELF file.
- Copyright (C) 2002 Red Hat, Inc.
+ Copyright (C) 2002, 2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
int
-__elf_getshnum_rdlock (elf, dst)
+__elf_getshdrnum_rdlock (elf, dst)
Elf *elf;
size_t *dst;
{
}
int
-elf_getshnum (elf, dst)
+elf_getshdrnum (elf, dst)
Elf *elf;
size_t *dst;
{
return -1;
rwlock_rdlock (elf->lock);
- result = __elf_getshnum_rdlock (elf, dst);
+ result = __elf_getshdrnum_rdlock (elf, dst);
rwlock_unlock (elf->lock);
return result;
}
+/* Alias for the deprecated name. */
+strong_alias (elf_getshdrnum, elf_getshnum)
/* Return section index of section header string table.
- Copyright (C) 2002, 2005 Red Hat, Inc.
+ Copyright (C) 2002, 2005, 2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
int
-elf_getshstrndx (elf, dst)
+elf_getshdrstrndx (elf, dst)
Elf *elf;
size_t *dst;
{
return result;
}
-INTDEF(elf_getshstrndx)
+INTDEF(elf_getshdrstrndx)
+/* Alias for the deprecated name. */
+strong_alias (elf_getshdrstrndx, elf_getshstrndx)
/* Interface for libelf.
- Copyright (C) 1998, 1999, 2000, 2002, 2004, 2005, 2006, 2007 Red Hat, Inc.
+ Copyright (C) 1998-2000, 2002, 2004-2007, 2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
sections than can be represented in the e_shnum field of the ELF
header the information from the sh_size field in the zeroth section
header is used. */
-extern int elf_getshnum (Elf *__elf, size_t *__dst);
+extern int elf_getshdrnum (Elf *__elf, size_t *__dst);
+/* Sun messed up the implementation of 'elf_getshnum' in their implementation.
+ It was agreed to make the same functionality available under a different
+ name and obsolete the old name. */
+extern int elf_getshnum (Elf *__elf, size_t *__dst)
+ __attribute__ ((__deprecated__));
/* Get the section index of the section header string table in the ELF
file. If the index cannot be represented in the e_shnum field of
the ELF header the information from the sh_link field in the zeroth
section header is used. */
-extern int elf_getshstrndx (Elf *__elf, size_t *__dst);
+extern int elf_getshdrstrndx (Elf *__elf, size_t *__dst);
+/* Sun messed up the implementation of 'elf_getshnum' in their implementation.
+ It was agreed to make the same functionality available under a different
+ name and obsolete the old name. */
+extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
+ __attribute__ ((__deprecated__));
/* Retrieve section header of ELFCLASS32 binary. */
global:
elf_scnshndx;
} ELFUTILS_1.3;
+
+ELFUTILS_1.5 {
+ global:
+ elf_getshdrnum; elf_getshdrstrndx;
+} ELFUTILS_1.4;
extern Elf64_Phdr *__elf64_newphdr_internal (Elf *__elf, size_t __cnt)
attribute_hidden;
extern Elf_Scn *__elf32_offscn_internal (Elf *__elf, Elf32_Off __offset)
- attribute_hidden;
+ attribute_hidden;
extern Elf_Scn *__elf64_offscn_internal (Elf *__elf, Elf64_Off __offset)
- attribute_hidden;
-extern int __elf_getshnum_rdlock (Elf *__elf, size_t *__dst) internal_function;
-extern int __elf_getshstrndx_internal (Elf *__elf, size_t *__dst)
+ attribute_hidden;
+extern int __elf_getshdrnum_rdlock (Elf *__elf, size_t *__dst)
+ internal_function;
+extern int __elf_getshdrstrndx_internal (Elf *__elf, size_t *__dst)
attribute_hidden;
extern Elf32_Shdr *__elf32_getshdr_rdlock (Elf_Scn *__scn) internal_function;
extern Elf64_Shdr *__elf64_getshdr_rdlock (Elf_Scn *__scn) internal_function;
+2009-06-13 Ulrich Drepper <drepper@redhat.com>
+
+ * ldgeneric.c: Don't use deprecated libelf functions.
+ * nm.c: Likewise.
+ * objdump.c: Likewise.
+ * readelf.c: Likewise.
+ * size.c: Likewise.
+ * strip.c: Likewise.
+ * unstrip.c: Likewise.
+ * ld.h: Fix up comment.
+
2009-06-01 Ulrich Drepper <drepper@redhat.com>
* readelf.c (print_relocs): Expect ELF header argument and pass on
-/* Copyright (C) 2001, 2002, 2003, 2005, 2006, 2008 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2005, 2006, 2008, 2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2001.
separate field and not the e_shstrndx field in the ELF header
since in case of a file with more than 64000 sections the index
might be stored in the section header of section zero. The
- elf_getshstrndx() function can find the value but it is too
+ elf_getshdrstrndx() function can find the value but it is too
costly to repeat this call over and over. */
size_t shstrndx;
-/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 Red Hat, Inc.
+/* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2001.
Elf32_Word xndx;
size_t shnum;
- if (elf_getshnum (fileinfo->elf, &shnum) < 0)
+ if (elf_getshdrnum (fileinfo->elf, &shnum) < 0)
error (EXIT_FAILURE, 0,
gettext ("cannot determine number of sections: %s"),
elf_errmsg (-1));
assert (fileinfo->elf != NULL);
/* Allocate memory for the sections. */
- if (unlikely (elf_getshnum (fileinfo->elf, &scncnt) < 0))
+ if (unlikely (elf_getshdrnum (fileinfo->elf, &scncnt) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot determine number of sections: %s"),
elf_errmsg (-1));
#ifndef NDEBUG
size_t shnum;
- assert (elf_getshnum (fileinfo->elf, &shnum) == 0);
+ assert (elf_getshdrnum (fileinfo->elf, &shnum) == 0);
assert (shndx < shnum);
#endif
}
/* Determine the section header string table section index. */
- if (unlikely (elf_getshstrndx (fileinfo->elf, &fileinfo->shstrndx)
+ if (unlikely (elf_getshdrstrndx (fileinfo->elf, &fileinfo->shstrndx)
< 0))
{
fprintf (stderr, gettext ("\
{
/* The call cannot fail. */
size_t shstrndx;
- (void) elf_getshstrndx (ld_state.outelf, &shstrndx);
+ (void) elf_getshdrstrndx (ld_state.outelf, &shstrndx);
const char *ident = elf_getident (ld_state.outelf, NULL);
bool same_byte_order = ((ident[EI_DATA] == ELFDATA2LSB
int longest_where)
{
size_t shnum;
- if (elf_getshnum (ebl->elf, &shnum) < 0)
+ if (elf_getshdrnum (ebl->elf, &shnum) < 0)
INTERNAL_ERROR (fullname);
bool scnnames_malloced = shnum * sizeof (const char *) > 128 * 1024;
scnnames = (const char **) alloca (sizeof (const char *) * shnum);
/* Get the section header string table index. */
size_t shstrndx;
- if (elf_getshstrndx (ebl->elf, &shstrndx) < 0)
+ if (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
{
/* Get the section header string table index. */
size_t shstrndx;
- if (elf_getshstrndx (ebl->elf, &shstrndx) < 0)
+ if (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (elf_getshstrndx (ebl->elf, &shstrndx) < 0)
+ if (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
}
/* Determine the number of sections. */
- if (unlikely (elf_getshnum (ebl->elf, &shnum) < 0))
+ if (unlikely (elf_getshdrnum (ebl->elf, &shnum) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot determine number of sections: %s"),
elf_errmsg (-1));
ehdr->e_shnum, ehdr->e_shoff);
/* Get the section header string table index. */
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
return;
/* Get the section header string table index. */
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
{
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
{
size_t shstrndx;
/* We know this call will succeed since it did in the caller. */
- (void) elf_getshstrndx (ebl->elf, &shstrndx);
+ (void) elf_getshdrstrndx (ebl->elf, &shstrndx);
const char *scnname = elf_strptr (ebl->elf, shstrndx, shdr->sh_name);
Elf_Data *data = elf_rawdata (scn, NULL);
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
{
/* Get the section header string table index. */
size_t shstrndx;
- if (elf_getshstrndx (ebl->elf, &shstrndx) < 0)
+ if (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
{
/* Get the section header string table index. */
size_t shstrndx;
- if (elf_getshstrndx (elf, &shstrndx) < 0)
+ if (elf_getshdrstrndx (elf, &shstrndx) < 0)
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
{
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
{
/* Get the section header string table index. */
size_t shstrndx;
- if (unlikely (elf_getshstrndx (elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
INTERNAL_ERROR (fname);
/* Get the section header string table index. */
- if (unlikely (elf_getshstrndx (elf, &shstrndx) < 0))
+ if (unlikely (elf_getshdrstrndx (elf, &shstrndx) < 0))
error (EXIT_FAILURE, 0,
gettext ("cannot get section header string table index"));
/* Number of sections. */
size_t shnum;
- if (unlikely (elf_getshnum (elf, &shnum) < 0))
+ if (unlikely (elf_getshdrnum (elf, &shnum) < 0))
{
error (0, 0, gettext ("cannot determine number of sections: %s"),
elf_errmsg (-1));
const GElf_Ehdr *stripped_ehdr, GElf_Addr bias)
{
size_t unstripped_shstrndx;
- ELF_CHECK (elf_getshstrndx (unstripped, &unstripped_shstrndx) == 0,
+ ELF_CHECK (elf_getshdrstrndx (unstripped, &unstripped_shstrndx) == 0,
_("cannot get section header string table section index: %s"));
size_t stripped_shstrndx;
- ELF_CHECK (elf_getshstrndx (stripped, &stripped_shstrndx) == 0,
+ ELF_CHECK (elf_getshdrstrndx (stripped, &stripped_shstrndx) == 0,
_("cannot get section header string table section index: %s"));
size_t unstripped_shnum;
- ELF_CHECK (elf_getshnum (unstripped, &unstripped_shnum) == 0,
+ ELF_CHECK (elf_getshdrnum (unstripped, &unstripped_shnum) == 0,
_("cannot get section count: %s"));
size_t stripped_shnum;
- ELF_CHECK (elf_getshnum (stripped, &stripped_shnum) == 0,
+ ELF_CHECK (elf_getshdrnum (stripped, &stripped_shnum) == 0,
_("cannot get section count: %s"));
/* Cache the stripped file's section details. */
strtab);
/* Get the updated section count. */
- ELF_CHECK (elf_getshnum (unstripped, &unstripped_shnum) == 0,
+ ELF_CHECK (elf_getshdrnum (unstripped, &unstripped_shnum) == 0,
_("cannot get section count: %s"));
bool placed[unstripped_shnum - 1];