Article View: comp.bugs.4bsd
Article #1147libraries may hide porting problems
From: wsmith
Date: Tue, 30 Aug 1988 19:30
Date: Tue, 30 Aug 1988 19:30
42 lines
1715 bytes
1715 bytes
This problem with the BSD linker can cause portability problems for
programs that use programmer created libraries.
Description:
In the BSD C compiler may not complain of multiply defined functions
while in other C compilers will fail to link the same program.
If the only data needed by the linker from a module is a variable
in BSS, multiply defined functions in that same module will be
ignored.
Repeat-By:
Create two files, one.c two.c
one.c:
extern int a;
main()
{
printf("%d\n",a);
}
four() { }
two.c:
int a;
four() { }
If the program is compiled with "cc -o aprog one.c two.c", _four is
reported as multiply defined. However, if the program is compiled with
"cc -c one.c two.c
ar r alib.a two.o
ranlib alib.a
cc -o aprog one.o alib.a" no error will be reported (under BSD).
With other compilers on other operating systems, _four will be multiply
defined in both cases. However, if the first line of two.c is changed to
"int a = 7;", the BSD C compiler will report _four as multiply defined in
both cases. Linking with a library should be equivalent to linking the
individual modules in the library that are needed. In this problematic
case, the equivalence is broken.
Fix: ???
Bill Smith wsmith@cs.uiuc.edu uiucdcs!wsmith
Technical Details
Message-ID:
<3400002@m.cs.uiuc.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!ames!haven!mimsy!oddjob!uxc!uxc.cso.uiuc.edu!a.cs.uiuc.edu!m.cs.uiuc.edu!wsmithShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!ames!haven!mimsy!oddjob!uxc!uxc.cso.uiuc.edu!a.cs.uiuc.edu!m.cs.uiuc.edu!wsmith From: wsmith@m.cs.uiuc.edu Newsgroups: comp.bugs.4bsd Subject: libraries may hide porting problems Message-ID: <3400002@m.cs.uiuc.edu> Date: 30 Aug 88 19:30:00 GMT Lines: 41 Nf-ID: #N:m.cs.uiuc.edu:3400002:000:1269 Nf-From: m.cs.uiuc.edu!wsmith Aug 30 14:30:00 1988