EmbDev.net

Forum: ARM programming with GCC/GNU tools arm-elf compiling questions


von Ierland F. (ierlandfan)


Rate this post
useful
not useful
Hello,

i want to port some package (libosip) to arm-bb-elf
(Some bluebird/philips arm chip for Siemens Gigaset SIP phone)

I've got the toolchain. I've got the package. And I have the semi-source
of the firmware. (I can invoke make and the firmware is being build
correctly. No errors)
So ready to go. Even an linkermap is provided.

But, when i try to configure libosip from source (which came with the
package) against arm-bb-elf it errors out on _sbrk and _exit. (cheking
whether compiler can create executables. error, cannot create
executables. Now I know  I can stub them out but I don't know where. And
maybe the linking is wrong, maybe the paths are wrong, please point me
into the right direction...

First:  CC=arm-bb-elf-gcc ./configure --with-gnu-ld  --with-gnu-as
--enable-debug LDFLAGS=-L /usr/local/arm-bb-tools/bin/
-L/usr/local/arm-bb-tools/lib/thumb/interwork

Here's a relevant part of the config.log


configure:2394: $? = 0
configure:2417: checking for C compiler default output file name
configure:2420: arm-bb-elf-gcc
-L/usr/local/arm-bb-tools/lib/gcc/arm-bb-elf/4.1.0/thumb/interwork
conftest.c  >&5
/usr/local/arm-bb-tools/lib/gcc/arm-bb-elf/4.1.0/../../../../arm-bb-elf/ 
lib/libc.a(exit.o):
In function `exit':
../../../../../../source/newlib-1.14.0/newlib/libc/stdlib/exit.c:65:
undefined reference to `_exit'
/usr/local/arm-bb-tools/lib/gcc/arm-bb-elf/4.1.0/../../../../arm-bb-elf/ 
lib/libc.a(sbrkr.o):
In function `_sbrk_r':
../../../../../../source/newlib-1.14.0/newlib/libc/reent/sbrkr.c:60:
undefined reference to `_sbrk'
collect2: ld returned 1 exit status
configure:2423: $? = 1
configure: failed program was:
| /* confdefs.h.  */


Questions

1. Do I need to configure against arm-bb-elf or can I just compile for
i386?
2. How to check the correct paths?
3. Where to sub out sbrk and exit. I have a lot of exit.o's and
sbrk.o's.
   I probably don't need them anyway.

I am a newbe in CC but I sort of know what I am doing. Just need a few
pointers.

von Clifford S. (clifford)


Rate this post
useful
not useful
Ierland Fan wrote:

> Now I know  I can stub them out but I don't know where.

If you stub out sbrk_r without implementing it correctly, dynamic memory
allocation will not work. It is a newlib syscall that you need ot
implement to map the C library to the target platform.

> Questions
>
> 1. Do I need to configure against arm-bb-elf or can I just compile for
> i386?

Not if you want to run it on an ARM target!

> 2. How to check the correct paths?

It is not a path issue, you need to provide the missing functions.

> 3. Where to sub out sbrk and exit. I have a lot of exit.o's and
> sbrk.o's.

Maybe you have not linked tham then?


>    I probably don't need them anyway.
>
You do if the code uses the heap and dynamic memory allocation. If the
linker is looking for them, something must be calling them for a reason.

Read the newlib documentation. Look at the available examples.

See also: http://www.state-machine.com/resources/papers.htm

Clifford

von Ierland F. (ierlandfan)


Rate this post
useful
not useful
You do if the code uses the heap and dynamic memory allocation. If the
 linker is looking for them, something must be calling them for a
reason.

-----

So basically:

1. the linkmap that's used is incorrect (probably need the provided
linkmap.ld)
By default it uses gnu-ld (arm-bb-elf-gcc is also configured with
gnu-ld)
How to check whether this is true?

2. The linker is provided by package or provided by toolchain?
I am trying to understand what's going on.

von Clifford S. (clifford)


Rate this post
useful
not useful
> 1. the linkmap that's used is incorrect (probably need the provided
> linkmap.ld)
> By default it uses gnu-ld (arm-bb-elf-gcc is also configured with
> gnu-ld)

Ah... by "linkmap" you mean the linker script. I do not believe that
this is relevant in this at all. It seems that you have simply not
completed the target support layer for the newlib library as I said.
However the use of the exit() function may be troublesome - in an
embedded system where do you 'exit' to? This may or may not make sense
in teh context of your target platform - I have no idea what a
"bluebird/philips arm chip for Siemens Gigaset SIP phone" is to be
honest.


> 2. The linker is provided by package or provided by toolchain?
> I am trying to understand what's going on.

The linker is part of the build toolchain. The compiler creates object
code from single source files. Libraries such as your libosip.a file
contain multiple object code modules. The linker is responsible for
linking all your application's object modules and any library modules
needed to resolve references in the application to form the final binary
executable.

In this case it seems that the library makes references to the standard
library, which in turn requires that you implement certain platform
specific functions.

Clifford

von Ierland F. (ierlandfan)


Rate this post
useful
not useful
I have no idea what a
> "bluebird/philips arm chip for Siemens Gigaset SIP phone" is to be
> honest.

According to the buildchain:


This toolchain is derived from the GNU ARM toolchain
http://www.gnuarm.com.

SHC made changes to build a special version for the Philips BlueBird
chip.

These changes mainly contain:
  Modification of the gcc multilib configuration in order to build for
  ARM, THUMB, ARM-Interworking and THUMB-Interworking.

  The newlib configuration was changed to get get a memory and code
  optimized version suitable for our target system.

