This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

msp430-elf linker not honoring linker script

Other Parts Discussed in Thread: MSP430F168, MSP430G2433

I'm having a linking issue with the newer version of msp430 compiler/linker.  I'm trying to compile several .c files to generate .o files, then link them to create "boot.elf" file.  

For reference, the versions are the followings. 

New compiler/linker from binutils: 5.2.0/2.25.1

Old compiler/linker from binutils:  4.6.3/2.21.1

"make_output_new.txt" (attached) shows the output from the new compiler/linker.  It shows that .o files are generated successfully, but at the linking stage, it raises an error saying that ".text" and ".trampoline" sections are over-wrapping.  In "boot.x" (attached), which is passed to the linker, it specifies ".text" to be at REGION_TEXT which is aliased to "boot2", which is at "0xfa00".  In "boot_new.map" (I renamed it from boot.map)(attached), which was generated with the linking command, it shows that ".text" is at 0xe000, not 0xfa00 as specified in boot.x.  

.text           0x000000000000e000      0x6d6

"make_output_old.txt" (attached) shows the output from the old compiler/linker.  All the object files are generated and it links them successfully.  In "boot_old.map" (I renamed it from boot.map) (attached), which was generated with the linking command, it shows that ".text" is at 0xfa00 as specified in boot.x. 

.text           0x0000fa00      0x3c6

Do you have any idea why the new compiler/linker fails to honor what is in boot.x?

Thanks!

0167.files.zip

  • Hi Kenji,

    I moved this thread to a more applicable forum. Someone will be able to help you more effectively here.

    Best regards,
    Caleb Overbay
  • I don't recognize all these version numbers ...

    Kenji Totsuka said:

    For reference, the versions are the followings. 

    New compiler/linker from binutils: 5.2.0/2.25.1

    Old compiler/linker from binutils:  4.6.3/2.21.1

    So I would appreciate if you would try again with the latest tools.  That is compiler version 5.3.0.219 and binutils version 2.25.1.

    Also, instead of using your own custom linker script, start with one from TI.  These files are installed with Code Composer Studio.  You can find them in a directory with a path similar to ...

    C:\ti\ccsv6\ccs_base\msp430\include_gcc

    The script has a file name similar to msp430f168.ld.  Use the script with the same name as the device you have.  First use it unmodified.  Then customize it as needed.

    Thanks and regards,

    -George

  • I think it was my way of writing the version numbers that was confusing.  Sorry about that.  Hopefully this will make it more clear.

    New setup

              compiler version: 5.2.0 (from msp430-elf-gcc --version)

              binutils version: 2.25.1 (from msp430-elf-ld --version)

    Old setup

              compiler version: 4.6.3 (from msp430-gcc --version)

              binutils version: 2.21.1 (from msp430-ld --version)

    For the new setup, looks like binutils is the latest version.  compiler version is not the latest (5.2.0 instead of 5.3.0.219), but hopefully once you understand my version correctly this is latest enough.  I'm building msp430-elf-gcc in our build system and the available base gcc version that msp430-elf-gcc is built from goes up to 5.2, so that's why my msp430-elf-gcc is version 5.2.0.  But If I need to update to 5.3, I will look into it.

    I'm on Linux and don't use Code Composer Studio.  I do see the linker script for my device at ""path to msp430 gcc install directory"/sysroots/x86_64-linux/usr/msp430-elf/lib/msp430g2433.ld.

    I tried to use the linker script "msp430g2433.ld", so I specified the script with "-T" option.  But I got errors about re-declaration of memory region for 'SFR', 'RAM' and others, so I assume that the linker is using the script twice.  So I just removed the "-T" option altogether assuming that will make the linker to use the "msp430g2433.ld" script once.  Then I got this error "

    error: no memory region specified for loadable section `.infob'.

    The whole command and output is

    msp430-elf-gcc --sysroot=/bonus/scratch/kenjit/yocto_5/build-bundle/poky/build/tmp/sysroots/msp430 -mmcu=msp430g2433 -Wl,-Map=boot.map,--cref boot/main.o boot/vector_table.o boot/vector_handlers.o boot/commands.o boot/flash.o boot/trampoline.o shared/shared.o shared/shared_flash.o shared/i2c.o -o boot.elf
    /bonus/scratch/kenjit/yocto_5/build-bundle/poky/build/tmp/sysroots/x86_64-linux/usr/libexec/msp430-elf/gcc/msp430-elf/5.2.0/ld: error: no memory region specified for loadable section `.infob'
    collect2: error: ld returned 1 exit status
    make: *** [boot.elf] Error 1

    In msp430g2433.ld, I see 
      INFOB            : ORIGIN = 0x1080, LENGTH = 0x0040 /* END=0x10BF, size 64 */
    So not sure why it is complaining about .infob region not specified...

    I have attached the generated map file in case it is useful.  

    Do you know why the default linker "msp430g2433.ld" is not working?

    I really appreciate your help.  Thank you very much.  

  • Forgot to attach the mentioned file, so here it is. boot_with_default_linker.zip

  • Hi Kenji,

      These are the options that we use:

    "/home/dlara/ti/ccsv6/tools/compiler/gcc_msp430_5.3.0.219/bin/msp430-elf-gcc" -c -mcpu=msp430 -mmcu=msp430g2433 -I"/home/dlara/ti/ccsv6/ccs_base/msp430/include_gcc" -I"/home/dlara/ti/ccsv6/tools/compiler/gcc_msp430_5.3.0.219/msp430-elf/include" -Os -g -gdwarf-3 -gstrict-dwarf -Wall -mhwmult=none -msilicon-errata=CPU4 -MMD -MP -MF"main.d" -MT"main.o" -o"main.o"  "../main.c"
    Finished building: ../main.c
     
    "/home/dlara/ti/ccsv6/tools/compiler/gcc_msp430_5.3.0.219/bin/msp430-elf-gcc" -mcpu=msp430 -Os -g -gdwarf-3 -gstrict-dwarf -Wall -Wl,-Map,"msp430g2433_gcc_test.map" -L"/home/dlara/ti/ccsv6/ccs_base/msp430/include_gcc" -o"msp430g2433_gcc_test.out" "./main.o" -T"../msp430g2433.ld"  -Wl,--start-group -lgcc -lc -Wl,--end-group 
    Finished building target: msp430g2433_gcc_test.out

      Could you please give this a try and let us know if you see the same issue.

       Thanks,

        David