arm-elf:thumb and exception

tanaka tanaka@personal-media.co.jp
Mon Dec 22 07:54:00 GMT 2003


Thank you!

 >Does the application work if you build all the code in Thumb?  You
 >currently have a mix of ARM and Thumb code.

Yes. The sample works fine, when all of the modules were compiled in Thumb.

 >3) Edit the file t-arm-elf
 >4) Uncomment the following 3 lines
 >
 >MULTILIB_OPTIONS    += mno-thumb-interwork/mthumb-interwork
 >MULTILIB_DIRNAMES   += normal interwork
 >MULTILIB_EXCEPTIONS += *mapcs-26/*mthumb-interwork*

Yes. These operations had been already done.

I wonder,
mov pc, r1
is used when return to each catch from the tail of 
_Unwind_SjLj_RaiseException.
The LSB of the value of the r1 is 0.
It means that, the mode is not changed to Thumb from Arm.
But it is not all of the problem.

Following is the log of the compile message.
------------------------------------
tanaka@r48:/u9/te/util/c++test/bad/thumb_exp/arm-elf2/$ ./mk2.rc
/work/linux/tool/Linux-i686/bin/arm-unknown-elf-gcc -g -O0 -c 
-mthumb-interwork ../src/arm/crt0.S -o crt0.o
/work/linux/tool/Linux-i686/bin/arm-unknown-elf-gcc -g -O0 -c 
-mthumb-interwork ../src/arm/arm.S -o arm.o
/work/linux/tool/Linux-i686/bin/arm-unknown-elf-gcc -g -O0 -c 
-mthumb-interwork ../src/startup.c -o startup.o
/work/linux/tool/Linux-i686/bin/arm-unknown-elf-g++ -g -O0 -c 
-mthumb-interwork ../src/exp16bit.cc -o exp16bit.o -I../src
/work/linux/tool/Linux-i686/bin/arm-unknown-elf-g++ -g -O0 -c 
-mthumb-interwork -mthumb ../src/expon16.cc -o expon16.o -I../src
/work/linux/tool/Linux-i686/bin/arm-unknown-elf-g++ -g -O0 -c 
-mthumb-interwork ../src/expon32.cc -o expon32.o -I../src
/work/linux/tool/Linux-i686/bin/arm-unknown-elf-gcc -g -O0 -c 
-mthumb-interwork ../src/misc.c -o misc.o -I../src
../src/misc.c:17: warning: conflicting types for built-in function `memset'
../src/misc.c: In function `abort':
../src/misc.c:25: warning: `noreturn' function does return

/work/linux/tool/Linux-i686/bin/arm-unknown-elf-g++ -mthumb-interwork 
-Wl,-verbose -nostartfiles -nostdlib -o exp16bit crt0.o 
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crti.o 
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crtbegin.o 
arm.o startup.o exp16bit.o expon32.o expon16.o misc.o 
/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a 
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/libgcc.a 
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crtend.o 
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crtn.o
GNU ld version 2.14 20030612
   Supported emulations:
    armelf
using internal linker script:
==================================================
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
	      "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SEARCH_DIR("/work/linux/tool/Linux-i686/arm-unknown-elf/lib");
/* Do we need any of these for elf?
    __DYNAMIC = 0;    */
