PDA

View Full Version : GNUARM link error



Sune Ahlgren
1st June 2008, 03:47 PM
Hi!

I've built and installed GNU ARM tools on my Fedora 6 x86_64 machine.
I fail to link a simple program and I haven't got the faintest as to why.
I give you a full trace of my actions including how I built my ARM tool chain.

If you can find something I'd really appreciate that!

Thank you in advance
/Sune

PS I'll cross post this to the chat lounge as well....



This is how I built my arm tools
===========================================
It's pretty much straight from http://www.gnuarm.com/

binutils
----------
../binutils-2.17/configure --target=arm-elf --prefix=/usr/local/ARMv5TE --enable-interwork --enable-multilib
make all install
export PATH="$PATH:/usr/local/ARMv5TE/bin"

GCC
----------
../gcc-4.1.1/configure --target=arm-elf --prefix=/usr/local/ARMv5TE --enable-interwork --enable-multilib --enable-languages="c,c++" --with-newlib --with-headers=../../newlib/src/newlib/libc/include/
make all-gcc install-gcc

newlib
----------
../src/configure --target=arm-elf --prefix=/usr/local/ARMv5TE --enable-interwork --enable-multilib
make all install

GCC
----------
make all install

GDB
----------
../gdb-6.8/configure --target=arm-elf --prefix=/usr/local/ARMv5TE --enable-interwork --enable-multilib
make all install


This is how I compile my simple LED example
=============================================
arm-elf-gcc -mcpu=xscale -g -c -Wall -I../include ../led.c

I've tried without -mcpu=xscale as well with the same error.


This is my program
=============================================
led.h:
#ifndef LED_H_
#define LED_H_

#include <stdint.h>

// Define address of GPDR0, the direction register for GPIO 0..31
#define GPIO_0_DIR_REG (*((uint32_t volatile*)0x40E0000C))

// Define the address of GPSR0, the SET register for GPIO 0..31
#define GPIO_0_SET_REG (*((uint32_t volatile*)0x40E00018))

// Define the address of GPCR0, the CLEAR register for GPIO 0..31
#define GPIO_0_CLR_REG (*((uint32_t volatile*)0x40E00024))

// Define the address of GPLR0, the LEVEL register for GPIO 0..31
#define GPIO_0_LVL_REG (*((uint32_t volatile*)0x40E00000))

// LED_GREEN Identifies GPIO22
#define LED_GREEN (0x00400000)

// Define address of GAFR0_U, the ALTERNATE function register for GPIO
// 16..31
#define GPIO_0_ALT_REG (*((uint32_t volatile*)0x40E00058))

// Set function for GPIO
#define LED_GREEN_GPIO22_NORMAL_FUNCTION (0xFFFFCFFF)

#endif /*LED_H_*/


led.c:
#include "led.h"

void led_init()
{
// Set GPIO22 low before configuring it
GPIO_0_CLR_REG = LED_GREEN;

// Disable alternate functions of GPIO22
GPIO_0_ALT_REG &= LED_GREEN_GPIO22_NORMAL_FUNCTION;

// Set direction OUT since itís a LED
GPIO_0_DIR_REG |= LED_GREEN;
}

void delay1s()
{
uint16_t rounds = 18000;

while (rounds--)
{}
}

void led_toggle()
{
if (GPIO_0_LVL_REG & LED_GREEN)
GPIO_0_CLR_REG = LED_GREEN;
else
GPIO_0_SET_REG = LED_GREEN;
}

int main(int argc, char** argv)
{
led_init();

while (1)
{
led_toggle();
delay1s();
}

return 0;
}



This is where it fails
=============================================

link command
---------------
arm-elf-ld -Map led.map -T viperlite.ld -No led led.o

link error
---------------
arm-elf-ld: error: no memory region specified for loadable section `.glue_7'

link script (viperlite.ld)
---------------
ENTRY (main)

MEMORY
{
ram : ORIGIN = 0x00400000, LENGTH = 64M
rom : ORIGIN = 0x60000000, LENGTH = 16M
}

SECTIONS
{
data : /* Initialized data. */
{
_DataStart = . ;
*(.data)
_DataEnd = . ;
} >ram

bss : /* Uninitialized data. */
{
_BssStart = . ;
*(.bss)
_BssEnd = . ;
} >ram

text : /* The actual instructions. */
{
*(.text)
} >ram
}

stevea
1st June 2008, 04:31 PM
You have double posted.
I predict a spanking in your future.
==
What does "readelf -S led.o" report on your object file ?
The host readelf will *probably* work if you didn't built the full arm target binutils.

I have no idea where the loadable section `.glue_7' is coming from, but you should also look at the sections in the C language intro routines, typically in crtbegin.o, crtend.o but other names are used in older gcc linkers.

[edit]

Sorry - it's probably crti.o for C on ARM.

stevea
1st June 2008, 11:56 PM
Just for grins I loaded the binary image of your compilers and got the same error with your .ld file.
I got just a warning when I used no .ld file. No errors or warning when . I used the arm-elf-gcc command to link.

The .glue_7 symbol comes from the linker (!??!) and it should resolve it. There something that the linker does n't like abt your .ld.

Sune Ahlgren
2nd June 2008, 04:28 AM
Hi again,

and thanks for helping.

True, a very strict man called Bob slapped me around a bit and closed the other thread. No hard feelings...

1)
I use RedBoot for loading my application. I just read that if RedBoot is used to load an application on my board, I should not locate the application as I try to do in the .ld file, I guess that means I can ignore the .ld file altogether to begin with. The application gets located by RedBoot when it is loaded. Is my understanding correct?

2)
Can I please have your gcc 'no warnings'-command for reference?

Thanks again
/Sune

stevea
2nd June 2008, 05:09 AM
[stevea@lycoperdon test]# ls
led.c led.h viperlite.ld
[stevea@lycoperdon test]# arm-elf-gcc ./led.c -o led
[stevea@lycoperdon test]# ls
led led.c led.h viperlite.ld

Sune Ahlgren
2nd June 2008, 01:23 PM
I changed my linking script to:


ENTRY (main)

MEMORY
{
ram : ORIGIN = 0x00400000, LENGTH = 64M
rom : ORIGIN = 0x60000000, LENGTH = 16M
}

SECTIONS
{
data : /* Initialized data. */
{
_DataStart = . ;
*(.data)
_DataEnd = . ;
} >ram

bss : /* Uninitialized data. */
{
_BssStart = . ;
*(.bss)
_BssEnd = . ;
} >ram

text : /* The actual instructions. */
{
*(.glue_7t) *(.glue_7)
*(.text)
} >ram
}


...and now it works.

I built my GNUARM tools with the --enable-interwork argument. The book I got my .ld file from did not and I somehow think that's related with the glue_7 thing.

Thanks again for helping out. I'm new at this and just needed a shove in the right direction.

BRs
/Sune