hns - 日記自動生成システム - Version 2.19.9

先月 2013年11月 来月
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Namazu for hns による簡易全文検索
詳しくは 詳細指定/ヘルプを参照して下さい
検索式:

2013年11月03日() 旧暦 [n年日記] [更新:"2013/11/04 01:34:17"]

#1 [pkgsrc] nios2-gcc (4.1) xgcc Segfaults at function call

modena@makoto 21:00:27/131103(..build/gcc)% gdb  /export/git-work/nios2/build/./gcc/xgcc 
GNU gdb (GDB) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64--netbsd".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /export/git-work/nios2/build/gcc/xgcc...done.
Breakpoint 1 at 0x403944: file ../../gcc-4.1/gcc/gcc.c, line 7055.
Function "internal_error" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Breakpoint 2 at 0x401880
Breakpoint 3 at 0x401810
(gdb) pwd
Working directory /export/git-work/nios2/build/gcc.

(gdb) run -B/export/git-work/nios2/build/./gcc/   \
-B/usr/pkg/cross/nios2-elf/bin/  \
-B/usr/pkg/cross/nios2-elf/lib/ -isystem  \
/usr/pkg/cross/nios2-elf/include -isystem  \
/usr/pkg/cross/nios2-elf/sys-include -O2 -O2 -g -O2 -DIN_GCC  \
-DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes  \
-Wmissing-prototypes -Wold-style-definition -isystem ./include  \
-I. -I. -I../../gcc-4.1/gcc  \
-I../../gcc-4.1/gcc/. -I../../gcc-4.1/gcc/../include  \
-I../../gcc-4.1/gcc/../libcpp/include -g0  \
-finhibit-size-directive -fno-inline-functions -fno-exceptions  \
-fno-zero-initialized-in-bss -fno-unit-at-a-time  \
-Dinhibit_libc \
-c ../../gcc-4.1/gcc/crtstuff.c -DCRT_BEGIN \
-o crtbegin.o

Starting program: /export/git-work/nios2/build/gcc/xgcc
-B/export/git-work/nios2/build/./gcc/
-B/usr/pkg/cross/nios2-elf/bin/
-B/usr/pkg/cross/nios2-elf/lib/ -isystem
/usr/pkg/cross/nios2-elf/include -isystem
/usr/pkg/cross/nios2-elf/sys-include -O2 -O2 -g -O2 -DIN_GCC
-DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes
-Wmissing-prototypes -Wold-style-definition -isystem ./include
-I. -Ip. -I../../gcc-4.1/gcc
-I../../gcc-4.1/gcc/. -I../../gcc-4.1/gcc/../include
-I../../gcc-4.1/gcc/../libcpp/include -g0
-finhibit-size-directive -fno-inline-functions -fno-exceptions
-fno-zero-initialized-in-bss -fno-unit-at-a-time
-Dinhibit_libc -c ../../gcc-4.1/gcc/crtstuff.c -DCRT_BEGIN -o
crtbegin.o

../../gcc-4.1/gcc/crtstuff.c: In function 'frame_dummy':
../../gcc-4.1/gcc/crtstuff.c:323: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
[Inferior 1 (process 5260) exited with code 01]
(gdb) bt
No stack.
(gdb) 

source code is:

modena@makoto 21:09:03/131103(..build/gcc)% \ cat -n ../../gcc-4.1/gcc/crtstuff.c |sed -n 310,339p
   310  #else /* !defined(FINI_SECTION_ASM_OP) */
   311  static func_ptr __do_global_dtors_aux_fini_array_entry[]
   312    __attribute__ ((__unused__, section(".fini_array")))
   313    = { __do_global_dtors_aux };
   314  #endif /* !defined(FINI_SECTION_ASM_OP) */
   315
   316  #if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
   317  /* Stick a call to __register_frame_info into the .init section.  For some
   318     reason calls with no arguments work more reliably in .init, so stick the
   319     call in another function.  */
   320
   321  static void __attribute__((used))
   322  frame_dummy (void)
   323  {
   324  #ifdef USE_EH_FRAME_REGISTRY
   325    static struct object object;
   326  #ifdef CRT_GET_RFIB_DATA
   327    void *tbase, *dbase;
   328    tbase = 0;
   329    CRT_GET_RFIB_DATA (dbase);
   330    if (__register_frame_info_bases)
   331      __register_frame_info_bases (__EH_FRAME_BEGIN__, &object, tbase, dbase);
   332  #else
   333    if (__register_frame_info)
   334      __register_frame_info (__EH_FRAME_BEGIN__, &object);
   335  #endif /* CRT_GET_RFIB_DATA */
   336  #endif /* USE_EH_FRAME_REGISTRY */
   337  #ifdef JCR_SECTION_NAME
   338    if (__JCR_LIST__[0])
   339      {
One possibility is this is the very first function call...
  • Above crtstuff.c is the code executing OR
  • crtstuff.c is just a source file to compile.
The answer is the second one. It will easily see by changing the code as
diff --git a/gcc-4.1/gcc/crtstuff.c b/gcc-4.1/gcc/crtstuff.c
index a712e4e..a5885aa 100644
--- a/gcc-4.1/gcc/crtstuff.c
+++ b/gcc-4.1/gcc/crtstuff.c
@@ -317,7 +317,8 @@ static func_ptr __do_global_dtors_aux_fini_array_entry[]
 /* Stick a call to __register_frame_info into the .init section.  For some
    reason calls with no arguments work more reliably in .init, so stick the
    call in another function.  */
-
+int tmp;
+xxx;
 static void __attribute__((used))
 frame_dummy (void)
 {

You will get
  -o crtbegin.o
../../gcc-4.1/gcc/crtstuff.c:321: warning: data definition has no type or storage class
../../gcc-4.1/gcc/crtstuff.c:321: warning: type defaults to 'int' in declaration of 'xxx'
../../gcc-4.1/gcc/crtstuff.c: In function 'frame_dummy':
../../gcc-4.1/gcc/crtstuff.c:324: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
gmake[2]: *** [crtbegin.o] Error 1
looping somewhere below around
nios2_use_reg_for_func: ../../gcc-4.1/gcc/config/nios2/nios2.c:383 +++ 
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:363 0
nios2_compute_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:339
nios2_compute_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:354 type -> 1 
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:366     1 
nios2_use_reg_for_func: ../../gcc-4.1/gcc/config/nios2/nios2.c:383 +++ 
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:363 1
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:366     1 
nios2_adjust_call_address: ../../gcc-4.1/gcc/config/nios2/nios2.c:1932
nios2_adjust_call_address: ../../gcc-4.1/gcc/config/nios2/nios2.c:1932
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:363 2
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:366     1 
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:363 3
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:366     1 
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:363 4
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:366     1 
nios2_current_func_type: ../../gcc-4.1/gcc/config/nios2/nios2.c:363 5
Todays diff
(including patches of wip/nios2-gcc/patches/)

gen_pic_load_call_addr:

You will soon come across the function gen_pic_load_call_addr. This is not found in source code. It is generated *.c file
modena@makoto 23:27:53/131103(..build/gcc)% grep -nr gen_pic_load_call_addr *.c *.h
insn-emit.c:2230:gen_pic_load_call_addr (rtx operand0 ATTRIBUTE_UNUSED,
insn-output.c:5946:    (insn_gen_fn) gen_pic_load_call_addr,
insn-flags.h:411:extern rtx        gen_pic_load_call_addr             (rtx, rtx, rtx);
modena@makoto 23:27:58/131103(..build/gcc)% view ./insn-emit.c
2228 /* ../../gcc-4.1/gcc/config/nios2/nios2.md:2988 */
2229 rtx
2230 gen_pic_load_call_addr (rtx operand0 ATTRIBUTE_UNUSED,
2231         rtx operand1 ATTRIBUTE_UNUSED,
2232         rtx operand2 ATTRIBUTE_UNUSED)  
2233 {       
2234   return gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2,
2235                 gen_rtx_SET (VOIDmode,
2236         operand0,
2237         gen_rtx_UNSPEC (SImode,
2238         gen_rtvec (2,
2239                 operand1,
2240                 operand2),
2241         33)),
2242                 gen_rtx_USE (VOIDmode,
2243         operand1)));
2244 }
This part comes (as commented in line 2228) from gcc/config/nios2/nios2.md:2988.

gcc/config/nios2/nios2.md:

2988 (define_insn "pic_load_call_addr"
2989   [(set (match_operand:SI 0 "register_operand" "=r")
2990         (unspec:SI [(match_operand:SI 1 "register_operand" "r")
2991                     (match_operand:SI 2 "" "mX")] UNSPEC_PIC_CALL_SYM))
2992    (use (match_dup 1))]
2993   "flag_pic" 
2994   "ldw\\t%0, %%call(%2)(%1)")

picture for calling sequence:

(click to enlarge)



最近の日記
2024年03月10日
停電 (瞬電)
2024年03月03日
the second try on bare-metal
useradd
2024年02月29日
opendkim and senmail
2024年01月24日
chat/iam 0.0.8
2024年01月21日
uselocale vs setlocale (textproc/R-readxl)
以上、1 日分です。
タイトル一覧
カテゴリ分類
Powered by hns-2.19.9, HyperNikkiSystem Project

Count.cgi (since 2000/02/05)