Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mira.net.au!inquo!in-news.erinet.com!izzy.net!aanews.merit.net!news.voyager.net!nntp.netrex.net!gatech!udel!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!newsflash.concordia.ca!news.nstn.ca!pirate.yohoho.org!digdon
From: digdon@yohoho.org (Mike Digdon)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Yacc libraries and yyparse
Date: 25 Apr 1996 02:03:52 GMT
Organization: Yohoho and a bottle of rum
Lines: 55
Message-ID: <4lmmi8$h4b@news.nstn.ca>
NNTP-Posting-Host: ts8-16.ott.istar.ca
X-Newsreader: TIN [version 1.2 PL2]
I'm fooling around with lex (which appears to actually be flex) and yacc.
I use the following to compile it:
yacc -d foo.y
lex foo.l
cc -o foo y.tab.c lex.yy.c -ly -ll
When I run the program, however, it does nothing. If I just compile the lex
code in the following way:
lex foo.l
cc -o foo lex.yy.c -ll
and run it, it does what I think it should.
This tells me there is something wrong with the yacc library definition of
main(). I confirmed this by including my *own* main function in the foo.y
source and compiling it. It worked fine.
If -ly had no main definition, it's my guess the executable would use the
main found in the lex library, and I should at least see the lex stuff
working.
An nm of /usr/lib/liby.so.2.0, which ldconfig -r shows as being the usable
library returns this:
00001000 d __DYNAMIC
00001060 D __GLOBAL_OFFSET_TABLE_
000010f0 D _edata
000010f0 B _end
00000234 T _etext
00000060 T _main
00000024 T _yyerror
00000060 F main.so
00000020 F yyerror.so
00000020 t yyerror.so.LC0
Here there is a reference to main.
An nm of liby.a gives this:
yyerror.o:
U ___sF
U _fprintf
00000004 T _yyerror
main.o:
U ___main
U _exit
00000000 T _main
U _yyparse
Here, it looks like main is calling yyparse. However, which library is
actually getting compiled into my code? Obviously, I will be including my
own main function anyway, but I am curious as to why the yacc library is
behaving this way.
--
*** Mike Digdon - digdon@yohoho.org ***
"Real Programmers never work nine to five."