无法在CygWin下构建AVR和ARM GDB 9.1(..重定位被截断以适合:R_X86_64_PC32针对未定义的符号.) [英] Failed to build AVR and ARM GDB 9.1 under CygWin (..relocation truncated to fit: R_X86_64_PC32 against undefined symbol..)

查看:83
本文介绍了无法在CygWin下构建AVR和ARM GDB 9.1(..重定位被截断以适合:R_X86_64_PC32针对未定义的符号.)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mkdir gdb
(
   cd gdb
   #--------------
   echo "Configuring gdb (for details see build/gdb-configure.log)"
   ../../source/${GDB}/configure \
   --build=x86_64-pc-cygwin \
   --host=x86_64-pc-cygwin \
   --target=${TARGET} \
   --prefix=${DSTDIR} \
   --disable-nls \
   --with-gmp=/usr/local \
   --with-mpfr=/usr/local \
   --with-expat \
   > ../gdb-configure.log 2>&1
   #--------------
   echo "Building gdb (for details see build/gdb-make.log)"
   make > ../gdb-make.log 2>&1
   #--------------
   echo "Installing gdb (for details see build/gdb-install.log)"
   make install > ../gdb-install.log 2>&1
   #--------------
   echo "done"
)

由于以下错误,我无法在CygWin64下构建AVR(以及ARM)GDB 9.1(使用上面的代码,这是我完整的GNU工具链生成器的一部分):

I cannot build AVR (and also ARM) GDB 9.1 under CygWin64 (using the above piece of code, part of my full GNU toolchain builder) because of this error:

  CXXLD  gdb.exe    
cp-support.o: in function `gdb_demangle(char const*, int)':
    /home/mario/Gcc101_maker/build/gdb/gdb/../../../source/gdb-9.1/gdb/cp-support.c:1552:(.text+0x1d14): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for thread_local_segv_handler'
    /home/mario/Gcc101_maker/build/gdb/gdb/../../../source/gdb-9.1/gdb/cp-support.c:1552:(.text+0x1d2d): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TLS init function for thread_local_segv_handler'
    collect2: error: ld returned 1 exit status
    make[2]: *** [Makefile:1908: gdb.exe] Error 1
    make[2]: Leaving directory '/home/mario/Gcc101_maker/build/gdb/gdb'
    make[1]: *** [Makefile:9567: all-gdb] Error 2
    make[1]: Leaving directory '/home/mario/Gcc101_maker/build/gdb'
    make: *** [Makefile:855: all] Error 2

在相同的环境中,我可以编译GDB 8.1.3(以及任何以前的版本).我该怎么做才能构建GDB 9.1?谢谢.

In the same environment I can compile GDB 8.1.3 (and any previous version). What can I do to build GDB 9.1? Thanks.

推荐答案

这为我修复了gdb的构建,也许对您也有帮助:

This fixed up gdb build for me, maybe it will help you as well:

感谢Yuri Phonin @ MIPT的补丁程序.

Thanks to Yuri Phonin @ MIPT for the patch.

diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index c1d62f17..30195f79 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1539,21 +1539,40 @@ report_failed_demangle (const char *name, bool core_dump_allowed,
 
 #endif
 
-/* A wrapper for bfd_demangle.  */
+#ifdef __CYGWIN__ 
+extern void set_segv_handler(void* hdl);
+#endif
 
+/* A wrapper for bfd_demangle.  */
 char *
 gdb_demangle (const char *name, int options)
 {
   char *result = NULL;
   int crash_signal = 0;
-
+  
 #ifdef HAVE_WORKING_FORK
+#ifdef __CYGWIN__ 
+  thread_local void (*thread_local_segv_handler_l) (int);
+  thread_local_segv_handler_l = NULL;
+
   scoped_restore restore_segv
+    = make_scoped_restore (&thread_local_segv_handler_l,
+              catch_demangler_crashes
+              ? gdb_demangle_signal_handler
+              : nullptr);
+  set_segv_handler((void*)thread_local_segv_handler_l);
+  
+#else
+  
+ scoped_restore restore_segv
     = make_scoped_restore (&thread_local_segv_handler,
               catch_demangler_crashes
               ? gdb_demangle_signal_handler
               : nullptr);
-
+#endif
+  
   bool core_dump_allowed = gdb_demangle_attempt_core_dump;
   SIGJMP_BUF jmp_buf;
   scoped_restore restore_jmp_buf
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 8ac6965f..982ab284 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -846,12 +846,20 @@ gdb_readline_no_editing_callback (gdb_client_data client_data)
   result = buffer_finish (&line_buffer);
   ui->input_handler (gdb::unique_xmalloc_ptr<char> (result));
 }
-
 
 /* See event-top.h.  */
 
 thread_local void (*thread_local_segv_handler) (int);
 
+#ifdef __CYGWIN__ 
+void set_segv_handler(void* hdl)
+{
+  thread_local_segv_handler = (void (*)(int))hdl;
+}
+#endif
+
 static void handle_sigsegv (int sig);
 
 /* Install the SIGSEGV handler.  */
@@ -879,9 +887,12 @@ static void
 handle_sigsegv (int sig)
 {
   install_handle_sigsegv ();
   if (thread_local_segv_handler == nullptr)
+  {
     abort ();
+  }
   thread_local_segv_handler (sig);
 }

这篇关于无法在CygWin下构建AVR和ARM GDB 9.1(..重定位被截断以适合:R_X86_64_PC32针对未定义的符号.)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