Blame tests/dwfl-bug-addr-overflow.c

Packit 032894
/* Test program for libdwfl basic module tracking, relocation.
Packit 032894
   Copyright (C) 2007 Red Hat, Inc.
Packit 032894
   This file is part of elfutils.
Packit 032894
Packit 032894
   This file is free software; you can redistribute it and/or modify
Packit 032894
   it under the terms of the GNU General Public License as published by
Packit 032894
   the Free Software Foundation; either version 3 of the License, or
Packit 032894
   (at your option) any later version.
Packit 032894
Packit 032894
   elfutils is distributed in the hope that it will be useful, but
Packit 032894
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 032894
   GNU General Public License for more details.
Packit 032894
Packit 032894
   You should have received a copy of the GNU General Public License
Packit 032894
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 032894
Packit 032894
#include <config.h>
Packit 032894
#include <assert.h>
Packit 032894
#include <inttypes.h>
Packit 032894
#include <stdio.h>
Packit 032894
#include <stdio_ext.h>
Packit 032894
#include <locale.h>
Packit 032894
#include ELFUTILS_HEADER(dwfl)
Packit 032894
Packit 032894
Packit 032894
static const Dwfl_Callbacks offline_callbacks =
Packit 032894
  {
Packit 032894
    .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo),
Packit 032894
    .section_address = INTUSE(dwfl_offline_section_address),
Packit 032894
  };
Packit 032894
Packit 032894
Packit 032894
int
Packit 032894
main (void)
Packit 032894
{
Packit 032894
  /* We use no threads here which can interfere with handling a stream.  */
Packit 032894
  (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
Packit 032894
Packit 032894
  /* Set locale.  */
Packit 032894
  (void) setlocale (LC_ALL, "");
Packit 032894
Packit 032894
  Dwfl *dwfl = dwfl_begin (&offline_callbacks);
Packit 032894
  assert (dwfl != NULL);
Packit 032894
Packit 032894
  Dwfl_Module *high = dwfl_report_module (dwfl, "high",
Packit 032894
					  UINT64_C (0xffffffff00010000),
Packit 032894
					  UINT64_C (0xffffffff00020000));
Packit 032894
  assert (high);
Packit 032894
  Dwfl_Module *low = dwfl_report_module (dwfl, "low",
Packit 032894
					 UINT64_C (0x00010000),
Packit 032894
					 UINT64_C (0x00020000));
Packit 032894
  assert (low);
Packit 032894
  Dwfl_Module *middle = dwfl_report_module (dwfl, "middle",
Packit 032894
					    UINT64_C (0xffff00010000),
Packit 032894
					    UINT64_C (0xffff00020000));
Packit 032894
  assert (middle);
Packit 032894
Packit 032894
  int ret = dwfl_report_end (dwfl, NULL, NULL);
Packit 032894
  assert (ret == 0);
Packit 032894
Packit 032894
  Dwfl_Module *mod = dwfl_addrmodule (dwfl, UINT64_C (0xffffffff00010123));
Packit 032894
  assert (mod == high);
Packit 032894
  mod = dwfl_addrmodule (dwfl, UINT64_C (0x00010123));
Packit 032894
  assert (mod == low);
Packit 032894
  mod = dwfl_addrmodule (dwfl, UINT64_C (0xffff00010123));
Packit 032894
  assert (mod == middle);
Packit 032894
Packit 032894
  dwfl_end (dwfl);
Packit 032894
Packit 032894
  return 0;
Packit 032894
}