EmbDev.net

Forum: ARM programming with GCC/GNU tools Trouble linking BREW objects under WinARM4.1x


von Adam (Guest)


Attached files:

Rate this post
useful
not useful
Hi,

I'm trying to use WinARM 4.1.1 to compile and link object files for a 
BREW project. I got started using this page: http://brew.wardco.com/.

First thing to note is that I have this successfully working under the 
GNUDE tool chain. When I switched over to WinARM, I initially got it to 
work till I noticed that I had -Lc:/gnude/arm-elf/lib instead of 
-Lc:/WinARM/arm-elf/lib in my library path. I obviously don't want to 
have both systems in place in my environment. Using the WinARM library 
path causes me to get the following linker errors (just the short 
version; see attached for the full list):
1
c:/WinARM/arm-elf/lib\libsupc++.a(eh_personality.o): In function `read_encoded_value_with_base':
2
c:/winarms/gcc-4.1.1/gcc/unwind-pe.h:259: undefined reference to `abort'
3
c:/WinARM/arm-elf/lib\libsupc++.a(eh_terminate.o):../../../../../gcc-4.1.1/libstdc++-v3/libsupc++/eh_terminate.cc:46: more undefined references to `abort' follow
4
c:/WinARM/arm-elf/lib\libc.a(fopen.o): In function `_fopen_r':
5
fopen.c:(.text+0x48): undefined reference to `_open_r'
6
c:/WinARM/arm-elf/lib\libc.a(freer.o): In function `_malloc_trim_r':
7
mallocr.c:(.text+0x48): undefined reference to `_sbrk_r'
8
C:\WinARM/lib/gcc/arm-elf/4.1.1/\libgcc.a(unwind-sjlj.o): In function `_Unwind_SjLj_Resume_or_Rethrow':
9
../../../gcc-4.1.1/gcc/unwind.inc:263: undefined reference to `abort'

I am not sure how to approach solving this; it appears that I am simply 
missing a path somewhere, but which path?

Any insight would be appreciated.

Thanks,
-=-Adam

von Martin Thomas (Guest)


Rate this post
useful
not useful
It seems that the linker gets forced to link non-interwork-enabled 
object- and/or library-code since you use a fixed library path, you may 
just try to modify the path so it points to the interwork-enabled 
libc-object-code.
It's difficult to analyse this without further information but you may 
check if you are calling the linker (arm-elf-ld) directly which is not 
recommended. If you are building a C++ application link with 
arm-elf-g++. It will "automatically" link with the correct libc-objects 
since the frontend "knows" about the multilibs, no need to set a fixed 
path to a libc.

von Adam (Guest)


Attached files:

Rate this post
useful
not useful
Martin, thanks for the reply. I am indeed explicitly calling arm-elf-ld. 
I am not sure how to go about making arm-elf-g++ automatically do the 
linking for me. Can you provide any details? I am not intimately 
familiar with the implicit workings of the linking process. I am using a 
template make file that allegedly works for other developers compiling 
BREW under WinARM. I have attached that (now modified from the original) 
file. I did try to get the linker to use the interworking version of 
libc.a, but actually ended up with more errors.

Two interesting notes: 1) While troubleshooting, I noticed that 
specifically using the basic libc.a from the GNUDE chain allows the 
linking to succeed (and the app to run properly). 2) I just upgraded to 
WinARM 4.1.2 (which I wasn't aware was out there till just today!) and 
the resulting errors were much smaller in scope:
1
C:\WinARM\arm-elf\lib\libc.a(lib_a-abort.o): In function `abort':
2
abort.c:(.text+0xc): undefined reference to `_exit'
3
C:\WinARM\arm-elf\lib\libc.a(lib_a-fopen.o): In function `_fopen_r':
4
fopen.c:(.text+0x58): undefined reference to `_open_r'
5
C:\WinARM\arm-elf\lib\libc.a(lib_a-freer.o): In function `_malloc_trim_r':
6
mallocr.c:(.text+0x48): undefined reference to `_sbrk_r'
7
mallocr.c:(.text+0x70): undefined reference to `_sbrk_r'
8
mallocr.c:(.text+0xb4): undefined reference to `_sbrk_r'
9
C:\WinARM\arm-elf\lib\libc.a(lib_a-fseek.o): In function `_fseek_r':
10
fseek.c:(.text+0xf4): undefined reference to `_fstat_r'
11
fseek.c:(.text+0x35c): undefined reference to `_fstat_r'
12
C:\WinARM\arm-elf\lib\libc.a(lib_a-makebuf.o): In function `__smakebuf_r':
13
makebuf.c:(.text+0x40): undefined reference to `_fstat_r'
14
makebuf.c:(.text+0x104): undefined reference to `isatty'
15
C:\WinARM\arm-elf\lib\libc.a(lib_a-mallocr.o): In function `_malloc_r':
16
mallocr.c:(.text+0x428): undefined reference to `_sbrk_r'
17
mallocr.c:(.text+0x5c0): undefined reference to `_sbrk_r'
18
C:\WinARM\arm-elf\lib\libc.a(lib_a-signal.o): In function `_raise_r':
19
signal.c:(.text+0x16c): undefined reference to `_getpid_r'
20
signal.c:(.text+0x180): undefined reference to `_kill_r'
21
C:\WinARM\arm-elf\lib\libc.a(lib_a-stdio.o): In function `__sclose':
22
stdio.c:(.text+0xc): undefined reference to `_close_r'
23
C:\WinARM\arm-elf\lib\libc.a(lib_a-stdio.o): In function `__sseek':
24
stdio.c:(.text+0x30): undefined reference to `_lseek_r'
25
C:\WinARM\arm-elf\lib\libc.a(lib_a-stdio.o): In function `__swrite':
26
stdio.c:(.text+0x90): undefined reference to `_lseek_r'
27
stdio.c:(.text+0xb4): undefined reference to `_write_r'
28
C:\WinARM\arm-elf\lib\libc.a(lib_a-stdio.o): In function `__sread':
29
stdio.c:(.text+0xd8): undefined reference to `_read_r'
30
C:\WinARM\arm-elf\lib\libc.a(lib_a-syswrite.o): In function `write':
31
syswrite.c:(.text+0x24): undefined reference to `_write_r'
32
C:\WinARM\bin\arm-elf-ld.EXE: link errors found, deleting executable `testpin.el
33
f'
34
NMAKE : fatal error U1077: 'C:\WinARM\bin\arm-elf-ld.EXE' : return code '0x1'
35
Stop.

von Narada (Guest)


Rate this post
useful
not useful
The libstdc++.a has an object file called eh_personality.o
This needs to be removed prior to linking.

Go to the WinARM\arm-elf\lib directory.
type the following

copy libstdc++.a libstdc++.a.bak
ar -d libstdc++.a eh_personality.o

Now link it again.

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.