SECTIONS
{
   /* Read-only sections, merged into text segment: */
   . = 0x8000;
   .interp         : { *(.interp) }
   .hash           : { *(.hash) }
   .dynsym         : { *(.dynsym) }
   .dynstr         : { *(.dynstr) }
   .gnu.version    : { *(.gnu.version) }
   .gnu.version_d  : { *(.gnu.version_d) }
   .gnu.version_r  : { *(.gnu.version_r) }
   .rel.dyn        :
     {
       *(.rel.init)
       *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
       *(.rel.fini)
       *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
       *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
       *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
       *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
       *(.rel.ctors)
       *(.rel.dtors)
       *(.rel.got)
       *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
       *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
       *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
       *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
       *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
     }
   .rela.dyn       :
     {
       *(.rela.init)
       *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
       *(.rela.fini)
       *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
       *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
       *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
       *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
       *(.rela.ctors)
       *(.rela.dtors)
       *(.rela.got)
       *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
       *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
       *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
       *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
       *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
     }
   .rel.plt        : { *(.rel.plt) }
   .rela.plt       : { *(.rela.plt) }
   .init           :
   {
     KEEP (*(.init))
   } =0
   .plt            : { *(.plt) }
   .text           :
   {
     *(.text .stub .text.* .gnu.linkonce.t.*)
     /* .gnu.warning sections are handled specially by elf32.em.  */
     *(.gnu.warning)
     *(.glue_7t) *(.glue_7)
   } =0
   .fini           :
   {
     KEEP (*(.fini))
   } =0
   PROVIDE (__etext = .);
   PROVIDE (_etext = .);
   PROVIDE (etext = .);
   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
   .rodata1        : { *(.rodata1) }
   .sdata2         : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
   .sbss2          : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
   .note.gnu.arm.ident : { KEEP (*(.note.gnu.arm.ident)) }
   .eh_frame_hdr : { *(.eh_frame_hdr) }
   /* Adjust the address for the data segment.  We want to adjust up to
      the same address within the page on the next page up.  */
   . = ALIGN(256) + (. & (256 - 1));
   /* Ensure the __preinit_array_start label is properly aligned.  We
      could instead move the label definition inside the section, but
      the linker would then create the section even if it turns out to
      be empty, which isn't pretty.  */
   . = ALIGN(32 / 8);
   PROVIDE (__preinit_array_start = .);
   .preinit_array     : { *(.preinit_array) }
   PROVIDE (__preinit_array_end = .);
   PROVIDE (__init_array_start = .);
   .init_array     : { *(.init_array) }
   PROVIDE (__init_array_end = .);
   PROVIDE (__fini_array_start = .);
   .fini_array     : { *(.fini_array) }
   PROVIDE (__fini_array_end = .);
   .data           :
   {
     __data_start = . ;
     *(.data .data.* .gnu.linkonce.d.*)
     SORT(CONSTRUCTORS)
   }
   .data1          : { *(.data1) }
   .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
   .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
   .eh_frame       : { KEEP (*(.eh_frame)) }
   .gcc_except_table   : { *(.gcc_except_table) }
   .dynamic        : { *(.dynamic) }
   .ctors          :
   {
     /* gcc uses crtbegin.o to find the start of
        the constructors, so we make sure it is
        first.  Because this is a wildcard, it
        doesn't matter if the user does not
        actually link against crtbegin.o; the
        linker won't look for a file to match a
        wildcard.  The wildcard also means that it
        doesn't matter which directory crtbegin.o
        is in.  */
     KEEP (*crtbegin*.o(.ctors))
     /* We don't want to include the .ctor section from
        from the crtend.o file until after the sorted ctors.
        The .ctor section from the crtend file contains the
        end of ctors marker and it must be last */
     KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
     KEEP (*(SORT(.ctors.*)))
     KEEP (*(.ctors))
   }
   .dtors          :
   {
     KEEP (*crtbegin*.o(.dtors))
     KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
     KEEP (*(SORT(.dtors.*)))
     KEEP (*(.dtors))
   }
   .jcr            : { KEEP (*(.jcr)) }
   .got            : { *(.got.plt) *(.got) }
   /* We want the small data sections together, so single-instruction 
offsets
      can access them all, and initialized data all before uninitialized, so
      we can shorten the on-disk segment size.  */
   .sdata          :
   {
     *(.sdata .sdata.* .gnu.linkonce.s.*)
   }
   _edata = .;
   PROVIDE (edata = .);
   __bss_start = .;
   __bss_start__ = .;
   .sbss           :
   {
     PROVIDE (__sbss_start = .);
     PROVIDE (___sbss_start = .);
     *(.dynsbss)
     *(.sbss .sbss.* .gnu.linkonce.sb.*)
     *(.scommon)
     PROVIDE (__sbss_end = .);
     PROVIDE (___sbss_end = .);
   }
   .bss            :
   {
    *(.dynbss)
    *(.bss .bss.* .gnu.linkonce.b.*)
    *(COMMON)
    /* Align here to ensure that the .bss section occupies space up to
       _end.  Align after .bss to ensure correct alignment even if the
       .bss section disappears because there are no input sections.  */
    . = ALIGN(32 / 8);
   }
   . = ALIGN(32 / 8);
   _end = .;
   _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
   PROVIDE (end = .);
   /* Stabs debugging sections.  */
   .stab          0 : { *(.stab) }
   .stabstr       0 : { *(.stabstr) }
   .stab.excl     0 : { *(.stab.excl) }
   .stab.exclstr  0 : { *(.stab.exclstr) }
   .stab.index    0 : { *(.stab.index) }
   .stab.indexstr 0 : { *(.stab.indexstr) }
   .comment       0 : { *(.comment) }
   /* DWARF debug sections.
      Symbols in the DWARF debugging sections are relative to the beginning
      of the section so we begin them at 0.  */
   /* DWARF 1 */
   .debug          0 : { *(.debug) }
   .line           0 : { *(.line) }
   /* GNU DWARF 1 extensions */
   .debug_srcinfo  0 : { *(.debug_srcinfo) }
   .debug_sfnames  0 : { *(.debug_sfnames) }
   /* DWARF 1.1 and DWARF 2 */
   .debug_aranges  0 : { *(.debug_aranges) }
   .debug_pubnames 0 : { *(.debug_pubnames) }
   /* DWARF 2 */
   .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
   .debug_abbrev   0 : { *(.debug_abbrev) }
   .debug_line     0 : { *(.debug_line) }
   .debug_frame    0 : { *(.debug_frame) }
   .debug_str      0 : { *(.debug_str) }
   .debug_loc      0 : { *(.debug_loc) }
   .debug_macinfo  0 : { *(.debug_macinfo) }
   /* SGI/MIPS DWARF 2 extensions */
   .debug_weaknames 0 : { *(.debug_weaknames) }
   .debug_funcnames 0 : { *(.debug_funcnames) }
   .debug_typenames 0 : { *(.debug_typenames) }
   .debug_varnames  0 : { *(.debug_varnames) }
     .stack         0x80000 :
   {
     _stack = .;
     *(.stack)
   }
}


==================================================
attempt to open crt0.o succeeded
crt0.o
attempt to open 
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crti.o 
succeeded
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crti.o
attempt to open 
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crtbegin.o 
succeeded
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crtbegin.o
attempt to open arm.o succeeded
arm.o
attempt to open startup.o succeeded
startup.o
attempt to open exp16bit.o succeeded
exp16bit.o
attempt to open expon32.o succeeded
expon32.o
attempt to open expon16.o succeeded
expon16.o
attempt to open misc.o succeeded
misc.o
attempt to open 
/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a 
succeeded
(/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a)eh_alloc.o
(/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a)eh_catch.o
(/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a)eh_globals.o
(/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a)eh_personality.o
(/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a)eh_terminate.o
(/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a)eh_throw.o
(/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a)tinfo.o
(/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a)del_op.o
(/work/linux/tool/Linux-i686/arm-unknown-elf/lib/interwork/libsupc++.a)eh_exception.o
attempt to open 
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/libgcc.a 
succeeded
(/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/libgcc.a)unwind-sjlj.o
attempt to open 
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crtend.o 
succeeded
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crtend.o
attempt to open 
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crtn.o 
succeeded
/work/linux/tool/Linux-i686/lib/gcc-lib/arm-unknown-elf/3.3.2/interwork/crtn.o

tanaka@r48:/u9/te/util/c++test/bad/thumb_exp/arm-elf2/$
------------------------------------

regards.
t_tanaka


Richard Earnshaw wrote:
>>Hello.
>>
>>I have a question. Does Arm's thumb instruction set support the
>>exception of C++?
>>The follwing sample code does not run correctly.
>>
>>The program counter does not reach to the tail of the main(), even on
>>the simulator of the gdb.
>>When all of the modules of the sample are compiled as arm instruction
>>set, The sample runs OK.
> 
> 
> Does the application work if you build all the code in Thumb?  You 
> currently have a mix of ARM and Thumb code.
> 
> My suspicion is that you aren't picking up the interworking libraries 
> correctly.  To get these you normally have to edit a source file in the 
> compiler to allow these to be built:
> 
> 1) Unpack the gcc source tree.
> 2) Go to the gcc/config/arm subdirectory
> 3) Edit the file t-arm-elf
> 4) Uncomment the following 3 lines
> 
> MULTILIB_OPTIONS    += mno-thumb-interwork/mthumb-interwork
> MULTILIB_DIRNAMES   += normal interwork
> MULTILIB_EXCEPTIONS += *mapcs-26/*mthumb-interwork*
> 
> 5) Rebuild and reinstall your compiler.
> 
> One final point.  When you link your application, you must also use 
> -mthumb-interwork or gcc will pick the wrong libraries.  You should also 
> use g++ for linking if your application has C++ code.  Hence:
> 
> /work/linux/tool/Linux-i686/bin/arm-unknown-elf-g++ -mthumb-interwork -o 
> exp16bit
> exp16bit.o expon32.o expon16.o misc.o
> 
> You can also choose between libraries containing ARM or Thumb code by 
> passing the option -mthumb when linking.
> 
> R. 
> 
> 
> 
> 
> 
> 



------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com



More information about the crossgcc mailing list