Furthermore, I see some refrences to -mcpu=arm7tdmi in makefile

von Clifford S. (clifford)


Rate this post
useful
not useful
> Modification of the gcc multilib configuration in order to build for
> ARM, THUMB, ARM-Interworking and THUMB-Interworking.
I am not sure what the means, they sound pretty much like the standard
multilib builds. Perhaps it means that they omitted some of the other
library builds not suited to the specific platform.


> The newlib configuration was changed to get get a memory and code
> optimized version suitable for our target system.

If the toolchain were built for a specific platform, then it would be
reasonable to expect that the necessary stubs were provided. I am not
sure why they would not be.

Clifford

von Ierland F. (ierlandfan)


Rate this post
useful
not useful
> If the toolchain were built for a specific platform, then it would be
> reasonable to expect that the necessary stubs were provided. I am not
> sure why they would not be.

So, the linker (in the toolchain) should point automatically to the
right stubs.
If it doesn't can we manually point it to the right path? Or can we
check for some error? I saw that the makefile builds with -no-stlibs and
-with-multilib.

von Ierland F. (ierlandfan)


Rate this post
useful
not useful
unfortunately, they did not include the config.log form libosip BUT they
left the config.h in place, maybe this tells us something? It says
addendum on top?



/* Addendum to oSIP library
** Copyright (c) 2006
** Siemens Home and Office Communication Devices GmbH & Co. KG (SHC)
** http://gigaset.siemens.com

//snap copyright things GNU Lesser General Public License

*/


#ifndef OSIP_CONFIG_H
 #define OSIP_CONFIG_H

#define SHC 1 /*mark as SHC portation*/

//***** Includes
***********************************************************

//***** Defines and Enums
**************************************************

// first UN-DEFINE some environment variables.
#undef  ENABLE_TRACE
#undef  SYSTEM_LOGGER_ENABLED

// oSIP library configuration

#if SHC
  #define SHC_OSIP_ENABLE_MSG_PROPERTY 0

  #define SIP_MESSAGE_MAX_LENGTH 1500
  #define BODY_MESSAGE_MAX_SIZE  1500
#endif

#undef HAVE_ASSERT_H

// Define to 1 if you have the <assert.h> header file.
#undef HAVE_ASSERT_H

// Define to 1 if you have the <ctype.h> header file.
#define HAVE_CTYPE_H 1

// Define to 1 if you have the <dlfcn.h> header file.
#undef HAVE_DLFCN_H

// Define to 1 if you have the <fcntl.h> header file.
#undef HAVE_FCNTL_H

// Define to 1 if you have the <inttypes.h> header file.
#define HAVE_INTTYPES_H 1

// Defined if you have lrand48
#undef HAVE_LRAND48

// Define to 1 if you have the <malloc.h> header file.
#undef HAVE_MALLOC_H

// Define to 1 if you have the <memory.h> header file.
#undef HAVE_MEMORY_H

// Define if you have POSIX threads libraries and header files.
#undef HAVE_PTHREAD

// Define to 1 if you have the <semaphore.h> header file.
#undef HAVE_SEMAPHORE_H

// Define to 1 if you have the <signal.h> header file.
#define HAVE_SIGNAL_H 1

// Define to 1 if you have the <stdarg.h> header file.
#define HAVE_STDARG_H 1

// Define to 1 if you have the <stdint.h> header file.
#define HAVE_STDINT_H 1

// Define to 1 if you have the <stdio.h> header file.
#define HAVE_STDIO_H 1

// Define to 1 if you have the <stdlib.h> header file.
#define HAVE_STDLIB_H 1

// Define to 1 if you have the <strings.h> header file.
#undef HAVE_STRINGS_H

// Define to 1 if you have the <string.h> header file.
#define HAVE_STRING_H 1

// Define to 1 if you have the <syslog.h> header file.
#undef HAVE_SYSLOG_H

// Define to 1 if you have the <sys/select.h> header file.
#undef HAVE_SYS_SELECT_H

// Define to 1 if you have the <sys/sem.h> header file.
#undef HAVE_SYS_SEM_H

// Define to 1 if you have the <sys/signal.h> header file.
#undef HAVE_SYS_SIGNAL_H

// Define to 1 if you have the <sys/stat.h> header file.
#undef HAVE_SYS_STAT_H

// Define to 1 if you have the <sys/time.h> header file.
#undef HAVE_SYS_TIME_H

// Define to 1 if you have the <sys/types.h> header file.
#undef HAVE_SYS_TYPES_H

// Define to 1 if you have the <sys/unistd.h> header file.
#undef HAVE_SYS_UNISTD_H

// Define to 1 if you have the <time.h> header file.
#undef HAVE_TIME_H

// Define to 1 if you have the <unistd.h> header file.
#undef HAVE_UNISTD_H

// Define to 1 if you have the <varargs.h> header file.
#undef HAVE_VARARGS_H

// Name of package
#define PACKAGE "libosip2"

// Define to the address where bug reports for this package should be
sent.
#define PACKAGE_BUGREPORT ""

// Define to the full name of this package.
#define PACKAGE_NAME ""

// Define to the full name and version of this package.
#define PACKAGE_STRING ""

// Define to the one symbol short name of this package.
#define PACKAGE_TARNAME ""

// Define to the version of this package.
#define PACKAGE_VERSION ""

// Define to the necessary symbol if this constant uses a non-standard
name on
// your system.
// #undef PTHREAD_CREATE_JOINABLE

// Define to 1 if you have the ANSI C header files.
#define STDC_HEADERS 1

// Version number of package
#define VERSION "2.2.2"



#endif // OSIP_CONFIG_H

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.