|
Packit Service |
97d2fb |
/* Test program for dwfl_report_elf incorrect BASE alignment.
|
|
Packit Service |
97d2fb |
Copyright (C) 2013 Red Hat, Inc.
|
|
Packit Service |
97d2fb |
This file is part of elfutils.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
This file is free software; you can redistribute it and/or modify
|
|
Packit Service |
97d2fb |
it under the terms of the GNU General Public License as published by
|
|
Packit Service |
97d2fb |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
97d2fb |
(at your option) any later version.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
elfutils is distributed in the hope that it will be useful, but
|
|
Packit Service |
97d2fb |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
97d2fb |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
97d2fb |
GNU General Public License for more details.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
You should have received a copy of the GNU General Public License
|
|
Packit Service |
97d2fb |
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#include <config.h>
|
|
Packit Service |
97d2fb |
#include <assert.h>
|
|
Packit Service |
97d2fb |
#include <inttypes.h>
|
|
Packit Service |
97d2fb |
#include <stdio.h>
|
|
Packit Service |
97d2fb |
#include <stdio_ext.h>
|
|
Packit Service |
97d2fb |
#include <locale.h>
|
|
Packit Service |
97d2fb |
#include <string.h>
|
|
Packit Service |
97d2fb |
#include <stdlib.h>
|
|
Packit Service |
97d2fb |
#include ELFUTILS_HEADER(dwfl)
|
|
Packit Service |
97d2fb |
#include "system.h"
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
static const Dwfl_Callbacks offline_callbacks =
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
.find_debuginfo = INTUSE(dwfl_standard_find_debuginfo),
|
|
Packit Service |
97d2fb |
.section_address = INTUSE(dwfl_offline_section_address),
|
|
Packit Service |
97d2fb |
};
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
int
|
|
Packit Service |
97d2fb |
main (int argc, char **argv)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
/* We use no threads here which can interfere with handling a stream. */
|
|
Packit Service |
97d2fb |
(void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Set locale. */
|
|
Packit Service |
97d2fb |
(void) setlocale (LC_ALL, "");
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
if (argc != 5)
|
|
Packit Service |
97d2fb |
error (1, 0, "dwfl-report-elf-align shlib.so base funcaddr funcname");
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
Dwfl *dwfl = dwfl_begin (&offline_callbacks);
|
|
Packit Service |
97d2fb |
assert (dwfl != NULL);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
char *endptr;
|
|
Packit Service |
97d2fb |
uintptr_t base = strtoull (argv[2], &endptr, 0);
|
|
Packit Service |
97d2fb |
assert (endptr && !*endptr);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
Dwfl_Module *mod = dwfl_report_elf (dwfl, argv[1], argv[1], -1, base, false);
|
|
Packit Service |
97d2fb |
assert (mod != NULL);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
uintptr_t funcaddr = strtoull (argv[3], &endptr, 0);
|
|
Packit Service |
97d2fb |
assert (endptr && !*endptr);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
Dwfl_Module *mod_found = dwfl_addrmodule (dwfl, funcaddr);
|
|
Packit Service |
97d2fb |
assert (mod_found == mod);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
const char *symname = dwfl_module_addrname (mod, funcaddr);
|
|
Packit Service |
97d2fb |
assert (symname != NULL);
|
|
Packit Service |
97d2fb |
assert (strcmp (symname, argv[4]) == 0);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
dwfl_end (dwfl);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
return 0;
|
|
Packit Service |
97d2fb |
}
|