[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] [PATCH 2/8] Allow IA64 cross-compilation
From: |
Tommi Rantala |
Subject: |
[Libunwind-devel] [PATCH 2/8] Allow IA64 cross-compilation |
Date: |
Tue, 31 Jul 2012 23:06:28 +0300 |
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.
---
src/Makefile.am | 15 ++++----
src/ia64/mk_Gcursor_i.c | 91 +++++++++++++----------------------------------
src/ia64/mk_cursor_i | 7 ++++
3 files changed, 40 insertions(+), 73 deletions(-)
create mode 100755 src/ia64/mk_cursor_i
diff --git a/src/Makefile.am b/src/Makefile.am
index 281f2f5..b3fd043 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -400,14 +400,15 @@ endif
libunwind_setjmp_la_SOURCES += arm/siglongjmp.S
else
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
-Gcursor_i.h: ia64/mk_Gcursor_i
- ia64/mk_Gcursor_i > $@
-Lcursor_i.h: ia64/mk_Lcursor_i
- ia64/mk_Lcursor_i > $@
+mk_Gcursor_i.s: ia64/mk_Gcursor_i.c
+ $(COMPILE) -S ia64/mk_Gcursor_i.c -o mk_Gcursor_i.s
+mk_Lcursor_i.s: ia64/mk_Lcursor_i.c
+ $(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
libunwind_la_SOURCES = $(libunwind_la_SOURCES_ia64)
diff --git a/src/ia64/mk_Gcursor_i.c b/src/ia64/mk_Gcursor_i.c
index 51cb0f4..b8f3253 100644
--- a/src/ia64/mk_Gcursor_i.c
+++ b/src/ia64/mk_Gcursor_i.c
@@ -25,8 +25,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
/* Utility to generate cursor_i.h. */
-#include <stdio.h>
-
#include "libunwind_i.h"
#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)
-static struct
- {
- 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";
+#define OFFSET(sym, offset) \
+ asm volatile("\n->" #sym " %0" : : "i" (offset))
int
-main (int argc, char **argv)
+main (void)
{
- const char *space;
- int i, num_tabs;
- size_t len;
-
- printf ("#ifndef cursor_i_h\n");
- printf ("#define cursor_i_h\n\n");
-
- printf ("/*\n * DO NOT MODIFY\n *\n * This file was generated by "
- "%s.\n *\n */\n\n", argv[0]);
-
- for (i = 0; i < (int) (sizeof (tab) / sizeof (tab[0])); ++i)
- {
- if (tab[i].name[0] == '\0')
- printf ("\n");
- else
- {
- len = strlen (tab[i].name);
-
- num_tabs = (40 - len) / 8;
- if (num_tabs <= 0)
- space = " ";
- else
- 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");
+ OFFSET("IP_OFF", offsetof (struct cursor, ip));
+ OFFSET("PR_OFF", offsetof (struct cursor, pr));
+ OFFSET("BSP_OFF", offsetof (struct cursor, bsp));
+ OFFSET("PSP_OFF", offsetof (struct cursor, psp));
+ OFFSET("PFS_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_PFS]));
+ OFFSET("RNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_RNAT]));
+ OFFSET("UNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_UNAT]));
+ OFFSET("LC_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_LC]));
+ OFFSET("FPSR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_FPSR]));
+ OFFSET("B1_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B1]));
+ OFFSET("B2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B2]));
+ OFFSET("B3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B3]));
+ OFFSET("B4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B4]));
+ OFFSET("B5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B5]));
+ OFFSET("F2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F2]));
+ OFFSET("F3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F3]));
+ OFFSET("F4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F4]));
+ OFFSET("F5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F5]));
+ OFFSET("FR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F16]));
+ OFFSET("LOC_SIZE",
+ (offsetof (struct cursor, loc[1]) - offsetof (struct cursor, loc[0])));
+ OFFSET("SIGCONTEXT_ADDR_OFF", offsetof (struct cursor, sigcontext_addr));
return 0;
}
diff --git a/src/ia64/mk_cursor_i b/src/ia64/mk_cursor_i
new file mode 100755
index 0000000..9211f91
--- /dev/null
+++ b/src/ia64/mk_cursor_i
@@ -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"
--
1.7.9.5
- [Libunwind-devel] [PATCH 0/8] misc fixes, Tommi Rantala, 2012/07/31
- [Libunwind-devel] [PATCH 1/8] Rip out AC_TYPE_SIGNAL and sighandler_t check, Tommi Rantala, 2012/07/31
- [Libunwind-devel] [PATCH 3/8] IA64: use tdep_find_unwind_table() in coredump lib, Tommi Rantala, 2012/07/31
- [Libunwind-devel] [PATCH 2/8] Allow IA64 cross-compilation,
Tommi Rantala <=
- [Libunwind-devel] [PATCH 4/8] Fix --enable-debug-frame build, Tommi Rantala, 2012/07/31
- [Libunwind-devel] [PATCH 5/8] IA64: `ent' needed conditionally in Gtables.c, Tommi Rantala, 2012/07/31
- [Libunwind-devel] [PATCH 6/8] Fix IP vs. PC confusion in tests on ARM, Tommi Rantala, 2012/07/31
- [Libunwind-devel] [PATCH 7/8] Use unw_context_t instead of ucontext_t in tests/Gtest-trace.c and tests/Gtest-bt.c, Tommi Rantala, 2012/07/31
- [Libunwind-devel] [PATCH 8/8] Fix typo in unw_get_proc_name documentation, Tommi Rantala, 2012/07/31