1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-29 18:27:37 +01:00

Regenerate.

}(Logical change 1.32)
This commit is contained in:
mostang.com!davidm 2002-12-19 07:16:50 +00:00
parent 4c56811949
commit 8c52e5fec1
22 changed files with 0 additions and 517 deletions

View file

@ -1,39 +0,0 @@
/* libunwind - a platform-independent unwind library
Copyright (C) 2002 Hewlett-Packard Co
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
This file is part of libunwind.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "unwind_i.h"
void
unw_flush_cache (unw_addr_space_t as, unw_word_t lo, unw_word_t hi)
{
/* This lets us flush caches lazily. The implementation currently
ignores the flush range arguments (lo-hi). This is OK because
unw_flush_cache() is allowed to flush more than the requested
range. */
/* XXX lock */
++as->cache_generation;
/* XXX unlock */
}

View file

View file

View file

@ -1,4 +0,0 @@
#ifndef UNW_REMOTE_ONLY
#define UNW_LOCAL_ONLY
#include "Ginit.c"
#endif

View file

View file

@ -1,4 +0,0 @@
#ifndef UNW_REMOTE_ONLY
#define UNW_LOCAL_ONLY
#include "Gparser.c"
#endif

View file

@ -1,4 +0,0 @@
#ifndef UNW_REMOTE_ONLY
#define UNW_LOCAL_ONLY
#include "Gregs.c"
#endif

View file

View file

@ -1,4 +0,0 @@
#ifndef UNW_REMOTE_ONLY
#define UNW_LOCAL_ONLY
#include "Gscript.c"
#endif

View file

View file

View file

View file

@ -1,379 +0,0 @@
/* libunwind - a platform-independent unwind library
Copyright (C) 2001-2002 Hewlett-Packard Co
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
This file is part of libunwind. */
#include <assert.h>
#include <stdlib.h>
#include "unwind_i.h"
struct ia64_table_entry
{
uint64_t start_offset;
uint64_t end_offset;
uint64_t info_offset;
};
static inline const struct ia64_table_entry *
lookup (struct ia64_table_entry *table, size_t table_size, unw_word_t rel_ip)
{
const struct ia64_table_entry *e = 0;
unsigned long lo, hi, mid;
/* do a binary search for right entry: */
for (lo = 0, hi = table_size / sizeof (struct ia64_table_entry); lo < hi;)
{
mid = (lo + hi) / 2;
e = table + mid;
if (rel_ip < e->start_offset)
hi = mid;
else if (rel_ip >= e->end_offset)
lo = mid + 1;
else
break;
}
if (rel_ip < e->start_offset || rel_ip >= e->end_offset)
return NULL;
return e;
}
static inline int
is_local_addr_space (unw_addr_space_t as)
{
extern unw_addr_space_t _ULia64_local_addr_space;
return (as == _Uia64_local_addr_space
#ifndef UNW_REMOTE_ONLY
|| as == _ULia64_local_addr_space
#endif
);
}
HIDDEN int
tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di,
unw_proc_info_t *pi, int need_unwind_info, void *arg)
{
unw_word_t addr, hdr_addr, info_addr, info_end_addr, hdr, *wp;
unw_word_t handler_offset;
const struct ia64_table_entry *e;
unw_accessors_t *a = unw_get_accessors (as);
int ret;
assert (di->format == UNW_INFO_FORMAT_TABLE
&& (ip >= di->start_ip && ip < di->end_ip));
e = lookup ((struct ia64_table_entry *) di->u.ti.table_data,
di->u.ti.table_len * sizeof (unw_word_t), ip - di->u.ti.segbase);
if (!e)
{
/* IP is inside this table's range, but there is no explicit
unwind info => use default conventions (i.e., this is NOT an
error). */
memset (pi, 0, sizeof (*pi));
return 0;
}
pi->start_ip = e->start_offset + di->u.ti.segbase;
pi->end_ip = e->end_offset + di->u.ti.segbase;
hdr_addr = e->info_offset + di->u.ti.segbase;
info_addr = hdr_addr + 8;
/* read the header word: */
ret = (*a->access_mem) (as, hdr_addr, &hdr, 0, arg);
if (ret < 0)
return ret;
if (IA64_UNW_VER (hdr) != 1)
return -UNW_EBADVERSION;
info_end_addr = info_addr + 8 * IA64_UNW_LENGTH (hdr);
pi->unwind_info = 0;
if (need_unwind_info)
{
pi->unwind_info_size = 8 * IA64_UNW_LENGTH (hdr);
if (is_local_addr_space (as))
pi->unwind_info = (void *) info_addr;
else
{
/* Internalize unwind info. Note: since we're doing this
only for non-local address spaces, there is no
signal-safety issue and it is OK to use malloc()/free(). */
pi->unwind_info = malloc (8 * IA64_UNW_LENGTH (hdr));
if (!pi->unwind_info)
return -UNW_ENOMEM;
wp = (unw_word_t *) pi->unwind_info;
for (addr = info_addr; addr < info_end_addr; addr += 8, ++wp)
{
ret = (*a->access_mem) (as, addr, wp, 0, arg);
if (ret < 0)
{
free (pi->unwind_info);
return ret;
}
}
}
}
pi->handler = 0;
if (IA64_UNW_FLAG_EHANDLER (hdr) || IA64_UNW_FLAG_UHANDLER (hdr))
{
/* read the personality routine address (address is gp-relative): */
ret = (*a->access_mem) (as, info_end_addr + 8, &handler_offset, 0, arg);
if (ret < 0)
return ret;
pi->handler = handler_offset + di->gp;
}
pi->lsda = info_end_addr + 16;
pi->gp = di->gp;
pi->flags = 0;
pi->format = di->format;
return 0;
}
HIDDEN void
tdep_put_unwind_info (unw_addr_space_t as, unw_proc_info_t *pi, void *arg)
{
if (!pi->unwind_info)
return;
if (!is_local_addr_space (as))
{
free (pi->unwind_info);
pi->unwind_info = NULL;
}
}
unw_word_t
_Uia64_find_dyn_list (unw_addr_space_t as, void *table, size_t table_size,
unw_word_t segbase, void *arg)
{
unw_word_t hdr_addr, info_addr, hdr, directives, pers, cookie, off;
unw_accessors_t *a = unw_get_accessors (as);
struct ia64_table_entry *tab = table;
int ret;
if (table_size < sizeof (struct ia64_table_entry))
return 0;
if (tab[0].start_offset != tab[0].end_offset)
/* dyn-list entry cover a zero-length "procedure" and should be
first entry (note: technically a binary could contain code
below the segment base, but this doesn't happen for normal
binaries and certainly doesn't happen when libunwind is a
separate shared object. For weird cases, the application may
have to provide its own (slower) version of this routine. */
return 0;
hdr_addr = tab[0].info_offset + segbase;
info_addr = hdr_addr + 8;
/* read the header word: */
ret = (*a->access_mem) (as, hdr_addr, &hdr, 0, arg);
if (ret < 0)
return ret;
if (IA64_UNW_VER (hdr) != 1
|| IA64_UNW_FLAG_EHANDLER (hdr) || IA64_UNW_FLAG_UHANDLER (hdr))
/* dyn-list entry must be version 1 and doesn't have ehandler
or uhandler */
return 0;
if (IA64_UNW_LENGTH (hdr) != 1)
/* dyn-list entry must consist of a single word of NOP directives */
return 0;
if (((ret = (*a->access_mem) (as, info_addr, &directives, 0, arg)) < 0)
|| ((ret = (*a->access_mem) (as, info_addr + 0x08, &pers, 0, arg)) < 0)
|| ((ret = (*a->access_mem) (as, info_addr + 0x10, &cookie, 0, arg)) < 0)
|| ((ret = (*a->access_mem) (as, info_addr + 0x10, &off, 0, arg)) < 0))
return 0;
if (directives != 0 || pers != 0
|| (!as->big_endian && cookie != 0x7473696c2d6e7964)
|| ( as->big_endian && cookie != 0x64796e2d6c697374))
return 0;
/* OK, we ran the gauntlet and found it: */
return off + segbase;
}
#ifndef UNW_REMOTE_ONLY
#include <link.h>
#include <stddef.h>
#include <stdlib.h>
#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) \
|| (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && !defined(DT_CONFIG))
# error You need GLIBC 2.2.4 or later on IA-64 Linux
#endif
#ifdef HAVE_GETUNWIND
extern unsigned long getunwind (void *buf, size_t len);
#else /* HAVE_GETUNWIND */
#include <unistd.h>
#include <sys/syscall.h>
# ifndef __NR_getunwind
# define __NR_getunwind 1215
# endif
static unsigned long
getunwind (void *buf, size_t len)
{
return syscall (SYS_getunwind, buf, len);
}
#endif /* HAVE_GETUNWIND */
static unw_dyn_info_t kernel_table;
static int
get_kernel_table (void *ptr)
{
struct ia64_table_entry *ktab, *etab;
unw_dyn_info_t *di = ptr;
size_t size;
debug (100, "unwind: checking kernel unwind table");
size = getunwind (NULL, 0);
ktab = sos_alloc (size);
if (!ktab)
{
dprintf (__FILE__".%s: failed to allocate %Zu bytes",
__FUNCTION__, size);
return -UNW_ENOMEM;
}
getunwind (ktab, size);
/* Determine length of kernel's unwind table & relocate its entries. */
for (etab = ktab; etab->start_offset; ++etab)
etab->info_offset += (uint64_t) ktab;
di->format = UNW_INFO_FORMAT_TABLE;
di->gp = 0;
di->start_ip = ktab[0].start_offset;
di->end_ip = etab[-1].end_offset;
di->u.ti.name_ptr = (unw_word_t) "<kernel>";
di->u.ti.segbase = 0;
di->u.ti.table_len = ((char *) etab - (char *) ktab) / sizeof (unw_word_t);
di->u.ti.table_data = (unw_word_t *) ktab;
debug (100, "unwind: found table `%s': segbase=%lx, len=%lu, gp=%lx\n",
(char *) di->u.ti.name_ptr, di->u.ti.segbase, di->u.ti.table_len,
di->gp);
return 0;
}
static int
callback (struct dl_phdr_info *info, size_t size, void *ptr)
{
unw_dyn_info_t *di = ptr;
const Elf64_Phdr *phdr, *p_unwind, *p_dynamic, *p_text;
long n;
Elf64_Addr load_base;
/* Make sure struct dl_phdr_info is at least as big as we need. */
if (size < offsetof (struct dl_phdr_info, dlpi_phnum)
+ sizeof (info->dlpi_phnum))
return -1;
debug (100, "unwind: checking `%s'\n", info->dlpi_name);
phdr = info->dlpi_phdr;
load_base = info->dlpi_addr;
p_text = NULL;
p_unwind = NULL;
p_dynamic = NULL;
/* See if PC falls into one of the loaded segments. Find the unwind
segment at the same time. */
for (n = info->dlpi_phnum; --n >= 0; phdr++)
{
if (phdr->p_type == PT_LOAD)
{
Elf64_Addr vaddr = phdr->p_vaddr + load_base;
if (di->u.ti.segbase >= vaddr
&& di->u.ti.segbase < vaddr + phdr->p_memsz)
p_text = phdr;
}
else if (phdr->p_type == PT_IA_64_UNWIND)
p_unwind = phdr;
else if (phdr->p_type == PT_DYNAMIC)
p_dynamic = phdr;
}
if (!p_text || !p_unwind)
return 0;
if (p_dynamic)
{
/* For dynamicly linked executables and shared libraries,
DT_PLTGOT is the gp value for that object. */
Elf64_Dyn *dyn = (Elf64_Dyn *)(p_dynamic->p_vaddr + load_base);
for (; dyn->d_tag != DT_NULL ; dyn++)
if (dyn->d_tag == DT_PLTGOT)
{
/* On IA-64, _DYNAMIC is writable and GLIBC has relocated it. */
di->gp = dyn->d_un.d_ptr;
break;
}
}
else
{
/* Otherwise this is a static executable with no _DYNAMIC.
The gp is constant program-wide. */
register unsigned long gp __asm__("gp");
di->gp = gp;
}
di->format = UNW_INFO_FORMAT_TABLE;
di->start_ip = p_text->p_vaddr + load_base;
di->end_ip = p_text->p_vaddr + load_base + p_text->p_memsz;
di->u.ti.name_ptr = (unw_word_t) info->dlpi_name;
di->u.ti.table_data = (void *) (p_unwind->p_vaddr + load_base);
di->u.ti.table_len = p_unwind->p_memsz / sizeof (unw_word_t);
di->u.ti.segbase = p_text->p_vaddr + load_base;
debug (100, "unwind: found table `%s': segbase=%lx, len=%lu, gp=%lx, "
"table_data=%p\n", (char *) di->u.ti.name_ptr, di->u.ti.segbase,
di->u.ti.table_len, di->gp, di->u.ti.table_data);
return 1;
}
HIDDEN int
_Uia64_find_proc_info (unw_addr_space_t as, unw_word_t ip,
unw_proc_info_t *pi, int need_unwind_info, void *arg)
{
unw_dyn_info_t di, *dip = &di;
int ret;
di.u.ti.segbase = ip; /* this is cheap... */
if (dl_iterate_phdr (callback, &di) <= 0)
{
if (!kernel_table.u.ti.table_data)
{
ret = get_kernel_table (&kernel_table);
if (ret < 0)
return ret;
}
if (ip < kernel_table.start_ip || ip >= kernel_table.end_ip)
return -UNW_ENOINFO;
dip = &kernel_table;
}
/* now search the table: */
return tdep_search_unwind_table (as, ip, dip, pi, need_unwind_info, arg);
}
#endif /* !UNW_REMOTE_ONLY */

