Linker errors - calling ASM routines from C code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I'm having a problem compiling my C and ASM code using gcc on linux.
I have a set of C files calling MMX/SSE/SSE2 optimized routines that
are coded in ASM and compiled using GAS. The ASM function names are
declared as global and have a leading underscore, which I believe is
required when calling the function from my C code. It compiles and
links as expected with DJGPP, gcc 3.2.3.

When some one else tried the compilation on a Linux machine with
gcc 3.3 it belches at the linking stage, unable to find the ASM
functions. Inspecting the C program's object files, I find that the
function calls do not have a leading underscore. The problem is solved
if I remove the leading underscore from my ASM routine name.

Why does the code not compile in one situation and work perfectly in the
other?


--- Here are the errors: ---

gcc -Wall -O -DDEBUG   -c -o sw_simd_x86.o sw_simd_x86.c
gcc -Wall -O -DDEBUG   -c -o sw_horiz.o sw_horiz.c
gcc -Wall -O -DDEBUG   -c -o sw_diag.o sw_diag.c
gcc -Wall -O -DDEBUG   -c -o asm/sw_sse2_horiz_w.o asm/sw_sse2_horiz_w.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_sse_horiz_w.o asm/sw_sse_horiz_w.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_mmx_horiz_w.o asm/sw_mmx_horiz_w.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_sse2_horiz_b.o asm/sw_sse2_horiz_b.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_sse_horiz_b.o asm/sw_sse_horiz_b.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_mmx_horiz_b.o asm/sw_mmx_horiz_b.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_sse2_diag_w.o asm/sw_sse2_diag_w.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_sse_diag_w.o asm/sw_sse_diag_w.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_mmx_diag_w.o asm/sw_mmx_diag_w.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_sse2_diag_b.o asm/sw_sse2_diag_b.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_sse_diag_b.o asm/sw_sse_diag_b.S
gcc -Wall -O -DDEBUG   -c -o asm/sw_mmx_diag_b.o asm/sw_mmx_diag_b.S
gcc -Wall -O -DDEBUG asm/sw_sse2_horiz_w.o asm/sw_sse_horiz_w.o
asm/sw_mmx_horiz_w.o asm/sw_sse2_horiz_b.o asm/sw_sse_horiz_b.o
asm/sw_mmx_horiz_b.o asm/sw_sse2_diag_w.o asm/sw_sse_diag_w.o
asm/sw_mmx_diag_w.o asm/sw_sse2_diag_b.o asm/sw_sse_diag_b.o
asm/sw_mmx_diag_b.o sw_simd_x86.o sw_horiz.o sw_diag.o -o sw_simd_x86
sw_horiz.o(.text+0x65): In function `sw_horiz':
: undefined reference to `sw_simd_mmx_horiz_b'
sw_horiz.o(.text+0x6f): In function `sw_horiz':
: undefined reference to `sw_simd_mmx_horiz_w'
sw_horiz.o(.text+0x8d): In function `sw_horiz':
: undefined reference to `sw_simd_sse_horiz_b'
sw_horiz.o(.text+0x97): In function `sw_horiz':
: undefined reference to `sw_simd_sse_horiz_w'
sw_horiz.o(.text+0xb5): In function `sw_horiz':
: undefined reference to `sw_simd_sse2_horiz_b'
sw_horiz.o(.text+0xbf): In function `sw_horiz':
: undefined reference to `sw_simd_sse2_horiz_w'
sw_diag.o(.text+0x65): In function `sw_diag':
: undefined reference to `sw_simd_mmx_diag_b'
sw_diag.o(.text+0x6f): In function `sw_diag':
: undefined reference to `sw_simd_mmx_diag_w'
sw_diag.o(.text+0x97): In function `sw_diag':
: undefined reference to `sw_simd_sse_diag_b'
sw_diag.o(.text+0xa1): In function `sw_diag':
: undefined reference to `sw_simd_sse_diag_w'
sw_diag.o(.text+0xc9): In function `sw_diag':
: undefined reference to `sw_simd_sse2_diag_b'
sw_diag.o(.text+0xd3): In function `sw_diag':
: undefined reference to `sw_simd_sse2_diag_w'
collect2: ld returned 1 exit status
make: *** [sw] Fehler 1


--- Here is the system configuration: ---

Linux 2.4.20-4GB-athlon #1 Fri Jul 11 20:16:51 UTC 2003 i686 unknown unknown
GNU/Linux

Reading specs from /usr/lib/gcc-lib/i486-suse-linux/3.3/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib
--enable-languages=c,c++,f77,objc,java,ada --disable-checking --enable-libgc
j
--with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib
--with-system-zlib --enable-shared --enable-__cxa_atexit i486-suse-linux
Thread model: posix

gcc version 3.3 20030226 (prerelease) (SuSE Linux)
GNU assembler 2.13.90.0.18 20030121
GNU ld version 2.13.90.0.18 20030121

--- Output of nm on sw_diag.o on belching machine ---

         U __strtol_internal
         U clock
         U end_counter
         U printf
         U start_counter
00000000 T sw_diag
         U sw_simd_mmx_diag_b
         U sw_simd_mmx_diag_w
         U sw_simd_sse2_diag_b
         U sw_simd_sse2_diag_w
         U sw_simd_sse_diag_b
         U sw_simd_sse_diag_w

--- Output of nm on sw_sse_horiz_b.o on belching machine ---

00000000 T _sw_simd_sse_horiz_b
00000043 t init_loop
00000077 t inner_loop
00000059 t outer_loop
00000120 t outside
0000011d t zero

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

--- Output of nm on sw_diag.o on working machine ---

         U ___dj_stderr
         U _clock
         U _end_counter
         U _printf
         U _start_counter
00000370 T _sw_diag
         U _sw_simd_mmx_diag_b
         U _sw_simd_mmx_diag_w
         U _sw_simd_sse2_diag_b
         U _sw_simd_sse2_diag_w
         U _sw_simd_sse_diag_b
         U _sw_simd_sse_diag_w

--- Output of nm on sw_sse_horiz_b.o on belching machine ---

00000000 T _sw_simd_sse_horiz_b
00000043 t init_loop
00000077 t inner_loop
00000059 t outer_loop
00000120 t outside
0000011d t zero


Thanks for your help,
-Nemo.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux