mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-25 16:47:38 +01:00
Allow IA64 cross-compilation
Change the way we generate the cursor header files, so that we do not need to invoke IA64 binaries, which would fail when cross-compiling libunwind. Adopt the strategy used in the Linux kernel build system, and parse our annotated offset information from the assembler file produced by the compiler.
This commit is contained in:
parent
a06f189baf
commit
354b3fd45b
3 changed files with 40 additions and 73 deletions
|
@ -400,14 +400,15 @@ endif
|
||||||
libunwind_setjmp_la_SOURCES += arm/siglongjmp.S
|
libunwind_setjmp_la_SOURCES += arm/siglongjmp.S
|
||||||
else
|
else
|
||||||
if ARCH_IA64
|
if ARCH_IA64
|
||||||
ia64_mk_Gcursor_i_SOURCES = ia64/mk_Gcursor_i.c
|
|
||||||
ia64_mk_Lcursor_i_SOURCES = ia64/mk_Lcursor_i.c
|
|
||||||
noinst_PROGRAMS = ia64/mk_Gcursor_i ia64/mk_Lcursor_i
|
|
||||||
BUILT_SOURCES = Gcursor_i.h Lcursor_i.h
|
BUILT_SOURCES = Gcursor_i.h Lcursor_i.h
|
||||||
Gcursor_i.h: ia64/mk_Gcursor_i
|
mk_Gcursor_i.s: ia64/mk_Gcursor_i.c
|
||||||
ia64/mk_Gcursor_i > $@
|
$(COMPILE) -S ia64/mk_Gcursor_i.c -o mk_Gcursor_i.s
|
||||||
Lcursor_i.h: ia64/mk_Lcursor_i
|
mk_Lcursor_i.s: ia64/mk_Lcursor_i.c
|
||||||
ia64/mk_Lcursor_i > $@
|
$(COMPILE) -S ia64/mk_Lcursor_i.c -o mk_Lcursor_i.s
|
||||||
|
Gcursor_i.h: mk_Gcursor_i.s
|
||||||
|
ia64/mk_cursor_i mk_Gcursor_i.s > Gcursor_i.h
|
||||||
|
Lcursor_i.h: mk_Lcursor_i.s
|
||||||
|
ia64/mk_cursor_i mk_Lcursor_i.s > Lcursor_i.h
|
||||||
|
|
||||||
lib_LTLIBRARIES += libunwind-ia64.la
|
lib_LTLIBRARIES += libunwind-ia64.la
|
||||||
libunwind_la_SOURCES = $(libunwind_la_SOURCES_ia64)
|
libunwind_la_SOURCES = $(libunwind_la_SOURCES_ia64)
|
||||||
|
|
|
@ -25,8 +25,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
|
||||||
/* Utility to generate cursor_i.h. */
|
/* Utility to generate cursor_i.h. */
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "libunwind_i.h"
|
#include "libunwind_i.h"
|
||||||
|
|
||||||
#ifdef offsetof
|
#ifdef offsetof
|
||||||
|
@ -35,72 +33,33 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
|
||||||
#define offsetof(type,field) ((char *) &((type *) 0)->field - (char *) 0)
|
#define offsetof(type,field) ((char *) &((type *) 0)->field - (char *) 0)
|
||||||
|
|
||||||
static struct
|
#define OFFSET(sym, offset) \
|
||||||
{
|
asm volatile("\n->" #sym " %0" : : "i" (offset))
|
||||||
const char name[256];
|
|
||||||
unsigned long value;
|
|
||||||
}
|
|
||||||
tab[] =
|
|
||||||
{
|
|
||||||
{ "IP_OFF", offsetof (struct cursor, ip) },
|
|
||||||
{ "PR_OFF", offsetof (struct cursor, pr) },
|
|
||||||
{ "BSP_OFF", offsetof (struct cursor, bsp) },
|
|
||||||
{ "PSP_OFF", offsetof (struct cursor, psp) },
|
|
||||||
{ "PFS_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_PFS]) },
|
|
||||||
{ "RNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_RNAT]) },
|
|
||||||
{ "UNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_UNAT]) },
|
|
||||||
{ "LC_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_LC]) },
|
|
||||||
{ "FPSR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_FPSR]) },
|
|
||||||
{ "B1_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B1]) },
|
|
||||||
{ "B2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B2]) },
|
|
||||||
{ "B3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B3]) },
|
|
||||||
{ "B4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B4]) },
|
|
||||||
{ "B5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B5]) },
|
|
||||||
{ "F2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F2]) },
|
|
||||||
{ "F3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F3]) },
|
|
||||||
{ "F4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F4]) },
|
|
||||||
{ "F5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F5]) },
|
|
||||||
{ "FR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F16]) },
|
|
||||||
{ "LOC_SIZE",
|
|
||||||
(offsetof (struct cursor, loc[1]) - offsetof (struct cursor, loc[0]))
|
|
||||||
},
|
|
||||||
{ "SIGCONTEXT_ADDR_OFF", offsetof (struct cursor, sigcontext_addr) },
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char *tabs = "\t\t\t\t\t\t\t\t\t\t";
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (void)
|
||||||
{
|
{
|
||||||
const char *space;
|
OFFSET("IP_OFF", offsetof (struct cursor, ip));
|
||||||
int i, num_tabs;
|
OFFSET("PR_OFF", offsetof (struct cursor, pr));
|
||||||
size_t len;
|
OFFSET("BSP_OFF", offsetof (struct cursor, bsp));
|
||||||
|
OFFSET("PSP_OFF", offsetof (struct cursor, psp));
|
||||||
printf ("#ifndef cursor_i_h\n");
|
OFFSET("PFS_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_PFS]));
|
||||||
printf ("#define cursor_i_h\n\n");
|
OFFSET("RNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_RNAT]));
|
||||||
|
OFFSET("UNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_UNAT]));
|
||||||
printf ("/*\n * DO NOT MODIFY\n *\n * This file was generated by "
|
OFFSET("LC_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_LC]));
|
||||||
"%s.\n *\n */\n\n", argv[0]);
|
OFFSET("FPSR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_FPSR]));
|
||||||
|
OFFSET("B1_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B1]));
|
||||||
for (i = 0; i < (int) (sizeof (tab) / sizeof (tab[0])); ++i)
|
OFFSET("B2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B2]));
|
||||||
{
|
OFFSET("B3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B3]));
|
||||||
if (tab[i].name[0] == '\0')
|
OFFSET("B4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B4]));
|
||||||
printf ("\n");
|
OFFSET("B5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B5]));
|
||||||
else
|
OFFSET("F2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F2]));
|
||||||
{
|
OFFSET("F3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F3]));
|
||||||
len = strlen (tab[i].name);
|
OFFSET("F4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F4]));
|
||||||
|
OFFSET("F5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F5]));
|
||||||
num_tabs = (40 - len) / 8;
|
OFFSET("FR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F16]));
|
||||||
if (num_tabs <= 0)
|
OFFSET("LOC_SIZE",
|
||||||
space = " ";
|
(offsetof (struct cursor, loc[1]) - offsetof (struct cursor, loc[0])));
|
||||||
else
|
OFFSET("SIGCONTEXT_ADDR_OFF", offsetof (struct cursor, sigcontext_addr));
|
||||||
space = strchr(tabs, '\0') - (40 - len) / 8;
|
|
||||||
|
|
||||||
printf ("#define %s%s%lu\t/* 0x%lx */\n",
|
|
||||||
tab[i].name, space, tab[i].value, tab[i].value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
printf ("\n#endif /* cursor_i_h */\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
7
src/ia64/mk_cursor_i
Executable file
7
src/ia64/mk_cursor_i
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
test -z "$1" && exit 1
|
||||||
|
echo "/* GENERATED */"
|
||||||
|
echo "#ifndef cursor_i_h"
|
||||||
|
echo "#define cursor_i_h"
|
||||||
|
sed -ne 's/^->"\(\S*\)" \(\d*\)/#define \1 \2/p' < $1 || exit $?
|
||||||
|
echo "#endif"
|
Loading…
Reference in a new issue