View file

@ -1,83 +0,0 @@
#include "unwind_i.h"
static const char *regname[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
"r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39",
"r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47",
"r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55",
"r56", "r57", "r58", "r59", "r60", "r61", "r62", "r63",
"r64", "r65", "r66", "r67", "r68", "r69", "r70", "r71",
"r72", "r73", "r74", "r75", "r76", "r77", "r78", "r79",
"r80", "r81", "r82", "r83", "r84", "r85", "r86", "r87",
"r88", "r89", "r90", "r91", "r92", "r93", "r94", "r95",
"r96", "r97", "r98", "r99", "r100", "r101", "r102", "r103",
"r104", "r105", "r106", "r107", "r108", "r109", "r110", "r111",
"r112", "r113", "r114", "r115", "r116", "r117", "r118", "r119",
"r120", "r121", "r122", "r123", "r124", "r125", "r126", "r127",
"nat0", "nat1", "nat2", "nat3", "nat4", "nat5", "nat6", "nat7",
"nat8", "nat9", "nat10", "nat11", "nat12", "nat13", "nat14", "nat15",
"nat16", "nat17", "nat18", "nat19", "nat20", "nat21", "nat22", "nat23",
"nat24", "nat25", "nat26", "nat27", "nat28", "nat29", "nat30", "nat31",
"nat32", "nat33", "nat34", "nat35", "nat36", "nat37", "nat38", "nat39",
"nat40", "nat41", "nat42", "nat43", "nat44", "nat45", "nat46", "nat47",
"nat48", "nat49", "nat50", "nat51", "nat52", "nat53", "nat54", "nat55",
"nat56", "nat57", "nat58", "nat59", "nat60", "nat61", "nat62", "nat63",
"nat64", "nat65", "nat66", "nat67", "nat68", "nat69", "nat70", "nat71",
"nat72", "nat73", "nat74", "nat75", "nat76", "nat77", "nat78", "nat79",
"nat80", "nat81", "nat82", "nat83", "nat84", "nat85", "nat86", "nat87",
"nat88", "nat89", "nat90", "nat91", "nat92", "nat93", "nat94", "nat95",
"nat96", "nat97", "nat98", "nat99", "nat100", "nat101", "nat102", "nat103",
"nat104","nat105","nat106", "nat107", "nat108", "nat109", "nat110", "nat111",
"nat112","nat113","nat114", "nat115", "nat116", "nat117", "nat118", "nat119",
"nat120","nat121","nat122", "nat123", "nat124", "nat125", "nat126", "nat127",
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
"f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39",
"f40", "f41", "f42", "f43", "f44", "f45", "f46", "f47",
"f48", "f49", "f50", "f51", "f52", "f53", "f54", "f55",
"f56", "f57", "f58", "f59", "f60", "f61", "f62", "f63",
"f64", "f65", "f66", "f67", "f68", "f69", "f70", "f71",
"f72", "f73", "f74", "f75", "f76", "f77", "f78", "f79",
"f80", "f81", "f82", "f83", "f84", "f85", "f86", "f87",
"f88", "f89", "f90", "f91", "f92", "f93", "f94", "f95",
"f96", "f97", "f98", "f99", "f100", "f101", "f102", "f103",
"f104", "f105", "f106", "f107", "f108", "f109", "f110", "f111",
"f112", "f113", "f114", "f115", "f116", "f117", "f118", "f119",
"f120", "f121", "f122", "f123", "f124", "f125", "f126", "f127",
"ar0", "ar1", "ar2", "ar3", "ar4", "ar5", "ar6", "ar7",
"ar8", "ar9", "ar10", "ar11", "ar12", "ar13", "ar14", "ar15",
"rsc", "bsp", "bspstore", "rnat", "ar20", "ar21", "ar22", "ar23",
"ar24", "ar25", "ar26", "ar27", "ar28", "ar29", "ar30", "ar31",
"ccv", "ar33", "ar34", "ar35", "unat", "ar37", "ar38", "ar39",
"fpsr", "ar41", "ar42", "ar43", "ar44", "ar45", "ar46", "ar47",
"ar48", "ar49", "ar50", "ar51", "ar52", "ar53", "ar54", "ar55",
"ar56", "ar57", "ar58", "ar59", "ar60", "ar61", "ar62", "ar63",
"pfs", "lc", "ec", "ar67", "ar68", "ar69", "ar70", "ar71",
"ar72", "ar73", "ar74", "ar75", "ar76", "ar77", "ar78", "ar79",
"ar80", "ar81", "ar82", "ar83", "ar84", "ar85", "ar86", "ar87",
"ar88", "ar89", "ar90", "ar91", "ar92", "ar93", "ar94", "ar95",
"ar96", "ar97", "ar98", "ar99", "ar100", "ar101", "ar102", "ar103",
"ar104", "ar105", "ar106", "ar107", "ar108", "ar109", "ar110", "ar111",
"ar112", "ar113", "ar114", "ar115", "ar116", "ar117", "ar118", "ar119",
"ar120", "ar121", "ar122", "ar123", "ar124", "ar125", "ar126", "ar127",
"rp", "b1", "b2", "b3", "b4", "b5", "b6", "b7",
"pr",
"cfm",
"bsp",
"ip",
"sp"
};
const char *
unw_regname (unw_regnum_t reg)
{
if (reg < sizeof (regname) / sizeof (regname[0]))
return regname[reg];
else
return "???";
}