Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

global pointer relative offset

The linker gives me this message:

“global pointer relative offset 34384 at address 0x008adcc8 out of range -32678 to 32767 »

I don’t see what does that mean ?

When I click on the error line the editor show me the line in fault, all is written in C.

left = MS_LEFT_BUTTON;

and the assembler listing gives :

46 000c 150080D0 stw r2, %gprel(left)(gp)

It seems the linker is not able to compute the effective address.

The compilation flags are :

-g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -DSYSTEM_BUS_WIDTH=32 -mno-hw-mul -mno-hw-div

The link flags are

-g -nostdlib -Wl,--gc-sections -Wl,-static -mno-hw-mul -mno-hw-div

I used NIOS II Version: 1.1.0 and the most recent version of eCos

Is there someone who know this problem ?

And is there a documentation where I can find some description of the compilation and linker errors for GNU compiler ?

Thanks.

10 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    From your post, I take it that you are trying to use microwindows.

    The problem is likely to be down to a pointer being accessed using gp relative addressing when it should be using absolute addressing. A simple workaround is to add the option: -G0 to the compiler flags, although it would be better for code performance to try and track down the underlying cause of the problem.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Another possibility is that your code really has got too big. In which case removing unwanted packages, or even just reducing the network buffers by a few Kbytes could be enough to pull this into range of the global pointer.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for your help,

    Yes I try to compile the eCos library with microwindows

    But the modification of the debug or optimization options produce the same message

    Modification of the size of some network buffers also

    With the “Build Microwindows eCos support” selected only the library compilation is ok, But adding the “Build complete eCos+Microwindows application” I don’t have success.

    I use the default options with the net package
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Which source file is the problem in? From the code line you've presented it looks like a mouse driver. Chances are you're not going to use that particular driver, and so you could drop it from the build.

    Did you try using the -G0 compiler option? Did that get you further?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Yes I tried this compiler option -g0

    Also I tried to remove all the data of my mouse driver, I preserved only the device structure. And now I get the same message in an other module

    « …….. ecos_install/lib/extras.o(.text.smsc_lan91cxx_init+0x30): In function `smsc_lan91cxx_init':

    : global pointer relative offset 34352 at address 0x008ad9a8 out of range -32678 to 32767 «

    In this case I built first the ecos library with « Microwindows eCos support selected » and then I compiled and linked my application to this library and I got the previous message.

    If I build with “Build complete eCos+Microwindows application” I have the message during the library building.

    nios2-elf-gcc -c -I/cygdrive/c/alt_projects/ecos_menu/ecos_install/include -I/cygdrive/c/altera/kits/nios2/components/ecos/ecos-current/packages/services/gfx/mw/current -I/cygdrive/c/altera/kits/nios2/components/ecos/ecos-current/packages/services/gfx/mw/current/src -I/cygdrive/c/altera/kits/nios2/components/ecos/ecos-current/packages/services/gfx/mw/current/tests -I. -finline-limit=7000 -g0 -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -DSYSTEM_BUS_WIDTH=32 -mno-hw-mul -mno-hw-div -I/cygdrive/c/alt_projects/ecos_menu/ecos_install/include/microwin -D__ECOS=1 -DMSDOS=0 -DELKS=0 -D__rtems__=0 -D_MINIX=0 -DNOTYET=0 -DUNIX=1 -DHAVE_FILEIO -DHAVE_BMP_SUPPORT=1 -DHAVE_PNM_SUPPORT=1 -DHAVE_XPM_SUPPORT=1 -DxHAVE_JPEG_SUPPORT=1 -DHAVESELECT=1 -o /cygdrive/c/alt_projects/ecos_menu/ecos_install/lib/ecos_app.o /cygdrive/c/altera/kits/nios2/components/ecos/ecos-current/packages/services/gfx/mw/current/src/ecos/ecos_app.c

    cc1: warning: command line option "-fno-rtti" is valid for C++/ObjC++ but not for C

    nios2-elf-gcc -g -nostdlib -Wl,--gc-sections -Wl,-static -mno-hw-mul -mno-hw-div -L/cygdrive/c/alt_projects/ecos_menu/ecos_install/lib -Ttarget.ld -o /cygdrive/c/alt_projects/ecos_menu/ecos_install/bin/ecos_mw.elf /cygdrive/c/alt_projects/ecos_menu/ecos_install/lib/ecos_app.o

    /cygdrive/c/alt_projects/ecos_menu/ecos_install/lib/ecos_app.o(.text.cyg_user_start+0x1c): In function `cyg_user_start':

    : global pointer relative offset 34348 at address 0x008700d4 out of range -32678 to 32767

    I use the default options with the net package and -G0

    As I understand now, some data of the .bss area are pointed with the gp + offset and the gp is constant, so this area must be lower than 0x10000.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It doesn't look like the -G0 option is really being used here. This option stops the compiler using gp relative addressing, and so should make it impossible to get the error you're showing.

    Looking at the make output that you've included, the -G0 seems to be missing (Note this is -G0 and not -g0).

    Make sure that you've really saved the change to the project, and try doing "generate build tree" and build "Clean" from the "Build" menu in configtool to make sure that you flush out any old settings.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks very much,

    Yes, I did a misunderstanding between –g0 and –G0.

    With –G0 I am able to compile now the eCos library and my application.

    I understand this option is only temporarily and will allow me to find which module is disturbing my working.

    Thanks again.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Again me

    The blocking point seems the location or the size of the MW table "__MW_APP_TAB__"

    I modified the STACKSIZE in the ecos_mw_app.h, and I am able to compile without –G0

    Here below an extract of the readelf file sorted by address.

    The _MW_APP_TAB_ area is located in the area pointed by gp

    The previous value of STACKSIZE was 65536 I modified in 15000 for this test.

    What is the best way now ? to modify the STACKSIZE or to modify the location of "__MW_APP_TAB__"

    Num Value Size Type Bind Vis Ndx Name

    ---------------------------------------------------------------

    925 008685d4 2 OBJECT LOCAL DEFAULT 6 id

    926 008685d8 4 OBJECT LOCAL DEFAULT 6 domainname

    933 008685dc 4 OBJECT LOCAL DEFAULT 6 init.1

    1686 008685e0 4 OBJECT GLOBAL DEFAULT 6 clipregion

    953 008685e4 4 OBJECT LOCAL DEFAULT 6 nextimageid

    1795 008685e8 4 OBJECT GLOBAL DEFAULT 6 gr_mode

    2234 008685ec 6 OBJECT GLOBAL DEFAULT 6 mwstdpal1

    1015 008685f4 4 OBJECT LOCAL DEFAULT 6 timerlist

    1264 008685f8 12 OBJECT GLOBAL DEFAULT 6 _net_init_tab0x50000000mb

    1945 008685f8 0 OBJECT GLOBAL DEFAULT 6 __NET_INIT_TAB__

    1675 00868604 12 OBJECT GLOBAL DEFAULT 6 _net_init_tab0x60000000de

    2168 00868610 12 OBJECT GLOBAL DEFAULT 6 _net_init_tab0x70000000if

    2474 0086861c 12 OBJECT GLOBAL DEFAULT 6 _net_init_tab0x84000000in

    2254 00868628 12 OBJECT GLOBAL DEFAULT 6 _net_init_tab0x88000000do

    2040 00868634 12 OBJECT GLOBAL DEFAULT 6 _net_init_tab0x88000001do

    1588 00868640 12 OBJECT GLOBAL DEFAULT 6 _net_init_tab0x88000001do

    2439 0086864c 12 OBJECT GLOBAL DEFAULT 6 _net_init_tab0x88000002ro

    1217 00868658 15260 OBJECT GLOBAL DEFAULT 6 _mw_app_ECOS_MW_NANOX_PRI

    1228 00868658 0 OBJECT GLOBAL DEFAULT 6 __NET_INIT_TAB_END__

    1510 00868658 0 OBJECT GLOBAL DEFAULT 6 __MW_APP_TAB__

    1199 0086c1f4 15260 OBJECT GLOBAL DEFAULT 6 _mw_app_ECOS_MW_NANOX_PRI

    1127 0086fd90 0 OBJECT GLOBAL DEFAULT 6 __DEVTAB__

    1153 0086fd90 0 OBJECT GLOBAL DEFAULT 6 __MW_APP_TAB_END__

    1884 0086fd90 28 OBJECT GLOBAL DEFAULT 6 uart1_io

    1385 0086fdac 28 OBJECT GLOBAL DEFAULT 6 jtag_uart_io

    2172 0086fdc8 28 OBJECT GLOBAL DEFAULT 6 lcd_display_io

    2291 0086fde4 28 OBJECT GLOBAL DEFAULT 6 tty_io_diag

    2016 0086fe00 28 OBJECT GLOBAL DEFAULT 6 haldiag_io0

    2150 0086fe1c 0 OBJECT GLOBAL DEFAULT 6 __DEVTAB_END__

    2242 0086fe1c 64 OBJECT GLOBAL DEFAULT 6 dev_fste

    2451 0086fe1c 0 OBJECT GLOBAL DEFAULT 6 cyg_fstab

    1272 0086fe5c 0 OBJECT GLOBAL DEFAULT 6 cyg_mtab

    1810 0086fe5c 28 OBJECT GLOBAL DEFAULT 6 dev_mte

    2396 0086fe5c 0 OBJECT GLOBAL DEFAULT 6 cyg_fstab_end

    1131 0086fe78 224 OBJECT GLOBAL DEFAULT 6 cyg_mtab_extra

    2019 0086ff58 16 OBJECT GLOBAL DEFAULT 6 lan91c111_netdev

    2137 0086ff58 0 OBJECT GLOBAL DEFAULT 6 cyg_mtab_end

    2313 0086ff58 0 OBJECT GLOBAL DEFAULT 6 __NETDEVTAB__

    1194 0086ff68 0 OBJECT GLOBAL DEFAULT 6 cyg_nstab

    1609 0086ff68 28 OBJECT GLOBAL DEFAULT 6 cyg_bsd_nste

    2122 0086ff68 0 OBJECT GLOBAL DEFAULT 6 __NETDEVTAB_END__

    7 0086ff84 0 SECTION LOCAL DEFAULT 7

    1804 0086ff84 0 OBJECT GLOBAL DEFAULT 6 cyg_nstab_end

    1991 0086ff84 4 OBJECT GLOBAL DEFAULT 7 startup_thread

    1995 0086ff84 0 NOTYPE GLOBAL DEFAULT ABS __bss_start

    2260 0086ff84 0 NOTYPE GLOBAL DEFAULT ABS _edata

    65 0086ff88 4 OBJECT LOCAL DEFAULT 7 lan91cxx_interrupt_handle

    102 0086ff8c 4 OBJECT LOCAL DEFAULT 7 _no_data

    113 0086ff90 1 OBJECT LOCAL DEFAULT 7 fileio_initializer

    2469 0086ff94 4 OBJECT GLOBAL DEFAULT 7 idle_thread_loops

    2430 0086ff98 8 OBJECT GLOBAL DEFAULT 7 _ZN10Cyg_Thread17exceptio

    1166 0086ffa0 4 OBJECT GLOBAL DEFAULT 7 _ZN13Cyg_Interrupt8dsr_li

    --------------------

    1017 008702b0 8 OBJECT LOCAL DEFAULT 7 current_time

    1029 008702b8 4 OBJECT LOCAL DEFAULT 7 cyg_libc_atexit_handlers_

    40 008702bc 15000 OBJECT LOCAL DEFAULT 7 startup_stack

    1330 00870324 0 NOTYPE GLOBAL DEFAULT ABS _gp

    1248 00873d54 240 OBJECT GLOBAL DEFAULT 7 startup_thread_obj

    66 00873e44 28 OBJECT LOCAL DEFAULT 7 lan91cxx_interrupt
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks again Monkeyboy

    The instructions that you provided, move the ecos table out of the area pointed by gp and its remains in the rwdata.

    But the memory footprint is not optimized.

    We have always some big arrays (=65796) in the rwdata which are normally preserved in Flash. For embedded system with a small flash is not a good point.

    It seems it is due to the _mw_app_entry structure declared in the ecos_mw_app.h

    The first fields are initialized and must be preserved in Flash but the last field stack[STACKSIZE] should be in bss (with STACKSIZE=65536). This structure should be perhaps split in two parts.