Thread View: gnu.gcc.bug
2 messages
2 total messages
Started by Matt Stainforth
Thu, 05 Dec 1996 00:00
#include not working right?
Author: Matt Stainforth
Date: Thu, 05 Dec 1996 00:00
Date: Thu, 05 Dec 1996 00:00
86 lines
3632 bytes
3632 bytes
Does anyone know why this is happening?
# gcc -c ping.c -o ping.o
# gcc ping.o -o ping -L../lib -linet6 -lresolv
ping.o: In function `main':
ping.o(.text+0x7c0): undefined reference to `clear_bit'
ping.o(.text+0x7d1): undefined reference to `clear_bit'
ping.o(.text+0x7e2): undefined reference to `clear_bit'
ping.o(.text+0x7f3): undefined reference to `clear_bit'
ping.o(.text+0x807): undefined reference to `clear_bit'
This is clear_bit which is defined in <asm/bitops.h>, which is included:
extern __inline__ int clear_bit(int nr, void * addr)
{
int oldbit;
__asm__ __volatile__(""
"btrl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"=m" ((*(struct __dummy *) addr) )
:"ir" (nr));
return oldbit;
}
So, I figure, I'll take the long way around to see where I'm losing clear_bit.
# rm -f ping.o
# gcc -E ping.c > pingnew.c
# grep clear_bit pingnew.c
extern __inline__ int clear_bit(int nr, void * addr)
clear_bit( 1 & 0x1f, &(( &filter )->data[ 1 >> 5])) ;
clear_bit( 2 & 0x1f, &(( &filter )->data[ 2 >> 5])) ;
clear_bit( 3 & 0x1f, &(( &filter )->data[ 3 >> 5])) ;
clear_bit( 4 & 0x1f, &(( &filter )->data[ 4 >> 5])) ;
clear_bit( 129 & 0x1f, &(( &filter )->data[ 129 >> 5])) ;
ok...there it is. clear_bit is in there, and there are the 5 calls to
the function. But watch this:
# /usr/lib/gcc-lib/i486-linux/2.7.2.1/cc1 pingnew.c
ustat cmsg_nxthdr __ntohl __ntohs set_bit clear_bit change_bit test_bit find_first_zero_bit find_next_zero_bit ffz main catcher pinger pr_pack pr_icmph tvsub finish pr_addr fill usage
time in parse: 0.800000
time in integration: 0.000000
time in jump: 0.000000
time in cse: 0.000000
time in loop: 0.000000
time in cse2: 0.000000
time in flow: 0.090000
time in combine: 0.000000
time in sched: 0.000000
time in local-alloc: 0.000000
time in global-alloc: 0.510000
time in sched2: 0.000000
time in dbranch: 0.000000
time in shorten-branch: 0.000000
time in stack-reg: 0.010000
time in final: 0.150000
time in varconst: 0.030000
time in symout: 0.000000
time in dump: 0.000000
# grep clear_bit pingnew.s
call clear_bit
call clear_bit
call clear_bit
call clear_bit
call clear_bit
#
So where did clear_bit go?
Needless to say, when I try to as the pingnew.s file, it fails with the
error message above (ping.o(.text+0x7c0): undefined reference to `clear_bit')
five times.
Why is gcc dropping that definition. For that matter, why is cc1 dropping
it?
--
Matt...
______________________________________________________________________________
Matthew Stainforth
Information Systems Analyst require "disclaim.pl";
NBCC - Moncton Campus &Disclaim($opinions)||die "drop dead $!";
Phone: (506) 856-2616
Email: mbs@gov.nb.ca _/\o_
______________________________________________________________________________
Re: #include not working right?
Author: Andreas Schwab
Date: Fri, 06 Dec 1996 00:00
Date: Fri, 06 Dec 1996 00:00
33 lines
1914 bytes
1914 bytes
Matt Stainforth <mbs@paladine.moncton.nbcc.nb.ca> writes:
|> Does anyone know why this is happening?
|> # gcc -c ping.c -o ping.o
|> # gcc ping.o -o ping -L../lib -linet6 -lresolv
|> ping.o: In function `main':
|> ping.o(.text+0x7c0): undefined reference to `clear_bit'
|> ping.o(.text+0x7d1): undefined reference to `clear_bit'
|> ping.o(.text+0x7e2): undefined reference to `clear_bit'
|> ping.o(.text+0x7f3): undefined reference to `clear_bit'
|> ping.o(.text+0x807): undefined reference to `clear_bit'
|> This is clear_bit which is defined in <asm/bitops.h>, which is included:
|> extern __inline__ int clear_bit(int nr, void * addr)
|> {
|> int oldbit;
|> __asm__ __volatile__(""
|> "btrl %2,%1\n\tsbbl %0,%0"
|> :"=r" (oldbit),"=m" ((*(struct __dummy *) addr) )
|> :"ir" (nr));
|> return oldbit;
|> }
You are not optimizing, so inlining is not performed. Because clear_bit
is declared extern, no non-inline version is generated either. So either
enable the optimizer or provide a non-inline definition of clear_bit (for
example, by changing extern to static).
--
Andreas Schwab "And now for something
schwab@issan.informatik.uni-dortmund.de completely different"
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads