pc386dx exception 6 was Re: 4.6.0pre2 and docs released

Steven Johnson sjohnson at neurizon.net
Mon Apr 28 04:35:11 UTC 2003


Your bsp_specs file will have an entry like:
%{!qnolinkcmds: -T Application.link}}}

The name after -T is your linker command file.

In your linker command file you will need to put KEEP() around (at 
least) .init, .fini

the ld manual also recomends putting KEEP() around .ctors and .dtors
it also recomends using SORT() but I didn't notice that it was required 
or did anything significant.

You may need to put it around other sections as well.  This prevents the 
linker excluding these sections, because it can not see any references 
to them, even though they exist (usually in an obscure way).

When debugging your code, if you get the exception in a section of code 
that used to work, check the map.  If the map says it is zero size, you 
need to wrap it in a KEEP.

I Don't know if this will fix the exception you were talking about 
before, but I found it shaved ~200K of crap off my static linked 


Angelo Fraietta wrote:
> Steven Johnson wrote:
>> Angelo,
>> Change LDFLAGS += to be
>> LDFLAGS += --gc-sections
> This one did not work.
>> Unless LD Flags is passed to gcc or g++ and not ld, in which case use:
>> LDFALGS += -Wl,'--gc-sections'
> This did work, however, I got an exception 13 after the device drivers 
> loaded
>> I don't actually use GNU Make.  I Use JAM Instead.  The Make File 
>> (JamFile) is a lot cleaner, and I haven't used GNU Make files (other 
>> than what comes with RTEMS and other stuff in our own development for 
>> a long time, but this is where I would try.  You will need to look at 
>> the output of running Make to see if the link is perfromed with ld or 
>> gcc/g++.
> It uses i386-rtems-g++ (I have attached the final link text)
> What is interesting is that this did not occur until gcc3.2.1
> In GCC3.2, my executables were substantially smaller, and this is why 
> they didn't crash with the exception 6 -- they did not include the code 
> -- unless I added the include <iostream> directive.  I don't have the 
> directive anywhere in my code but it must still be including the 
> iostream. Maybe there is a flag that allows me to not add it.
> ------------------------------------------------------------------------
> i386-rtems-g++ -B/opt/rtems/i386-rtems/pc386dx/lib/ -specs bsp_specs -qrtems   -g -Wall  -g     -msoft-float -mno-fp-ret-in-387 -D_E_STL    -I ../../../estl  -I ../engine -I ../engineinterface -I ../hal_include -I ../link_driver -I ../../../threads/source -I ../../../mididriver -I ../../../mididriver/hal_rtems   -Wl,'-gc-sections'     -Wl,-Ttext,0x00100000 -o o-optimize/smart.obj  o-optimize/diags.o o-optimize/fsmount.o o-optimize/rtems_init.o o-optimize/midioutput.o o-optimize/scheduler.o o-optimize/rtems_simulator.o o-optimize/commtasks.o  /opt/rtems/i386-rtems/pc386dx/lib/no-dpmem.rel /opt/rtems/i386-rtems/pc386dx/lib/no-mp.rel /opt/rtems/i386-rtems/pc386dx/lib/no-part.rel /opt/rtems/i386-rtems/pc386dx/lib/no-signal.rel ../engine/o-optimize/sm_engine.a   ../engineinterface/o-optimize/sm_engineinterface.a   ../engine/o-optimize/sm_engine.a   ../link_driver/o-optimize/sm_link_driver.a   ../link_driver/hal_rtems/o-optimize/sm_comm.a   ../../../threads/source/o-optimize/sm_r
tems_active.a   ../../../threads/source/hal_rtems/o-optimize/sm_rtems_thread.a   ../../../mididriver/hal_rtems/o-optimize/rtems_midi.a    
> i386-rtems-objcopy -O elf32-i386 --remove-section=.rodata --remove-section=.comment --remove-section=.note --strip-unneeded o-optimize/smart.obj o-optimize/smart.exe
> i386-rtems-objcopy -O binary o-optimize/smart.obj o-optimize/smart.bin
> /opt/rtems/i386-rtems/pc386dx/build-tools/bin2boot -v o-optimize/smart.bt 0x00097E00 /opt/rtems/i386-rtems/pc386dx/lib/start16.bin 0x00097C00 0 o-optimize/smart.bin 0x00100000 0
> header address       0x00097e00, its memory size 0x00000200
> first  image address 0x00097c00, its memory size 0x00000200
> second image address 0x00100000, its memory size 0x0007f000
> i386-rtems-nm -g -n o-optimize/smart.obj > o-optimize/smart.num
> i386-rtems-size o-optimize/smart.obj
>    text	   data	    bss	    dec	    hex	filename
>  495630	  24218	  36508	 556356	  87d44	o-optimize/smart.obj

More information about the users mailing list