libdwelf: Add dwelf_dwarf_gnu_debugaltlink

Signed-off-by: Florian Weimer <fweimer@redhat.com>
This commit is contained in:
Florian Weimer
2014-04-24 14:06:43 +02:00
committed by Mark Wielaard
parent 35e2a765c0
commit 4813dbbcb8
11 changed files with 215 additions and 4 deletions
+8
View File
@@ -1,3 +1,11 @@
2014-04-24 Florian Weimer <fweimer@redhat.com>
* dwelf_dwarf_gnu_debugaltlink.c: New file.
* Makefile.am (libdwelf_a_SOURCES): Add it.
* libdwelf.h (dwelf_dwarf_gnu_debugaltlink): Declare new function.
* libdwelfP.h (dwelf_dwarf_gnu_debugaltlink): Add internal
declaration.
2014-04-11 Mark Wielaard <mjw@redhat.com>
* Makefile.am: New file.
+1 -1
View File
@@ -38,7 +38,7 @@ noinst_LIBRARIES = libdwelf.a libdwelf_pic.a
pkginclude_HEADERS = libdwelf.h
noinst_HEADERS = libdwelfP.h
libdwelf_a_SOURCES = dwelf_elf_gnu_debuglink.c
libdwelf_a_SOURCES = dwelf_elf_gnu_debuglink.c dwelf_dwarf_gnu_debugaltlink.c
libdwelf = $(libdw)
+62
View File
@@ -0,0 +1,62 @@
/* Returns the file name and build ID stored in the .gnu_altdebuglink if found.
Copyright (C) 2014 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
it under the terms of either
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at
your option) any later version
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at
your option) any later version
or both in parallel, as here.
elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "libdwelfP.h"
ssize_t
dwelf_dwarf_gnu_debugaltlink (Dwarf *dwarf,
const char **name_p,
const void **build_idp)
{
Elf_Data *data = dwarf->sectiondata[IDX_gnu_debugaltlink];
if (data == NULL)
{
return 0;
}
const void *ptr = memchr (data->d_buf, '\0', data->d_size);
if (ptr == NULL)
{
__libdw_seterrno (DWARF_E_INVALID_ELF);
return -1;
}
size_t build_id_len = data->d_size - (ptr - data->d_buf + 1);
if (build_id_len == 0 || (size_t) (ssize_t) build_id_len != build_id_len)
{
__libdw_seterrno (DWARF_E_INVALID_ELF);
return -1;
}
*name_p = data->d_buf;
*build_idp = ptr + 1;
return build_id_len;
}
INTDEF(dwelf_dwarf_gnu_debugaltlink)
+10
View File
@@ -47,6 +47,16 @@ extern "C" {
section or some other error occured. */
extern const char *dwelf_elf_gnu_debuglink (Elf *elf, GElf_Word *crc);
/* Returns the name and build ID from the .gnu_debugaltlink section if
found in the ELF. On success, pointers to the name and build ID
are written to *NAMEP and *BUILDID_P, and the positive length of
the build ID is returned. Returns 0 if the ELF lacks a
.gnu_debugaltlink section. Returns -1 in case of malformed data or
other errors. */
extern ssize_t dwelf_dwarf_gnu_debugaltlink (Dwarf *dwarf,
const char **namep,
const void **build_idp);
#ifdef __cplusplus
}
#endif
+1
View File
@@ -36,5 +36,6 @@
/* Avoid PLT entries. */
INTDECL (dwelf_elf_gnu_debuglink)
INTDECL (dwelf_dwarf_gnu_debugaltlink)
#endif /* libdwelfP.h */